@amos.com/amos-js 0.9.13 → 0.9.15
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 +67 -74
- package/dist/apple-pay.d.ts +14 -9
- package/dist/google-pay.d.ts +16 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +214 -237
- package/dist/messaging.d.ts +4 -2
- package/dist/mount.d.ts +14 -0
- package/dist/types.d.ts +25 -81
- package/package.json +1 -1
- package/src/apple-pay.ts +25 -23
- package/src/google-pay.ts +27 -27
- package/src/index.ts +1 -9
- package/src/messaging.ts +8 -4
- package/src/mount.ts +29 -4
- package/src/types.ts +43 -179
package/dist/index.mjs
CHANGED
|
@@ -85,82 +85,55 @@ function i(e) {
|
|
|
85
85
|
//#endregion
|
|
86
86
|
//#region src/types.ts
|
|
87
87
|
function a(e) {
|
|
88
|
-
if (!e || typeof e != "object") return;
|
|
89
|
-
let t = {};
|
|
90
|
-
for (let [n, r] of Object.entries(e)) {
|
|
91
|
-
if (typeof r == "string") {
|
|
92
|
-
if (r.length === 0) continue;
|
|
93
|
-
t[n] = r;
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
typeof r == "number" && Number.isFinite(r) && (t[n] = r);
|
|
97
|
-
}
|
|
98
|
-
return Object.keys(t).length > 0 ? t : void 0;
|
|
99
|
-
}
|
|
100
|
-
function o(e) {
|
|
101
|
-
let t = {};
|
|
102
|
-
if (e.fullWidth !== void 0 && (t.fullWidth = e.fullWidth), e.buttonstyle !== void 0 && (t.buttonstyle = e.buttonstyle), e.type !== void 0 && (t.type = e.type), e.locale !== void 0 && (t.locale = e.locale), e.style !== void 0) {
|
|
103
|
-
let n = a(e.style);
|
|
104
|
-
n && (t.style = n);
|
|
105
|
-
}
|
|
106
|
-
return t;
|
|
107
|
-
}
|
|
108
|
-
function s(e) {
|
|
109
|
-
let t = {};
|
|
110
|
-
if (e.fullWidth !== void 0 && (t.fullWidth = e.fullWidth), e.buttonType !== void 0 && (t.buttonType = e.buttonType), e.buttonColor !== void 0 && (t.buttonColor = e.buttonColor), e.buttonRadius !== void 0 && (t.buttonRadius = e.buttonRadius), e.buttonSizeMode !== void 0 && (t.buttonSizeMode = e.buttonSizeMode), e.buttonLocale !== void 0 && (t.buttonLocale = e.buttonLocale), e.buttonBorderType !== void 0 && (t.buttonBorderType = e.buttonBorderType), e.style !== void 0) {
|
|
111
|
-
let n = a(e.style);
|
|
112
|
-
n && (t.style = n);
|
|
113
|
-
}
|
|
114
|
-
return t;
|
|
115
|
-
}
|
|
116
|
-
function c(e) {
|
|
117
88
|
return e;
|
|
118
89
|
}
|
|
119
90
|
//#endregion
|
|
120
91
|
//#region src/messaging.ts
|
|
121
|
-
function
|
|
92
|
+
function o(e) {
|
|
122
93
|
return new URL(e.src).origin;
|
|
123
94
|
}
|
|
124
|
-
function
|
|
125
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
95
|
+
function s(e) {
|
|
96
|
+
e?.contentWindow && e.contentWindow.postMessage(a({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), o(e));
|
|
126
97
|
}
|
|
127
|
-
function
|
|
128
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
98
|
+
function c({ iframe: e, appearance: t = {} }) {
|
|
99
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
129
100
|
type: "UPDATE_APPEARANCE",
|
|
130
101
|
appearance: t
|
|
131
|
-
}),
|
|
102
|
+
}), o(e));
|
|
132
103
|
}
|
|
133
|
-
function
|
|
134
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
104
|
+
function l({ iframe: e, props: t, height: n }) {
|
|
105
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
135
106
|
type: "UPDATE_APPLE_PAY_BUTTON",
|
|
136
|
-
|
|
137
|
-
|
|
107
|
+
height: n,
|
|
108
|
+
props: t
|
|
109
|
+
}), o(e));
|
|
138
110
|
}
|
|
139
|
-
function
|
|
140
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
111
|
+
function u({ iframe: e, props: t, height: n }) {
|
|
112
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
141
113
|
type: "UPDATE_GOOGLE_PAY_BUTTON",
|
|
142
|
-
|
|
143
|
-
|
|
114
|
+
height: n,
|
|
115
|
+
props: t
|
|
116
|
+
}), o(e));
|
|
144
117
|
}
|
|
145
|
-
function
|
|
146
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
118
|
+
function d({ iframe: e, amount: t }) {
|
|
119
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
147
120
|
type: "UPDATE_AMOUNT",
|
|
148
121
|
amount: t
|
|
149
|
-
}),
|
|
122
|
+
}), o(e));
|
|
150
123
|
}
|
|
151
|
-
function
|
|
152
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
124
|
+
function f({ iframe: e, merchantName: t }) {
|
|
125
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
153
126
|
type: "UPDATE_MERCHANT_NAME",
|
|
154
127
|
merchantName: t
|
|
155
|
-
}),
|
|
128
|
+
}), o(e));
|
|
156
129
|
}
|
|
157
|
-
function
|
|
130
|
+
function p({ iframe: e }) {
|
|
158
131
|
let t = crypto.randomUUID();
|
|
159
132
|
return new Promise((n) => {
|
|
160
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
133
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
161
134
|
type: "VALIDATE_FORM",
|
|
162
135
|
requestId: t
|
|
163
|
-
}),
|
|
136
|
+
}), o(e));
|
|
164
137
|
let r = setTimeout(() => {
|
|
165
138
|
window.removeEventListener("message", i), n(!1);
|
|
166
139
|
}, 5e3);
|
|
@@ -170,211 +143,213 @@ function g({ iframe: e }) {
|
|
|
170
143
|
window.addEventListener("message", i);
|
|
171
144
|
});
|
|
172
145
|
}
|
|
173
|
-
function
|
|
174
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
146
|
+
function m({ iframe: e }) {
|
|
147
|
+
e?.contentWindow && e.contentWindow.postMessage(a({ type: "RESET_FORM" }), o(e));
|
|
175
148
|
}
|
|
176
|
-
function
|
|
149
|
+
function h({ iframe: e, token: t }) {
|
|
177
150
|
if (!e?.contentWindow) return;
|
|
178
151
|
let { payment_intent_id: n } = r(t).payload;
|
|
179
|
-
e.contentWindow.postMessage(
|
|
152
|
+
e.contentWindow.postMessage(a({
|
|
180
153
|
type: "CONFIRM_PAYMENT_INTENT",
|
|
181
154
|
token: t,
|
|
182
155
|
id: n ?? void 0
|
|
183
|
-
}),
|
|
156
|
+
}), o(e));
|
|
184
157
|
}
|
|
185
|
-
function
|
|
158
|
+
function g({ iframe: e, token: t }) {
|
|
186
159
|
if (!e?.contentWindow) return;
|
|
187
160
|
let { setup_intent_id: n } = r(t).payload;
|
|
188
|
-
e.contentWindow.postMessage(
|
|
161
|
+
e.contentWindow.postMessage(a({
|
|
189
162
|
type: "CONFIRM_SETUP_INTENT",
|
|
190
163
|
token: t,
|
|
191
164
|
id: n ?? void 0
|
|
192
|
-
}),
|
|
165
|
+
}), o(e));
|
|
193
166
|
}
|
|
194
|
-
function
|
|
195
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
167
|
+
function _({ iframe: e, result: t }) {
|
|
168
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
196
169
|
type: "CONFIRMATION_RESULT",
|
|
197
170
|
result: t
|
|
198
|
-
}),
|
|
171
|
+
}), o(e));
|
|
199
172
|
}
|
|
200
173
|
//#endregion
|
|
201
174
|
//#region src/apple-pay.ts
|
|
202
|
-
function
|
|
175
|
+
function v(e) {
|
|
203
176
|
return `${i(e)}/iframe/apple-pay?token=${e}`;
|
|
204
177
|
}
|
|
205
|
-
function
|
|
206
|
-
return "
|
|
178
|
+
function y() {
|
|
179
|
+
return "48px";
|
|
207
180
|
}
|
|
208
|
-
function
|
|
209
|
-
e.contentWindow?.postMessage(
|
|
181
|
+
function b(e) {
|
|
182
|
+
e.contentWindow?.postMessage(a({ type: "APPLE_PAY_CANCEL" }), o(e));
|
|
210
183
|
}
|
|
211
|
-
function
|
|
212
|
-
let
|
|
213
|
-
|
|
214
|
-
|
|
184
|
+
function x(e, { height: r = "48px", ...i }) {
|
|
185
|
+
let a = {
|
|
186
|
+
...i,
|
|
187
|
+
height: r
|
|
188
|
+
};
|
|
189
|
+
function o() {
|
|
190
|
+
d({
|
|
215
191
|
iframe: e,
|
|
216
|
-
amount:
|
|
192
|
+
amount: a.amount
|
|
217
193
|
});
|
|
218
194
|
}
|
|
219
|
-
function
|
|
220
|
-
|
|
195
|
+
function u() {
|
|
196
|
+
f({
|
|
221
197
|
iframe: e,
|
|
222
|
-
merchantName:
|
|
198
|
+
merchantName: a.merchantName
|
|
223
199
|
});
|
|
224
200
|
}
|
|
225
|
-
function
|
|
226
|
-
|
|
201
|
+
function p() {
|
|
202
|
+
l({
|
|
227
203
|
iframe: e,
|
|
228
|
-
|
|
204
|
+
height: a.height ?? "48px",
|
|
205
|
+
props: a.buttonProps ?? {}
|
|
229
206
|
});
|
|
230
207
|
}
|
|
231
|
-
function
|
|
208
|
+
function m(r) {
|
|
232
209
|
if (r.source === e.contentWindow) switch (r.data.type) {
|
|
233
210
|
case "IFRAME_READY":
|
|
234
|
-
|
|
211
|
+
s(e), c({
|
|
235
212
|
iframe: e,
|
|
236
|
-
appearance:
|
|
237
|
-
}),
|
|
213
|
+
appearance: {}
|
|
214
|
+
}), o(), u(), p();
|
|
238
215
|
break;
|
|
239
216
|
case "UPDATE_HEIGHT":
|
|
240
|
-
|
|
217
|
+
a.onHeightChange?.(r.data.height);
|
|
241
218
|
break;
|
|
242
219
|
case "UPDATE_APPEARANCE":
|
|
243
|
-
|
|
220
|
+
c({
|
|
244
221
|
iframe: e,
|
|
245
222
|
appearance: r.data.appearance
|
|
246
223
|
});
|
|
247
224
|
break;
|
|
248
225
|
case "UPDATED_APPEARANCE":
|
|
249
|
-
|
|
226
|
+
a.onAppearanceReady?.();
|
|
250
227
|
break;
|
|
251
228
|
case "APPLE_PAY_WINDOW_OPEN":
|
|
252
229
|
t({ onCancel: () => {
|
|
253
|
-
|
|
230
|
+
b(e), n();
|
|
254
231
|
} });
|
|
255
232
|
break;
|
|
256
233
|
case "APPLE_PAY_WINDOW_CLOSE":
|
|
257
234
|
n();
|
|
258
235
|
break;
|
|
259
236
|
case "CREATE_PAYMENT_INTENT":
|
|
260
|
-
|
|
237
|
+
a.onInitiatePaymentIntentRequest({
|
|
261
238
|
paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
|
|
262
239
|
customerCreateAttributes: r.data.customerCreateAttributes
|
|
263
240
|
}).then((t) => {
|
|
264
|
-
|
|
241
|
+
h({
|
|
265
242
|
iframe: e,
|
|
266
243
|
token: t
|
|
267
244
|
});
|
|
268
245
|
}).catch((e) => {
|
|
269
|
-
n(),
|
|
246
|
+
n(), a.onResult({
|
|
270
247
|
status: "failed",
|
|
271
248
|
errorMessage: e instanceof Error ? e.message : "Unknown error"
|
|
272
249
|
});
|
|
273
250
|
});
|
|
274
251
|
break;
|
|
275
|
-
case "CONFIRMATION_RESULT": n(),
|
|
252
|
+
case "CONFIRMATION_RESULT": n(), a.onResult(r.data.result);
|
|
276
253
|
}
|
|
277
254
|
}
|
|
278
|
-
return window.addEventListener("message",
|
|
279
|
-
update(
|
|
280
|
-
let
|
|
281
|
-
|
|
282
|
-
...
|
|
283
|
-
...
|
|
284
|
-
}, n &&
|
|
285
|
-
iframe: e,
|
|
286
|
-
appearance: i.appearance
|
|
287
|
-
}), r && a(), c && o(), l && s();
|
|
255
|
+
return window.addEventListener("message", m), {
|
|
256
|
+
update(e) {
|
|
257
|
+
let t = "amount" in e, n = "merchantName" in e, r = "height" in e || "buttonProps" in e;
|
|
258
|
+
a = {
|
|
259
|
+
...a,
|
|
260
|
+
...e
|
|
261
|
+
}, t && o(), n && u(), r && p();
|
|
288
262
|
},
|
|
289
263
|
destroy() {
|
|
290
|
-
window.removeEventListener("message",
|
|
264
|
+
window.removeEventListener("message", m), n();
|
|
291
265
|
}
|
|
292
266
|
};
|
|
293
267
|
}
|
|
294
268
|
//#endregion
|
|
295
269
|
//#region src/google-pay.ts
|
|
296
|
-
function
|
|
270
|
+
function S(e) {
|
|
297
271
|
return `${i(e)}/iframe/google-pay?token=${e}`;
|
|
298
272
|
}
|
|
299
|
-
function
|
|
300
|
-
return "
|
|
273
|
+
function C() {
|
|
274
|
+
return "48px";
|
|
301
275
|
}
|
|
302
|
-
function
|
|
303
|
-
let
|
|
304
|
-
|
|
305
|
-
|
|
276
|
+
function w(e, { height: t = "48px", ...n }) {
|
|
277
|
+
let r = {
|
|
278
|
+
...n,
|
|
279
|
+
height: t
|
|
280
|
+
};
|
|
281
|
+
function i() {
|
|
282
|
+
d({
|
|
306
283
|
iframe: e,
|
|
307
|
-
amount:
|
|
284
|
+
amount: r.amount
|
|
308
285
|
});
|
|
309
286
|
}
|
|
310
|
-
function
|
|
311
|
-
|
|
287
|
+
function a() {
|
|
288
|
+
f({
|
|
312
289
|
iframe: e,
|
|
313
|
-
merchantName:
|
|
290
|
+
merchantName: r.merchantName
|
|
314
291
|
});
|
|
315
292
|
}
|
|
316
|
-
function
|
|
317
|
-
|
|
293
|
+
function o() {
|
|
294
|
+
u({
|
|
318
295
|
iframe: e,
|
|
319
|
-
|
|
296
|
+
height: r.height ?? "48px",
|
|
297
|
+
props: r.buttonProps ?? {}
|
|
320
298
|
});
|
|
321
299
|
}
|
|
322
|
-
function
|
|
300
|
+
function l(t) {
|
|
323
301
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
324
302
|
case "IFRAME_READY":
|
|
325
|
-
|
|
303
|
+
s(e), c({
|
|
326
304
|
iframe: e,
|
|
327
|
-
appearance:
|
|
328
|
-
}),
|
|
305
|
+
appearance: {}
|
|
306
|
+
}), i(), a(), o();
|
|
329
307
|
break;
|
|
330
308
|
case "UPDATE_HEIGHT":
|
|
331
|
-
|
|
309
|
+
r.onHeightChange?.(t.data.height);
|
|
332
310
|
break;
|
|
333
311
|
case "UPDATE_APPEARANCE":
|
|
334
|
-
|
|
312
|
+
c({
|
|
335
313
|
iframe: e,
|
|
336
314
|
appearance: t.data.appearance
|
|
337
315
|
});
|
|
338
316
|
break;
|
|
339
317
|
case "UPDATED_APPEARANCE":
|
|
340
|
-
|
|
318
|
+
r.onAppearanceReady?.();
|
|
341
319
|
break;
|
|
342
320
|
case "CREATE_PAYMENT_INTENT":
|
|
343
|
-
|
|
321
|
+
r.onInitiatePaymentIntentRequest({
|
|
344
322
|
paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
|
|
345
323
|
customerCreateAttributes: t.data.customerCreateAttributes
|
|
346
324
|
}).then((t) => {
|
|
347
|
-
|
|
325
|
+
h({
|
|
348
326
|
iframe: e,
|
|
349
327
|
token: t
|
|
350
328
|
});
|
|
351
329
|
}).catch((e) => {
|
|
352
|
-
|
|
330
|
+
r.onResult({
|
|
353
331
|
status: "failed",
|
|
354
332
|
errorMessage: e instanceof Error ? e.message : "Unknown error"
|
|
355
333
|
});
|
|
356
334
|
});
|
|
357
335
|
break;
|
|
358
|
-
case "CONFIRMATION_RESULT":
|
|
336
|
+
case "CONFIRMATION_RESULT": r.onResult(t.data.result);
|
|
359
337
|
}
|
|
360
338
|
}
|
|
361
|
-
return window.addEventListener("message",
|
|
362
|
-
update(
|
|
363
|
-
let
|
|
364
|
-
|
|
365
|
-
...
|
|
366
|
-
...
|
|
367
|
-
},
|
|
368
|
-
iframe: e,
|
|
369
|
-
appearance: n.appearance
|
|
370
|
-
}), s && r(), c && i(), l && a();
|
|
339
|
+
return window.addEventListener("message", l), {
|
|
340
|
+
update(e) {
|
|
341
|
+
let t = "amount" in e, n = "merchantName" in e, s = "height" in e || "buttonProps" in e;
|
|
342
|
+
r = {
|
|
343
|
+
...r,
|
|
344
|
+
...e
|
|
345
|
+
}, t && i(), n && a(), s && o();
|
|
371
346
|
},
|
|
372
347
|
destroy() {
|
|
373
|
-
window.removeEventListener("message",
|
|
348
|
+
window.removeEventListener("message", l);
|
|
374
349
|
}
|
|
375
350
|
};
|
|
376
351
|
}
|
|
377
|
-
function
|
|
352
|
+
function T({ paymentData: e }) {
|
|
378
353
|
return { paymentMethod: {
|
|
379
354
|
type: "googlepay",
|
|
380
355
|
billing_address_attributes: {
|
|
@@ -393,7 +368,7 @@ function O({ paymentData: e }) {
|
|
|
393
368
|
}
|
|
394
369
|
//#endregion
|
|
395
370
|
//#region src/form-skeleton.ts
|
|
396
|
-
var
|
|
371
|
+
var E = "amos-js-form-skeleton-styles", D = {
|
|
397
372
|
"--accent": "oklch(0.97 0 0)",
|
|
398
373
|
"--radius": "0.625rem",
|
|
399
374
|
"--input-height": "2.25rem",
|
|
@@ -401,71 +376,71 @@ var k = "amos-js-form-skeleton-styles", A = {
|
|
|
401
376
|
"--field-gap": "1rem",
|
|
402
377
|
"--control-gap": "0.5rem",
|
|
403
378
|
"--label-font-size": "0.875rem"
|
|
404
|
-
},
|
|
405
|
-
function
|
|
406
|
-
if (document.getElementById(
|
|
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;
|
|
407
382
|
let e = document.createElement("style");
|
|
408
|
-
e.id =
|
|
383
|
+
e.id = E, e.textContent = O, document.head.appendChild(e);
|
|
409
384
|
}
|
|
410
|
-
function
|
|
411
|
-
for (let [t, n] of Object.entries(
|
|
385
|
+
function A(e, t) {
|
|
386
|
+
for (let [t, n] of Object.entries(D)) e.style.setProperty(t, n);
|
|
412
387
|
let n = t?.themeVariables;
|
|
413
388
|
if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
|
|
414
389
|
}
|
|
415
|
-
function
|
|
390
|
+
function j(e, t) {
|
|
416
391
|
let n = document.createElement("div");
|
|
417
392
|
if (n.className = e, t) for (let e of t) n.appendChild(e);
|
|
418
393
|
return n;
|
|
419
394
|
}
|
|
420
|
-
function
|
|
421
|
-
let n =
|
|
422
|
-
t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(
|
|
423
|
-
let r =
|
|
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");
|
|
424
399
|
return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
|
|
425
400
|
}
|
|
426
|
-
function
|
|
427
|
-
return
|
|
401
|
+
function N(e, t) {
|
|
402
|
+
return j(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
|
|
428
403
|
}
|
|
429
|
-
function
|
|
404
|
+
function P({ labels: e, requirement: t, wrapCountryZip: n }) {
|
|
430
405
|
return t === "full" ? [
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
406
|
+
M(e),
|
|
407
|
+
M(e),
|
|
408
|
+
N([
|
|
409
|
+
M(e, 1.4),
|
|
410
|
+
M(e, .7),
|
|
411
|
+
M(e, .8)
|
|
437
412
|
], !1),
|
|
438
|
-
|
|
439
|
-
] : [
|
|
413
|
+
M(e)
|
|
414
|
+
] : [N([M(e), M(e)], n)];
|
|
440
415
|
}
|
|
441
|
-
function
|
|
416
|
+
function F(e) {
|
|
442
417
|
let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
|
|
443
418
|
if (e.kind === "card") {
|
|
444
|
-
let r = [
|
|
445
|
-
return e.additionalFields?.cardholderName && r.push(
|
|
419
|
+
let r = [M(t), N([M(t), M(t)], !1)];
|
|
420
|
+
return e.additionalFields?.cardholderName && r.push(M(t)), r.push(...P({
|
|
446
421
|
labels: t,
|
|
447
422
|
requirement: n,
|
|
448
423
|
wrapCountryZip: !1
|
|
449
424
|
})), r;
|
|
450
425
|
}
|
|
451
426
|
return [
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
...
|
|
427
|
+
M(t),
|
|
428
|
+
N([M(t), M(t)], !0),
|
|
429
|
+
M(t),
|
|
430
|
+
N([M("above"), M("above")], !0),
|
|
431
|
+
...P({
|
|
457
432
|
labels: t,
|
|
458
433
|
requirement: n,
|
|
459
434
|
wrapCountryZip: !0
|
|
460
435
|
})
|
|
461
436
|
];
|
|
462
437
|
}
|
|
463
|
-
function
|
|
464
|
-
|
|
465
|
-
let t =
|
|
438
|
+
function I(e) {
|
|
439
|
+
k();
|
|
440
|
+
let t = j("amos-js-form-skeleton");
|
|
466
441
|
t.setAttribute("aria-hidden", "true");
|
|
467
442
|
function n(e) {
|
|
468
|
-
|
|
443
|
+
A(t, e.appearance), t.replaceChildren(...F(e));
|
|
469
444
|
}
|
|
470
445
|
return n(e), {
|
|
471
446
|
element: t,
|
|
@@ -474,14 +449,14 @@ function z(e) {
|
|
|
474
449
|
}
|
|
475
450
|
//#endregion
|
|
476
451
|
//#region src/payment-method-form.ts
|
|
477
|
-
var
|
|
452
|
+
var L = {
|
|
478
453
|
country: 212,
|
|
479
454
|
full: 452
|
|
480
|
-
},
|
|
455
|
+
}, R = 80, z = {
|
|
481
456
|
country: 400,
|
|
482
457
|
full: 640
|
|
483
458
|
};
|
|
484
|
-
function
|
|
459
|
+
function B(e, t = { cardholderName: !1 }, n = "country") {
|
|
485
460
|
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
|
|
486
461
|
token: e,
|
|
487
462
|
additionalFields: r,
|
|
@@ -489,25 +464,25 @@ function U(e, t = { cardholderName: !1 }, n = "country") {
|
|
|
489
464
|
});
|
|
490
465
|
return `${i(e)}/iframe/card?${a}`;
|
|
491
466
|
}
|
|
492
|
-
function
|
|
467
|
+
function V(e, t = "country") {
|
|
493
468
|
let n = new URLSearchParams({
|
|
494
469
|
token: e,
|
|
495
470
|
billingAddressRequirement: t
|
|
496
471
|
});
|
|
497
472
|
return `${i(e)}/iframe/bank?${n}`;
|
|
498
473
|
}
|
|
499
|
-
function
|
|
500
|
-
return `${(
|
|
474
|
+
function H(e = { cardholderName: !1 }, t = "country") {
|
|
475
|
+
return `${(L[t] ?? L.country) + (e.cardholderName ? R : 0)}px`;
|
|
501
476
|
}
|
|
502
|
-
function
|
|
503
|
-
return `${
|
|
477
|
+
function U(e = "country") {
|
|
478
|
+
return `${z[e] ?? z.country}px`;
|
|
504
479
|
}
|
|
505
|
-
function
|
|
480
|
+
function W(e, t) {
|
|
506
481
|
let n = { ...t };
|
|
507
482
|
function r(t) {
|
|
508
483
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
509
484
|
case "IFRAME_READY":
|
|
510
|
-
|
|
485
|
+
s(e), c({
|
|
511
486
|
iframe: e,
|
|
512
487
|
appearance: n.appearance
|
|
513
488
|
});
|
|
@@ -516,7 +491,7 @@ function q(e, t) {
|
|
|
516
491
|
n.onHeightChange?.(t.data.height);
|
|
517
492
|
break;
|
|
518
493
|
case "UPDATE_APPEARANCE":
|
|
519
|
-
|
|
494
|
+
c({
|
|
520
495
|
iframe: e,
|
|
521
496
|
appearance: t.data.appearance
|
|
522
497
|
});
|
|
@@ -536,7 +511,7 @@ function q(e, t) {
|
|
|
536
511
|
n = {
|
|
537
512
|
...n,
|
|
538
513
|
...t
|
|
539
|
-
}, r &&
|
|
514
|
+
}, r && c({
|
|
540
515
|
iframe: e,
|
|
541
516
|
appearance: n.appearance
|
|
542
517
|
});
|
|
@@ -548,7 +523,7 @@ function q(e, t) {
|
|
|
548
523
|
}
|
|
549
524
|
//#endregion
|
|
550
525
|
//#region src/mount.ts
|
|
551
|
-
function
|
|
526
|
+
function G(e) {
|
|
552
527
|
if (typeof e == "string") {
|
|
553
528
|
let t = document.querySelector(e);
|
|
554
529
|
if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
|
|
@@ -556,19 +531,19 @@ function J(e) {
|
|
|
556
531
|
}
|
|
557
532
|
return e;
|
|
558
533
|
}
|
|
559
|
-
var
|
|
534
|
+
var K = {
|
|
560
535
|
width: "calc(100% + 8px)",
|
|
561
536
|
transition: "opacity 150ms ease-in, height 200ms ease-in-out",
|
|
562
537
|
margin: "0 -4px",
|
|
563
538
|
opacity: "0",
|
|
564
539
|
border: "0"
|
|
565
|
-
},
|
|
540
|
+
}, q = {
|
|
566
541
|
width: "100%",
|
|
567
542
|
transition: "height 200ms ease-in-out",
|
|
568
543
|
margin: "0",
|
|
569
544
|
opacity: "0",
|
|
570
545
|
border: "0"
|
|
571
|
-
},
|
|
546
|
+
}, J = {
|
|
572
547
|
position: "absolute",
|
|
573
548
|
top: "0",
|
|
574
549
|
left: "-4px",
|
|
@@ -578,15 +553,15 @@ var Y = {
|
|
|
578
553
|
transition: "none",
|
|
579
554
|
pointerEvents: "none"
|
|
580
555
|
};
|
|
581
|
-
function
|
|
582
|
-
let
|
|
583
|
-
return
|
|
556
|
+
function Y({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = K }) {
|
|
557
|
+
let s = document.createElement("iframe");
|
|
558
|
+
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;
|
|
584
559
|
}
|
|
585
|
-
function
|
|
560
|
+
function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
586
561
|
let i = document.createElement("div");
|
|
587
562
|
i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
|
|
588
|
-
let a =
|
|
589
|
-
Object.assign(t.style,
|
|
563
|
+
let a = I(r);
|
|
564
|
+
Object.assign(t.style, J), i.append(a.element, t), e.appendChild(i);
|
|
590
565
|
let o = !1, s = !1, c, l = r.appearance, u, d;
|
|
591
566
|
function f() {
|
|
592
567
|
return i.getBoundingClientRect().height;
|
|
@@ -598,7 +573,7 @@ function $({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
598
573
|
if (o) return;
|
|
599
574
|
o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
|
|
600
575
|
let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
|
|
601
|
-
t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin =
|
|
576
|
+
t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = K.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
|
|
602
577
|
t.style.transition = "height 200ms ease-in-out";
|
|
603
578
|
}, 400);
|
|
604
579
|
}
|
|
@@ -607,7 +582,7 @@ function $({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
607
582
|
let e = p(), t = f();
|
|
608
583
|
Number.isFinite(e) && e >= t - 2 && m();
|
|
609
584
|
}
|
|
610
|
-
let g =
|
|
585
|
+
let g = W(t, {
|
|
611
586
|
...n,
|
|
612
587
|
onHeightChange: (e) => {
|
|
613
588
|
c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
|
|
@@ -631,15 +606,15 @@ function $({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
631
606
|
}
|
|
632
607
|
};
|
|
633
608
|
}
|
|
634
|
-
function
|
|
635
|
-
let n =
|
|
636
|
-
return
|
|
609
|
+
function Z(e, t) {
|
|
610
|
+
let n = G(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
|
|
611
|
+
return X({
|
|
637
612
|
host: n,
|
|
638
|
-
iframe:
|
|
639
|
-
src:
|
|
613
|
+
iframe: Y({
|
|
614
|
+
src: B(r, i, a),
|
|
640
615
|
title: "Secure credit card payment method form powered by Amos",
|
|
641
616
|
name: "amos-credit-card-payment-method-form",
|
|
642
|
-
height:
|
|
617
|
+
height: H(i, a)
|
|
643
618
|
}),
|
|
644
619
|
listenerOptions: o,
|
|
645
620
|
skeletonOptions: {
|
|
@@ -650,15 +625,15 @@ function ee(e, t) {
|
|
|
650
625
|
}
|
|
651
626
|
});
|
|
652
627
|
}
|
|
653
|
-
function
|
|
654
|
-
let n =
|
|
655
|
-
return
|
|
628
|
+
function Q(e, t) {
|
|
629
|
+
let n = G(e), { renderToken: r, billingAddressRequirement: i = "country", ...a } = t;
|
|
630
|
+
return X({
|
|
656
631
|
host: n,
|
|
657
|
-
iframe:
|
|
658
|
-
src:
|
|
632
|
+
iframe: Y({
|
|
633
|
+
src: V(r, i),
|
|
659
634
|
title: "Secure bank account payment method form powered by Amos",
|
|
660
635
|
name: "amos-bank-account-payment-method-form",
|
|
661
|
-
height:
|
|
636
|
+
height: U(i)
|
|
662
637
|
}),
|
|
663
638
|
listenerOptions: a,
|
|
664
639
|
skeletonOptions: {
|
|
@@ -668,59 +643,61 @@ function te(e, t) {
|
|
|
668
643
|
}
|
|
669
644
|
});
|
|
670
645
|
}
|
|
671
|
-
function
|
|
672
|
-
let n =
|
|
673
|
-
src:
|
|
646
|
+
function $(e, t) {
|
|
647
|
+
let n = G(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Y({
|
|
648
|
+
src: S(r),
|
|
674
649
|
title: "Secure Google Pay button powered by Amos",
|
|
675
650
|
name: "amos-google-pay-button",
|
|
676
|
-
height:
|
|
651
|
+
height: o.height ?? C(),
|
|
677
652
|
allow: "payment",
|
|
678
|
-
|
|
653
|
+
className: i,
|
|
654
|
+
style: q
|
|
679
655
|
});
|
|
680
|
-
n.appendChild(
|
|
681
|
-
let
|
|
682
|
-
...
|
|
656
|
+
Object.assign(s.style, a), n.appendChild(s);
|
|
657
|
+
let c = w(s, {
|
|
658
|
+
...o,
|
|
683
659
|
onHeightChange: (e) => {
|
|
684
|
-
|
|
660
|
+
s.style.height = e, o.onHeightChange?.(e);
|
|
685
661
|
},
|
|
686
662
|
onAppearanceReady: () => {
|
|
687
|
-
|
|
663
|
+
s.style.opacity = "1", o.onAppearanceReady?.();
|
|
688
664
|
}
|
|
689
665
|
});
|
|
690
666
|
return {
|
|
691
|
-
iframe:
|
|
692
|
-
update:
|
|
667
|
+
iframe: s,
|
|
668
|
+
update: c.update,
|
|
693
669
|
destroy() {
|
|
694
|
-
|
|
670
|
+
c.destroy(), s.remove();
|
|
695
671
|
}
|
|
696
672
|
};
|
|
697
673
|
}
|
|
698
|
-
function
|
|
699
|
-
let n =
|
|
700
|
-
src:
|
|
674
|
+
function ee(e, t) {
|
|
675
|
+
let n = G(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Y({
|
|
676
|
+
src: v(r),
|
|
701
677
|
title: "Secure Apple Pay button powered by Amos",
|
|
702
678
|
name: "amos-apple-pay-button",
|
|
703
|
-
height:
|
|
679
|
+
height: o.height ?? y(),
|
|
704
680
|
allow: "payment",
|
|
705
|
-
|
|
681
|
+
className: i,
|
|
682
|
+
style: q
|
|
706
683
|
});
|
|
707
|
-
n.appendChild(
|
|
708
|
-
let
|
|
709
|
-
...
|
|
684
|
+
Object.assign(s.style, a), n.appendChild(s);
|
|
685
|
+
let c = x(s, {
|
|
686
|
+
...o,
|
|
710
687
|
onHeightChange: (e) => {
|
|
711
|
-
|
|
688
|
+
s.style.height = e, o.onHeightChange?.(e);
|
|
712
689
|
},
|
|
713
690
|
onAppearanceReady: () => {
|
|
714
|
-
|
|
691
|
+
s.style.opacity = "1", o.onAppearanceReady?.();
|
|
715
692
|
}
|
|
716
693
|
});
|
|
717
694
|
return {
|
|
718
|
-
iframe:
|
|
719
|
-
update:
|
|
695
|
+
iframe: s,
|
|
696
|
+
update: c.update,
|
|
720
697
|
destroy() {
|
|
721
|
-
|
|
698
|
+
c.destroy(), s.remove();
|
|
722
699
|
}
|
|
723
700
|
};
|
|
724
701
|
}
|
|
725
702
|
//#endregion
|
|
726
|
-
export {
|
|
703
|
+
export { x as attachApplePayButtonListeners, w as attachGooglePayButtonListeners, W as attachPaymentMethodFormListeners, h as confirmPaymentIntent, g as confirmSetupIntent, a as createMessage, r as decodeJwt, T as formatGooglePayPaymentData, y as getApplePayButtonInitialHeight, v as getApplePayButtonSrc, U as getBankAccountFormInitialHeight, V as getBankAccountFormSrc, H as getCreditCardFormInitialHeight, B as getCreditCardFormSrc, i as getEmbedOrigin, C as getGooglePayButtonInitialHeight, S as getGooglePayButtonSrc, ee as mountAmosApplePayButton, Q as mountAmosBankAccountPaymentMethodForm, Z as mountAmosCreditCardPaymentMethodForm, $ as mountAmosGooglePayButton, m as resetForm, _ as sendConfirmationResult, s as sendParentReadyMessage, d as updateAmount, c as updateAppearance, l as updateApplePayButton, u as updateGooglePayButton, f as updateMerchantName, p as validateForm };
|