@xsolla/xui-input-payment 0.64.0-pr56.1768440195

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/web/index.js ADDED
@@ -0,0 +1,945 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.tsx
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ InputPayment: () => InputPayment
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/InputPayment.tsx
38
+ var import_react4 = __toESM(require("react"));
39
+
40
+ // ../primitives-web/src/Box.tsx
41
+ var import_react = __toESM(require("react"));
42
+ var import_styled_components = __toESM(require("styled-components"));
43
+ var import_jsx_runtime = require("react/jsx-runtime");
44
+ var StyledBox = import_styled_components.default.div`
45
+ display: flex;
46
+ box-sizing: border-box;
47
+ background-color: ${(props) => props.backgroundColor || "transparent"};
48
+ border-color: ${(props) => props.borderColor || "transparent"};
49
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
50
+
51
+ ${(props) => props.borderBottomWidth !== void 0 && `
52
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
53
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
54
+ border-bottom-style: solid;
55
+ `}
56
+ ${(props) => props.borderTopWidth !== void 0 && `
57
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
58
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
59
+ border-top-style: solid;
60
+ `}
61
+ ${(props) => props.borderLeftWidth !== void 0 && `
62
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
63
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
64
+ border-left-style: solid;
65
+ `}
66
+ ${(props) => props.borderRightWidth !== void 0 && `
67
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
68
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
69
+ border-right-style: solid;
70
+ `}
71
+
72
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
73
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
74
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
75
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
76
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
77
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
78
+
79
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
80
+ ${(props) => props.paddingHorizontal && `
81
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
82
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
83
+ `}
84
+ ${(props) => props.paddingVertical && `
85
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
86
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
87
+ `}
88
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
89
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
90
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
91
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
92
+
93
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
94
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
95
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
96
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
97
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
98
+
99
+ flex-direction: ${(props) => props.flexDirection || "column"};
100
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
101
+ align-items: ${(props) => props.alignItems || "stretch"};
102
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
103
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
104
+ position: ${(props) => props.position || "static"};
105
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
106
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
107
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
108
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
109
+ flex: ${(props) => props.flex};
110
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
111
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
112
+ align-self: ${(props) => props.alignSelf || "auto"};
113
+ overflow: ${(props) => props.overflow || "visible"};
114
+ overflow-x: ${(props) => props.overflowX || "visible"};
115
+ overflow-y: ${(props) => props.overflowY || "visible"};
116
+ z-index: ${(props) => props.zIndex};
117
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
118
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
119
+
120
+ &:hover {
121
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
122
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
123
+ }
124
+
125
+ &:active {
126
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
127
+ }
128
+ `;
129
+ var Box = import_react.default.forwardRef(
130
+ ({
131
+ children,
132
+ onPress,
133
+ onKeyDown,
134
+ onKeyUp,
135
+ role,
136
+ "aria-label": ariaLabel,
137
+ "aria-labelledby": ariaLabelledBy,
138
+ "aria-current": ariaCurrent,
139
+ "aria-disabled": ariaDisabled,
140
+ "aria-live": ariaLive,
141
+ "aria-busy": ariaBusy,
142
+ "aria-describedby": ariaDescribedBy,
143
+ "aria-expanded": ariaExpanded,
144
+ "aria-haspopup": ariaHasPopup,
145
+ "aria-pressed": ariaPressed,
146
+ "aria-controls": ariaControls,
147
+ tabIndex,
148
+ as,
149
+ src,
150
+ alt,
151
+ type,
152
+ disabled,
153
+ id,
154
+ ...props
155
+ }, ref) => {
156
+ if (as === "img" && src) {
157
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
158
+ "img",
159
+ {
160
+ src,
161
+ alt: alt || "",
162
+ style: {
163
+ display: "block",
164
+ objectFit: "cover",
165
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
166
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
167
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
168
+ position: props.position,
169
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
170
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
171
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
172
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
173
+ }
174
+ }
175
+ );
176
+ }
177
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
+ StyledBox,
179
+ {
180
+ ref,
181
+ as,
182
+ id,
183
+ type: as === "button" ? type || "button" : void 0,
184
+ disabled: as === "button" ? disabled : void 0,
185
+ onClick: onPress,
186
+ onKeyDown,
187
+ onKeyUp,
188
+ role,
189
+ "aria-label": ariaLabel,
190
+ "aria-labelledby": ariaLabelledBy,
191
+ "aria-current": ariaCurrent,
192
+ "aria-disabled": ariaDisabled,
193
+ "aria-busy": ariaBusy,
194
+ "aria-describedby": ariaDescribedBy,
195
+ "aria-expanded": ariaExpanded,
196
+ "aria-haspopup": ariaHasPopup,
197
+ "aria-pressed": ariaPressed,
198
+ "aria-controls": ariaControls,
199
+ "aria-live": ariaLive,
200
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
201
+ ...props,
202
+ children
203
+ }
204
+ );
205
+ }
206
+ );
207
+ Box.displayName = "Box";
208
+
209
+ // ../primitives-web/src/Text.tsx
210
+ var import_styled_components2 = __toESM(require("styled-components"));
211
+ var import_jsx_runtime2 = require("react/jsx-runtime");
212
+ var StyledText = import_styled_components2.default.span`
213
+ color: ${(props) => props.color || "inherit"};
214
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
215
+ font-weight: ${(props) => props.fontWeight || "normal"};
216
+ font-family: ${(props) => props.fontFamily || '"Pilat Wide Bold", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important'};
217
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
218
+ white-space: ${(props) => props.whiteSpace || "normal"};
219
+ text-align: ${(props) => props.textAlign || "inherit"};
220
+ text-decoration: ${(props) => props.textDecoration || "none"};
221
+ `;
222
+ var Text = ({
223
+ style,
224
+ className,
225
+ id,
226
+ role,
227
+ ...props
228
+ }) => {
229
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
230
+ StyledText,
231
+ {
232
+ ...props,
233
+ style,
234
+ className,
235
+ id,
236
+ role
237
+ }
238
+ );
239
+ };
240
+
241
+ // ../primitives-web/src/Spinner.tsx
242
+ var import_styled_components3 = __toESM(require("styled-components"));
243
+ var import_jsx_runtime3 = require("react/jsx-runtime");
244
+ var rotate = import_styled_components3.keyframes`
245
+ from {
246
+ transform: rotate(0deg);
247
+ }
248
+ to {
249
+ transform: rotate(360deg);
250
+ }
251
+ `;
252
+ var StyledSpinner = import_styled_components3.default.div`
253
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
254
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
255
+ border: ${(props) => props.strokeWidth || 2}px solid
256
+ ${(props) => props.color || "currentColor"};
257
+ border-bottom-color: transparent;
258
+ border-radius: 50%;
259
+ display: inline-block;
260
+ box-sizing: border-box;
261
+ animation: ${rotate} 1s linear infinite;
262
+ `;
263
+ var Spinner = ({
264
+ role = "status",
265
+ "aria-label": ariaLabel,
266
+ "aria-live": ariaLive = "polite",
267
+ "aria-describedby": ariaDescribedBy,
268
+ testID,
269
+ ...props
270
+ }) => {
271
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
272
+ StyledSpinner,
273
+ {
274
+ role,
275
+ "aria-label": ariaLabel,
276
+ "aria-live": ariaLive,
277
+ "aria-describedby": ariaDescribedBy,
278
+ "data-testid": testID,
279
+ ...props
280
+ }
281
+ );
282
+ };
283
+ Spinner.displayName = "Spinner";
284
+
285
+ // ../primitives-web/src/Icon.tsx
286
+ var import_styled_components4 = __toESM(require("styled-components"));
287
+ var import_jsx_runtime4 = require("react/jsx-runtime");
288
+ var StyledIcon = import_styled_components4.default.div`
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: center;
292
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
293
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
294
+ color: ${(props) => props.color || "currentColor"};
295
+
296
+ svg {
297
+ width: 100%;
298
+ height: 100%;
299
+ fill: none;
300
+ stroke: currentColor;
301
+ }
302
+ `;
303
+
304
+ // ../primitives-web/src/Divider.tsx
305
+ var import_styled_components5 = __toESM(require("styled-components"));
306
+ var import_jsx_runtime5 = require("react/jsx-runtime");
307
+ var StyledDivider = import_styled_components5.default.div`
308
+ background-color: ${(props) => props.dashStroke ? "transparent" : props.color || "rgba(255, 255, 255, 0.15)"};
309
+ width: ${(props) => props.vertical ? typeof props.width === "number" ? `${props.width}px` : props.width || "1px" : "100%"};
310
+ height: ${(props) => props.vertical ? "100%" : typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
311
+
312
+ ${(props) => props.dashStroke && `
313
+ border-style: dashed;
314
+ border-color: ${props.color || "rgba(255, 255, 255, 0.15)"};
315
+ border-width: 0;
316
+ ${props.vertical ? `
317
+ border-left-width: ${typeof props.width === "number" ? `${props.width}px` : props.width || "1px"};
318
+ height: 100%;
319
+ ` : `
320
+ border-top-width: ${typeof props.height === "number" ? `${props.height}px` : props.height || "1px"};
321
+ width: 100%;
322
+ `}
323
+ `}
324
+ `;
325
+
326
+ // ../primitives-web/src/Input.tsx
327
+ var import_react2 = require("react");
328
+ var import_styled_components6 = __toESM(require("styled-components"));
329
+ var import_jsx_runtime6 = require("react/jsx-runtime");
330
+ var StyledInput = import_styled_components6.default.input`
331
+ background: transparent;
332
+ border: none;
333
+ outline: none;
334
+ width: 100%;
335
+ height: 100%;
336
+ padding: 0;
337
+ margin: 0;
338
+ color: ${(props) => props.color || "inherit"};
339
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
340
+ font-family: inherit;
341
+ text-align: inherit;
342
+
343
+ &::placeholder {
344
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
345
+ }
346
+
347
+ &:disabled {
348
+ cursor: not-allowed;
349
+ }
350
+ `;
351
+ var InputPrimitive = (0, import_react2.forwardRef)(
352
+ ({
353
+ value,
354
+ placeholder,
355
+ onChange,
356
+ onChangeText,
357
+ onFocus,
358
+ onBlur,
359
+ onKeyDown,
360
+ disabled,
361
+ secureTextEntry,
362
+ style,
363
+ color,
364
+ fontSize,
365
+ placeholderTextColor,
366
+ maxLength,
367
+ name,
368
+ type,
369
+ inputMode,
370
+ autoComplete,
371
+ id,
372
+ "aria-invalid": ariaInvalid,
373
+ "aria-describedby": ariaDescribedBy,
374
+ "aria-labelledby": ariaLabelledBy,
375
+ "aria-label": ariaLabel,
376
+ "aria-disabled": ariaDisabled,
377
+ "data-testid": dataTestId,
378
+ ...rest
379
+ }, ref) => {
380
+ const handleChange = (e) => {
381
+ if (onChange) {
382
+ onChange(e);
383
+ }
384
+ if (onChangeText) {
385
+ onChangeText(e.target.value);
386
+ }
387
+ };
388
+ const inputValue = value !== void 0 ? value : "";
389
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
390
+ StyledInput,
391
+ {
392
+ ref,
393
+ id,
394
+ value: inputValue,
395
+ name,
396
+ placeholder,
397
+ onChange: handleChange,
398
+ onFocus,
399
+ onBlur,
400
+ onKeyDown,
401
+ disabled,
402
+ type: secureTextEntry ? "password" : type || "text",
403
+ inputMode,
404
+ autoComplete,
405
+ style,
406
+ color,
407
+ fontSize,
408
+ placeholderTextColor,
409
+ maxLength,
410
+ "aria-invalid": ariaInvalid,
411
+ "aria-describedby": ariaDescribedBy,
412
+ "aria-labelledby": ariaLabelledBy,
413
+ "aria-label": ariaLabel,
414
+ "aria-disabled": ariaDisabled,
415
+ "data-testid": dataTestId,
416
+ ...rest
417
+ }
418
+ );
419
+ }
420
+ );
421
+ InputPrimitive.displayName = "InputPrimitive";
422
+
423
+ // ../primitives-web/src/TextArea.tsx
424
+ var import_react3 = require("react");
425
+ var import_styled_components7 = __toESM(require("styled-components"));
426
+ var import_jsx_runtime7 = require("react/jsx-runtime");
427
+ var StyledTextArea = import_styled_components7.default.textarea`
428
+ background: transparent;
429
+ border: none;
430
+ outline: none;
431
+ width: 100%;
432
+ height: 100%;
433
+ padding: 0;
434
+ margin: 0;
435
+ color: ${(props) => props.color || "inherit"};
436
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
437
+ font-family: inherit;
438
+ text-align: inherit;
439
+ resize: none;
440
+
441
+ &::placeholder {
442
+ color: ${(props) => props.placeholderTextColor || "rgba(255, 255, 255, 0.5)"};
443
+ }
444
+
445
+ &:disabled {
446
+ cursor: not-allowed;
447
+ }
448
+ `;
449
+ var TextAreaPrimitive = (0, import_react3.forwardRef)(
450
+ ({
451
+ value,
452
+ placeholder,
453
+ onChangeText,
454
+ onFocus,
455
+ onBlur,
456
+ onKeyDown,
457
+ disabled,
458
+ style,
459
+ color,
460
+ fontSize,
461
+ placeholderTextColor,
462
+ maxLength,
463
+ rows
464
+ }, ref) => {
465
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
466
+ StyledTextArea,
467
+ {
468
+ ref,
469
+ value,
470
+ placeholder,
471
+ onChange: (e) => onChangeText?.(e.target.value),
472
+ onFocus,
473
+ onBlur,
474
+ onKeyDown,
475
+ disabled,
476
+ style,
477
+ color,
478
+ fontSize,
479
+ placeholderTextColor,
480
+ maxLength,
481
+ rows
482
+ }
483
+ );
484
+ }
485
+ );
486
+ TextAreaPrimitive.displayName = "TextAreaPrimitive";
487
+
488
+ // src/InputPayment.tsx
489
+ var import_xui_core = require("@xsolla/xui-core");
490
+ var import_xui_icons_payment = require("@xsolla/xui-icons-payment");
491
+ var import_jsx_runtime8 = require("react/jsx-runtime");
492
+ var DEFAULT_POSSIBLE_PAYMENTS = [
493
+ "mastercard",
494
+ "visa",
495
+ "maestro",
496
+ "diners",
497
+ "amex",
498
+ "discover",
499
+ "jcb",
500
+ "unionpay"
501
+ ];
502
+ var paymentIconComponents = {
503
+ visa: import_xui_icons_payment.Visa,
504
+ mastercard: import_xui_icons_payment.Mastercard,
505
+ maestro: import_xui_icons_payment.Maestro,
506
+ amex: import_xui_icons_payment.AmericanExpress,
507
+ diners: import_xui_icons_payment.Dinersclub,
508
+ discover: import_xui_icons_payment.Discover,
509
+ jcb: import_xui_icons_payment.Jcb,
510
+ unionpay: import_xui_icons_payment.Unionpay,
511
+ aura: import_xui_icons_payment.Aura,
512
+ cartesbancaires: import_xui_icons_payment.CartesBancaires,
513
+ cirrus: import_xui_icons_payment.Cirrus,
514
+ dankort: import_xui_icons_payment.Dankort,
515
+ elo: import_xui_icons_payment.Elo,
516
+ hipercard: import_xui_icons_payment.Hipercard,
517
+ mir: import_xui_icons_payment.Mir,
518
+ naranja: import_xui_icons_payment.Naranja,
519
+ paypal: import_xui_icons_payment.Paypal,
520
+ sodexo: import_xui_icons_payment.Sodexo,
521
+ uatp: import_xui_icons_payment.Uatp
522
+ };
523
+ var detectPaymentSystem = (cardNumber) => {
524
+ const cleanNumber = cardNumber.replace(/\s/g, "");
525
+ if (!cleanNumber) return null;
526
+ if (/^1/.test(cleanNumber)) return "uatp";
527
+ if (/^220[0-4]/.test(cleanNumber)) return "mir";
528
+ if (/^3[47]/.test(cleanNumber)) return "amex";
529
+ if (/^3(?:0[0-5]|[68])/.test(cleanNumber)) return "diners";
530
+ if (/^35(?:2[89]|[3-8])/.test(cleanNumber)) return "jcb";
531
+ if (/^(401178|401179|431274|438935|451416|457393|457631|457632|504175|506699|5067[0-9]{2}|509[0-9]{3}|627780|636297|636368|650[0-9]{3}|651[0-9]{3}|655[0-9]{3})/.test(
532
+ cleanNumber
533
+ ))
534
+ return "elo";
535
+ if (/^4/.test(cleanNumber)) return "visa";
536
+ if (/^(606282|637095|637568|637599|637609|637612)/.test(cleanNumber))
537
+ return "hipercard";
538
+ if (/^507860/.test(cleanNumber)) return "aura";
539
+ if (/^5019/.test(cleanNumber)) return "dankort";
540
+ if (/^589562/.test(cleanNumber)) return "naranja";
541
+ if (/^5[1-5]/.test(cleanNumber)) return "mastercard";
542
+ if (cleanNumber.length >= 4 && /^(?:222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)/.test(cleanNumber))
543
+ return "mastercard";
544
+ if (/^(?:6011|65|64[4-9])/.test(cleanNumber)) return "discover";
545
+ if (cleanNumber.length >= 6 && /^(?:6221(?:2[6-9]|[3-9]\d)|622[2-8]\d{2}|6229(?:[01]\d|2[0-5]))/.test(cleanNumber))
546
+ return "discover";
547
+ if (/^62/.test(cleanNumber)) return "unionpay";
548
+ if (/^(?:5[06-9]|6)/.test(cleanNumber)) return "maestro";
549
+ return null;
550
+ };
551
+ var CARD_GAP = 4;
552
+ var PaymentIcons = ({ possiblePayments, maxVisible, recognizedPayment, iconHeight }) => {
553
+ const [cyclingIndex, setCyclingIndex] = (0, import_react4.useState)(0);
554
+ const [isTransitioning, setIsTransitioning] = (0, import_react4.useState)(false);
555
+ const [isRecognized, setIsRecognized] = (0, import_react4.useState)(false);
556
+ const scaledCardHeight = iconHeight;
557
+ const scaledCardWidth = Math.round(iconHeight * (4 / 3));
558
+ const scaledGap = CARD_GAP;
559
+ const constantCards = possiblePayments.slice(0, maxVisible - 1);
560
+ const cyclingCards = possiblePayments.slice(maxVisible - 1);
561
+ (0, import_react4.useEffect)(() => {
562
+ if (recognizedPayment) {
563
+ setIsRecognized(true);
564
+ } else {
565
+ const timeout = setTimeout(() => {
566
+ setIsRecognized(false);
567
+ }, 50);
568
+ return () => clearTimeout(timeout);
569
+ }
570
+ }, [recognizedPayment]);
571
+ (0, import_react4.useEffect)(() => {
572
+ if (cyclingCards.length <= 1 || recognizedPayment) return;
573
+ const interval = setInterval(() => {
574
+ setIsTransitioning(true);
575
+ setTimeout(() => {
576
+ setCyclingIndex((prev) => (prev + 1) % cyclingCards.length);
577
+ setIsTransitioning(false);
578
+ }, 150);
579
+ }, 2e3);
580
+ return () => clearInterval(interval);
581
+ }, [cyclingCards.length, recognizedPayment]);
582
+ const paymentLabels = {
583
+ mastercard: "Mastercard",
584
+ visa: "Visa",
585
+ maestro: "Maestro",
586
+ diners: "Diners Club",
587
+ amex: "American Express",
588
+ discover: "Discover",
589
+ jcb: "JCB",
590
+ unionpay: "UnionPay",
591
+ aura: "Aura",
592
+ cartesbancaires: "Cartes Bancaires",
593
+ cirrus: "Cirrus",
594
+ dankort: "Dankort",
595
+ elo: "Elo",
596
+ hipercard: "Hipercard",
597
+ mir: "Mir",
598
+ naranja: "Naranja",
599
+ paypal: "PayPal",
600
+ sodexo: "Sodexo",
601
+ uatp: "UATP"
602
+ };
603
+ const getAriaLabel = () => {
604
+ if (recognizedPayment) {
605
+ return `Recognized payment: ${paymentLabels[recognizedPayment]}`;
606
+ }
607
+ return `Accepted payment cards: ${possiblePayments.map((key) => paymentLabels[key]).join(", ")}`;
608
+ };
609
+ const totalVisibleCards = Math.min(possiblePayments.length, maxVisible);
610
+ const containerWidth = totalVisibleCards * scaledCardWidth + (totalVisibleCards - 1) * scaledGap;
611
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
612
+ Box,
613
+ {
614
+ flexDirection: "row",
615
+ alignItems: "center",
616
+ role: "img",
617
+ "aria-label": getAriaLabel(),
618
+ position: "relative",
619
+ width: containerWidth,
620
+ height: scaledCardHeight,
621
+ style: { overflow: "hidden" },
622
+ children: [
623
+ constantCards.map((key, index) => {
624
+ const IconComponent = paymentIconComponents[key];
625
+ const isRecognizedCard = recognizedPayment === key;
626
+ let translateX = 0;
627
+ let opacity = 1;
628
+ if (isRecognized && recognizedPayment) {
629
+ if (isRecognizedCard) {
630
+ const targetPosition = (totalVisibleCards - 1) * (scaledCardWidth + scaledGap);
631
+ const currentPosition = index * (scaledCardWidth + scaledGap);
632
+ translateX = targetPosition - currentPosition;
633
+ opacity = 1;
634
+ } else {
635
+ translateX = containerWidth;
636
+ opacity = 0;
637
+ }
638
+ }
639
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
640
+ Box,
641
+ {
642
+ position: "absolute",
643
+ left: index * (scaledCardWidth + scaledGap),
644
+ style: {
645
+ transform: import_xui_core.isWeb ? `translateX(${translateX}px)` : void 0,
646
+ opacity,
647
+ ...import_xui_core.isWeb && { transition: "transform 300ms ease-out, opacity 300ms ease-out" }
648
+ },
649
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IconComponent, { size: scaledCardHeight })
650
+ },
651
+ key
652
+ );
653
+ }),
654
+ cyclingCards.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
655
+ Box,
656
+ {
657
+ position: "absolute",
658
+ left: (maxVisible - 1) * (scaledCardWidth + scaledGap),
659
+ width: scaledCardWidth,
660
+ height: scaledCardHeight,
661
+ children: cyclingCards.map((key, index) => {
662
+ const IconComponent = paymentIconComponents[key];
663
+ const isCurrentCycling = index === cyclingIndex;
664
+ const isRecognizedCard = recognizedPayment === key;
665
+ let translateX = 0;
666
+ let opacity = isCurrentCycling && !isTransitioning ? 1 : 0;
667
+ if (isRecognized && recognizedPayment) {
668
+ if (isRecognizedCard) {
669
+ opacity = 1;
670
+ } else {
671
+ translateX = containerWidth;
672
+ opacity = 0;
673
+ }
674
+ }
675
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
676
+ Box,
677
+ {
678
+ position: "absolute",
679
+ top: 0,
680
+ left: 0,
681
+ style: {
682
+ transform: import_xui_core.isWeb ? `translateX(${translateX}px)` : void 0,
683
+ opacity,
684
+ ...import_xui_core.isWeb && {
685
+ transition: isRecognized ? "transform 300ms ease-out, opacity 300ms ease-out" : "opacity 150ms ease-in-out"
686
+ }
687
+ },
688
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(IconComponent, { size: scaledCardHeight })
689
+ },
690
+ key
691
+ );
692
+ })
693
+ }
694
+ )
695
+ ]
696
+ }
697
+ );
698
+ };
699
+ var InputPayment = (0, import_react4.forwardRef)(
700
+ ({
701
+ value,
702
+ icon,
703
+ placeholder = "Card number",
704
+ onChange,
705
+ onChangeText,
706
+ onKeyDown,
707
+ size = "m",
708
+ name,
709
+ disabled = false,
710
+ errorMessage,
711
+ error,
712
+ possiblePayments = DEFAULT_POSSIBLE_PAYMENTS,
713
+ maxVisiblePossiblePayments = 5,
714
+ recognizedPayment: controlledRecognizedPayment,
715
+ onRecognizedPaymentChange,
716
+ autoDetect = true,
717
+ id: providedId,
718
+ "aria-label": ariaLabel,
719
+ testID,
720
+ ...rest
721
+ }, ref) => {
722
+ const { theme } = (0, import_xui_core.useDesignSystem)();
723
+ const [internalState, setInternalState] = (0, import_react4.useState)(
724
+ "default"
725
+ );
726
+ const [passValue, setPassValue] = (0, import_react4.useState)(value ?? "");
727
+ const [detectedPayment, setDetectedPayment] = (0, import_react4.useState)(null);
728
+ const inputRef = (0, import_react4.useRef)(null);
729
+ const rawId = (0, import_xui_core.useId)();
730
+ const safeId = rawId.replace(/:/g, "");
731
+ const inputId = providedId || `input-payment-${safeId}`;
732
+ const errorId = `${inputId}-error`;
733
+ import_react4.default.useImperativeHandle(
734
+ ref,
735
+ () => inputRef.current,
736
+ []
737
+ );
738
+ (0, import_react4.useEffect)(() => {
739
+ if (value !== void 0) {
740
+ setPassValue(value);
741
+ }
742
+ }, [value]);
743
+ (0, import_react4.useEffect)(() => {
744
+ if (autoDetect && passValue) {
745
+ const detected = detectPaymentSystem(passValue);
746
+ const validDetected = detected && possiblePayments.includes(detected) ? detected : null;
747
+ setDetectedPayment(validDetected);
748
+ onRecognizedPaymentChange?.(validDetected);
749
+ } else if (!passValue) {
750
+ setDetectedPayment(null);
751
+ if (autoDetect) {
752
+ onRecognizedPaymentChange?.(null);
753
+ }
754
+ }
755
+ }, [passValue, autoDetect, onRecognizedPaymentChange, possiblePayments]);
756
+ const isDisable = disabled;
757
+ const isError = !!(errorMessage || error);
758
+ const isFocus = internalState === "focus";
759
+ const displayRecognizedPayment = controlledRecognizedPayment ?? detectedPayment;
760
+ const sizeStyles = theme.sizing.input(size);
761
+ const inputColors = theme.colors.control.input;
762
+ const handleFocus = () => {
763
+ if (!isDisable) {
764
+ setInternalState("focus");
765
+ }
766
+ };
767
+ const handleBlur = () => {
768
+ if (!isDisable) {
769
+ setInternalState("default");
770
+ }
771
+ };
772
+ const handleChange = (e) => {
773
+ const newValue = e.target.value;
774
+ if (onChange) {
775
+ onChange(e);
776
+ }
777
+ if (onChangeText) {
778
+ onChangeText(newValue);
779
+ }
780
+ setPassValue(newValue);
781
+ };
782
+ const handleKeyDown = (e) => {
783
+ if (e.key === "Escape") {
784
+ e.currentTarget.blur();
785
+ }
786
+ if (onKeyDown) {
787
+ onKeyDown(e);
788
+ }
789
+ };
790
+ let backgroundColor = inputColors.bg;
791
+ let borderColor = inputColors.border;
792
+ let outlineColor;
793
+ if (isDisable) {
794
+ backgroundColor = inputColors.bgDisable;
795
+ borderColor = inputColors.borderDisable;
796
+ } else if (isError) {
797
+ outlineColor = theme.colors.border.alert;
798
+ if (isFocus) {
799
+ backgroundColor = theme.colors.control.focus.bg;
800
+ }
801
+ } else if (isFocus) {
802
+ backgroundColor = theme.colors.control.focus.bg;
803
+ outlineColor = theme.colors.border.brand;
804
+ }
805
+ const textColor = isDisable ? inputColors.textDisable : inputColors.text;
806
+ const placeholderColor = inputColors.placeholder;
807
+ const iconColor = inputColors.placeholder;
808
+ const paddingConfig = {
809
+ xl: { vertical: 12, horizontal: 12 },
810
+ l: { vertical: 14, horizontal: 12 },
811
+ m: { vertical: 11, horizontal: 12 },
812
+ s: { vertical: 7, horizontal: 10 },
813
+ xs: { vertical: 7, horizontal: 10 }
814
+ };
815
+ const borderRadiusConfig = {
816
+ xl: 4,
817
+ l: 4,
818
+ m: 2,
819
+ s: 2,
820
+ xs: 2
821
+ };
822
+ const iconSizeConfig = {
823
+ xl: 18,
824
+ l: 18,
825
+ m: 18,
826
+ s: 16,
827
+ xs: 16
828
+ };
829
+ const focusOutlineConfig = {
830
+ xl: { width: 2, offset: -2 },
831
+ l: { width: 2, offset: -2 },
832
+ m: { width: 1, offset: -1 },
833
+ s: { width: 1, offset: -1 },
834
+ xs: { width: 1, offset: -1 }
835
+ };
836
+ const padding = paddingConfig[size];
837
+ const borderRadius = borderRadiusConfig[size];
838
+ const iconSize = iconSizeConfig[size];
839
+ const focusOutline = focusOutlineConfig[size];
840
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Box, { flexDirection: "column", gap: 8, width: "100%", testID, children: [
841
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
842
+ Box,
843
+ {
844
+ backgroundColor,
845
+ borderColor,
846
+ borderWidth: borderColor !== "transparent" ? 1 : 0,
847
+ borderRadius,
848
+ height: sizeStyles.height,
849
+ paddingVertical: padding.vertical,
850
+ paddingHorizontal: padding.horizontal,
851
+ flexDirection: "row",
852
+ alignItems: "center",
853
+ gap: 10,
854
+ position: "relative",
855
+ style: {
856
+ ...outlineColor ? {
857
+ outline: `${focusOutline.width}px solid ${outlineColor}`,
858
+ outlineOffset: `${focusOutline.offset}px`
859
+ } : {}
860
+ },
861
+ hoverStyle: !isDisable && !isFocus && !isError ? {
862
+ backgroundColor: inputColors.bgHover,
863
+ borderColor: inputColors.borderHover
864
+ } : void 0,
865
+ children: [
866
+ icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
867
+ Box,
868
+ {
869
+ alignItems: "center",
870
+ justifyContent: "center",
871
+ role: "img",
872
+ "aria-hidden": "true",
873
+ children: import_react4.default.isValidElement(icon) ? import_react4.default.cloneElement(icon, {
874
+ size: iconSize,
875
+ color: iconColor
876
+ }) : icon
877
+ }
878
+ ),
879
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Box, { flex: 1, height: "100%", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
880
+ InputPrimitive,
881
+ {
882
+ ref: inputRef,
883
+ id: inputId,
884
+ value: passValue,
885
+ name,
886
+ placeholder,
887
+ onChange: handleChange,
888
+ onFocus: handleFocus,
889
+ onBlur: handleBlur,
890
+ onKeyDown: handleKeyDown,
891
+ disabled: isDisable,
892
+ type: "text",
893
+ inputMode: "numeric",
894
+ autoComplete: "off",
895
+ color: textColor,
896
+ fontSize: sizeStyles.fontSize,
897
+ placeholderTextColor: placeholderColor,
898
+ "aria-invalid": isError || void 0,
899
+ "aria-describedby": errorMessage ? errorId : void 0,
900
+ "aria-label": ariaLabel || "Card number",
901
+ "aria-disabled": isDisable || void 0,
902
+ "data-testid": "input-payment__field",
903
+ ...rest
904
+ }
905
+ ) }),
906
+ possiblePayments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
907
+ Box,
908
+ {
909
+ alignItems: "center",
910
+ justifyContent: "center",
911
+ "data-testid": "input-payment__card-icons",
912
+ style: { overflow: "hidden" },
913
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
914
+ PaymentIcons,
915
+ {
916
+ possiblePayments,
917
+ maxVisible: maxVisiblePossiblePayments,
918
+ recognizedPayment: displayRecognizedPayment,
919
+ iconHeight: iconSize
920
+ }
921
+ )
922
+ }
923
+ )
924
+ ]
925
+ }
926
+ ),
927
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
928
+ Text,
929
+ {
930
+ id: errorId,
931
+ role: "alert",
932
+ color: theme.colors.content.alert.primary,
933
+ fontSize: sizeStyles.fontSize - 2,
934
+ children: errorMessage
935
+ }
936
+ )
937
+ ] });
938
+ }
939
+ );
940
+ InputPayment.displayName = "InputPayment";
941
+ // Annotate the CommonJS export names for ESM import in node:
942
+ 0 && (module.exports = {
943
+ InputPayment
944
+ });
945
+ //# sourceMappingURL=index.js.map