@amos.com/amos-js 0.9.15 → 0.9.17
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 +58 -42
- package/dist/apple-pay.d.ts +5 -1
- package/dist/form-skeleton.d.ts +31 -0
- package/dist/google-pay.d.ts +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -2
- package/dist/index.mjs +217 -160
- package/dist/messaging.d.ts +2 -1
- package/dist/mount.d.ts +6 -0
- package/dist/types.d.ts +4 -1
- package/package.json +1 -1
- package/src/apple-pay.ts +5 -1
- package/src/form-skeleton.ts +77 -2
- package/src/google-pay.ts +5 -1
- package/src/index.ts +14 -2
- package/src/messaging.ts +2 -1
- package/src/mount.ts +170 -40
- package/src/types.ts +4 -1
package/dist/index.mjs
CHANGED
|
@@ -178,10 +178,10 @@ function v(e) {
|
|
|
178
178
|
function y() {
|
|
179
179
|
return "48px";
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function ee(e) {
|
|
182
182
|
e.contentWindow?.postMessage(a({ type: "APPLE_PAY_CANCEL" }), o(e));
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function b(e, { height: r = "48px", ...i }) {
|
|
185
185
|
let a = {
|
|
186
186
|
...i,
|
|
187
187
|
height: r
|
|
@@ -227,7 +227,7 @@ function x(e, { height: r = "48px", ...i }) {
|
|
|
227
227
|
break;
|
|
228
228
|
case "APPLE_PAY_WINDOW_OPEN":
|
|
229
229
|
t({ onCancel: () => {
|
|
230
|
-
|
|
230
|
+
ee(e), n();
|
|
231
231
|
} });
|
|
232
232
|
break;
|
|
233
233
|
case "APPLE_PAY_WINDOW_CLOSE":
|
|
@@ -266,14 +266,114 @@ function x(e, { height: r = "48px", ...i }) {
|
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
268
|
//#endregion
|
|
269
|
+
//#region src/form-skeleton.ts
|
|
270
|
+
var x = "amos-js-form-skeleton-styles", S = {
|
|
271
|
+
"--accent": "oklch(0.97 0 0)",
|
|
272
|
+
"--radius": "0.625rem",
|
|
273
|
+
"--input-height": "2.25rem",
|
|
274
|
+
"--floating-input-height": "3.25rem",
|
|
275
|
+
"--field-gap": "1rem",
|
|
276
|
+
"--control-gap": "0.5rem",
|
|
277
|
+
"--label-font-size": "0.875rem"
|
|
278
|
+
}, C = "\n.amos-js-form-skeleton {\n box-sizing: border-box;\n container-type: inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n margin: 0 -4px;\n padding-block: 0.25rem;\n pointer-events: none;\n width: calc(100% + 8px);\n}\n.amos-js-form-skeleton-field {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n min-width: 0;\n width: 100%;\n}\n.amos-js-form-skeleton-label {\n flex-shrink: 0;\n font-size: var(--label-font-size);\n height: 1.75rem;\n line-height: 1.75rem;\n}\n.amos-js-form-skeleton-input {\n animation: amos-js-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n background: var(--accent);\n border-radius: calc(var(--radius) * 0.8);\n box-sizing: border-box;\n height: var(--input-height);\n width: 100%;\n}\n.amos-js-form-skeleton-input-floating {\n height: var(--floating-input-height);\n}\n.amos-js-form-skeleton-row {\n align-items: flex-start;\n display: flex;\n gap: var(--control-gap);\n width: 100%;\n}\n.amos-js-form-skeleton-row-stack {\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n width: 100%;\n}\n@container (min-width: 24rem) {\n .amos-js-form-skeleton-row-stack {\n align-items: flex-start;\n flex-direction: row;\n gap: var(--control-gap);\n }\n}\n.amos-js-wallet-skeleton {\n flex: none;\n width: 100%;\n}\n@keyframes amos-js-skeleton-pulse {\n 50% { opacity: 0.5; }\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-form-skeleton-input {\n animation: none;\n }\n}\n";
|
|
279
|
+
function w() {
|
|
280
|
+
if (document.getElementById(x)) return;
|
|
281
|
+
let e = document.createElement("style");
|
|
282
|
+
e.id = x, e.textContent = C, document.head.appendChild(e);
|
|
283
|
+
}
|
|
284
|
+
function T(e, t) {
|
|
285
|
+
for (let [t, n] of Object.entries(S)) e.style.setProperty(t, n);
|
|
286
|
+
let n = t?.themeVariables;
|
|
287
|
+
if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
|
|
288
|
+
}
|
|
289
|
+
function E(e, t) {
|
|
290
|
+
let n = document.createElement("div");
|
|
291
|
+
if (n.className = e, t) for (let e of t) n.appendChild(e);
|
|
292
|
+
return n;
|
|
293
|
+
}
|
|
294
|
+
function D(e, t) {
|
|
295
|
+
let n = E("amos-js-form-skeleton-field");
|
|
296
|
+
t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(E("amos-js-form-skeleton-label"));
|
|
297
|
+
let r = E("amos-js-form-skeleton-input");
|
|
298
|
+
return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
|
|
299
|
+
}
|
|
300
|
+
function O(e, t) {
|
|
301
|
+
return E(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
|
|
302
|
+
}
|
|
303
|
+
function k({ labels: e, requirement: t, wrapCountryZip: n }) {
|
|
304
|
+
return t === "full" ? [
|
|
305
|
+
D(e),
|
|
306
|
+
D(e),
|
|
307
|
+
O([
|
|
308
|
+
D(e, 1.4),
|
|
309
|
+
D(e, .7),
|
|
310
|
+
D(e, .8)
|
|
311
|
+
], !1),
|
|
312
|
+
D(e)
|
|
313
|
+
] : [O([D(e), D(e)], n)];
|
|
314
|
+
}
|
|
315
|
+
function A(e) {
|
|
316
|
+
let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
|
|
317
|
+
if (e.kind === "card") {
|
|
318
|
+
let r = [D(t), O([D(t), D(t)], !1)];
|
|
319
|
+
return e.additionalFields?.cardholderName && r.push(D(t)), r.push(...k({
|
|
320
|
+
labels: t,
|
|
321
|
+
requirement: n,
|
|
322
|
+
wrapCountryZip: !1
|
|
323
|
+
})), r;
|
|
324
|
+
}
|
|
325
|
+
return [
|
|
326
|
+
D(t),
|
|
327
|
+
O([D(t), D(t)], !0),
|
|
328
|
+
D(t),
|
|
329
|
+
O([D("above"), D("above")], !0),
|
|
330
|
+
...k({
|
|
331
|
+
labels: t,
|
|
332
|
+
requirement: n,
|
|
333
|
+
wrapCountryZip: !0
|
|
334
|
+
})
|
|
335
|
+
];
|
|
336
|
+
}
|
|
337
|
+
function j(e) {
|
|
338
|
+
w();
|
|
339
|
+
let t = E("amos-js-form-skeleton");
|
|
340
|
+
t.setAttribute("aria-hidden", "true");
|
|
341
|
+
function n(e) {
|
|
342
|
+
T(t, e.appearance), t.replaceChildren(...A(e));
|
|
343
|
+
}
|
|
344
|
+
return n(e), {
|
|
345
|
+
element: t,
|
|
346
|
+
update: n
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function M(e) {
|
|
350
|
+
w();
|
|
351
|
+
let t = E("amos-js-form-skeleton-input amos-js-wallet-skeleton");
|
|
352
|
+
t.setAttribute("aria-hidden", "true");
|
|
353
|
+
function n(e) {
|
|
354
|
+
T(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
|
|
355
|
+
}
|
|
356
|
+
return n(e), {
|
|
357
|
+
element: t,
|
|
358
|
+
update: n
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function N(e) {
|
|
362
|
+
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
363
|
+
if (typeof e == "string" && e.trim() !== "") return e.trim();
|
|
364
|
+
}
|
|
365
|
+
function P({ iframeStyle: e, buttonProps: t }) {
|
|
366
|
+
return N(e?.borderRadius) ?? N(t?.buttonRadius) ?? N(t?.style?.borderRadius) ?? N(t?.style?.["--apple-pay-button-border-radius"]) ?? "4px";
|
|
367
|
+
}
|
|
368
|
+
//#endregion
|
|
269
369
|
//#region src/google-pay.ts
|
|
270
|
-
function
|
|
370
|
+
function F(e) {
|
|
271
371
|
return `${i(e)}/iframe/google-pay?token=${e}`;
|
|
272
372
|
}
|
|
273
|
-
function
|
|
373
|
+
function I() {
|
|
274
374
|
return "48px";
|
|
275
375
|
}
|
|
276
|
-
function
|
|
376
|
+
function L(e, { height: t = "48px", ...n }) {
|
|
277
377
|
let r = {
|
|
278
378
|
...n,
|
|
279
379
|
height: t
|
|
@@ -349,7 +449,7 @@ function w(e, { height: t = "48px", ...n }) {
|
|
|
349
449
|
}
|
|
350
450
|
};
|
|
351
451
|
}
|
|
352
|
-
function
|
|
452
|
+
function R({ paymentData: e }) {
|
|
353
453
|
return { paymentMethod: {
|
|
354
454
|
type: "googlepay",
|
|
355
455
|
billing_address_attributes: {
|
|
@@ -367,96 +467,15 @@ function T({ paymentData: e }) {
|
|
|
367
467
|
} };
|
|
368
468
|
}
|
|
369
469
|
//#endregion
|
|
370
|
-
//#region src/form-skeleton.ts
|
|
371
|
-
var E = "amos-js-form-skeleton-styles", D = {
|
|
372
|
-
"--accent": "oklch(0.97 0 0)",
|
|
373
|
-
"--radius": "0.625rem",
|
|
374
|
-
"--input-height": "2.25rem",
|
|
375
|
-
"--floating-input-height": "3.25rem",
|
|
376
|
-
"--field-gap": "1rem",
|
|
377
|
-
"--control-gap": "0.5rem",
|
|
378
|
-
"--label-font-size": "0.875rem"
|
|
379
|
-
}, O = "\n.amos-js-form-skeleton {\n box-sizing: border-box;\n container-type: inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n margin: 0 -4px;\n padding-block: 0.25rem;\n pointer-events: none;\n width: calc(100% + 8px);\n}\n.amos-js-form-skeleton-field {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n min-width: 0;\n width: 100%;\n}\n.amos-js-form-skeleton-label {\n flex-shrink: 0;\n font-size: var(--label-font-size);\n height: 1.75rem;\n line-height: 1.75rem;\n}\n.amos-js-form-skeleton-input {\n animation: amos-js-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n background: var(--accent);\n border-radius: calc(var(--radius) * 0.8);\n box-sizing: border-box;\n height: var(--input-height);\n width: 100%;\n}\n.amos-js-form-skeleton-input-floating {\n height: var(--floating-input-height);\n}\n.amos-js-form-skeleton-row {\n align-items: flex-start;\n display: flex;\n gap: var(--control-gap);\n width: 100%;\n}\n.amos-js-form-skeleton-row-stack {\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n width: 100%;\n}\n@container (min-width: 24rem) {\n .amos-js-form-skeleton-row-stack {\n align-items: flex-start;\n flex-direction: row;\n gap: var(--control-gap);\n }\n}\n@keyframes amos-js-skeleton-pulse {\n 50% { opacity: 0.5; }\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-form-skeleton-input {\n animation: none;\n }\n}\n";
|
|
380
|
-
function k() {
|
|
381
|
-
if (document.getElementById(E)) return;
|
|
382
|
-
let e = document.createElement("style");
|
|
383
|
-
e.id = E, e.textContent = O, document.head.appendChild(e);
|
|
384
|
-
}
|
|
385
|
-
function A(e, t) {
|
|
386
|
-
for (let [t, n] of Object.entries(D)) e.style.setProperty(t, n);
|
|
387
|
-
let n = t?.themeVariables;
|
|
388
|
-
if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
|
|
389
|
-
}
|
|
390
|
-
function j(e, t) {
|
|
391
|
-
let n = document.createElement("div");
|
|
392
|
-
if (n.className = e, t) for (let e of t) n.appendChild(e);
|
|
393
|
-
return n;
|
|
394
|
-
}
|
|
395
|
-
function M(e, t) {
|
|
396
|
-
let n = j("amos-js-form-skeleton-field");
|
|
397
|
-
t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(j("amos-js-form-skeleton-label"));
|
|
398
|
-
let r = j("amos-js-form-skeleton-input");
|
|
399
|
-
return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
|
|
400
|
-
}
|
|
401
|
-
function N(e, t) {
|
|
402
|
-
return j(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
|
|
403
|
-
}
|
|
404
|
-
function P({ labels: e, requirement: t, wrapCountryZip: n }) {
|
|
405
|
-
return t === "full" ? [
|
|
406
|
-
M(e),
|
|
407
|
-
M(e),
|
|
408
|
-
N([
|
|
409
|
-
M(e, 1.4),
|
|
410
|
-
M(e, .7),
|
|
411
|
-
M(e, .8)
|
|
412
|
-
], !1),
|
|
413
|
-
M(e)
|
|
414
|
-
] : [N([M(e), M(e)], n)];
|
|
415
|
-
}
|
|
416
|
-
function F(e) {
|
|
417
|
-
let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
|
|
418
|
-
if (e.kind === "card") {
|
|
419
|
-
let r = [M(t), N([M(t), M(t)], !1)];
|
|
420
|
-
return e.additionalFields?.cardholderName && r.push(M(t)), r.push(...P({
|
|
421
|
-
labels: t,
|
|
422
|
-
requirement: n,
|
|
423
|
-
wrapCountryZip: !1
|
|
424
|
-
})), r;
|
|
425
|
-
}
|
|
426
|
-
return [
|
|
427
|
-
M(t),
|
|
428
|
-
N([M(t), M(t)], !0),
|
|
429
|
-
M(t),
|
|
430
|
-
N([M("above"), M("above")], !0),
|
|
431
|
-
...P({
|
|
432
|
-
labels: t,
|
|
433
|
-
requirement: n,
|
|
434
|
-
wrapCountryZip: !0
|
|
435
|
-
})
|
|
436
|
-
];
|
|
437
|
-
}
|
|
438
|
-
function I(e) {
|
|
439
|
-
k();
|
|
440
|
-
let t = j("amos-js-form-skeleton");
|
|
441
|
-
t.setAttribute("aria-hidden", "true");
|
|
442
|
-
function n(e) {
|
|
443
|
-
A(t, e.appearance), t.replaceChildren(...F(e));
|
|
444
|
-
}
|
|
445
|
-
return n(e), {
|
|
446
|
-
element: t,
|
|
447
|
-
update: n
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
//#endregion
|
|
451
470
|
//#region src/payment-method-form.ts
|
|
452
|
-
var
|
|
471
|
+
var z = {
|
|
453
472
|
country: 212,
|
|
454
473
|
full: 452
|
|
455
|
-
},
|
|
474
|
+
}, te = 80, B = {
|
|
456
475
|
country: 400,
|
|
457
476
|
full: 640
|
|
458
477
|
};
|
|
459
|
-
function
|
|
478
|
+
function V(e, t = { cardholderName: !1 }, n = "country") {
|
|
460
479
|
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
|
|
461
480
|
token: e,
|
|
462
481
|
additionalFields: r,
|
|
@@ -464,20 +483,20 @@ function B(e, t = { cardholderName: !1 }, n = "country") {
|
|
|
464
483
|
});
|
|
465
484
|
return `${i(e)}/iframe/card?${a}`;
|
|
466
485
|
}
|
|
467
|
-
function
|
|
486
|
+
function H(e, t = "country") {
|
|
468
487
|
let n = new URLSearchParams({
|
|
469
488
|
token: e,
|
|
470
489
|
billingAddressRequirement: t
|
|
471
490
|
});
|
|
472
491
|
return `${i(e)}/iframe/bank?${n}`;
|
|
473
492
|
}
|
|
474
|
-
function
|
|
475
|
-
return `${(
|
|
493
|
+
function U(e = { cardholderName: !1 }, t = "country") {
|
|
494
|
+
return `${(z[t] ?? z.country) + (e.cardholderName ? te : 0)}px`;
|
|
476
495
|
}
|
|
477
|
-
function
|
|
478
|
-
return `${
|
|
496
|
+
function W(e = "country") {
|
|
497
|
+
return `${B[e] ?? B.country}px`;
|
|
479
498
|
}
|
|
480
|
-
function
|
|
499
|
+
function G(e, t) {
|
|
481
500
|
let n = { ...t };
|
|
482
501
|
function r(t) {
|
|
483
502
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
@@ -523,7 +542,7 @@ function W(e, t) {
|
|
|
523
542
|
}
|
|
524
543
|
//#endregion
|
|
525
544
|
//#region src/mount.ts
|
|
526
|
-
function
|
|
545
|
+
function K(e) {
|
|
527
546
|
if (typeof e == "string") {
|
|
528
547
|
let t = document.querySelector(e);
|
|
529
548
|
if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
|
|
@@ -531,19 +550,29 @@ function G(e) {
|
|
|
531
550
|
}
|
|
532
551
|
return e;
|
|
533
552
|
}
|
|
534
|
-
var
|
|
553
|
+
var q = {
|
|
535
554
|
width: "calc(100% + 8px)",
|
|
536
555
|
transition: "opacity 150ms ease-in, height 200ms ease-in-out",
|
|
537
556
|
margin: "0 -4px",
|
|
538
557
|
opacity: "0",
|
|
539
558
|
border: "0"
|
|
540
|
-
},
|
|
559
|
+
}, J = {
|
|
541
560
|
width: "100%",
|
|
542
561
|
transition: "height 200ms ease-in-out",
|
|
543
562
|
margin: "0",
|
|
544
563
|
opacity: "0",
|
|
545
564
|
border: "0"
|
|
546
|
-
},
|
|
565
|
+
}, Y = {
|
|
566
|
+
position: "absolute",
|
|
567
|
+
top: "0",
|
|
568
|
+
left: "0",
|
|
569
|
+
width: "100%",
|
|
570
|
+
height: "100%",
|
|
571
|
+
margin: "0",
|
|
572
|
+
opacity: "0",
|
|
573
|
+
transition: "none",
|
|
574
|
+
pointerEvents: "none"
|
|
575
|
+
}, X = {
|
|
547
576
|
position: "absolute",
|
|
548
577
|
top: "0",
|
|
549
578
|
left: "-4px",
|
|
@@ -553,15 +582,15 @@ var K = {
|
|
|
553
582
|
transition: "none",
|
|
554
583
|
pointerEvents: "none"
|
|
555
584
|
};
|
|
556
|
-
function
|
|
585
|
+
function Z({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = q }) {
|
|
557
586
|
let s = document.createElement("iframe");
|
|
558
587
|
return s.src = e, s.title = t, s.name = n, s.setAttribute("role", "presentation"), s.scrolling = "no", i && (s.allow = i), a != null && (s.className = a), Object.assign(s.style, o, { height: r }), s;
|
|
559
588
|
}
|
|
560
|
-
function
|
|
589
|
+
function Q({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
561
590
|
let i = document.createElement("div");
|
|
562
591
|
i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
|
|
563
|
-
let a =
|
|
564
|
-
Object.assign(t.style,
|
|
592
|
+
let a = j(r);
|
|
593
|
+
Object.assign(t.style, X), i.append(a.element, t), e.appendChild(i);
|
|
565
594
|
let o = !1, s = !1, c, l = r.appearance, u, d;
|
|
566
595
|
function f() {
|
|
567
596
|
return i.getBoundingClientRect().height;
|
|
@@ -573,7 +602,7 @@ function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
573
602
|
if (o) return;
|
|
574
603
|
o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
|
|
575
604
|
let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
|
|
576
|
-
t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin =
|
|
605
|
+
t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = q.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
|
|
577
606
|
t.style.transition = "height 200ms ease-in-out";
|
|
578
607
|
}, 400);
|
|
579
608
|
}
|
|
@@ -582,7 +611,7 @@ function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
582
611
|
let e = p(), t = f();
|
|
583
612
|
Number.isFinite(e) && e >= t - 2 && m();
|
|
584
613
|
}
|
|
585
|
-
let g =
|
|
614
|
+
let g = G(t, {
|
|
586
615
|
...n,
|
|
587
616
|
onHeightChange: (e) => {
|
|
588
617
|
c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
|
|
@@ -606,15 +635,63 @@ function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
606
635
|
}
|
|
607
636
|
};
|
|
608
637
|
}
|
|
609
|
-
function
|
|
610
|
-
let
|
|
611
|
-
|
|
638
|
+
function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
|
|
639
|
+
let a = {
|
|
640
|
+
height: n.height ?? "48px",
|
|
641
|
+
borderRadius: P({
|
|
642
|
+
iframeStyle: r,
|
|
643
|
+
buttonProps: n.buttonProps
|
|
644
|
+
})
|
|
645
|
+
}, o = M(a), s = document.createElement("div");
|
|
646
|
+
s.style.position = "relative", s.style.width = "100%", s.style.height = a.height, s.style.overflow = "hidden", s.setAttribute("aria-busy", "true"), Object.assign(t.style, Y), t.style.height = "100%", s.append(o.element, t), e.appendChild(s);
|
|
647
|
+
let c = !1, l = !1, u, d = n;
|
|
648
|
+
function f() {
|
|
649
|
+
c || (c = !0, u !== void 0 && (clearTimeout(u), u = void 0), t.style.opacity = "1", t.style.pointerEvents = "", o.element.remove(), s.removeAttribute("aria-busy"));
|
|
650
|
+
}
|
|
651
|
+
function p() {
|
|
652
|
+
c || !l || f();
|
|
653
|
+
}
|
|
654
|
+
let m = i(t, {
|
|
655
|
+
...n,
|
|
656
|
+
onHeightChange: (e) => {
|
|
657
|
+
d.onHeightChange?.(e);
|
|
658
|
+
},
|
|
659
|
+
onAppearanceReady: () => {
|
|
660
|
+
l = !0, p(), d.onAppearanceReady?.();
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
return u = setTimeout(() => {
|
|
664
|
+
f();
|
|
665
|
+
}, 1500), {
|
|
666
|
+
iframe: t,
|
|
667
|
+
update(e) {
|
|
668
|
+
d = {
|
|
669
|
+
...d,
|
|
670
|
+
...e
|
|
671
|
+
};
|
|
672
|
+
let t = { ...e };
|
|
673
|
+
delete t.onAppearanceReady, delete t.onHeightChange, m.update(t), a = {
|
|
674
|
+
height: d.height ?? a.height,
|
|
675
|
+
borderRadius: P({
|
|
676
|
+
iframeStyle: r,
|
|
677
|
+
buttonProps: d.buttonProps
|
|
678
|
+
})
|
|
679
|
+
}, s.style.height = a.height, c || o.update(a);
|
|
680
|
+
},
|
|
681
|
+
destroy() {
|
|
682
|
+
u !== void 0 && clearTimeout(u), m.destroy(), s.remove();
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
function ne(e, t) {
|
|
687
|
+
let n = K(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
|
|
688
|
+
return Q({
|
|
612
689
|
host: n,
|
|
613
|
-
iframe:
|
|
614
|
-
src:
|
|
690
|
+
iframe: Z({
|
|
691
|
+
src: V(r, i, a),
|
|
615
692
|
title: "Secure credit card payment method form powered by Amos",
|
|
616
693
|
name: "amos-credit-card-payment-method-form",
|
|
617
|
-
height:
|
|
694
|
+
height: U(i, a)
|
|
618
695
|
}),
|
|
619
696
|
listenerOptions: o,
|
|
620
697
|
skeletonOptions: {
|
|
@@ -625,15 +702,15 @@ function Z(e, t) {
|
|
|
625
702
|
}
|
|
626
703
|
});
|
|
627
704
|
}
|
|
628
|
-
function
|
|
629
|
-
let n =
|
|
630
|
-
return
|
|
705
|
+
function re(e, t) {
|
|
706
|
+
let n = K(e), { renderToken: r, billingAddressRequirement: i = "country", ...a } = t;
|
|
707
|
+
return Q({
|
|
631
708
|
host: n,
|
|
632
|
-
iframe:
|
|
633
|
-
src:
|
|
709
|
+
iframe: Z({
|
|
710
|
+
src: H(r, i),
|
|
634
711
|
title: "Secure bank account payment method form powered by Amos",
|
|
635
712
|
name: "amos-bank-account-payment-method-form",
|
|
636
|
-
height:
|
|
713
|
+
height: W(i)
|
|
637
714
|
}),
|
|
638
715
|
listenerOptions: a,
|
|
639
716
|
skeletonOptions: {
|
|
@@ -643,61 +720,41 @@ function Q(e, t) {
|
|
|
643
720
|
}
|
|
644
721
|
});
|
|
645
722
|
}
|
|
646
|
-
function
|
|
647
|
-
let n =
|
|
648
|
-
src:
|
|
723
|
+
function ie(e, t) {
|
|
724
|
+
let n = K(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Z({
|
|
725
|
+
src: F(r),
|
|
649
726
|
title: "Secure Google Pay button powered by Amos",
|
|
650
727
|
name: "amos-google-pay-button",
|
|
651
|
-
height: o.height ??
|
|
728
|
+
height: o.height ?? I(),
|
|
652
729
|
allow: "payment",
|
|
653
730
|
className: i,
|
|
654
|
-
style:
|
|
655
|
-
});
|
|
656
|
-
Object.assign(s.style, a), n.appendChild(s);
|
|
657
|
-
let c = w(s, {
|
|
658
|
-
...o,
|
|
659
|
-
onHeightChange: (e) => {
|
|
660
|
-
s.style.height = e, o.onHeightChange?.(e);
|
|
661
|
-
},
|
|
662
|
-
onAppearanceReady: () => {
|
|
663
|
-
s.style.opacity = "1", o.onAppearanceReady?.();
|
|
664
|
-
}
|
|
731
|
+
style: J
|
|
665
732
|
});
|
|
666
|
-
return {
|
|
733
|
+
return Object.assign(s.style, a), $({
|
|
734
|
+
host: n,
|
|
667
735
|
iframe: s,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
};
|
|
736
|
+
listenerOptions: o,
|
|
737
|
+
iframeStyle: a,
|
|
738
|
+
attachListeners: L
|
|
739
|
+
});
|
|
673
740
|
}
|
|
674
|
-
function
|
|
675
|
-
let n =
|
|
741
|
+
function ae(e, t) {
|
|
742
|
+
let n = K(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Z({
|
|
676
743
|
src: v(r),
|
|
677
744
|
title: "Secure Apple Pay button powered by Amos",
|
|
678
745
|
name: "amos-apple-pay-button",
|
|
679
746
|
height: o.height ?? y(),
|
|
680
747
|
allow: "payment",
|
|
681
748
|
className: i,
|
|
682
|
-
style:
|
|
749
|
+
style: J
|
|
683
750
|
});
|
|
684
|
-
Object.assign(s.style, a),
|
|
685
|
-
|
|
686
|
-
...o,
|
|
687
|
-
onHeightChange: (e) => {
|
|
688
|
-
s.style.height = e, o.onHeightChange?.(e);
|
|
689
|
-
},
|
|
690
|
-
onAppearanceReady: () => {
|
|
691
|
-
s.style.opacity = "1", o.onAppearanceReady?.();
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
return {
|
|
751
|
+
return Object.assign(s.style, a), $({
|
|
752
|
+
host: n,
|
|
695
753
|
iframe: s,
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
};
|
|
754
|
+
listenerOptions: o,
|
|
755
|
+
iframeStyle: a,
|
|
756
|
+
attachListeners: b
|
|
757
|
+
});
|
|
701
758
|
}
|
|
702
759
|
//#endregion
|
|
703
|
-
export {
|
|
760
|
+
export { C as SKELETON_STYLES, b as attachApplePayButtonListeners, L as attachGooglePayButtonListeners, G as attachPaymentMethodFormListeners, h as confirmPaymentIntent, g as confirmSetupIntent, a as createMessage, j as createPaymentMethodFormSkeleton, M as createWalletButtonSkeleton, r as decodeJwt, w as ensureSkeletonStyles, R as formatGooglePayPaymentData, y as getApplePayButtonInitialHeight, v as getApplePayButtonSrc, W as getBankAccountFormInitialHeight, H as getBankAccountFormSrc, U as getCreditCardFormInitialHeight, V as getCreditCardFormSrc, i as getEmbedOrigin, I as getGooglePayButtonInitialHeight, F as getGooglePayButtonSrc, ae as mountAmosApplePayButton, re as mountAmosBankAccountPaymentMethodForm, ne as mountAmosCreditCardPaymentMethodForm, ie as mountAmosGooglePayButton, m as resetForm, P as resolveWalletButtonSkeletonBorderRadius, _ as sendConfirmationResult, s as sendParentReadyMessage, d as updateAmount, c as updateAppearance, l as updateApplePayButton, u as updateGooglePayButton, f as updateMerchantName, p as validateForm };
|
package/dist/messaging.d.ts
CHANGED
|
@@ -43,7 +43,8 @@ export declare function updateGooglePayButton({ iframe, props, height, }: {
|
|
|
43
43
|
height?: string;
|
|
44
44
|
}): void;
|
|
45
45
|
/**
|
|
46
|
-
* Push the express-checkout amount into the embedded
|
|
46
|
+
* Push the express-checkout amount into the embedded wallet iframe.
|
|
47
|
+
* `amount` is a major-currency decimal string (e.g. `"50.00"` for $50.00).
|
|
47
48
|
*/
|
|
48
49
|
export declare function updateAmount({ iframe, amount, }: {
|
|
49
50
|
iframe: Iframe;
|
package/dist/mount.d.ts
CHANGED
|
@@ -116,6 +116,9 @@ export type AmosGooglePayButtonMountController = GooglePayButtonController & {
|
|
|
116
116
|
* Mount the secure Google Pay button (express checkout) into a
|
|
117
117
|
* container element. Returns a controller exposing the underlying
|
|
118
118
|
* iframe, an `update()` method, and a `destroy()` method.
|
|
119
|
+
*
|
|
120
|
+
* A button-shaped skeleton is shown immediately and replaced by the
|
|
121
|
+
* iframe once appearance is applied.
|
|
119
122
|
*/
|
|
120
123
|
export declare function mountAmosGooglePayButton(container: Container, options: AmosGooglePayButtonOptions): AmosGooglePayButtonMountController;
|
|
121
124
|
/**
|
|
@@ -150,6 +153,9 @@ export type AmosApplePayButtonMountController = ApplePayButtonController & {
|
|
|
150
153
|
* Mount the secure Apple Pay button (express checkout) into a
|
|
151
154
|
* container element. Returns a controller exposing the underlying
|
|
152
155
|
* iframe, an `update()` method, and a `destroy()` method.
|
|
156
|
+
*
|
|
157
|
+
* A button-shaped skeleton is shown immediately and replaced by the
|
|
158
|
+
* iframe once appearance is applied.
|
|
153
159
|
*/
|
|
154
160
|
export declare function mountAmosApplePayButton(container: Container, options: AmosApplePayButtonOptions): AmosApplePayButtonMountController;
|
|
155
161
|
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -145,7 +145,10 @@ export type Message = {
|
|
|
145
145
|
type: "UPDATE_HEIGHT";
|
|
146
146
|
height: string;
|
|
147
147
|
} | {
|
|
148
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Parent → embed: express-checkout amount changed. Major-currency
|
|
150
|
+
* decimal string (e.g. `"50.00"` for $50.00).
|
|
151
|
+
*/
|
|
149
152
|
type: "UPDATE_AMOUNT";
|
|
150
153
|
amount: string;
|
|
151
154
|
} | {
|
package/package.json
CHANGED
package/src/apple-pay.ts
CHANGED
|
@@ -38,7 +38,11 @@ export function getApplePayButtonInitialHeight(): string {
|
|
|
38
38
|
* Options accepted by {@link attachApplePayButtonListeners}.
|
|
39
39
|
*/
|
|
40
40
|
export type ApplePayButtonListenerOptions = {
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Major-currency decimal string shown in the Apple Pay sheet
|
|
43
|
+
* (e.g. `"50.00"` for $50.00). Converted to cents in
|
|
44
|
+
* `paymentIntentCreateAttributes.amount`.
|
|
45
|
+
*/
|
|
42
46
|
amount: string;
|
|
43
47
|
/** A user-visible merchant name. */
|
|
44
48
|
merchantName: string;
|