@binopartner/pay-sdk 0.1.1 → 0.3.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 +145 -2
- package/dist/core/api-base.d.ts +49 -0
- package/dist/core/api-base.js +196 -0
- package/dist/core/appearance.d.ts +17 -0
- package/dist/core/appearance.js +122 -0
- package/dist/core/auth.d.ts +32 -0
- package/dist/core/auth.js +233 -0
- package/dist/core/client.d.ts +71 -0
- package/dist/core/client.js +307 -0
- package/dist/core/clock.d.ts +7 -0
- package/dist/core/clock.js +17 -0
- package/dist/core/errors.d.ts +29 -0
- package/dist/core/errors.js +87 -0
- package/dist/core/events.d.ts +50 -0
- package/dist/core/events.js +1 -0
- package/dist/core/flows/deposit.d.ts +63 -0
- package/dist/core/flows/deposit.js +502 -0
- package/dist/core/flows/withdraw.d.ts +51 -0
- package/dist/core/flows/withdraw.js +413 -0
- package/dist/core/i18n/ar.d.ts +2 -0
- package/dist/core/i18n/ar.js +314 -0
- package/dist/core/i18n/base.d.ts +14 -0
- package/dist/core/i18n/base.js +86 -0
- package/dist/core/i18n/cs.d.ts +2 -0
- package/dist/core/i18n/cs.js +314 -0
- package/dist/core/i18n/de.d.ts +2 -0
- package/dist/core/i18n/de.js +314 -0
- package/dist/core/i18n/en-ui.d.ts +39 -0
- package/dist/core/i18n/en-ui.js +39 -0
- package/dist/core/i18n/en.d.ts +316 -0
- package/dist/core/i18n/en.js +280 -0
- package/dist/core/i18n/es.d.ts +2 -0
- package/dist/core/i18n/es.js +314 -0
- package/dist/core/i18n/fr.d.ts +2 -0
- package/dist/core/i18n/fr.js +314 -0
- package/dist/core/i18n/hi.d.ts +2 -0
- package/dist/core/i18n/hi.js +314 -0
- package/dist/core/i18n/index.d.ts +16 -0
- package/dist/core/i18n/index.js +39 -0
- package/dist/core/i18n/it.d.ts +2 -0
- package/dist/core/i18n/it.js +314 -0
- package/dist/core/i18n/ru.d.ts +2 -0
- package/dist/core/i18n/ru.js +314 -0
- package/dist/core/i18n/tr.d.ts +2 -0
- package/dist/core/i18n/tr.js +314 -0
- package/dist/core/i18n/ua.d.ts +2 -0
- package/dist/core/i18n/ua.js +314 -0
- package/dist/core/index.d.ts +37 -0
- package/dist/core/index.js +19 -0
- package/dist/core/intent.d.ts +13 -0
- package/dist/core/intent.js +45 -0
- package/dist/core/money.d.ts +22 -0
- package/dist/core/money.js +178 -0
- package/dist/core/poll.d.ts +16 -0
- package/dist/core/poll.js +100 -0
- package/dist/core/requisites-frame.d.ts +32 -0
- package/dist/core/requisites-frame.js +202 -0
- package/dist/core/rules/address.d.ts +3 -0
- package/dist/core/rules/address.js +29 -0
- package/dist/core/rules/limits.d.ts +17 -0
- package/dist/core/rules/limits.js +19 -0
- package/dist/core/rules/paying.d.ts +10 -0
- package/dist/core/rules/paying.js +32 -0
- package/dist/core/rules/receipt.d.ts +6 -0
- package/dist/core/rules/receipt.js +33 -0
- package/dist/core/rules/requisites.d.ts +42 -0
- package/dist/core/rules/requisites.js +68 -0
- package/dist/core/rules/slippage.d.ts +1 -0
- package/dist/core/rules/slippage.js +7 -0
- package/dist/core/store.d.ts +15 -0
- package/dist/core/store.js +53 -0
- package/dist/core/types.d.ts +244 -0
- package/dist/core/types.js +1 -0
- package/dist/core/wire.d.ts +178 -0
- package/dist/core/wire.js +602 -0
- package/dist/elements/Root.d.ts +37 -0
- package/dist/elements/Root.js +143 -0
- package/dist/elements/chains.d.ts +1 -0
- package/dist/elements/chains.js +1 -0
- package/dist/elements/components/Qr.d.ts +17 -0
- package/dist/elements/components/Qr.js +28 -0
- package/dist/elements/components/basic.d.ts +42 -0
- package/dist/elements/components/basic.js +129 -0
- package/dist/elements/components/deposit.d.ts +61 -0
- package/dist/elements/components/deposit.js +272 -0
- package/dist/elements/components/inputs.d.ts +24 -0
- package/dist/elements/components/inputs.js +92 -0
- package/dist/elements/components/pickers.d.ts +32 -0
- package/dist/elements/components/pickers.js +267 -0
- package/dist/elements/components/status.d.ts +25 -0
- package/dist/elements/components/status.js +221 -0
- package/dist/elements/context.d.ts +47 -0
- package/dist/elements/context.js +33 -0
- package/dist/elements/hooks/deposit.d.ts +52 -0
- package/dist/elements/hooks/deposit.js +215 -0
- package/dist/elements/hooks/root.d.ts +70 -0
- package/dist/elements/hooks/root.js +125 -0
- package/dist/elements/hooks/withdraw.d.ts +30 -0
- package/dist/elements/hooks/withdraw.js +145 -0
- package/dist/elements/index.d.ts +28 -0
- package/dist/elements/index.js +14 -0
- package/dist/elements/part.d.ts +2 -0
- package/dist/elements/part.js +1 -0
- package/dist/elements/presets/DepositForm.d.ts +32 -0
- package/dist/elements/presets/DepositForm.js +97 -0
- package/dist/elements/presets/WithdrawForm.d.ts +25 -0
- package/dist/elements/presets/WithdrawForm.js +44 -0
- package/dist/elements/presets/focus.d.ts +2 -0
- package/dist/elements/presets/focus.js +26 -0
- package/dist/elements.css +2777 -0
- package/dist/fonts.css +31 -0
- package/dist/frame.d.ts +1 -0
- package/dist/frame.js +37 -6
- package/dist/types.d.ts +1 -0
- package/dist/ui/chains.d.ts +3 -0
- package/dist/ui/chains.js +42 -0
- package/dist/ui/context.d.ts +51 -0
- package/dist/ui/context.js +63 -0
- package/dist/ui/crypto.d.ts +67 -0
- package/dist/ui/crypto.js +68 -0
- package/dist/ui/entry.d.ts +25 -0
- package/dist/ui/entry.js +26 -0
- package/dist/ui/fiat.d.ts +94 -0
- package/dist/ui/fiat.js +149 -0
- package/dist/ui/fields.d.ts +76 -0
- package/dist/ui/fields.js +71 -0
- package/dist/ui/fonts.d.ts +4 -0
- package/dist/ui/fonts.js +31 -0
- package/dist/ui/icons.d.ts +39 -0
- package/dist/ui/icons.js +116 -0
- package/dist/ui/index.d.ts +31 -0
- package/dist/ui/index.js +17 -0
- package/dist/ui/layout.d.ts +36 -0
- package/dist/ui/layout.js +44 -0
- package/dist/ui/logos.d.ts +14 -0
- package/dist/ui/logos.js +61 -0
- package/dist/ui/part.d.ts +32 -0
- package/dist/ui/part.js +33 -0
- package/dist/ui/pickers.d.ts +71 -0
- package/dist/ui/pickers.js +167 -0
- package/dist/ui/qr-encode.d.ts +30 -0
- package/dist/ui/qr-encode.js +340 -0
- package/dist/ui/summary.d.ts +31 -0
- package/dist/ui/summary.js +36 -0
- package/dist/ui/types.d.ts +67 -0
- package/dist/ui/types.js +1 -0
- package/dist/ui/urls.d.ts +4 -0
- package/dist/ui/urls.js +41 -0
- package/dist/ui/withdraw.d.ts +38 -0
- package/dist/ui/withdraw.js +30 -0
- package/dist/ui.css +2699 -0
- package/dist/widget-url.d.ts +1 -0
- package/dist/widget-url.js +16 -0
- package/package.json +46 -5
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
const ECC_FORMAT_BITS = { L: 1, M: 0, Q: 3, H: 2 };
|
|
2
|
+
export const ECC_CODEWORDS_PER_BLOCK = {
|
|
3
|
+
L: [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
4
|
+
M: [-1, 10, 16, 26, 18, 24, 16, 18, 22, 22, 26, 30, 22, 22, 24, 24, 28, 28, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28],
|
|
5
|
+
Q: [-1, 13, 22, 18, 26, 18, 24, 18, 22, 20, 24, 28, 26, 24, 20, 30, 24, 28, 28, 26, 30, 28, 30, 30, 30, 30, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
6
|
+
H: [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
7
|
+
};
|
|
8
|
+
export const NUM_ERROR_CORRECTION_BLOCKS = {
|
|
9
|
+
L: [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
10
|
+
M: [-1, 1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49],
|
|
11
|
+
Q: [-1, 1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25, 27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68],
|
|
12
|
+
H: [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81],
|
|
13
|
+
};
|
|
14
|
+
const bit = (value, index) => ((value >>> index) & 1) !== 0;
|
|
15
|
+
export const numRawDataModules = (version) => {
|
|
16
|
+
let result = (16 * version + 128) * version + 64;
|
|
17
|
+
if (version >= 2) {
|
|
18
|
+
const numAlign = Math.floor(version / 7) + 2;
|
|
19
|
+
result -= (25 * numAlign - 10) * numAlign - 55;
|
|
20
|
+
if (version >= 7)
|
|
21
|
+
result -= 36;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
export const numDataCodewords = (version, ecc) => Math.floor(numRawDataModules(version) / 8) -
|
|
26
|
+
ECC_CODEWORDS_PER_BLOCK[ecc][version] *
|
|
27
|
+
NUM_ERROR_CORRECTION_BLOCKS[ecc][version];
|
|
28
|
+
export const alignmentPositions = (version) => {
|
|
29
|
+
if (version === 1)
|
|
30
|
+
return [];
|
|
31
|
+
const size = version * 4 + 17;
|
|
32
|
+
const numAlign = Math.floor(version / 7) + 2;
|
|
33
|
+
const step = Math.floor((version * 8 + numAlign * 3 + 5) / (numAlign * 4 - 4)) * 2;
|
|
34
|
+
const result = [6];
|
|
35
|
+
for (let pos = size - 7; result.length < numAlign; pos -= step)
|
|
36
|
+
result.splice(1, 0, pos);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
export const gfMultiply = (x, y) => {
|
|
40
|
+
let z = 0;
|
|
41
|
+
for (let i = 7; i >= 0; i -= 1) {
|
|
42
|
+
z = (z << 1) ^ ((z >>> 7) * 0x11d);
|
|
43
|
+
z ^= ((y >>> i) & 1) * x;
|
|
44
|
+
}
|
|
45
|
+
return z & 0xff;
|
|
46
|
+
};
|
|
47
|
+
const rsDivisor = (degree) => {
|
|
48
|
+
const result = new Array(degree).fill(0);
|
|
49
|
+
result[degree - 1] = 1;
|
|
50
|
+
let root = 1;
|
|
51
|
+
for (let i = 0; i < degree; i += 1) {
|
|
52
|
+
for (let j = 0; j < degree; j += 1) {
|
|
53
|
+
result[j] = gfMultiply(result[j], root);
|
|
54
|
+
if (j + 1 < degree)
|
|
55
|
+
result[j] = result[j] ^ result[j + 1];
|
|
56
|
+
}
|
|
57
|
+
root = gfMultiply(root, 0x02);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
const rsRemainder = (data, divisor) => {
|
|
62
|
+
const result = new Array(divisor.length).fill(0);
|
|
63
|
+
for (const value of data) {
|
|
64
|
+
const factor = value ^ result.shift();
|
|
65
|
+
result.push(0);
|
|
66
|
+
divisor.forEach((coefficient, index) => {
|
|
67
|
+
result[index] = result[index] ^ gfMultiply(coefficient, factor);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
};
|
|
72
|
+
class Grid {
|
|
73
|
+
constructor(size) {
|
|
74
|
+
this.size = size;
|
|
75
|
+
this.modules = Array.from({ length: size }, () => new Array(size).fill(false));
|
|
76
|
+
this.isFunction = Array.from({ length: size }, () => new Array(size).fill(false));
|
|
77
|
+
}
|
|
78
|
+
setFunction(x, y, dark) {
|
|
79
|
+
this.modules[y][x] = dark;
|
|
80
|
+
this.isFunction[y][x] = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const drawFinder = (grid, cx, cy) => {
|
|
84
|
+
for (let dy = -4; dy <= 4; dy += 1) {
|
|
85
|
+
for (let dx = -4; dx <= 4; dx += 1) {
|
|
86
|
+
const distance = Math.max(Math.abs(dx), Math.abs(dy));
|
|
87
|
+
const x = cx + dx;
|
|
88
|
+
const y = cy + dy;
|
|
89
|
+
if (x >= 0 && x < grid.size && y >= 0 && y < grid.size) {
|
|
90
|
+
grid.setFunction(x, y, distance !== 2 && distance !== 4);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const drawFormatBits = (grid, ecc, mask) => {
|
|
96
|
+
const data = (ECC_FORMAT_BITS[ecc] << 3) | mask;
|
|
97
|
+
let rem = data;
|
|
98
|
+
for (let i = 0; i < 10; i += 1)
|
|
99
|
+
rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
|
|
100
|
+
const bits = ((data << 10) | rem) ^ 0x5412;
|
|
101
|
+
const size = grid.size;
|
|
102
|
+
for (let i = 0; i <= 5; i += 1)
|
|
103
|
+
grid.setFunction(8, i, bit(bits, i));
|
|
104
|
+
grid.setFunction(8, 7, bit(bits, 6));
|
|
105
|
+
grid.setFunction(8, 8, bit(bits, 7));
|
|
106
|
+
grid.setFunction(7, 8, bit(bits, 8));
|
|
107
|
+
for (let i = 9; i < 15; i += 1)
|
|
108
|
+
grid.setFunction(14 - i, 8, bit(bits, i));
|
|
109
|
+
for (let i = 0; i < 8; i += 1)
|
|
110
|
+
grid.setFunction(size - 1 - i, 8, bit(bits, i));
|
|
111
|
+
for (let i = 8; i < 15; i += 1)
|
|
112
|
+
grid.setFunction(8, size - 15 + i, bit(bits, i));
|
|
113
|
+
grid.setFunction(8, size - 8, true);
|
|
114
|
+
};
|
|
115
|
+
const drawVersion = (grid, version) => {
|
|
116
|
+
if (version < 7)
|
|
117
|
+
return;
|
|
118
|
+
let rem = version;
|
|
119
|
+
for (let i = 0; i < 12; i += 1)
|
|
120
|
+
rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);
|
|
121
|
+
const bits = (version << 12) | rem;
|
|
122
|
+
for (let i = 0; i < 18; i += 1) {
|
|
123
|
+
const dark = bit(bits, i);
|
|
124
|
+
const a = grid.size - 11 + (i % 3);
|
|
125
|
+
const b = Math.floor(i / 3);
|
|
126
|
+
grid.setFunction(a, b, dark);
|
|
127
|
+
grid.setFunction(b, a, dark);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
export const functionPatternGrid = (version, ecc = "M") => {
|
|
131
|
+
const grid = new Grid(version * 4 + 17);
|
|
132
|
+
const size = grid.size;
|
|
133
|
+
for (let i = 0; i < size; i += 1) {
|
|
134
|
+
grid.setFunction(6, i, i % 2 === 0);
|
|
135
|
+
grid.setFunction(i, 6, i % 2 === 0);
|
|
136
|
+
}
|
|
137
|
+
drawFinder(grid, 3, 3);
|
|
138
|
+
drawFinder(grid, size - 4, 3);
|
|
139
|
+
drawFinder(grid, 3, size - 4);
|
|
140
|
+
const positions = alignmentPositions(version);
|
|
141
|
+
const last = positions.length - 1;
|
|
142
|
+
positions.forEach((py, i) => {
|
|
143
|
+
positions.forEach((px, j) => {
|
|
144
|
+
if ((i === 0 && j === 0) || (i === 0 && j === last) || (i === last && j === 0))
|
|
145
|
+
return;
|
|
146
|
+
for (let dy = -2; dy <= 2; dy += 1) {
|
|
147
|
+
for (let dx = -2; dx <= 2; dx += 1) {
|
|
148
|
+
grid.setFunction(px + dx, py + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
drawFormatBits(grid, ecc, 0);
|
|
154
|
+
drawVersion(grid, version);
|
|
155
|
+
return grid;
|
|
156
|
+
};
|
|
157
|
+
export const zigzagOrder = (grid) => {
|
|
158
|
+
const order = [];
|
|
159
|
+
const size = grid.size;
|
|
160
|
+
for (let right = size - 1; right >= 1; right -= 2) {
|
|
161
|
+
if (right === 6)
|
|
162
|
+
right = 5;
|
|
163
|
+
for (let vert = 0; vert < size; vert += 1) {
|
|
164
|
+
for (let j = 0; j < 2; j += 1) {
|
|
165
|
+
const x = right - j;
|
|
166
|
+
const upward = ((right + 1) & 2) === 0;
|
|
167
|
+
const y = upward ? size - 1 - vert : vert;
|
|
168
|
+
if (!grid.isFunction[y][x])
|
|
169
|
+
order.push([x, y]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return order;
|
|
174
|
+
};
|
|
175
|
+
export const maskApplies = (mask, x, y) => {
|
|
176
|
+
switch (mask) {
|
|
177
|
+
case 0:
|
|
178
|
+
return (x + y) % 2 === 0;
|
|
179
|
+
case 1:
|
|
180
|
+
return y % 2 === 0;
|
|
181
|
+
case 2:
|
|
182
|
+
return x % 3 === 0;
|
|
183
|
+
case 3:
|
|
184
|
+
return (x + y) % 3 === 0;
|
|
185
|
+
case 4:
|
|
186
|
+
return (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
|
|
187
|
+
case 5:
|
|
188
|
+
return ((x * y) % 2) + ((x * y) % 3) === 0;
|
|
189
|
+
case 6:
|
|
190
|
+
return (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
191
|
+
default:
|
|
192
|
+
return (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const FINDER_LIKE = ["10111010000", "00001011101"];
|
|
196
|
+
const penalty = (modules) => {
|
|
197
|
+
const size = modules.length;
|
|
198
|
+
let score = 0;
|
|
199
|
+
const lines = [];
|
|
200
|
+
for (let y = 0; y < size; y += 1) {
|
|
201
|
+
lines.push(modules[y].map((dark) => (dark ? "1" : "0")).join(""));
|
|
202
|
+
}
|
|
203
|
+
for (let x = 0; x < size; x += 1) {
|
|
204
|
+
let column = "";
|
|
205
|
+
for (let y = 0; y < size; y += 1)
|
|
206
|
+
column += modules[y][x] ? "1" : "0";
|
|
207
|
+
lines.push(column);
|
|
208
|
+
}
|
|
209
|
+
for (const line of lines) {
|
|
210
|
+
let run = 1;
|
|
211
|
+
for (let i = 1; i <= line.length; i += 1) {
|
|
212
|
+
if (i < line.length && line[i] === line[i - 1]) {
|
|
213
|
+
run += 1;
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (run >= 5)
|
|
217
|
+
score += 3 + (run - 5);
|
|
218
|
+
run = 1;
|
|
219
|
+
}
|
|
220
|
+
const padded = `0000${line}0000`;
|
|
221
|
+
for (const pattern of FINDER_LIKE) {
|
|
222
|
+
for (let at = padded.indexOf(pattern); at !== -1; at = padded.indexOf(pattern, at + 1)) {
|
|
223
|
+
score += 40;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
let dark = 0;
|
|
228
|
+
for (let y = 0; y < size; y += 1) {
|
|
229
|
+
for (let x = 0; x < size; x += 1) {
|
|
230
|
+
const value = modules[y][x];
|
|
231
|
+
if (value)
|
|
232
|
+
dark += 1;
|
|
233
|
+
if (x + 1 < size &&
|
|
234
|
+
y + 1 < size &&
|
|
235
|
+
value === modules[y][x + 1] &&
|
|
236
|
+
value === modules[y + 1][x] &&
|
|
237
|
+
value === modules[y + 1][x + 1]) {
|
|
238
|
+
score += 3;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const total = size * size;
|
|
243
|
+
score += (Math.ceil(Math.abs(dark * 20 - total * 10) / total) - 1) * 10;
|
|
244
|
+
return score;
|
|
245
|
+
};
|
|
246
|
+
const interleave = (data, version, ecc) => {
|
|
247
|
+
const numBlocks = NUM_ERROR_CORRECTION_BLOCKS[ecc][version];
|
|
248
|
+
const blockEccLen = ECC_CODEWORDS_PER_BLOCK[ecc][version];
|
|
249
|
+
const rawCodewords = Math.floor(numRawDataModules(version) / 8);
|
|
250
|
+
const numShortBlocks = numBlocks - (rawCodewords % numBlocks);
|
|
251
|
+
const shortBlockLen = Math.floor(rawCodewords / numBlocks);
|
|
252
|
+
const divisor = rsDivisor(blockEccLen);
|
|
253
|
+
const blocks = [];
|
|
254
|
+
for (let i = 0, k = 0; i < numBlocks; i += 1) {
|
|
255
|
+
const length = shortBlockLen - blockEccLen + (i < numShortBlocks ? 0 : 1);
|
|
256
|
+
const chunk = data.slice(k, k + length);
|
|
257
|
+
k += length;
|
|
258
|
+
const eccBytes = rsRemainder(chunk, divisor);
|
|
259
|
+
if (i < numShortBlocks)
|
|
260
|
+
chunk.push(0);
|
|
261
|
+
blocks.push(chunk.concat(eccBytes));
|
|
262
|
+
}
|
|
263
|
+
const result = [];
|
|
264
|
+
const width = blocks[0].length;
|
|
265
|
+
for (let i = 0; i < width; i += 1) {
|
|
266
|
+
blocks.forEach((block, j) => {
|
|
267
|
+
if (i !== shortBlockLen - blockEccLen || j >= numShortBlocks)
|
|
268
|
+
result.push(block[i]);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
export const encodeQr = (text, ecc = "M") => {
|
|
274
|
+
const bytes = Array.from(new TextEncoder().encode(text));
|
|
275
|
+
let version = 1;
|
|
276
|
+
for (; version <= 40; version += 1) {
|
|
277
|
+
const countBits = version <= 9 ? 8 : 16;
|
|
278
|
+
const usedBits = 4 + countBits + bytes.length * 8;
|
|
279
|
+
if (bytes.length < 2 ** countBits && usedBits <= numDataCodewords(version, ecc) * 8)
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
if (version > 40)
|
|
283
|
+
throw new RangeError("Data too long for a QR code");
|
|
284
|
+
const capacityBits = numDataCodewords(version, ecc) * 8;
|
|
285
|
+
const bits = [];
|
|
286
|
+
const append = (value, length) => {
|
|
287
|
+
for (let i = length - 1; i >= 0; i -= 1)
|
|
288
|
+
bits.push((value >>> i) & 1);
|
|
289
|
+
};
|
|
290
|
+
append(0b0100, 4);
|
|
291
|
+
append(bytes.length, version <= 9 ? 8 : 16);
|
|
292
|
+
bytes.forEach((value) => append(value, 8));
|
|
293
|
+
append(0, Math.min(4, capacityBits - bits.length));
|
|
294
|
+
append(0, (8 - (bits.length % 8)) % 8);
|
|
295
|
+
for (let pad = 0xec; bits.length < capacityBits; pad ^= 0xec ^ 0x11)
|
|
296
|
+
append(pad, 8);
|
|
297
|
+
const data = [];
|
|
298
|
+
for (let i = 0; i < bits.length; i += 8) {
|
|
299
|
+
let value = 0;
|
|
300
|
+
for (let j = 0; j < 8; j += 1)
|
|
301
|
+
value = (value << 1) | bits[i + j];
|
|
302
|
+
data.push(value);
|
|
303
|
+
}
|
|
304
|
+
const codewords = interleave(data, version, ecc);
|
|
305
|
+
const base = functionPatternGrid(version, ecc);
|
|
306
|
+
const order = zigzagOrder(base);
|
|
307
|
+
const placed = base.modules.map((row) => row.slice());
|
|
308
|
+
order.forEach(([x, y], index) => {
|
|
309
|
+
const byte = codewords[index >>> 3];
|
|
310
|
+
placed[y][x] = byte !== undefined && ((byte >>> (7 - (index & 7))) & 1) === 1;
|
|
311
|
+
});
|
|
312
|
+
let best = null;
|
|
313
|
+
for (let mask = 0; mask < 8; mask += 1) {
|
|
314
|
+
const grid = new Grid(base.size);
|
|
315
|
+
for (let y = 0; y < base.size; y += 1) {
|
|
316
|
+
for (let x = 0; x < base.size; x += 1) {
|
|
317
|
+
const fixed = base.isFunction[y][x];
|
|
318
|
+
grid.isFunction[y][x] = fixed;
|
|
319
|
+
const value = placed[y][x];
|
|
320
|
+
grid.modules[y][x] = fixed ? value : value !== maskApplies(mask, x, y);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
drawFormatBits(grid, ecc, mask);
|
|
324
|
+
const score = penalty(grid.modules);
|
|
325
|
+
if (!best || score < best.score)
|
|
326
|
+
best = { mask, modules: grid.modules, score };
|
|
327
|
+
}
|
|
328
|
+
const chosen = best;
|
|
329
|
+
return { version, size: base.size, mask: chosen.mask, ecc, modules: chosen.modules };
|
|
330
|
+
};
|
|
331
|
+
export const qrPath = (matrix, quietZone = 4) => {
|
|
332
|
+
let path = "";
|
|
333
|
+
matrix.modules.forEach((row, y) => {
|
|
334
|
+
row.forEach((dark, x) => {
|
|
335
|
+
if (dark)
|
|
336
|
+
path += `M${x + quietZone} ${y + quietZone}h1v1h-1z`;
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
return path;
|
|
340
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { type PartStyleProps } from "./part.js";
|
|
3
|
+
import type { DetailRow, QuoteRow, SummaryRow } from "./types.js";
|
|
4
|
+
type DivProps = Omit<HTMLAttributes<HTMLDivElement>, "className" | "style" | "children"> & PartStyleProps;
|
|
5
|
+
export interface SummaryProps extends DivProps {
|
|
6
|
+
rows: SummaryRow[];
|
|
7
|
+
part?: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const Summary: import("react").ForwardRefExoticComponent<SummaryProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export interface QuoteRowsProps extends DivProps {
|
|
12
|
+
rows: QuoteRow[];
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
loadingRows?: number;
|
|
15
|
+
loadingLabel?: string;
|
|
16
|
+
part?: string;
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare const QuoteRows: import("react").ForwardRefExoticComponent<QuoteRowsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export interface DetailsAccordionProps extends DivProps {
|
|
21
|
+
label: ReactNode;
|
|
22
|
+
value?: ReactNode;
|
|
23
|
+
rows: DetailRow[];
|
|
24
|
+
variant?: "deposit" | "withdraw";
|
|
25
|
+
open?: boolean;
|
|
26
|
+
defaultOpen?: boolean;
|
|
27
|
+
onOpenChange?: (open: boolean) => void;
|
|
28
|
+
part?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const DetailsAccordion: import("react").ForwardRefExoticComponent<DetailsAccordionProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useState } from "react";
|
|
4
|
+
import { useClasses } from "./context.js";
|
|
5
|
+
import { Skeleton } from "./fields.js";
|
|
6
|
+
import { ChevronIcon } from "./icons.js";
|
|
7
|
+
import { viewProps } from "./part.js";
|
|
8
|
+
const rowKey = (row, index) => row.key ?? (typeof row.label === "string" ? row.label : String(index));
|
|
9
|
+
export const Summary = forwardRef(function Summary({ rows, part = "summary", children, className, style, unstyled, ...rest }, ref) {
|
|
10
|
+
const { c, off } = useClasses(unstyled);
|
|
11
|
+
if (!rows.length && !children)
|
|
12
|
+
return null;
|
|
13
|
+
return (_jsxs("div", { ...rest, ref: ref, ...viewProps(part, "summary", { className, style, unstyled }, off), children: [rows.map((row, index) => (_jsxs("div", { className: c("summary-row"), "data-binodex-pay": "summary-row", "data-row": row.key, children: [_jsx("span", { className: c("summary-label"), children: row.label }), _jsx("span", { className: c("summary-value"), children: row.value })] }, rowKey(row, index)))), children] }));
|
|
14
|
+
});
|
|
15
|
+
export const QuoteRows = forwardRef(function QuoteRows({ rows, loading = false, loadingRows = 3, loadingLabel, part = "quote-rows", children, className, style, unstyled, ...rest }, ref) {
|
|
16
|
+
const { c, off } = useClasses(unstyled);
|
|
17
|
+
if (loading) {
|
|
18
|
+
return (_jsxs("div", { role: "status", "aria-label": loadingLabel, ...rest, ref: ref, ...viewProps(part, "quote-rows", { className, style, unstyled }, off), "data-loading": "", children: [_jsxs("div", { className: c("quote-row"), children: [_jsx(Skeleton, { width: 96, height: 8, radius: 3, unstyled: unstyled }), _jsxs("span", { className: c("quote-value"), children: [_jsx(Skeleton, { width: 18, height: 18, radius: "circle", unstyled: unstyled }), _jsx(Skeleton, { width: 72, height: 12, radius: 3, unstyled: unstyled })] })] }), _jsxs("div", { className: c("quote-row"), children: [_jsx(Skeleton, { width: 96, height: 8, radius: 3, unstyled: unstyled }), _jsx(Skeleton, { width: 48, height: 12, radius: 3, unstyled: unstyled })] }), loadingRows > 2 && (_jsxs("div", { className: c("quote-row"), children: [_jsx(Skeleton, { width: 40, height: 8, radius: 3, unstyled: unstyled }), _jsx(Skeleton, { width: 40, height: 12, radius: 3, unstyled: unstyled })] }))] }));
|
|
19
|
+
}
|
|
20
|
+
return (_jsxs("div", { ...rest, ref: ref, ...viewProps(part, "quote-rows", { className, style, unstyled }, off), children: [rows.map((row, index) => (_jsxs("div", { className: c("quote-row"), "data-binodex-pay": "quote-row", "data-row": row.key, ...row.attrs, children: [_jsx("span", { children: row.label }), _jsxs("span", { className: c(row.tone === "warning" ? "quote-value-warning" : row.icon !== undefined ? "quote-value" : null), children: [row.icon, row.value] })] }, rowKey(row, index)))), children] }));
|
|
21
|
+
});
|
|
22
|
+
export const DetailsAccordion = forwardRef(function DetailsAccordion({ label, value, rows, variant = "deposit", open: openProp, defaultOpen = false, onOpenChange, part = "details", className, style, unstyled, ...rest }, ref) {
|
|
23
|
+
const { c, off } = useClasses(unstyled);
|
|
24
|
+
const [ownOpen, setOwnOpen] = useState(defaultOpen);
|
|
25
|
+
const open = openProp ?? ownOpen;
|
|
26
|
+
const toggle = () => {
|
|
27
|
+
if (openProp === undefined)
|
|
28
|
+
setOwnOpen(!open);
|
|
29
|
+
onOpenChange?.(!open);
|
|
30
|
+
};
|
|
31
|
+
const chevron = _jsx(ChevronIcon, { className: c("details-chevron", open && "details-chevron-open") });
|
|
32
|
+
if (variant === "withdraw") {
|
|
33
|
+
return (_jsxs("div", { ...rest, ref: ref, ...viewProps(part, "details", { className, style, unstyled }, off), "data-variant": variant, "data-open": open ? "" : undefined, children: [_jsxs("button", { type: "button", className: c("details-toggle"), "data-binodex-pay": "details-toggle", "aria-expanded": open, onClick: toggle, children: [_jsx("span", { className: c("details-label"), children: label }), chevron] }), open && (_jsx("div", { className: c("details-content"), children: rows.map((row, index) => (_jsxs("div", { className: c("status-row"), "data-binodex-pay": "details-row", ...row.attrs, children: [_jsx("span", { className: c("status-row-label"), children: row.label }), _jsx("span", { className: c("status-row-value"), children: row.value })] }, rowKey(row, index)))) }))] }));
|
|
34
|
+
}
|
|
35
|
+
return (_jsxs("div", { ...rest, ref: ref, ...viewProps(part, "details", { className, style, unstyled }, off), "data-variant": variant, "data-open": open ? "" : undefined, children: [_jsxs("button", { type: "button", className: c("details-toggle"), "data-binodex-pay": "details-toggle", "aria-expanded": open, onClick: toggle, children: [_jsx("span", { children: label }), _jsxs("span", { className: c("details-toggle-right"), children: [value, chevron] })] }), _jsx("div", { className: c("details-collapse", open && "details-collapse-open"), children: _jsxs("div", { className: c("details-inner"), children: [_jsx("div", { className: c("details-divider") }), _jsx("dl", { className: c("details-list"), children: rows.map((row, index) => (_jsxs("div", { className: c("detail-row"), "data-binodex-pay": "details-row", ...row.attrs, children: [_jsx("dt", { className: c("detail-label"), children: row.label }), _jsx("dd", { className: c("detail-value"), children: row.value })] }, rowKey(row, index)))) })] }) })] }));
|
|
36
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { DataAttributes } from "./part.js";
|
|
3
|
+
export type StatusTone = "pending" | "completed" | "failed";
|
|
4
|
+
export type ResultState = "pending" | "success" | "failed";
|
|
5
|
+
export interface MethodOption {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
subtitle?: string | null;
|
|
9
|
+
minLabel?: string | null;
|
|
10
|
+
logoKey?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
attrs?: DataAttributes;
|
|
13
|
+
}
|
|
14
|
+
export interface EntryOption {
|
|
15
|
+
id: string;
|
|
16
|
+
title: ReactNode;
|
|
17
|
+
subtitle?: ReactNode;
|
|
18
|
+
icon?: ReactNode;
|
|
19
|
+
icons?: ReactNode[];
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
attrs?: DataAttributes;
|
|
22
|
+
}
|
|
23
|
+
export interface EntryTab {
|
|
24
|
+
id: string;
|
|
25
|
+
label: ReactNode;
|
|
26
|
+
attrs?: DataAttributes;
|
|
27
|
+
}
|
|
28
|
+
export interface RouteOption {
|
|
29
|
+
value: string;
|
|
30
|
+
label: string;
|
|
31
|
+
icon?: ReactNode;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
hint?: string | null;
|
|
34
|
+
attrs?: DataAttributes;
|
|
35
|
+
}
|
|
36
|
+
export interface CountryOption {
|
|
37
|
+
code: string;
|
|
38
|
+
name?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface SummaryRow {
|
|
41
|
+
label: ReactNode;
|
|
42
|
+
value: ReactNode;
|
|
43
|
+
key?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface QuoteRow {
|
|
46
|
+
label: ReactNode;
|
|
47
|
+
value: ReactNode;
|
|
48
|
+
icon?: ReactNode;
|
|
49
|
+
tone?: "default" | "warning";
|
|
50
|
+
key?: string;
|
|
51
|
+
attrs?: DataAttributes;
|
|
52
|
+
}
|
|
53
|
+
export interface RequisiteRow {
|
|
54
|
+
label: string;
|
|
55
|
+
value: string;
|
|
56
|
+
copy?: string;
|
|
57
|
+
mono?: boolean;
|
|
58
|
+
accent?: boolean;
|
|
59
|
+
key?: string;
|
|
60
|
+
attrs?: DataAttributes;
|
|
61
|
+
}
|
|
62
|
+
export interface DetailRow {
|
|
63
|
+
label: ReactNode;
|
|
64
|
+
value: ReactNode;
|
|
65
|
+
key?: string;
|
|
66
|
+
attrs?: DataAttributes;
|
|
67
|
+
}
|
package/dist/ui/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const warnIgnoredUrl: (option: string, value: string, fallback: string) => void;
|
|
2
|
+
export declare const safeBaseUrl: (value: string) => string | null;
|
|
3
|
+
export declare const resolveBaseUrl: (option: string, value: string | undefined, fallback: string) => string;
|
|
4
|
+
export declare const cssString: (value: string) => string;
|
package/dist/ui/urls.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const LOOPBACK_HOST = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\])$|\.localhost$/i;
|
|
2
|
+
const isProduction = () => {
|
|
3
|
+
try {
|
|
4
|
+
return process.env.NODE_ENV === "production";
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
export const warnIgnoredUrl = (option, value, fallback) => {
|
|
11
|
+
if (isProduction())
|
|
12
|
+
return;
|
|
13
|
+
console.warn(`[@binopartner/pay-sdk] ${option} ${JSON.stringify(value)} is ignored: use an https URL ` +
|
|
14
|
+
`(http only on localhost). Falling back to ${JSON.stringify(fallback)}.`);
|
|
15
|
+
};
|
|
16
|
+
export const safeBaseUrl = (value) => {
|
|
17
|
+
const trimmed = value.trim();
|
|
18
|
+
if (trimmed === "")
|
|
19
|
+
return "";
|
|
20
|
+
let url;
|
|
21
|
+
try {
|
|
22
|
+
url = new URL(trimmed);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (url.username || url.password || url.search || url.hash)
|
|
28
|
+
return null;
|
|
29
|
+
const secure = url.protocol === "https:" || (url.protocol === "http:" && LOOPBACK_HOST.test(url.hostname));
|
|
30
|
+
return secure ? url.href.replace(/\/+$/, "") : null;
|
|
31
|
+
};
|
|
32
|
+
export const resolveBaseUrl = (option, value, fallback) => {
|
|
33
|
+
if (value === undefined)
|
|
34
|
+
return fallback;
|
|
35
|
+
const safe = safeBaseUrl(value);
|
|
36
|
+
if (safe !== null)
|
|
37
|
+
return safe;
|
|
38
|
+
warnIgnoredUrl(option, value, fallback);
|
|
39
|
+
return fallback;
|
|
40
|
+
};
|
|
41
|
+
export const cssString = (value) => `"${value.replace(/[\\"]/g, "\\$&").replace(/[\n\r\f]/g, (char) => `\\${char.charCodeAt(0).toString(16)} `)}"`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { type PartStyleProps } from "./part.js";
|
|
3
|
+
import type { DetailRow, ResultState } from "./types.js";
|
|
4
|
+
type DivProps = Omit<HTMLAttributes<HTMLDivElement>, "className" | "style" | "children" | "title"> & PartStyleProps;
|
|
5
|
+
export interface SlippageWarningProps extends DivProps {
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
body: ReactNode;
|
|
8
|
+
actionLabel?: ReactNode;
|
|
9
|
+
onAccept?: () => void;
|
|
10
|
+
part?: string;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare const SlippageWarning: import("react").ForwardRefExoticComponent<SlippageWarningProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
|
+
export declare const StatusSteps: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "style" | "title" | "children" | "className"> & PartStyleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export declare const ResultIcon: ({ state, unstyled }: {
|
|
16
|
+
state: Exclude<ResultState, "pending">;
|
|
17
|
+
unstyled?: boolean;
|
|
18
|
+
}) => import("react").JSX.Element;
|
|
19
|
+
export declare const StatusText: ({ tone, children, unstyled }: {
|
|
20
|
+
tone: ResultState;
|
|
21
|
+
children?: ReactNode;
|
|
22
|
+
unstyled?: boolean;
|
|
23
|
+
}) => import("react").JSX.Element;
|
|
24
|
+
export interface StatusCardProps extends DivProps {
|
|
25
|
+
rows: DetailRow[];
|
|
26
|
+
}
|
|
27
|
+
export declare const StatusCard: import("react").ForwardRefExoticComponent<StatusCardProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
28
|
+
export interface WithdrawResultProps extends DivProps {
|
|
29
|
+
state: ResultState;
|
|
30
|
+
title: ReactNode;
|
|
31
|
+
subtitle?: ReactNode;
|
|
32
|
+
rows: DetailRow[];
|
|
33
|
+
details?: ReactNode;
|
|
34
|
+
part?: string;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
export declare const WithdrawResult: import("react").ForwardRefExoticComponent<WithdrawResultProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useClasses } from "./context.js";
|
|
5
|
+
import { FailIcon, SuccessIcon } from "./icons.js";
|
|
6
|
+
import { viewProps, partProps } from "./part.js";
|
|
7
|
+
export const SlippageWarning = forwardRef(function SlippageWarning({ title, body, actionLabel, onAccept, part = "slippage-warning", children, className, style, unstyled, ...rest }, ref) {
|
|
8
|
+
const { ui, c, off } = useClasses(unstyled);
|
|
9
|
+
return (_jsxs("div", { role: "alert", ...rest, ref: ref, ...viewProps(part, "slippage-warning", { className, style, unstyled }, off), children: [_jsx("div", { className: c("warn-title"), "data-binodex-pay": "slippage-title", children: title }), _jsx("div", { children: body }), children, onAccept && (_jsx("button", { type: "button", className: c("warn-button"), "data-binodex-pay": "accept-slippage", onClick: onAccept, children: actionLabel ?? ui.t("withdraw.slippageAccept") }))] }));
|
|
10
|
+
});
|
|
11
|
+
export const StatusSteps = forwardRef(function StatusSteps({ className, style, unstyled, ...rest }, ref) {
|
|
12
|
+
const { c, off } = useClasses(unstyled);
|
|
13
|
+
return (_jsxs("div", { ...rest, ref: ref, ...partProps("steps", { className, style, unstyled }, off), children: [_jsx("div", { className: c("step", "step-active"), children: "1" }), _jsxs("span", { className: c("step-loader"), "aria-hidden": "true", children: [_jsx("span", { className: c("step-dot") }), _jsx("span", { className: c("step-dot") }), _jsx("span", { className: c("step-dot") })] }), _jsx("div", { className: c("step"), children: "2" })] }));
|
|
14
|
+
});
|
|
15
|
+
export const ResultIcon = ({ state, unstyled }) => {
|
|
16
|
+
const { c } = useClasses(unstyled);
|
|
17
|
+
return (_jsx("div", { className: c("result-icon-wrap"), "data-binodex-pay": "result-icon", "data-state": state, children: state === "success" ? (_jsx("div", { className: c("result-icon-success"), children: _jsx(SuccessIcon, {}) })) : (_jsx("div", { className: c("result-icon-failed"), children: _jsx(FailIcon, {}) })) }));
|
|
18
|
+
};
|
|
19
|
+
export const StatusText = ({ tone, children, unstyled }) => {
|
|
20
|
+
const { c } = useClasses(unstyled);
|
|
21
|
+
return (_jsx("span", { className: c(tone === "success" ? "status-success" : tone === "failed" ? "status-failed" : "status-pending"), children: children }));
|
|
22
|
+
};
|
|
23
|
+
export const StatusCard = forwardRef(function StatusCard({ rows, className, style, unstyled, ...rest }, ref) {
|
|
24
|
+
const { c, off } = useClasses(unstyled);
|
|
25
|
+
return (_jsx("div", { ...rest, ref: ref, ...partProps("status-card", { className, style, unstyled }, off), children: rows.map((row, index) => (_jsxs("div", { className: c("status-row"), "data-binodex-pay": "quote-row", "data-row": row.key, ...row.attrs, children: [_jsx("span", { className: c("status-row-label"), children: row.label }), _jsx("span", { className: c("status-row-value"), children: row.value })] }, row.key ?? index))) }));
|
|
26
|
+
});
|
|
27
|
+
export const WithdrawResult = forwardRef(function WithdrawResult({ state, title, subtitle, rows, details, part = "withdraw-result", children, className, style, unstyled, ...rest }, ref) {
|
|
28
|
+
const { c, off } = useClasses(unstyled);
|
|
29
|
+
return (_jsxs("div", { ...rest, ref: ref, ...viewProps(part, "withdraw-result", { className, style, unstyled }, off), "data-state": state, children: [state === "pending" ? _jsx(StatusSteps, { unstyled: unstyled }) : _jsx(ResultIcon, { state: state, unstyled: unstyled }), _jsxs("div", { className: c("title-block"), children: [_jsx("h2", { className: c("status-title"), "data-binodex-pay": "status-label", children: title }), subtitle && _jsx("p", { className: c("status-subtitle"), children: subtitle })] }), _jsx(StatusCard, { rows: rows, unstyled: unstyled }), details, children] }));
|
|
30
|
+
});
|