@coinflowlabs/angular 1.12.0 → 1.13.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
CHANGED
|
@@ -4,6 +4,10 @@ This library was generated with [Angular CLI](https://github.com/angular/angular
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
+
## 1.13.0
|
|
8
|
+
|
|
9
|
+
- Added loading states to the `CoinflowCardForm`, `CoinflowCardNumberInput`, `CoinflowCvvOnlyInput` components
|
|
10
|
+
|
|
7
11
|
## 1.11.0
|
|
8
12
|
|
|
9
13
|
- Added `cardBackground` to `MerchantTheme` to control the inner card-entry surface independently of the outer canvas `background`
|
|
@@ -5,6 +5,7 @@ import base58Imported from 'bs58';
|
|
|
5
5
|
import LZString from 'lz-string';
|
|
6
6
|
import nsureSDK from '@nsure-ai/web-client-sdk';
|
|
7
7
|
import * as i1 from '@angular/platform-browser';
|
|
8
|
+
import { NgStyle } from '@angular/common';
|
|
8
9
|
|
|
9
10
|
var WithdrawCategory;
|
|
10
11
|
(function (WithdrawCategory) {
|
|
@@ -1270,6 +1271,366 @@ function CSSPropertiesToComponent(dict) {
|
|
|
1270
1271
|
return str;
|
|
1271
1272
|
}
|
|
1272
1273
|
|
|
1274
|
+
/**
|
|
1275
|
+
* Single source of truth for the card-entry responsive layout.
|
|
1276
|
+
*
|
|
1277
|
+
* The real card-entry form (`UnifiedCardEntry` in the core-flows app) and the
|
|
1278
|
+
* React/Vue/Angular skeleton loaders all render the same grid. Historically the
|
|
1279
|
+
* form drove the inline↔two-row switch from JS (a ResizeObserver toggling React
|
|
1280
|
+
* state) while the skeletons hard-coded their own guesses, so the two drifted.
|
|
1281
|
+
*
|
|
1282
|
+
* This module defines the grid templates and the breakpoint ONCE, as pure data
|
|
1283
|
+
* plus a CSS builder, so every consumer reflows at exactly the same width via a
|
|
1284
|
+
* CSS container query — no JS width measurement, nothing to keep in sync.
|
|
1285
|
+
*/
|
|
1286
|
+
/**
|
|
1287
|
+
* Minimum width (px) each field needs before the row is too cramped and the
|
|
1288
|
+
* layout drops to two rows. Mirrors the real form's field sizing.
|
|
1289
|
+
*/
|
|
1290
|
+
const CARD_ENTRY_MIN_WIDTHS = {
|
|
1291
|
+
'card-number': 180,
|
|
1292
|
+
expiration: 96,
|
|
1293
|
+
cvv: 80,
|
|
1294
|
+
};
|
|
1295
|
+
/** Notional gap (px) between fields, summed into the reflow breakpoint. */
|
|
1296
|
+
const CARD_ENTRY_SLOT_GAP_PX = 8;
|
|
1297
|
+
/** Field row height — matches the real form's `3rem` grid rows. */
|
|
1298
|
+
const CARD_ENTRY_ROW_HEIGHT = '3rem';
|
|
1299
|
+
const CARD_ENTRY_ROW_HEIGHT_PX = 48;
|
|
1300
|
+
/** 1px accent line between rows / between exp & cvv in the two-row layout. */
|
|
1301
|
+
const CARD_ENTRY_DIVIDER_PX = 1;
|
|
1302
|
+
/**
|
|
1303
|
+
* The form draws its fields inside a 1px border, so the query container (the
|
|
1304
|
+
* full iframe width) is 2px wider than the field row that `minRowWidth`
|
|
1305
|
+
* describes. The breakpoint bakes this in so form and skeleton flip together.
|
|
1306
|
+
*/
|
|
1307
|
+
const CARD_ENTRY_BORDER_PX = 1;
|
|
1308
|
+
/**
|
|
1309
|
+
* The form insets its box by this much on every side (Tailwind `m-0.5`) so the
|
|
1310
|
+
* focus ring has room and isn't clipped at the iframe edge. It adds to the box's
|
|
1311
|
+
* rendered height, so the skeleton's height guess includes it to avoid a jump
|
|
1312
|
+
* when the loaded form replaces the skeleton.
|
|
1313
|
+
*/
|
|
1314
|
+
const CARD_ENTRY_MARGIN_PX = 2;
|
|
1315
|
+
/** Inline (wide-layout) track width for each field. */
|
|
1316
|
+
const INLINE_SLOT_WIDTH = {
|
|
1317
|
+
'card-number': '1fr',
|
|
1318
|
+
expiration: '96px',
|
|
1319
|
+
cvv: '80px',
|
|
1320
|
+
};
|
|
1321
|
+
/** grid-area name a field occupies. */
|
|
1322
|
+
const FIELD_AREA = {
|
|
1323
|
+
'card-number': 'card',
|
|
1324
|
+
expiration: 'exp',
|
|
1325
|
+
cvv: 'cvv',
|
|
1326
|
+
};
|
|
1327
|
+
function has(inputs, name) {
|
|
1328
|
+
return inputs.includes(name);
|
|
1329
|
+
}
|
|
1330
|
+
/** The reflow breakpoint on the field row, before adding the form border. */
|
|
1331
|
+
function minRowWidthPx(inputs) {
|
|
1332
|
+
const fields = inputs.reduce((sum, name) => sum + CARD_ENTRY_MIN_WIDTHS[name], 0);
|
|
1333
|
+
const gaps = Math.max(0, inputs.length - 1) * CARD_ENTRY_SLOT_GAP_PX;
|
|
1334
|
+
return fields + gaps;
|
|
1335
|
+
}
|
|
1336
|
+
/** grid-template for the single-row inline layout. */
|
|
1337
|
+
function inlineTemplate({ inputs, hasIcon, }) {
|
|
1338
|
+
const areas = [];
|
|
1339
|
+
const cols = [];
|
|
1340
|
+
const pushSlot = (area, width) => {
|
|
1341
|
+
if (areas.length > 0) {
|
|
1342
|
+
areas.push(`d${area.toUpperCase()}`);
|
|
1343
|
+
cols.push('1px');
|
|
1344
|
+
}
|
|
1345
|
+
areas.push(area);
|
|
1346
|
+
cols.push(width);
|
|
1347
|
+
};
|
|
1348
|
+
if (hasIcon && has(inputs, 'card-number'))
|
|
1349
|
+
pushSlot('icon', 'auto');
|
|
1350
|
+
for (const name of inputs)
|
|
1351
|
+
pushSlot(FIELD_AREA[name], INLINE_SLOT_WIDTH[name]);
|
|
1352
|
+
return `"${areas.join(' ')}" ${CARD_ENTRY_ROW_HEIGHT} / ${cols.join(' ')}`;
|
|
1353
|
+
}
|
|
1354
|
+
/** grid-template + dividers for the two-row layout (PAN on top). */
|
|
1355
|
+
function twoRowTemplate({ inputs, hasIcon, }) {
|
|
1356
|
+
const showsCard = has(inputs, 'card-number');
|
|
1357
|
+
const showsExp = has(inputs, 'expiration');
|
|
1358
|
+
const showsCvv = has(inputs, 'cvv');
|
|
1359
|
+
if (!showsCard || (!showsExp && !showsCvv))
|
|
1360
|
+
return null;
|
|
1361
|
+
const rows = `${CARD_ENTRY_ROW_HEIGHT} ${CARD_ENTRY_DIVIDER_PX}px ${CARD_ENTRY_ROW_HEIGHT}`;
|
|
1362
|
+
if (showsExp && showsCvv) {
|
|
1363
|
+
const areas = hasIcon
|
|
1364
|
+
? '"icon card card card" "dHR dHR dHR dHR" "exp exp dEV cvv"'
|
|
1365
|
+
: '"card card card" "dHR dHR dHR" "exp dEV cvv"';
|
|
1366
|
+
const cols = hasIcon
|
|
1367
|
+
? 'auto minmax(0, 1fr) 1px minmax(0, 1fr)'
|
|
1368
|
+
: 'minmax(0, 1fr) 1px minmax(0, 1fr)';
|
|
1369
|
+
return {
|
|
1370
|
+
template: gridShorthand(areas, rows, cols),
|
|
1371
|
+
dividers: [
|
|
1372
|
+
{ area: 'dHR', orientation: 'h' },
|
|
1373
|
+
{ area: 'dEV', orientation: 'v' },
|
|
1374
|
+
],
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
const onlyBottom = showsExp ? 'exp' : 'cvv';
|
|
1378
|
+
const areas = hasIcon
|
|
1379
|
+
? `"icon card" "dHR dHR" "${onlyBottom} ${onlyBottom}"`
|
|
1380
|
+
: `"card" "dHR" "${onlyBottom}"`;
|
|
1381
|
+
const cols = hasIcon ? 'auto minmax(0, 1fr)' : 'minmax(0, 1fr)';
|
|
1382
|
+
return {
|
|
1383
|
+
template: gridShorthand(areas, rows, cols),
|
|
1384
|
+
dividers: [{ area: 'dHR', orientation: 'h' }],
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
/**
|
|
1388
|
+
* Compose a `grid-template` shorthand from a multi-row areas string, a matching
|
|
1389
|
+
* row-size list, and the column list — e.g. `"a" "b" 3rem 1px / 1fr`.
|
|
1390
|
+
*/
|
|
1391
|
+
function gridShorthand(areas, rows, cols) {
|
|
1392
|
+
const areaRows = areas.match(/"[^"]*"/g) ?? [];
|
|
1393
|
+
const rowSizes = rows.split(/\s+/);
|
|
1394
|
+
const withRowSizes = areaRows
|
|
1395
|
+
.map((row, i) => `${row} ${rowSizes[i] ?? ''}`.trim())
|
|
1396
|
+
.join(' ');
|
|
1397
|
+
return `${withRowSizes} / ${cols}`;
|
|
1398
|
+
}
|
|
1399
|
+
/** Resolve the full layout (templates + breakpoint + areas) for a config. */
|
|
1400
|
+
function buildCardEntryLayout({ inputs, hasIcon = false, allowTwoRow = true, }) {
|
|
1401
|
+
const fieldAreas = inputs.map(name => FIELD_AREA[name]);
|
|
1402
|
+
// A lone field fills the width and never reflows (matches the real form's
|
|
1403
|
+
// single-input case — the fixed slot width and the icon are ignored).
|
|
1404
|
+
if (inputs.length === 1) {
|
|
1405
|
+
return {
|
|
1406
|
+
inline: `"${fieldAreas[0]}" ${CARD_ENTRY_ROW_HEIGHT} / 1fr`,
|
|
1407
|
+
twoRow: null,
|
|
1408
|
+
breakpointPx: null,
|
|
1409
|
+
fieldAreas,
|
|
1410
|
+
hasIconArea: false,
|
|
1411
|
+
twoRowDividers: [],
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
const hasIconArea = hasIcon && has(inputs, 'card-number');
|
|
1415
|
+
const inline = inlineTemplate({ inputs, hasIcon: hasIconArea });
|
|
1416
|
+
const twoRow = allowTwoRow
|
|
1417
|
+
? twoRowTemplate({ inputs, hasIcon: hasIconArea })
|
|
1418
|
+
: null;
|
|
1419
|
+
return {
|
|
1420
|
+
inline,
|
|
1421
|
+
twoRow: twoRow?.template ?? null,
|
|
1422
|
+
breakpointPx: twoRow
|
|
1423
|
+
? minRowWidthPx(inputs) + 2 * CARD_ENTRY_BORDER_PX
|
|
1424
|
+
: null,
|
|
1425
|
+
fieldAreas,
|
|
1426
|
+
hasIconArea,
|
|
1427
|
+
twoRowDividers: twoRow?.dividers ?? [],
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Container-query CSS that switches `gridSelector` between the inline and
|
|
1432
|
+
* two-row templates at the layout's breakpoint. The element matched by
|
|
1433
|
+
* `gridSelector` must be a descendant of a `container-type: inline-size`
|
|
1434
|
+
* ancestor named `containerName`.
|
|
1435
|
+
*
|
|
1436
|
+
* `extraBaseRules` are emitted before the `@container` block (e.g. the default
|
|
1437
|
+
* hidden state of two-row-only dividers); `extraCompactRules` are emitted inside
|
|
1438
|
+
* it (e.g. revealing those dividers / hiding wide-only chrome). Keeping the base
|
|
1439
|
+
* state first ensures the compact rules win when the query matches.
|
|
1440
|
+
*/
|
|
1441
|
+
function buildCardEntryGridCss({ gridSelector, layout, containerName, extraBaseRules = '', extraCompactRules = '', }) {
|
|
1442
|
+
const base = `${gridSelector} { display: grid; grid-template: ${layout.inline}; }
|
|
1443
|
+
${extraBaseRules}`;
|
|
1444
|
+
if (!layout.twoRow || layout.breakpointPx === null)
|
|
1445
|
+
return base;
|
|
1446
|
+
const container = containerName ? `${containerName} ` : '';
|
|
1447
|
+
return `${base}
|
|
1448
|
+
@container ${container}(width < ${layout.breakpointPx}px) {
|
|
1449
|
+
${gridSelector} { grid-template: ${layout.twoRow}; }
|
|
1450
|
+
${extraCompactRules}
|
|
1451
|
+
}`;
|
|
1452
|
+
}
|
|
1453
|
+
|
|
1454
|
+
/**
|
|
1455
|
+
* Framework-agnostic definitions for the V2 card-form skeleton loader.
|
|
1456
|
+
*
|
|
1457
|
+
* The React, Vue, and Angular libraries all render the same skeleton while the
|
|
1458
|
+
* card-form iframe loads. The grid templates and breakpoint come from the shared
|
|
1459
|
+
* {@link buildCardEntryLayout} — the SAME source of truth the real form uses —
|
|
1460
|
+
* so the skeleton reflows at exactly the width the loaded form does. Only the
|
|
1461
|
+
* box styling and per-framework wiring live here.
|
|
1462
|
+
*/
|
|
1463
|
+
/** Which fields each iframe variant mounts. */
|
|
1464
|
+
const VARIANT_INPUTS = {
|
|
1465
|
+
'card-form': ['card-number', 'expiration', 'cvv'],
|
|
1466
|
+
'card-number-form': ['card-number', 'expiration'],
|
|
1467
|
+
'cvv-form': ['cvv'],
|
|
1468
|
+
};
|
|
1469
|
+
// The iframe skeletons render without the optional card-brand icon.
|
|
1470
|
+
const CARD_ENTRY_LAYOUTS = {
|
|
1471
|
+
'card-form': buildCardEntryLayout({ inputs: VARIANT_INPUTS['card-form'] }),
|
|
1472
|
+
'card-number-form': buildCardEntryLayout({
|
|
1473
|
+
inputs: VARIANT_INPUTS['card-number-form'],
|
|
1474
|
+
}),
|
|
1475
|
+
'cvv-form': buildCardEntryLayout({ inputs: VARIANT_INPUTS['cvv-form'] }),
|
|
1476
|
+
};
|
|
1477
|
+
// Iframe height (px) to guess before it reports its real height. Matches the
|
|
1478
|
+
// form's rendered height so the skeleton→form swap doesn't jump: field row(s) +
|
|
1479
|
+
// the 1px border and the box's `m-0.5` margin on top and bottom.
|
|
1480
|
+
const CARD_ENTRY_VERTICAL_CHROME_PX = 2 * CARD_ENTRY_BORDER_PX + 2 * CARD_ENTRY_MARGIN_PX;
|
|
1481
|
+
const INLINE_SKELETON_HEIGHT_PX = CARD_ENTRY_ROW_HEIGHT_PX + CARD_ENTRY_VERTICAL_CHROME_PX;
|
|
1482
|
+
/** Two-row layouts are a second field row plus the 1px divider taller. */
|
|
1483
|
+
const COMPACT_SKELETON_HEIGHT_PX = 2 * CARD_ENTRY_ROW_HEIGHT_PX +
|
|
1484
|
+
CARD_ENTRY_DIVIDER_PX +
|
|
1485
|
+
CARD_ENTRY_VERTICAL_CHROME_PX;
|
|
1486
|
+
function toSkeletonLayout(layout) {
|
|
1487
|
+
return {
|
|
1488
|
+
inline: layout.inline,
|
|
1489
|
+
compact: layout.twoRow ?? undefined,
|
|
1490
|
+
compactMaxWidthPx: layout.breakpointPx ?? undefined,
|
|
1491
|
+
areas: layout.fieldAreas,
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
const SKELETON_LAYOUTS = {
|
|
1495
|
+
'card-form': toSkeletonLayout(CARD_ENTRY_LAYOUTS['card-form']),
|
|
1496
|
+
'card-number-form': toSkeletonLayout(CARD_ENTRY_LAYOUTS['card-number-form']),
|
|
1497
|
+
'cvv-form': toSkeletonLayout(CARD_ENTRY_LAYOUTS['cvv-form']),
|
|
1498
|
+
};
|
|
1499
|
+
/** Name of the shared pulse keyframes; referenced by the box `animation`. */
|
|
1500
|
+
const SKELETON_PULSE_ANIMATION_NAME = 'coinflow-card-form-skeleton-pulse';
|
|
1501
|
+
/**
|
|
1502
|
+
* Duration (ms) of the skeleton's opacity fade-out. Matches the `opacity 300ms`
|
|
1503
|
+
* transition each renderer applies. Renderers unmount the skeleton on
|
|
1504
|
+
* `transitionend`, but that event can be skipped (reduced-motion, an ancestor
|
|
1505
|
+
* `display:none`, or opacity already 0) — so they also use this as a fallback
|
|
1506
|
+
* timeout to force the unmount and avoid a stuck (invisible) skeleton.
|
|
1507
|
+
*/
|
|
1508
|
+
const SKELETON_FADE_MS = 300;
|
|
1509
|
+
/**
|
|
1510
|
+
* Whether the given container width would trigger the variant's two-row layout.
|
|
1511
|
+
* Mirrors the real form's container query (`width < breakpoint`). Variants
|
|
1512
|
+
* without a two-row layout never reflow.
|
|
1513
|
+
*/
|
|
1514
|
+
function shouldStackSkeleton({ variant, width, }) {
|
|
1515
|
+
const { compact, compactMaxWidthPx } = SKELETON_LAYOUTS[variant];
|
|
1516
|
+
return (compact !== undefined &&
|
|
1517
|
+
compactMaxWidthPx !== undefined &&
|
|
1518
|
+
width > 0 &&
|
|
1519
|
+
width < compactMaxWidthPx);
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Height to guess before the iframe reports its real height. The two-row layout
|
|
1523
|
+
* is a field row plus divider taller than the inline one.
|
|
1524
|
+
*/
|
|
1525
|
+
function guessSkeletonHeightPx({ variant, width, }) {
|
|
1526
|
+
return shouldStackSkeleton({ variant, width })
|
|
1527
|
+
? COMPACT_SKELETON_HEIGHT_PX
|
|
1528
|
+
: INLINE_SKELETON_HEIGHT_PX;
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* The `grid-template` to apply for the given container width. Frameworks that
|
|
1532
|
+
* drive the layout from JS (Vue, Angular) call this from their resize observer;
|
|
1533
|
+
* React instead injects a CSS container query via {@link buildSkeletonCss}.
|
|
1534
|
+
*/
|
|
1535
|
+
function getSkeletonGridTemplate({ variant, width, }) {
|
|
1536
|
+
const { inline, compact } = SKELETON_LAYOUTS[variant];
|
|
1537
|
+
if (compact && shouldStackSkeleton({ variant, width }))
|
|
1538
|
+
return compact;
|
|
1539
|
+
return inline;
|
|
1540
|
+
}
|
|
1541
|
+
/** Stable class name for a variant's skeleton grid element. */
|
|
1542
|
+
function getSkeletonGridClass(variant) {
|
|
1543
|
+
return `coinflow-card-form-skeleton-grid--${variant}`;
|
|
1544
|
+
}
|
|
1545
|
+
/**
|
|
1546
|
+
* CSS (keyframes + grid + container-query breakpoint) for the container-query
|
|
1547
|
+
* driven renderer used by React, where the skeleton root is a query container.
|
|
1548
|
+
*/
|
|
1549
|
+
function buildSkeletonCss(variant) {
|
|
1550
|
+
const gridClass = getSkeletonGridClass(variant);
|
|
1551
|
+
const grid = buildCardEntryGridCss({
|
|
1552
|
+
gridSelector: `.${gridClass}`,
|
|
1553
|
+
layout: CARD_ENTRY_LAYOUTS[variant],
|
|
1554
|
+
extraBaseRules: `.${gridClass} { gap: 0; flex: 1; }`,
|
|
1555
|
+
});
|
|
1556
|
+
return `@keyframes ${SKELETON_PULSE_ANIMATION_NAME} {0%,100%{opacity:1}50%{opacity:0.4}}
|
|
1557
|
+
${grid}`;
|
|
1558
|
+
}
|
|
1559
|
+
/**
|
|
1560
|
+
* Padding (px) to inset the skeleton grid by, applied on the skeleton root. It
|
|
1561
|
+
* equals the form's own chrome — its `m-0.5` margin plus 1px border — so the
|
|
1562
|
+
* boxes land in the same area the real fields will, and the grid fills the root
|
|
1563
|
+
* exactly (no dead space that would make the boxes look too short).
|
|
1564
|
+
*/
|
|
1565
|
+
const SKELETON_ROOT_PADDING_PX = CARD_ENTRY_MARGIN_PX + CARD_ENTRY_BORDER_PX;
|
|
1566
|
+
/**
|
|
1567
|
+
* Inline style for each skeleton box, MINUS the `background` — the fill color is
|
|
1568
|
+
* theme-dependent (see {@link getSkeletonColors}) so each renderer merges it in.
|
|
1569
|
+
* A hairline margin keeps a subtle gap between boxes while letting them fill
|
|
1570
|
+
* nearly the full field height (the root padding handles the outer inset). Uses
|
|
1571
|
+
* string units so it renders identically in React, Vue, and Angular.
|
|
1572
|
+
*/
|
|
1573
|
+
const SKELETON_BOX_STYLE = {
|
|
1574
|
+
minWidth: '0',
|
|
1575
|
+
margin: '1px',
|
|
1576
|
+
borderRadius: '4px',
|
|
1577
|
+
opacity: '1',
|
|
1578
|
+
animation: `${SKELETON_PULSE_ANIMATION_NAME} 1.5s ease-in-out infinite`,
|
|
1579
|
+
};
|
|
1580
|
+
// Dark surface → light skeleton; light surface → dark skeleton (the original
|
|
1581
|
+
// look); unknown → a neutral mid-grey that reads on either.
|
|
1582
|
+
const DARK_SURFACE_COLORS = {
|
|
1583
|
+
backdrop: 'rgba(255, 255, 255, 0.05)',
|
|
1584
|
+
box: 'rgba(255, 255, 255, 0.30)',
|
|
1585
|
+
};
|
|
1586
|
+
const LIGHT_SURFACE_COLORS = {
|
|
1587
|
+
backdrop: 'rgba(0, 0, 0, 0.04)',
|
|
1588
|
+
box: 'rgba(0, 0, 0, 0.30)',
|
|
1589
|
+
};
|
|
1590
|
+
const NEUTRAL_COLORS = {
|
|
1591
|
+
backdrop: 'rgba(128, 128, 128, 0.08)',
|
|
1592
|
+
box: 'rgba(128, 128, 128, 0.38)',
|
|
1593
|
+
};
|
|
1594
|
+
/** Parse a hex (#rgb/#rrggbb/#rrggbbaa) or rgb()/rgba() string to [r,g,b]. */
|
|
1595
|
+
function parseRgb(color) {
|
|
1596
|
+
const c = color.trim().toLowerCase();
|
|
1597
|
+
let hex = c.startsWith('#') ? c.slice(1) : '';
|
|
1598
|
+
if (hex && /^[0-9a-f]+$/.test(hex)) {
|
|
1599
|
+
if (hex.length === 3)
|
|
1600
|
+
hex = hex
|
|
1601
|
+
.split('')
|
|
1602
|
+
.map(x => x + x)
|
|
1603
|
+
.join('');
|
|
1604
|
+
if (hex.length === 8)
|
|
1605
|
+
hex = hex.slice(0, 6);
|
|
1606
|
+
if (hex.length === 6)
|
|
1607
|
+
return [
|
|
1608
|
+
parseInt(hex.slice(0, 2), 16),
|
|
1609
|
+
parseInt(hex.slice(2, 4), 16),
|
|
1610
|
+
parseInt(hex.slice(4, 6), 16),
|
|
1611
|
+
];
|
|
1612
|
+
}
|
|
1613
|
+
const m = c.match(/rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/);
|
|
1614
|
+
if (m)
|
|
1615
|
+
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
1616
|
+
return null;
|
|
1617
|
+
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Best-effort skeleton palette. The skeleton renders in the SDK (parent), so it
|
|
1620
|
+
* can't see the form's resolved colors — it only has the optional `theme` the
|
|
1621
|
+
* integrator passed. When `theme.background` is a parseable color we tint the
|
|
1622
|
+
* skeleton light-on-dark or dark-on-light to match; otherwise we fall back to a
|
|
1623
|
+
* neutral mid-grey that stays visible on any surface.
|
|
1624
|
+
*/
|
|
1625
|
+
function getSkeletonColors(theme) {
|
|
1626
|
+
const rgb = theme?.background ? parseRgb(theme.background) : null;
|
|
1627
|
+
if (!rgb)
|
|
1628
|
+
return NEUTRAL_COLORS;
|
|
1629
|
+
const [r, g, b] = rgb;
|
|
1630
|
+
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
1631
|
+
return luminance < 0.5 ? DARK_SURFACE_COLORS : LIGHT_SURFACE_COLORS;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1273
1634
|
/* generated using openapi-typescript-codegen -- do no edit */
|
|
1274
1635
|
/* istanbul ignore file */
|
|
1275
1636
|
/* tslint:disable */
|
|
@@ -1985,17 +2346,112 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
|
|
|
1985
2346
|
}] } });
|
|
1986
2347
|
|
|
1987
2348
|
class CoinflowCardForm {
|
|
1988
|
-
constructor(sanitizer) {
|
|
2349
|
+
constructor(sanitizer, zone) {
|
|
1989
2350
|
this.sanitizer = sanitizer;
|
|
2351
|
+
this.zone = zone;
|
|
1990
2352
|
this.loaded = false;
|
|
1991
2353
|
this.iframeHeight = null;
|
|
2354
|
+
this.areas = [];
|
|
2355
|
+
this.guessHeight = INLINE_SKELETON_HEIGHT_PX;
|
|
2356
|
+
this.gridTemplate = '';
|
|
2357
|
+
// Keep the skeleton mounted while it fades out so the opacity transition can
|
|
2358
|
+
// play, then unmount on transition end. Remount instantly when shown again.
|
|
2359
|
+
this.rendered = true;
|
|
2360
|
+
this.observer = null;
|
|
2361
|
+
this.unmountTimer = null;
|
|
1992
2362
|
}
|
|
1993
2363
|
ngOnInit() {
|
|
2364
|
+
this.layout = SKELETON_LAYOUTS[this.args.variant];
|
|
2365
|
+
this.areas = this.layout.areas;
|
|
2366
|
+
this.gridTemplate = this.layout.inline;
|
|
1994
2367
|
this.buildUrl();
|
|
2368
|
+
this.observeWidth();
|
|
2369
|
+
}
|
|
2370
|
+
ngOnDestroy() {
|
|
2371
|
+
this.observer?.disconnect();
|
|
2372
|
+
if (this.unmountTimer)
|
|
2373
|
+
clearTimeout(this.unmountTimer);
|
|
2374
|
+
}
|
|
2375
|
+
get height() {
|
|
2376
|
+
return this.loaded && this.iframeHeight
|
|
2377
|
+
? `${this.iframeHeight}px`
|
|
2378
|
+
: `${this.guessHeight}px`;
|
|
2379
|
+
}
|
|
2380
|
+
get skeletonRootStyle() {
|
|
2381
|
+
return {
|
|
2382
|
+
position: 'absolute',
|
|
2383
|
+
top: 0,
|
|
2384
|
+
left: 0,
|
|
2385
|
+
width: '100%',
|
|
2386
|
+
height: '100%',
|
|
2387
|
+
display: 'flex',
|
|
2388
|
+
pointerEvents: 'none',
|
|
2389
|
+
flexDirection: 'column',
|
|
2390
|
+
gap: '8px',
|
|
2391
|
+
padding: `${SKELETON_ROOT_PADDING_PX}px`,
|
|
2392
|
+
boxSizing: 'border-box',
|
|
2393
|
+
borderRadius: '8px',
|
|
2394
|
+
background: this.skeletonColors.backdrop,
|
|
2395
|
+
opacity: this.loaded ? '0%' : '100%',
|
|
2396
|
+
transition: 'opacity 300ms linear, height 150ms ease-out',
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2399
|
+
get gridStyle() {
|
|
2400
|
+
return {
|
|
2401
|
+
display: 'grid',
|
|
2402
|
+
gap: 0,
|
|
2403
|
+
flex: 1,
|
|
2404
|
+
width: '100%',
|
|
2405
|
+
gridTemplate: this.gridTemplate,
|
|
2406
|
+
};
|
|
2407
|
+
}
|
|
2408
|
+
// Best-effort skeleton tint from the merchant theme's background (neutral when
|
|
2409
|
+
// absent), so the loader reads on light and dark forms alike.
|
|
2410
|
+
get skeletonColors() {
|
|
2411
|
+
return getSkeletonColors(this.args.theme);
|
|
2412
|
+
}
|
|
2413
|
+
boxStyle(area) {
|
|
2414
|
+
return {
|
|
2415
|
+
...SKELETON_BOX_STYLE,
|
|
2416
|
+
background: this.skeletonColors.box,
|
|
2417
|
+
gridArea: area,
|
|
2418
|
+
};
|
|
1995
2419
|
}
|
|
1996
2420
|
onMessage(event) {
|
|
2421
|
+
// Only honor messages from THIS instance's iframe. Multiple card forms on
|
|
2422
|
+
// one page each listen on `window`, so without this every instance would
|
|
2423
|
+
// apply every other iframe's height/loaded events to itself.
|
|
2424
|
+
if (event.source !== this.iframeRef?.nativeElement?.contentWindow)
|
|
2425
|
+
return;
|
|
1997
2426
|
this.handleMessage(event.data, event.origin);
|
|
1998
2427
|
}
|
|
2428
|
+
onSkeletonTransitionEnd(e) {
|
|
2429
|
+
if (e.propertyName === 'opacity' && this.loaded)
|
|
2430
|
+
this.rendered = false;
|
|
2431
|
+
}
|
|
2432
|
+
observeWidth() {
|
|
2433
|
+
// Measure the wrapper div, not the iframe: a freshly-mounted <iframe> is a
|
|
2434
|
+
// replaced element with an intrinsic 300px default width before its
|
|
2435
|
+
// width:100% resolves, which would briefly (and wrongly) trip the compact
|
|
2436
|
+
// breakpoint. A block div reports the true container width immediately.
|
|
2437
|
+
const el = this.wrapperRef?.nativeElement;
|
|
2438
|
+
if (!el || !this.layout.compact)
|
|
2439
|
+
return;
|
|
2440
|
+
const measure = () => {
|
|
2441
|
+
const width = el.clientWidth;
|
|
2442
|
+
this.guessHeight = guessSkeletonHeightPx({
|
|
2443
|
+
variant: this.args.variant,
|
|
2444
|
+
width,
|
|
2445
|
+
});
|
|
2446
|
+
this.gridTemplate = getSkeletonGridTemplate({
|
|
2447
|
+
variant: this.args.variant,
|
|
2448
|
+
width,
|
|
2449
|
+
});
|
|
2450
|
+
};
|
|
2451
|
+
measure();
|
|
2452
|
+
this.observer = new ResizeObserver(() => this.zone.run(measure));
|
|
2453
|
+
this.observer.observe(el);
|
|
2454
|
+
}
|
|
1999
2455
|
buildUrl() {
|
|
2000
2456
|
const baseUrl = CoinflowUtils.getCoinflowBaseUrl(this.args.env);
|
|
2001
2457
|
const iframeUrl = new URL(`/form/v2/${this.args.variant}`, baseUrl);
|
|
@@ -2018,6 +2474,14 @@ class CoinflowCardForm {
|
|
|
2018
2474
|
if (parsed.method === IFrameMessageMethods.Loaded) {
|
|
2019
2475
|
this.loaded = true;
|
|
2020
2476
|
this.args.onLoad?.();
|
|
2477
|
+
// Fallback unmount: `transitionend` may never fire (reduced-motion, an
|
|
2478
|
+
// ancestor display:none, or opacity already 0), so force cleanup after
|
|
2479
|
+
// the fade window.
|
|
2480
|
+
if (this.unmountTimer)
|
|
2481
|
+
clearTimeout(this.unmountTimer);
|
|
2482
|
+
this.unmountTimer = setTimeout(() => {
|
|
2483
|
+
this.zone.run(() => (this.rendered = false));
|
|
2484
|
+
}, SKELETON_FADE_MS);
|
|
2021
2485
|
}
|
|
2022
2486
|
else if (parsed.method === IFrameMessageMethods.HeightChange) {
|
|
2023
2487
|
const parsedHeight = Number(parsed.data);
|
|
@@ -2066,44 +2530,84 @@ class CoinflowCardForm {
|
|
|
2066
2530
|
iframe.contentWindow.postMessage('tokenize', targetOrigin);
|
|
2067
2531
|
});
|
|
2068
2532
|
}
|
|
2069
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CoinflowCardForm, deps: [{ token: i1.DomSanitizer }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2070
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
2071
|
-
#
|
|
2072
|
-
[
|
|
2073
|
-
title="Card Form"
|
|
2074
|
-
frameBorder="0"
|
|
2075
|
-
allow="payment"
|
|
2533
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CoinflowCardForm, deps: [{ token: i1.DomSanitizer }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2534
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.10", type: CoinflowCardForm, isStandalone: true, selector: "lib-coinflow-card-form", inputs: { args: "args" }, host: { listeners: { "window:message": "onMessage($event)" } }, viewQueries: [{ propertyName: "iframeRef", first: true, predicate: ["cardFormIframe"], descendants: true, static: true }, { propertyName: "wrapperRef", first: true, predicate: ["wrapper"], descendants: true, static: true }], ngImport: i0, template: `<div
|
|
2535
|
+
#wrapper
|
|
2536
|
+
[style.position]="'relative'"
|
|
2076
2537
|
[style.width]="'100%'"
|
|
2077
|
-
[style.height]="
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2538
|
+
[style.height]="height"
|
|
2539
|
+
>
|
|
2540
|
+
@if (rendered) {
|
|
2541
|
+
<div
|
|
2542
|
+
role="status"
|
|
2543
|
+
aria-label="Loading card form"
|
|
2544
|
+
(transitionend)="onSkeletonTransitionEnd($event)"
|
|
2545
|
+
[ngStyle]="skeletonRootStyle"
|
|
2546
|
+
>
|
|
2547
|
+
<div [ngStyle]="gridStyle">
|
|
2548
|
+
@for (area of areas; track area) {
|
|
2549
|
+
<div [ngStyle]="boxStyle(area)"></div>
|
|
2550
|
+
}
|
|
2551
|
+
</div>
|
|
2552
|
+
</div>
|
|
2553
|
+
}
|
|
2554
|
+
<iframe
|
|
2555
|
+
#cardFormIframe
|
|
2556
|
+
[src]="url"
|
|
2557
|
+
title="Card Form"
|
|
2558
|
+
frameBorder="0"
|
|
2559
|
+
allow="payment"
|
|
2560
|
+
[style.width]="'100%'"
|
|
2561
|
+
[style.height]="height"
|
|
2562
|
+
[style.border]="'none'"
|
|
2563
|
+
[style.opacity]="loaded ? 1 : 0"
|
|
2564
|
+
[style.transition]="'opacity 300ms linear, height 150ms ease-out'"
|
|
2565
|
+
></iframe>
|
|
2566
|
+
</div>`, isInline: true, styles: ["@keyframes coinflow-card-form-skeleton-pulse{0%,to{opacity:1}50%{opacity:.4}}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] }); }
|
|
2082
2567
|
}
|
|
2083
2568
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CoinflowCardForm, decorators: [{
|
|
2084
2569
|
type: Component,
|
|
2085
|
-
args: [{
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
imports: [],
|
|
2089
|
-
template: `<iframe
|
|
2090
|
-
#cardFormIframe
|
|
2091
|
-
[src]="url"
|
|
2092
|
-
title="Card Form"
|
|
2093
|
-
frameBorder="0"
|
|
2094
|
-
allow="payment"
|
|
2570
|
+
args: [{ selector: 'lib-coinflow-card-form', standalone: true, imports: [NgStyle], template: `<div
|
|
2571
|
+
#wrapper
|
|
2572
|
+
[style.position]="'relative'"
|
|
2095
2573
|
[style.width]="'100%'"
|
|
2096
|
-
[style.height]="
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2574
|
+
[style.height]="height"
|
|
2575
|
+
>
|
|
2576
|
+
@if (rendered) {
|
|
2577
|
+
<div
|
|
2578
|
+
role="status"
|
|
2579
|
+
aria-label="Loading card form"
|
|
2580
|
+
(transitionend)="onSkeletonTransitionEnd($event)"
|
|
2581
|
+
[ngStyle]="skeletonRootStyle"
|
|
2582
|
+
>
|
|
2583
|
+
<div [ngStyle]="gridStyle">
|
|
2584
|
+
@for (area of areas; track area) {
|
|
2585
|
+
<div [ngStyle]="boxStyle(area)"></div>
|
|
2586
|
+
}
|
|
2587
|
+
</div>
|
|
2588
|
+
</div>
|
|
2589
|
+
}
|
|
2590
|
+
<iframe
|
|
2591
|
+
#cardFormIframe
|
|
2592
|
+
[src]="url"
|
|
2593
|
+
title="Card Form"
|
|
2594
|
+
frameBorder="0"
|
|
2595
|
+
allow="payment"
|
|
2596
|
+
[style.width]="'100%'"
|
|
2597
|
+
[style.height]="height"
|
|
2598
|
+
[style.border]="'none'"
|
|
2599
|
+
[style.opacity]="loaded ? 1 : 0"
|
|
2600
|
+
[style.transition]="'opacity 300ms linear, height 150ms ease-out'"
|
|
2601
|
+
></iframe>
|
|
2602
|
+
</div>`, styles: ["@keyframes coinflow-card-form-skeleton-pulse{0%,to{opacity:1}50%{opacity:.4}}\n"] }]
|
|
2603
|
+
}], ctorParameters: () => [{ type: i1.DomSanitizer }, { type: i0.NgZone }], propDecorators: { args: [{
|
|
2103
2604
|
type: Input
|
|
2104
2605
|
}], iframeRef: [{
|
|
2105
2606
|
type: ViewChild,
|
|
2106
2607
|
args: ['cardFormIframe', { static: true }]
|
|
2608
|
+
}], wrapperRef: [{
|
|
2609
|
+
type: ViewChild,
|
|
2610
|
+
args: ['wrapper', { static: true }]
|
|
2107
2611
|
}], onMessage: [{
|
|
2108
2612
|
type: HostListener,
|
|
2109
2613
|
args: ['window:message', ['$event']]
|
|
@@ -2477,5 +2981,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
|
|
|
2477
2981
|
* Generated bundle index. Do not edit.
|
|
2478
2982
|
*/
|
|
2479
2983
|
|
|
2480
|
-
export { BankingCurrencies, CARD_TYPE_MAPPING, CardType, ChargebackProtectionAccountType, CoinflowApplePayButtonComponent, CoinflowCardForm, CoinflowCardFormV2, CoinflowCardNumberInput, CoinflowCardNumberOnlyInput, CoinflowCvvInputComponent, CoinflowCvvOnlyInputComponent, CoinflowGooglePayButtonComponent, CoinflowIFrameComponent, CoinflowPurchaseComponent, CoinflowPurchaseHistoryComponent, CoinflowPurchaseProtectionComponent, CoinflowUtils, CoinflowWithdrawComponent, CoinflowWithdrawHistoryComponent, Currency, CurrencyToISO4217, DEVICE_ID_HEADER, EventBus, FORTER_TOKEN_HEADER, IFrameMessageMethods, MerchantStyle, PaymentMethods, REFERRER_HEADER, RN_REDIRECT_MESSAGE_NAME, SESSION_ID_HEADER, SettlementType, ThreeDsChallengePreference, TokenExCardNumberIframeId, TokenExCvvContainerID, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, awaitForterToken, captureForterToken, doInitializeCvvOnlyTokenExIframe, doInitializeTokenExCardOnlyIframe, doInitializeTokenExIframe, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getForterToken, getHandlers, getIframeConfig, getWalletPubkey, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, paymentMethodLabels, recordFrontendError, setTokenExScriptTag };
|
|
2984
|
+
export { BankingCurrencies, CARD_ENTRY_BORDER_PX, CARD_ENTRY_DIVIDER_PX, CARD_ENTRY_MARGIN_PX, CARD_ENTRY_MIN_WIDTHS, CARD_ENTRY_ROW_HEIGHT, CARD_ENTRY_ROW_HEIGHT_PX, CARD_ENTRY_SLOT_GAP_PX, CARD_TYPE_MAPPING, COMPACT_SKELETON_HEIGHT_PX, CardType, ChargebackProtectionAccountType, CoinflowApplePayButtonComponent, CoinflowCardForm, CoinflowCardFormV2, CoinflowCardNumberInput, CoinflowCardNumberOnlyInput, CoinflowCvvInputComponent, CoinflowCvvOnlyInputComponent, CoinflowGooglePayButtonComponent, CoinflowIFrameComponent, CoinflowPurchaseComponent, CoinflowPurchaseHistoryComponent, CoinflowPurchaseProtectionComponent, CoinflowUtils, CoinflowWithdrawComponent, CoinflowWithdrawHistoryComponent, Currency, CurrencyToISO4217, DEVICE_ID_HEADER, EventBus, FORTER_TOKEN_HEADER, IFrameMessageMethods, INLINE_SKELETON_HEIGHT_PX, MerchantStyle, PaymentMethods, REFERRER_HEADER, RN_REDIRECT_MESSAGE_NAME, SESSION_ID_HEADER, SKELETON_BOX_STYLE, SKELETON_FADE_MS, SKELETON_LAYOUTS, SKELETON_PULSE_ANIMATION_NAME, SKELETON_ROOT_PADDING_PX, SettlementType, ThreeDsChallengePreference, TokenExCardNumberIframeId, TokenExCvvContainerID, WithdrawCategory, WithdrawCurrencies, WithdrawSpeed, awaitForterToken, buildCardEntryGridCss, buildCardEntryLayout, buildSkeletonCss, captureForterToken, doInitializeCvvOnlyTokenExIframe, doInitializeTokenExCardOnlyIframe, doInitializeTokenExIframe, getCoinflowProtectionHeaders, getCoinflowPurchaseHeaders, getCurrencyDecimals, getCustomerName, getForterToken, getHandlers, getIframeConfig, getSkeletonColors, getSkeletonGridClass, getSkeletonGridTemplate, getWalletPubkey, guessSkeletonHeightPx, handleIFrameMessage, initCoinflowProtection, invertRate, isBankingCurrency, isTypedCurrencyCents, isWithdrawCurrency, isZeroAuthSavedPaymentMethods, isZeroAuthVerifyCard, nftCartItem, paymentMethodLabels, recordFrontendError, setTokenExScriptTag, shouldStackSkeleton };
|
|
2481
2985
|
//# sourceMappingURL=coinflowlabs-angular.mjs.map
|