@amos.com/react-amos-js 0.11.22 → 0.11.24

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
@@ -588,6 +588,8 @@ Renders the secure bank account iframe form. A field-shaped skeleton covers a vi
588
588
 
589
589
  When `requireAchVerification` is true (or `intent` is `"setup"`), and the render token allows verification, the SDK hides the routing/account iframe and mounts [Plaid Embedded Institution Search](https://plaid.com/docs/link/embedded-institution-search/) in the parent. A **350px pulse skeleton** covers that slot until Plaid's `onLoad` (1.5s fallback). Do not overlay a host loader. Hosts do not proxy Pay API (`GET /merchants`, `POST /plaid_link_tokens`); embed does that with `PAY_API_KEY`. Do not put Plaid secrets in the browser.
590
590
 
591
+ After Link succeeds, Institution Search is replaced by a connected-account row: institution name, masked account (`****` plus last4, or "Connected"), and an outline Disconnect button. Disconnect clears the linked account and shows Institution Search again. The row uses existing `appearance.themeVariables` (`--border`, `--background`, `--foreground`, `--muted` falling back to `--accent`, `--muted-foreground`, `--accent`, `--accent-foreground`, `--radius`, `--ring`). In dark mode the Disconnect border uses `--input`. No new theme variable or appearance rule is required.
592
+
591
593
  **Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`.
592
594
 
593
595
  **Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `defaultValues`, `onValidityChange` (`isValid` is also true after Plaid returns credentials), `onPostalCodeChange`, `onEscapeKeyPressed` — plus:
@@ -710,7 +712,7 @@ Re-export from `@amos.com/amos-js`. Fills omitted Inter `fonts` / `--font-family
710
712
  - **Amount format**: for `AmosGooglePayButton` and `AmosApplePayButton`, `amount` is a major-currency decimal string (e.g. `"50.00"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server (card/bank create, and the object the wallet iframe sends to `onConfirm`), `amount` is a number in cents (e.g. `5000`).
711
713
  - **Embed host / CSP**: iframes load from `https://js.amos.com` (production) and `https://js-sandbox.amos.com` (sandbox) via `getEmbedOrigin`. Parent pages that pin CSP must allow `frame-src https://js.amos.com https://js-sandbox.amos.com` (and `Permissions-Policy payment=` for those origins) **before** upgrading this package. Older SDK versions still load `embed.amos.com` / `embed-sandbox.amos.com`.
712
714
  - **Iframe handshake**: iframe URLs include canonical search params so the embed does not 307. If the document loads but never posts `IFRAME_READY`, the SDK rewrites `src` once with `amosReload`. Appearance is applied after handshake. The iframe stays visible under the skeleton until `UPDATED_APPEARANCE`, or for 1.5s after `IFRAME_READY` if appearance never acks. Embed messages match on origin plus `iframeName` when `contentWindow` identity changes.
713
- - **Plaid Embedded Link (ACH verification)**: load `cdn.plaid.com` from the **parent** document (see CSP on `AmosBankAccountPaymentMethodForm`). Merchants do not proxy Pay API; the bank iframe mints link tokens. Pass `requireAchVerification` when the host wants Plaid, or `intent="setup"` to always show it, unless the render token disables verification. Toggling that prop hides or shows the existing Embedded handler — it does not reload Institution Search. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method. While Link loads, the SDK shows a 350px pulse skeleton until `onLoad` (1.5s fallback) — do not overlay a host loader.
715
+ - **Plaid Embedded Link (ACH verification)**: load `cdn.plaid.com` from the **parent** document (see CSP on `AmosBankAccountPaymentMethodForm`). Merchants do not proxy Pay API; the bank iframe mints link tokens. Pass `requireAchVerification` when the host wants Plaid, or `intent="setup"` to always show it, unless the render token disables verification. Toggling that prop hides or shows the existing Embedded handler — it does not reload Institution Search. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method. While Link loads, the SDK shows a 350px pulse skeleton until `onLoad` (1.5s fallback) — do not overlay a host loader. After success the same slot is a connected-account row (institution name, mask, outline Disconnect) styled with existing `themeVariables`. Disconnect shows Institution Search again.
714
716
  - **Apple Pay waiting overlay**: on browsers where Apple's QR handoff opens in a popup (non-Safari), `AmosApplePayButton` shows a fixed full-viewport overlay on the host page. **Cancel payment** is available until the buyer authorizes; after that the overlay shows **Completing your payment…** with no Cancel, then hides when `onConfirm` settles. Avoid stacking other fixed UI above it.
715
717
  - **Going framework-free**: if you need to use Amos outside of React (vanilla JS, another framework, etc.), use [`@amos.com/amos-js`](../amos-js) directly.
716
718
 
package/dist/index.d.ts CHANGED
@@ -112,7 +112,7 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
112
112
  */
113
113
  defaultValues?: PaymentMethodFormDefaultValues;
114
114
  };
115
- export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onCardBrandChanged, onPostalCodeChange, onEscapeKeyPressed, additionalFields, billingAddressRequirement, defaultValues, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
115
+ export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onCardBrandChanged, onPostalCodeChange, onEscapeKeyPressed, additionalFields, billingAddressRequirement, defaultValues, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import('react').JSX.Element;
116
116
  type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
117
117
  renderToken: string;
118
118
  appearance?: Appearance;
@@ -167,7 +167,7 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
167
167
  */
168
168
  intent?: "payment" | "setup";
169
169
  };
170
- export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onPostalCodeChange, onEscapeKeyPressed, billingAddressRequirement, defaultValues, requireAchVerification, intent, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
170
+ export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onPostalCodeChange, onEscapeKeyPressed, billingAddressRequirement, defaultValues, requireAchVerification, intent, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import('react').JSX.Element;
171
171
  type AmosGooglePayButtonProps = {
172
172
  ref?: ForwardedIframeRef;
173
173
  renderToken: string;
@@ -220,7 +220,7 @@ type AmosGooglePayButtonProps = {
220
220
  * skeleton is painted in the parent document on first render (including
221
221
  * SSR) so the slot height is reserved before the iframe loads.
222
222
  */
223
- export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, height, buttonProps, phoneRequired, shippingAddressRequired, iframeProps, onConfirm, }: AmosGooglePayButtonProps): import("react").JSX.Element;
223
+ export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, height, buttonProps, phoneRequired, shippingAddressRequired, iframeProps, onConfirm, }: AmosGooglePayButtonProps): import('react').JSX.Element;
224
224
  type AmosApplePayButtonProps = {
225
225
  ref?: ForwardedIframeRef;
226
226
  renderToken: string;
@@ -273,4 +273,4 @@ type AmosApplePayButtonProps = {
273
273
  * skeleton is painted in the parent document on first render (including
274
274
  * SSR) so the slot height is reserved before the iframe loads.
275
275
  */
276
- export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, height, buttonProps, phoneRequired, shippingAddressRequired, iframeProps, onConfirm, }: AmosApplePayButtonProps): import("react").JSX.Element;
276
+ export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, height, buttonProps, phoneRequired, shippingAddressRequired, iframeProps, onConfirm, }: AmosApplePayButtonProps): import('react').JSX.Element;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@amos.com/amos-js"),t=require("react"),n=require("react/jsx-runtime");function r(e){var t;return e?(t=e.current)==null?null:t:null}function i({iframeRef:t}){return(0,e.validateForm)({iframe:r(t)})}function a({iframeRef:t,token:n,defaultValues:i}){return(0,e.confirmPayment)({iframe:r(t),token:n,defaultValues:i})}function o({iframeRef:t,token:n,defaultValues:i}){return(0,e.confirmSetup)({iframe:r(t),token:n,defaultValues:i})}function s({iframeRef:t}){(0,e.resetForm)({iframe:r(t)})}function c({iframeRef:t,field:n}){(0,e.focusField)({iframe:r(t),field:n})}function l(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function u(e,{style:t,className:n,id:r,...i}){n!=null&&(e.className=n),r!=null&&(e.id=r),Object.assign(e.style,t);for(let[t,n]of Object.entries(i))n!=null&&(t in e?Reflect.set(e,t,n):e.setAttribute(t,String(n)))}function d({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){let c=(0,t.useRef)(null);(0,t.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return c.current=a,l(n,a.iframe),u(a.iframe,o),()=>{a.destroy(),c.current=null,l(n,null)}},[...a]),(0,t.useEffect)(()=>{var e;(e=c.current)==null||e.update(i)},[...s]),(0,t.useEffect)(()=>{var e;let t=(e=c.current)==null?void 0:e.iframe;t&&u(t,o)})}var f=`oklch(0.97 0 0)`;function p({height:r,borderRadius:i,containerRef:a}){return(0,t.useLayoutEffect)(()=>{(0,e.ensureSkeletonStyles)()},[]),(0,n.jsxs)(`div`,{style:{boxSizing:`border-box`,position:`relative`,width:`100%`,height:r,minHeight:r,overflow:`hidden`},children:[(0,n.jsx)(`div`,{className:`amos-js-form-skeleton-input amos-js-wallet-skeleton`,style:{position:`absolute`,inset:0,height:r,borderRadius:i,background:f,pointerEvents:`none`,zIndex:0},"aria-hidden":!0}),(0,n.jsx)(`div`,{ref:a,style:{position:`absolute`,inset:0,zIndex:1,width:`100%`,height:`100%`}})]})}function m(t,n){return(0,e.mountAmosCreditCardPaymentMethodForm)(t,n)}function h(t,n){return(0,e.mountAmosBankAccountPaymentMethodForm)(t,n)}function g({ref:e,renderToken:r,appearance:i,onValidityChange:a,onCardBrandChanged:o,onPostalCodeChange:s,onEscapeKeyPressed:c,additionalFields:l={cardholderName:!1},billingAddressRequirement:u=`country`,defaultValues:f,style:p,...h}){let g=(0,t.useRef)(null);return d({containerRef:g,iframeRef:e,mount:m,options:{renderToken:r,appearance:i,additionalFields:l,billingAddressRequirement:u,defaultValues:f,onValidityChange:a,onCardBrandChanged:o,onPostalCodeChange:s,onEscapeKeyPressed:c},remountDeps:[r,l.cardholderName,u],iframePassthrough:{style:p,...h},updateDeps:[i,l,u,f,a,o,s,c]}),(0,n.jsx)(`div`,{ref:g})}function _({ref:e,renderToken:r,appearance:i,onValidityChange:a,onPostalCodeChange:o,onEscapeKeyPressed:s,billingAddressRequirement:c=`country`,defaultValues:l,requireAchVerification:u=!1,intent:f=`payment`,style:p,...m}){let g=(0,t.useRef)(null);return d({containerRef:g,iframeRef:e,mount:h,options:{renderToken:r,appearance:i,billingAddressRequirement:c,defaultValues:l,requireAchVerification:u,intent:f,onValidityChange:a,onPostalCodeChange:o,onEscapeKeyPressed:s},remountDeps:[r,c,f],iframePassthrough:{style:p,...m},updateDeps:[i,c,l,u,f,a,o,s]}),(0,n.jsx)(`div`,{ref:g})}function v({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:f,onConfirm:m}){let h=(0,t.useRef)(null),g=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:f==null?void 0:f.style,buttonProps:c});return d({containerRef:h,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:m},remountDeps:[i],iframePassthrough:f==null?{}:f,updateDeps:[a,o,s,c,l,u,m]}),(0,n.jsx)(p,{height:s,borderRadius:g,containerRef:h})}function y({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:f,onConfirm:m}){let h=(0,t.useRef)(null),g=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:f==null?void 0:f.style,buttonProps:c});return d({containerRef:h,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:m},remountDeps:[i],iframePassthrough:f==null?{}:f,updateDeps:[a,o,s,c,l,u,m]}),(0,n.jsx)(p,{height:s,borderRadius:g,containerRef:h})}exports.AmosApplePayButton=y,exports.AmosBankAccountPaymentMethodForm=_,exports.AmosCreditCardPaymentMethodForm=g,exports.AmosGooglePayButton=v,exports.confirmPayment=a,exports.confirmSetup=o,exports.focusField=c,exports.resetForm=s,exports.validateForm=i,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@amos.com/amos-js"),t=require("react"),n=require("react/jsx-runtime");function resolveIframe(e){var t;return e?(t=e.current)==null?null:t:null}function validateForm({iframeRef:t}){return(0,e.validateForm)({iframe:resolveIframe(t)})}function confirmPayment({iframeRef:t,token:n,defaultValues:r}){return(0,e.confirmPayment)({iframe:resolveIframe(t),token:n,defaultValues:r})}function confirmSetup({iframeRef:t,token:n,defaultValues:r}){return(0,e.confirmSetup)({iframe:resolveIframe(t),token:n,defaultValues:r})}function resetForm({iframeRef:t}){(0,e.resetForm)({iframe:resolveIframe(t)})}function focusField({iframeRef:t,field:n}){(0,e.focusField)({iframe:resolveIframe(t),field:n})}function setForwardedRef(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function applyIframePassthrough(e,{style:t,className:n,id:r,...i}){n!=null&&(e.className=n),r!=null&&(e.id=r),Object.assign(e.style,t);for(let[t,n]of Object.entries(i))n!=null&&(t in e?Reflect.set(e,t,n):e.setAttribute(t,String(n)))}function useAmosEmbed({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){let c=(0,t.useRef)(null);(0,t.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return c.current=a,setForwardedRef(n,a.iframe),applyIframePassthrough(a.iframe,o),()=>{a.destroy(),c.current=null,setForwardedRef(n,null)}},[...a]),(0,t.useEffect)(()=>{var e;(e=c.current)==null||e.update(i)},[...s]),(0,t.useEffect)(()=>{var e;let t=(e=c.current)==null?void 0:e.iframe;t&&applyIframePassthrough(t,o)})}var r=`oklch(0.97 0 0)`;function WalletButtonSlot({height:i,borderRadius:a,containerRef:o}){return(0,t.useLayoutEffect)(()=>{(0,e.ensureSkeletonStyles)()},[]),(0,n.jsxs)(`div`,{style:{boxSizing:`border-box`,position:`relative`,width:`100%`,height:i,minHeight:i,overflow:`hidden`},children:[(0,n.jsx)(`div`,{className:`amos-js-form-skeleton-input amos-js-wallet-skeleton`,style:{position:`absolute`,inset:0,height:i,borderRadius:a,background:r,pointerEvents:`none`,zIndex:0},"aria-hidden":!0}),(0,n.jsx)(`div`,{ref:o,style:{position:`absolute`,inset:0,zIndex:1,width:`100%`,height:`100%`}})]})}function mountCreditCardPaymentMethodForm(t,n){return(0,e.mountAmosCreditCardPaymentMethodForm)(t,n)}function mountBankAccountPaymentMethodForm(t,n){return(0,e.mountAmosBankAccountPaymentMethodForm)(t,n)}function AmosCreditCardPaymentMethodForm({ref:e,renderToken:r,appearance:i,onValidityChange:a,onCardBrandChanged:o,onPostalCodeChange:s,onEscapeKeyPressed:c,additionalFields:l={cardholderName:!1},billingAddressRequirement:u=`country`,defaultValues:d,style:f,...p}){let m=(0,t.useRef)(null);return useAmosEmbed({containerRef:m,iframeRef:e,mount:mountCreditCardPaymentMethodForm,options:{renderToken:r,appearance:i,additionalFields:l,billingAddressRequirement:u,defaultValues:d,onValidityChange:a,onCardBrandChanged:o,onPostalCodeChange:s,onEscapeKeyPressed:c},remountDeps:[r,l.cardholderName,u],iframePassthrough:{style:f,...p},updateDeps:[i,l,u,d,a,o,s,c]}),(0,n.jsx)(`div`,{ref:m})}function AmosBankAccountPaymentMethodForm({ref:e,renderToken:r,appearance:i,onValidityChange:a,onPostalCodeChange:o,onEscapeKeyPressed:s,billingAddressRequirement:c=`country`,defaultValues:l,requireAchVerification:u=!1,intent:d=`payment`,style:f,...p}){let m=(0,t.useRef)(null);return useAmosEmbed({containerRef:m,iframeRef:e,mount:mountBankAccountPaymentMethodForm,options:{renderToken:r,appearance:i,billingAddressRequirement:c,defaultValues:l,requireAchVerification:u,intent:d,onValidityChange:a,onPostalCodeChange:o,onEscapeKeyPressed:s},remountDeps:[r,c,d],iframePassthrough:{style:f,...p},updateDeps:[i,c,l,u,d,a,o,s]}),(0,n.jsx)(`div`,{ref:m})}function AmosGooglePayButton({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:d,onConfirm:f}){let p=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:d==null?void 0:d.style,buttonProps:c});return useAmosEmbed({containerRef:p,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:f},remountDeps:[i],iframePassthrough:d==null?{}:d,updateDeps:[a,o,s,c,l,u,f]}),(0,n.jsx)(WalletButtonSlot,{height:s,borderRadius:m,containerRef:p})}function AmosApplePayButton({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:d,onConfirm:f}){let p=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:d==null?void 0:d.style,buttonProps:c});return useAmosEmbed({containerRef:p,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:f},remountDeps:[i],iframePassthrough:d==null?{}:d,updateDeps:[a,o,s,c,l,u,f]}),(0,n.jsx)(WalletButtonSlot,{height:s,borderRadius:m,containerRef:p})}exports.AmosApplePayButton=AmosApplePayButton,exports.AmosBankAccountPaymentMethodForm=AmosBankAccountPaymentMethodForm,exports.AmosCreditCardPaymentMethodForm=AmosCreditCardPaymentMethodForm,exports.AmosGooglePayButton=AmosGooglePayButton,exports.confirmPayment=confirmPayment,exports.confirmSetup=confirmSetup,exports.focusField=focusField,exports.resetForm=resetForm,exports.validateForm=validateForm,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
package/dist/index.mjs CHANGED
@@ -2,52 +2,53 @@ import { confirmPayment as e, confirmSetup as t, ensureSkeletonStyles as n, focu
2
2
  import { useEffect as d, useLayoutEffect as f, useRef as p } from "react";
3
3
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
4
4
  export * from "@amos.com/amos-js";
5
+ //#endregion
5
6
  //#region src/index.tsx
6
- function g(e) {
7
+ function resolveIframe(e) {
7
8
  var t;
8
9
  return e ? (t = e.current) == null ? null : t : null;
9
10
  }
10
- function _({ iframeRef: e }) {
11
- return u({ iframe: g(e) });
11
+ function validateForm({ iframeRef: e }) {
12
+ return u({ iframe: resolveIframe(e) });
12
13
  }
13
- function v({ iframeRef: t, token: n, defaultValues: r }) {
14
+ function confirmPayment({ iframeRef: t, token: n, defaultValues: r }) {
14
15
  return e({
15
- iframe: g(t),
16
+ iframe: resolveIframe(t),
16
17
  token: n,
17
18
  defaultValues: r
18
19
  });
19
20
  }
20
- function y({ iframeRef: e, token: n, defaultValues: r }) {
21
+ function confirmSetup({ iframeRef: e, token: n, defaultValues: r }) {
21
22
  return t({
22
- iframe: g(e),
23
+ iframe: resolveIframe(e),
23
24
  token: n,
24
25
  defaultValues: r
25
26
  });
26
27
  }
27
- function b({ iframeRef: e }) {
28
- c({ iframe: g(e) });
28
+ function resetForm({ iframeRef: e }) {
29
+ c({ iframe: resolveIframe(e) });
29
30
  }
30
- function x({ iframeRef: e, field: t }) {
31
+ function focusField({ iframeRef: e, field: t }) {
31
32
  r({
32
- iframe: g(e),
33
+ iframe: resolveIframe(e),
33
34
  field: t
34
35
  });
35
36
  }
36
- function S(e, t) {
37
+ function setForwardedRef(e, t) {
37
38
  typeof e == "function" ? e(t) : e && (e.current = t);
38
39
  }
39
- function C(e, { style: t, className: n, id: r, ...i }) {
40
+ function applyIframePassthrough(e, { style: t, className: n, id: r, ...i }) {
40
41
  n != null && (e.className = n), r != null && (e.id = r), Object.assign(e.style, t);
41
42
  for (let [t, n] of Object.entries(i)) n != null && (t in e ? Reflect.set(e, t, n) : e.setAttribute(t, String(n)));
42
43
  }
43
- function w({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: o }) {
44
+ function useAmosEmbed({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: o }) {
44
45
  let s = p(null);
45
46
  f(() => {
46
47
  let i = e.current;
47
48
  if (!i) return;
48
49
  let o = n(i, r);
49
- return s.current = o, S(t, o.iframe), C(o.iframe, a), () => {
50
- o.destroy(), s.current = null, S(t, null);
50
+ return s.current = o, setForwardedRef(t, o.iframe), applyIframePassthrough(o.iframe, a), () => {
51
+ o.destroy(), s.current = null, setForwardedRef(t, null);
51
52
  };
52
53
  }, [...i]), d(() => {
53
54
  var e;
@@ -55,11 +56,11 @@ function w({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i
55
56
  }, [...o]), d(() => {
56
57
  var e;
57
58
  let t = (e = s.current) == null ? void 0 : e.iframe;
58
- t && C(t, a);
59
+ t && applyIframePassthrough(t, a);
59
60
  });
60
61
  }
61
- var T = "oklch(0.97 0 0)";
62
- function E({ height: e, borderRadius: t, containerRef: r }) {
62
+ var g = "oklch(0.97 0 0)";
63
+ function WalletButtonSlot({ height: e, borderRadius: t, containerRef: r }) {
63
64
  return f(() => {
64
65
  n();
65
66
  }, []), /* @__PURE__ */ h("div", {
@@ -78,7 +79,7 @@ function E({ height: e, borderRadius: t, containerRef: r }) {
78
79
  inset: 0,
79
80
  height: e,
80
81
  borderRadius: t,
81
- background: T,
82
+ background: g,
82
83
  pointerEvents: "none",
83
84
  zIndex: 0
84
85
  },
@@ -95,18 +96,18 @@ function E({ height: e, borderRadius: t, containerRef: r }) {
95
96
  })]
96
97
  });
97
98
  }
98
- function D(e, t) {
99
+ function mountCreditCardPaymentMethodForm(e, t) {
99
100
  return o(e, t);
100
101
  }
101
- function O(e, t) {
102
+ function mountBankAccountPaymentMethodForm(e, t) {
102
103
  return a(e, t);
103
104
  }
104
- function k({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardBrandChanged: i, onPostalCodeChange: a, onEscapeKeyPressed: o, additionalFields: s = { cardholderName: !1 }, billingAddressRequirement: c = "country", defaultValues: l, style: u, ...d }) {
105
+ function AmosCreditCardPaymentMethodForm({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardBrandChanged: i, onPostalCodeChange: a, onEscapeKeyPressed: o, additionalFields: s = { cardholderName: !1 }, billingAddressRequirement: c = "country", defaultValues: l, style: u, ...d }) {
105
106
  let f = p(null);
106
- return w({
107
+ return useAmosEmbed({
107
108
  containerRef: f,
108
109
  iframeRef: e,
109
- mount: D,
110
+ mount: mountCreditCardPaymentMethodForm,
110
111
  options: {
111
112
  renderToken: t,
112
113
  appearance: n,
@@ -139,12 +140,12 @@ function k({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardB
139
140
  ]
140
141
  }), /* @__PURE__ */ m("div", { ref: f });
141
142
  }
142
- function A({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onPostalCodeChange: i, onEscapeKeyPressed: a, billingAddressRequirement: o = "country", defaultValues: s, requireAchVerification: c = !1, intent: l = "payment", style: u, ...d }) {
143
+ function AmosBankAccountPaymentMethodForm({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onPostalCodeChange: i, onEscapeKeyPressed: a, billingAddressRequirement: o = "country", defaultValues: s, requireAchVerification: c = !1, intent: l = "payment", style: u, ...d }) {
143
144
  let f = p(null);
144
- return w({
145
+ return useAmosEmbed({
145
146
  containerRef: f,
146
147
  iframeRef: e,
147
- mount: O,
148
+ mount: mountBankAccountPaymentMethodForm,
148
149
  options: {
149
150
  renderToken: t,
150
151
  appearance: n,
@@ -177,12 +178,12 @@ function A({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onPosta
177
178
  ]
178
179
  }), /* @__PURE__ */ m("div", { ref: f });
179
180
  }
180
- function j({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: a, phoneRequired: o, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
181
+ function AmosGooglePayButton({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: a, phoneRequired: o, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
181
182
  let f = p(null), h = l({
182
183
  iframeStyle: u == null ? void 0 : u.style,
183
184
  buttonProps: a
184
185
  });
185
- return w({
186
+ return useAmosEmbed({
186
187
  containerRef: f,
187
188
  iframeRef: e,
188
189
  mount: s,
@@ -207,18 +208,18 @@ function j({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48
207
208
  c,
208
209
  d
209
210
  ]
210
- }), /* @__PURE__ */ m(E, {
211
+ }), /* @__PURE__ */ m(WalletButtonSlot, {
211
212
  height: i,
212
213
  borderRadius: h,
213
214
  containerRef: f
214
215
  });
215
216
  }
216
- function M({ ref: e, renderToken: t, amount: n, merchantName: r, height: a = "48px", buttonProps: o, phoneRequired: s, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
217
+ function AmosApplePayButton({ ref: e, renderToken: t, amount: n, merchantName: r, height: a = "48px", buttonProps: o, phoneRequired: s, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
217
218
  let f = p(null), h = l({
218
219
  iframeStyle: u == null ? void 0 : u.style,
219
220
  buttonProps: o
220
221
  });
221
- return w({
222
+ return useAmosEmbed({
222
223
  containerRef: f,
223
224
  iframeRef: e,
224
225
  mount: i,
@@ -243,11 +244,11 @@ function M({ ref: e, renderToken: t, amount: n, merchantName: r, height: a = "48
243
244
  c,
244
245
  d
245
246
  ]
246
- }), /* @__PURE__ */ m(E, {
247
+ }), /* @__PURE__ */ m(WalletButtonSlot, {
247
248
  height: a,
248
249
  borderRadius: h,
249
250
  containerRef: f
250
251
  });
251
252
  }
252
253
  //#endregion
253
- export { M as AmosApplePayButton, A as AmosBankAccountPaymentMethodForm, k as AmosCreditCardPaymentMethodForm, j as AmosGooglePayButton, v as confirmPayment, y as confirmSetup, x as focusField, b as resetForm, _ as validateForm };
254
+ export { AmosApplePayButton, AmosBankAccountPaymentMethodForm, AmosCreditCardPaymentMethodForm, AmosGooglePayButton, confirmPayment, confirmSetup, focusField, resetForm, validateForm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.11.22",
3
+ "version": "0.11.24",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "watch": "vite build --watch",
28
28
  "preview": "vite preview",
29
29
  "test": "vitest",
30
- "typecheck": "tsc --noEmit",
30
+ "typecheck": "node ./node_modules/typescript/bin/tsc --noEmit",
31
31
  "prepack": "npm run build",
32
32
  "changeset": "changeset",
33
33
  "version": "changeset version",
@@ -46,22 +46,22 @@
46
46
  ],
47
47
  "description": "React SDK for embedding Amos payment methods via iframes. Wraps @amos.com/amos-js.",
48
48
  "devDependencies": {
49
- "@amos.com/node": "0.1.64",
50
- "@biomejs/biome": "2.5.11",
51
- "@changesets/cli": "2.31.1",
52
- "@types/node": "26.4.0",
53
- "@types/react": "19.2.18",
49
+ "@amos.com/node": "0.1.65",
50
+ "@biomejs/biome": "2.5.14",
51
+ "@changesets/cli": "3.0.3",
52
+ "@types/node": "26.6.2",
53
+ "@types/react": "19.3.0",
54
54
  "@typescript/typescript6": "6.0.2",
55
55
  "typescript": "7.0.2",
56
- "vite": "8.2.2",
57
- "vite-plugin-dts": "5.0.3"
56
+ "vite": "8.3.0",
57
+ "vite-plugin-dts": "5.1.1"
58
58
  },
59
59
  "dependencies": {
60
- "@amos.com/amos-js": "0.11.24",
61
- "@types/googlepay": "0.7.12"
60
+ "@amos.com/amos-js": "0.11.26",
61
+ "@types/googlepay": "0.7.13"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "react": "^17 || ^18 || ^19",
65
- "@amos.com/node": ">=0.1.64"
65
+ "@amos.com/node": ">=0.1.65"
66
66
  }
67
67
  }