@stridge/kit 0.1.0-alpha.26 → 0.1.0-alpha.27

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
@@ -47,7 +47,7 @@ import { WithdrawDialog } from "@stridge/kit/withdraw/dialog";
47
47
  </StridgeProvider>;
48
48
  ```
49
49
 
50
- Open or close the dialogs with `useDeposit().open()` / `useWithdraw().open()`. Headless integrators render their own UI via `useDeposit()`, `useDepositState()`, `useDepositSnapshot()` and the withdraw mirrors — the root entry ships no UI, so the headless bundle stays clean.
50
+ Open or close the dialogs with `useDeposit().open()` / `useWithdraw().open()`. Headless integrators render their own UI via `useDeposit()`, `useDepositState()`, `useDepositSnapshot()` and the withdraw mirrors — the root entry ships no UI, so the headless bundle stays clean. `useOptionalDeposit()` / `useOptionalWithdraw()` return `null` when called outside the provider, for hosts that mount `<StridgeProvider />` conditionally (e.g. only after a wallet is connected).
51
51
 
52
52
  ## Documentation
53
53
 
@@ -1 +1 @@
1
- "use client";import{KitStorageProvider as e}from"./storage/context.js";import"./storage/index.js";import{DepositDriverProvider as t}from"./flows/deposit/driver/context.js";import{getLocaleDirection as n}from"./shared/i18n/getLocaleDirection.js";import{KitI18nProvider as r}from"./shared/i18n/KitI18nProvider.js";import"./i18n/index.js";import{GatewayController as i}from"./flows/deposit/orchestrator/controller.js";import{WithdrawBindingsProvider as a}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{WithdrawDriverProvider as o}from"./flows/withdraw/driver/context.js";import{WithdrawControllerProvider as s}from"./flows/withdraw/orchestrator/controller.js";import{KitScope as c}from"./scope/KitScope.js";import"./scope/index.js";import{SupportConfigContext as l}from"./shared/support/SupportConfigContext.js";import{useMemo as u}from"react";import{jsx as d}from"react/jsx-runtime";function f({children:f,i18n:p,direction:m,deposit:h,withdraw:g,storage:_,storageNamespace:v,support:y,merchantContext:b,attribution:x=`visible`,...S}){let C=n(p?.locale),w=f;g&&(w=d(a,{children:d(o,{driver:g,children:d(s,{children:w})})})),h&&(w=d(t,{driver:h,children:d(i,{children:w})}));let T=u(()=>({config:y,merchantContext:b??null}),[y,b]),E=y!==void 0||b!==void 0,D=d(r,{locale:p?.locale,messages:p?.messages,children:d(c,{...S,direction:m??C,locale:p?.locale,attribution:x,children:d(e,{storage:_,namespace:v,children:w})})});return E?d(l.Provider,{value:T,children:D}):D}export{f as KitProvider};
1
+ "use client";import{KitStorageProvider as e}from"./storage/context.js";import"./storage/index.js";import{DepositDriverProvider as t}from"./flows/deposit/driver/context.js";import{getLocaleDirection as n}from"./shared/i18n/getLocaleDirection.js";import{KitI18nProvider as r}from"./shared/i18n/KitI18nProvider.js";import"./i18n/index.js";import{GatewayController as i}from"./flows/deposit/orchestrator/controller.js";import{WithdrawBindingsProvider as a}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{WithdrawDriverProvider as o}from"./flows/withdraw/driver/context.js";import{WithdrawControllerProvider as s}from"./flows/withdraw/orchestrator/controller.js";import{KitScope as c}from"./scope/KitScope.js";import"./scope/index.js";import{SupportConfigContext as l}from"./shared/support/SupportConfigContext.js";import{useMemo as u}from"react";import{jsx as d}from"react/jsx-runtime";import{LazyMotion as f,domMax as p}from"motion/react";function m({children:m,i18n:h,direction:g,deposit:_,withdraw:v,storage:y,storageNamespace:b,support:x,merchantContext:S,attribution:C=`visible`,...w}){let T=n(h?.locale),E=m;v&&(E=d(a,{children:d(o,{driver:v,children:d(s,{children:E})})})),_&&(E=d(t,{driver:_,children:d(i,{children:E})}));let D=u(()=>({config:x,merchantContext:S??null}),[x,S]),O=x!==void 0||S!==void 0,k=d(r,{locale:h?.locale,messages:h?.messages,children:d(c,{...w,direction:g??T,locale:h?.locale,attribution:C,children:d(e,{storage:y,namespace:b,children:E})})});return d(f,{features:p,children:O?d(l.Provider,{value:D,children:k}):k})}export{m as KitProvider};
@@ -1 +1 @@
1
- "use client";import{useDepositDriverInstance as e}from"../driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{isUserRejectionFailure as a}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as o}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{initialState as s,reducer as c}from"./reducer.js";import{resolveAssetById as l}from"./resolveAssetById.js";import{createContext as u,use as d,useCallback as f,useEffect as p,useMemo as m,useReducer as h,useRef as g}from"react";import{jsx as _}from"react/jsx-runtime";const v={id:`ELhVSL`,message:`Failed to submit deposit.`},y={id:`Ej5HL9`,message:`Signature declined. Please try again.`},b=u(null);b.displayName=`GatewayControllerContext`;function x(){let e=d(b);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function S(){return x().state}function C(){return x().effectiveState}function w(){return x().actions}function T({children:t}){let n=e(),[r,a]=h(c,s),o=D(r,a,n);O(r,a,n),k(r,a,n);let l=i(r),u=E(r,a,n,o);return _(b,{value:m(()=>({state:r,effectiveState:l,dispatch:a,controller:u,actions:o}),[r,l,u,o]),children:t})}function E(e,t,n,r){let i=g(n);i.current=n;let a=f(e=>{if(!e)return t({type:`OPEN`,input:void 0}),!0;if(e.method===`transfer`)return t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=l(i.current.getSnapshot(),e.assetId);return n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):!1}return t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),o=f(()=>{t({type:`CLOSE`})},[t]);return m(()=>({open:a,close:o,actions:r}),[a,o,r])}function D(e,r,i){let o=g(e);o.current=e;let s=g(i);s.current=i;let c=g(r);c.current=r;let{i18n:l}=t(),u=g(l);u.current=l;let d=f((e,t)=>{let r=s.current,i=new AbortController,o=j(e,t);r.submitDeposit(o,i.signal).then(e=>{i.signal.aborted||c.current({type:`DEPOSIT_SUBMITTED`,tx:e})}).catch(e=>{if(i.signal.aborted)return;let t=n(e,u.current._(v));if(a(t)){c.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:u.current._(y)});return}c.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),p=f(e=>{c.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),h=f(e=>{c.current({type:`ASSET_CONFIRMED`,asset:e})},[]),_=f(e=>{o.current.name===`amountEntry`&&c.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),b=f(()=>{let e=o.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){c.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;c.current({type:`DEPOSIT_CONFIRMED`}),d(n,r)},[d]),x=f(()=>{c.current({type:`BACK`})},[]),S=f(()=>{c.current({type:`CLOSE`})},[]),C=f(()=>{c.current({type:`SUCCESS_DONE`})},[]),w=f(()=>{c.current({type:`ERROR_TRY_AGAIN`})},[]),T=f((e,t)=>{c.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),E=f((e,t)=>{c.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),D=f(e=>{c.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]);return m(()=>({selectMethod:p,confirmAsset:h,confirmAmount:_,confirmDeposit:b,back:x,close:S,successDone:C,tryAgain:w,resumeToProcessing:T,resumeToSuccess:E,resumeToError:D}),[p,h,_,b,x,S,C,w,T,E,D])}function O(e,t,r){p(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let i=new AbortController,a=A(e.ctx.asset,e.ctx.amount);return r.requestQuote(a,i.signal).catch(e=>{i.signal.aborted||t({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>i.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,r,t]),p(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let n=e.ctx.phase.quoteExpiresAt,r=Math.max(0,n-Date.now()),i=setTimeout(()=>{t({type:`QUOTE_EXPIRED`})},r);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,t])}function k(e,t,n){let i=e.name===`processing`?e.ctx.tx:void 0;o(n,i?{tx:i}:void 0,i?.hash),p(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{t.signal.aborted||r||(r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal))},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]),p(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,n]);let a=g(e);a.current=e,r(n,e=>{a.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let s=g(null);p(()=>{let e=()=>{let e=n.getSnapshot(),r=a.current,i=e.quote;i.status!==s.current&&(s.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name}}))},r=n.subscribe(e);return e(),r},[n,t])}function A(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function j(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{T as GatewayController,x as useControllerContext,w as useDepositActions,C as useDepositEffectiveState,S as useDepositState};
1
+ "use client";import{useDepositDriverInstance as e}from"../driver/context.js";import{useLingui as t}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as n}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as r}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as i}from"../../../shared/orchestrator/useEffectiveState.js";import{isUserRejectionFailure as a}from"../../../shared/orchestrator/userRejection.js";import{useSettlementWatcher as o}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{initialState as s,reducer as c}from"./reducer.js";import{resolveAssetById as l}from"./resolveAssetById.js";import{createContext as u,use as d,useCallback as f,useEffect as p,useMemo as m,useReducer as h,useRef as g}from"react";import{jsx as _}from"react/jsx-runtime";const v={id:`ELhVSL`,message:`Failed to submit deposit.`},y={id:`Ej5HL9`,message:`Signature declined. Please try again.`},b=u(null);b.displayName=`GatewayControllerContext`;function x(){let e=d(b);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function S(){return d(b)}function C(){return x().state}function w(){return x().effectiveState}function T(){return x().actions}function E({children:t}){let n=e(),[r,a]=h(c,s),o=O(r,a,n);k(r,a,n),A(r,a,n);let l=i(r),u=D(r,a,n,o);return _(b,{value:m(()=>({state:r,effectiveState:l,dispatch:a,controller:u,actions:o}),[r,l,u,o]),children:t})}function D(e,t,n,r){let i=g(n);i.current=n;let a=f(e=>{if(!e)return t({type:`OPEN`,input:void 0}),!0;if(e.method===`transfer`)return t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=l(i.current.getSnapshot(),e.assetId);return n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):!1}return t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),o=f(()=>{t({type:`CLOSE`})},[t]);return m(()=>({open:a,close:o,actions:r}),[a,o,r])}function O(e,r,i){let o=g(e);o.current=e;let s=g(i);s.current=i;let c=g(r);c.current=r;let{i18n:l}=t(),u=g(l);u.current=l;let d=f((e,t)=>{let r=s.current,i=new AbortController,o=M(e,t);r.submitDeposit(o,i.signal).then(e=>{i.signal.aborted||c.current({type:`DEPOSIT_SUBMITTED`,tx:e})}).catch(e=>{if(i.signal.aborted)return;let t=n(e,u.current._(v));if(a(t)){c.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:u.current._(y)});return}c.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),p=f(e=>{c.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),h=f(e=>{c.current({type:`ASSET_CONFIRMED`,asset:e})},[]),_=f(e=>{o.current.name===`amountEntry`&&c.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),b=f(()=>{let e=o.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){c.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;c.current({type:`DEPOSIT_CONFIRMED`}),d(n,r)},[d]),x=f(()=>{c.current({type:`BACK`})},[]),S=f(()=>{c.current({type:`CLOSE`})},[]),C=f(()=>{c.current({type:`SUCCESS_DONE`})},[]),w=f(()=>{c.current({type:`ERROR_TRY_AGAIN`})},[]),T=f((e,t)=>{c.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),E=f((e,t)=>{c.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),D=f(e=>{c.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]);return m(()=>({selectMethod:p,confirmAsset:h,confirmAmount:_,confirmDeposit:b,back:x,close:S,successDone:C,tryAgain:w,resumeToProcessing:T,resumeToSuccess:E,resumeToError:D}),[p,h,_,b,x,S,C,w,T,E,D])}function k(e,t,r){p(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let i=new AbortController,a=j(e.ctx.asset,e.ctx.amount);return r.requestQuote(a,i.signal).catch(e=>{i.signal.aborted||t({type:`QUOTE_FAILED`,failure:n(e,`Failed to fetch quote.`)})}),()=>i.abort()},[e.name,e.name===`confirmDeposit`?e.ctx.phase.kind:void 0,e.name===`confirmDeposit`?e.ctx.asset:void 0,e.name===`confirmDeposit`?e.ctx.amount:void 0,r,t]),p(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`ready`)return;let n=e.ctx.phase.quoteExpiresAt,r=Math.max(0,n-Date.now()),i=setTimeout(()=>{t({type:`QUOTE_EXPIRED`})},r);return()=>clearTimeout(i)},[e.name,e.name===`confirmDeposit`&&e.ctx.phase.kind===`ready`?e.ctx.phase.quoteExpiresAt:void 0,t])}function A(e,t,n){let i=e.name===`processing`?e.ctx.tx:void 0;o(n,i?{tx:i}:void 0,i?.hash),p(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{t.signal.aborted||r||(r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal))},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]),p(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||!n.fetchActiveSettlement)return;let t=new AbortController,r,i,a=!1,o=async()=>{try{let e=await n.fetchActiveSettlement({},t.signal);if(a)return;if(e&&!r&&e.payload.kind===`pending`){let t=e.payload.txHash?.value;t&&(r=new AbortController,n.watchSettlement({tx:{hash:t}},()=>{},r.signal))}}catch{}a||(i=setTimeout(o,5e3))};return o(),()=>{a=!0,t.abort(),r?.abort(),i&&clearTimeout(i)}},[e.name,n]);let a=g(e);a.current=e,r(n,e=>{a.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let s=g(null);p(()=>{let e=()=>{let e=n.getSnapshot(),r=a.current,i=e.quote;i.status!==s.current&&(s.current=i.status,i.status===`ready`&&r.name===`confirmDeposit`?(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_RESOLVED`,expiresAt:i.payload.expiresAt}):i.status===`error`&&r.name===`confirmDeposit`&&(r.ctx.phase.kind===`loading`||r.ctx.phase.kind===`regenerating`)&&t({type:`QUOTE_FAILED`,failure:{reason:i.error.message,code:i.error.name}}))},r=n.subscribe(e);return e(),r},[n,t])}function j(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build quote input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceTokenSymbol:e.symbol,sourceIsNative:e.isNative,amount:t,...e.priceUsd===void 0?{}:{sourcePriceUsd:e.priceUsd}}}function M(e,t){let n=e.eip155Id;if(!n)throw Error(`Asset ${e.symbol} is missing eip155Id; cannot build submit input.`);return{sourceChainId:Number(n),sourceTokenAddress:e.address,sourceTokenDecimals:e.decimals,sourceIsNative:e.isNative,amount:t}}export{E as GatewayController,x as useControllerContext,T as useDepositActions,w as useDepositEffectiveState,C as useDepositState,S as useOptionalControllerContext};
@@ -31,5 +31,22 @@ import { DepositController } from "./types.js";
31
31
  * ```
32
32
  */
33
33
  declare function useDeposit(): DepositController;
34
+ /**
35
+ * Non-throwing variant of {@link useDeposit} — returns `null` when called outside a
36
+ * `<KitProvider deposit={…} />`. Lets hosts mount `<StridgeProvider />` conditionally
37
+ * (e.g. only after a wallet is connected) without descendants crashing the moment they render
38
+ * before the provider exists.
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * const deposit = useOptionalDeposit();
43
+ * return (
44
+ * <button onClick={() => deposit?.open()} disabled={!deposit}>
45
+ * Deposit
46
+ * </button>
47
+ * );
48
+ * ```
49
+ */
50
+ declare function useOptionalDeposit(): DepositController | null;
34
51
  //#endregion
35
- export { useDeposit };
52
+ export { useDeposit, useOptionalDeposit };
@@ -1 +1 @@
1
- "use client";import{useControllerContext as e}from"./controller.js";function t(){return e().controller}export{t as useDeposit};
1
+ "use client";import{useControllerContext as e,useOptionalControllerContext as t}from"./controller.js";function n(){return e().controller}function r(){return t()?.controller??null}export{n as useDeposit,r as useOptionalDeposit};
@@ -1 +1 @@
1
- "use client";import{useLingui as e}from"../../../../../shared/i18n/useLingui.js";import"../../../../../i18n/index.js";import{useKitConfig as t}from"../../../../../scope/context.js";import{Collapsible as n}from"../../../../../shared/ui/Collapsible/Collapsible.js";import"../../../../../shared/ui/Collapsible/index.js";import{DEPOSIT_STATUS_BANNER_SLOTS as r}from"./DepositStatusBanner.slots.js";import{styles as i}from"./DepositStatusBanner.styles.js";import{DepositStatusBannerBody as a}from"./components/Body.js";import{DepositStatusBannerContext as o}from"./context.js";import{DepositStatusBannerClose as s}from"./components/Close.js";import{DepositStatusBannerDetail as c}from"./components/Detail.js";import{DepositStatusBannerDetails as l}from"./components/Details.js";import{DepositStatusBannerFooter as u}from"./components/Footer.js";import{DepositStatusBannerHero as d}from"./components/Hero.js";import{DepositStatusBannerPrimaryAction as f}from"./components/PrimaryAction.js";import{DepositStatusBannerCompletionTxRow as p,DepositStatusBannerDepositTxRow as m,DepositStatusBannerFilledAtRow as h,DepositStatusBannerSubmittedAtRow as g}from"./components/Rows.js";import{DepositStatusBannerToggle as _}from"./components/Toggle.js";import{useEffect as v,useLayoutEffect as y,useMemo as b,useRef as x}from"react";import{jsx as S}from"react/jsx-runtime";import*as C from"@stylexjs/stylex";import{motion as w}from"motion/react";const T=[.16,1,.3,1],E=[.4,0,1,1];function D({kind:a,asset:s,headline:c,subline:l,expanded:u,onToggleExpanded:d,onDismiss:f,depositTx:p,completionTx:m,submittedAt:h,filledAt:g,onPrimaryAction:_,inline:D,children:O}){let{_:k}=e(),{direction:A}=t(),j=c??k(a===`succeeded`?{id:`3kg1gB`,message:`Deposit completed`}:a===`failed`?{id:`Rxjdjn`,message:`Deposit didn't complete`}:{id:`junZX6`,message:`Deposit received and processing…`}),M=l??k(a===`succeeded`?{id:`9JHY2T`,message:`Your deposit has been credited to your account.`}:a===`failed`?{id:`Z1WbO6`,message:`Funds are safe on the source chain — contact support to recover.`}:{id:`Offl0a`,message:`Your deposit will be credited to your account.`}),N=b(()=>({kind:a,asset:s,headline:j,subline:M,expanded:u,onToggleExpanded:d,onDismiss:f,depositTx:p,completionTx:m,submittedAt:h,filledAt:g,onPrimaryAction:_}),[a,s,j,M,u,d,f,p,m,h,g,_]),P=x(null),F=x(null),I=x(a),L=x(null),R=x(null);y(()=>{let e=P.current;if(!e)return;let t=e.getBoundingClientRect().height;if(I.current===a){F.current=t;return}let n=F.current;if(I.current=a,F.current=t,n===null||n===t||document.visibilityState===`hidden`)return;let r=e.style.transition;e.style.transition=`none`,e.style.height=`${n}px`,e.offsetHeight,e.style.transition=r,R.current!==null&&window.cancelAnimationFrame(R.current),R.current=window.requestAnimationFrame(()=>{R.current=null,P.current&&(P.current.style.height=`${t}px`)}),L.current!==null&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>{L.current=null;let e=P.current;e&&(e.style.height=``)},320)}),v(()=>{let e=()=>{if(document.visibilityState!==`hidden`)return;R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null),L.current!==null&&(window.clearTimeout(L.current),L.current=null);let e=P.current;e&&(e.style.height=``)};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),L.current!==null&&(window.clearTimeout(L.current),L.current=null),R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null)}},[]);let z=D?`0%`:`-50%`;return S(o.Provider,{value:N,children:S(n,{open:u,onOpenChange:e=>{e!==u&&d()},children:S(w.div,{"data-stridge-slot":r.root,dir:A,...C.props(i.root,D&&i.rootInline),initial:{x:z,y:`100%`,opacity:0},animate:{x:z,y:`0%`,opacity:1,transition:{duration:.3,ease:T}},exit:{x:z,y:`100%`,opacity:0,transition:{duration:.22,ease:E}},children:S(`div`,{ref:P,style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,transition:`height 260ms cubic-bezier(0.3, 0, 0.06, 1)`},children:O})})})})}(function(e){e.Body=a,e.Hero=d,e.Close=s,e.Details=l,e.Detail=c,e.Footer=u,e.Toggle=_,e.PrimaryAction=f,e.DepositTxRow=m,e.CompletionTxRow=p,e.SubmittedAtRow=g,e.FilledAtRow=h})(D||={});export{D as DepositStatusBanner};
1
+ "use client";import{useLingui as e}from"../../../../../shared/i18n/useLingui.js";import"../../../../../i18n/index.js";import{useKitConfig as t}from"../../../../../scope/context.js";import{Collapsible as n}from"../../../../../shared/ui/Collapsible/Collapsible.js";import"../../../../../shared/ui/Collapsible/index.js";import{DEPOSIT_STATUS_BANNER_SLOTS as r}from"./DepositStatusBanner.slots.js";import{styles as i}from"./DepositStatusBanner.styles.js";import{DepositStatusBannerBody as a}from"./components/Body.js";import{DepositStatusBannerContext as o}from"./context.js";import{DepositStatusBannerClose as s}from"./components/Close.js";import{DepositStatusBannerDetail as c}from"./components/Detail.js";import{DepositStatusBannerDetails as l}from"./components/Details.js";import{DepositStatusBannerFooter as u}from"./components/Footer.js";import{DepositStatusBannerHero as d}from"./components/Hero.js";import{DepositStatusBannerPrimaryAction as f}from"./components/PrimaryAction.js";import{DepositStatusBannerCompletionTxRow as p,DepositStatusBannerDepositTxRow as m,DepositStatusBannerFilledAtRow as h,DepositStatusBannerSubmittedAtRow as g}from"./components/Rows.js";import{DepositStatusBannerToggle as _}from"./components/Toggle.js";import{useEffect as v,useLayoutEffect as y,useMemo as b,useRef as x}from"react";import{jsx as S}from"react/jsx-runtime";import{m as C}from"motion/react";import*as w from"@stylexjs/stylex";const T=[.16,1,.3,1],E=[.4,0,1,1];function D({kind:a,asset:s,headline:c,subline:l,expanded:u,onToggleExpanded:d,onDismiss:f,depositTx:p,completionTx:m,submittedAt:h,filledAt:g,onPrimaryAction:_,inline:D,children:O}){let{_:k}=e(),{direction:A}=t(),j=c??k(a===`succeeded`?{id:`3kg1gB`,message:`Deposit completed`}:a===`failed`?{id:`Rxjdjn`,message:`Deposit didn't complete`}:{id:`junZX6`,message:`Deposit received and processing…`}),M=l??k(a===`succeeded`?{id:`9JHY2T`,message:`Your deposit has been credited to your account.`}:a===`failed`?{id:`Z1WbO6`,message:`Funds are safe on the source chain — contact support to recover.`}:{id:`Offl0a`,message:`Your deposit will be credited to your account.`}),N=b(()=>({kind:a,asset:s,headline:j,subline:M,expanded:u,onToggleExpanded:d,onDismiss:f,depositTx:p,completionTx:m,submittedAt:h,filledAt:g,onPrimaryAction:_}),[a,s,j,M,u,d,f,p,m,h,g,_]),P=x(null),F=x(null),I=x(a),L=x(null),R=x(null);y(()=>{let e=P.current;if(!e)return;let t=e.getBoundingClientRect().height;if(I.current===a){F.current=t;return}let n=F.current;if(I.current=a,F.current=t,n===null||n===t||document.visibilityState===`hidden`)return;let r=e.style.transition;e.style.transition=`none`,e.style.height=`${n}px`,e.offsetHeight,e.style.transition=r,R.current!==null&&window.cancelAnimationFrame(R.current),R.current=window.requestAnimationFrame(()=>{R.current=null,P.current&&(P.current.style.height=`${t}px`)}),L.current!==null&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>{L.current=null;let e=P.current;e&&(e.style.height=``)},320)}),v(()=>{let e=()=>{if(document.visibilityState!==`hidden`)return;R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null),L.current!==null&&(window.clearTimeout(L.current),L.current=null);let e=P.current;e&&(e.style.height=``)};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),L.current!==null&&(window.clearTimeout(L.current),L.current=null),R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null)}},[]);let z=D?`0%`:`-50%`;return S(o.Provider,{value:N,children:S(n,{open:u,onOpenChange:e=>{e!==u&&d()},children:S(C.div,{"data-stridge-slot":r.root,dir:A,...w.props(i.root,D&&i.rootInline),initial:{x:z,y:`100%`,opacity:0},animate:{x:z,y:`0%`,opacity:1,transition:{duration:.3,ease:T}},exit:{x:z,y:`100%`,opacity:0,transition:{duration:.22,ease:E}},children:S(`div`,{ref:P,style:{display:`flex`,flexDirection:`column`,overflow:`hidden`,transition:`height 260ms cubic-bezier(0.3, 0, 0.06, 1)`},children:O})})})})}(function(e){e.Body=a,e.Hero=d,e.Close=s,e.Details=l,e.Detail=c,e.Footer=u,e.Toggle=_,e.PrimaryAction=f,e.DepositTxRow=m,e.CompletionTxRow=p,e.SubmittedAtRow=g,e.FilledAtRow=h})(D||={});export{D as DepositStatusBanner};
@@ -1 +1 @@
1
- "use client";import{AlertIcon as e}from"../../../../../../shared/icons/AlertIcon.js";import{ArrowDownIcon as t}from"../../../../../../shared/icons/ArrowDownIcon.js";import{CheckIcon as n}from"../../../../../../shared/icons/CheckIcon.js";import"../../../../../../icons/index.js";import{TokenLogo as r}from"../../../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../../../shared/ui/TokenLogo/index.js";import{DEPOSIT_STATUS_BANNER_SLOTS as i}from"../DepositStatusBanner.slots.js";import{styles as a}from"../DepositStatusBanner.styles.js";import{useDepositStatusBannerContext as o}from"../context.js";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import*as u from"@stylexjs/stylex";import{AnimatePresence as d,motion as f}from"motion/react";const p=[.16,1,.3,1],m=.22,h=.08,g=.14,_={enter:{opacity:0,y:6,filter:`blur(4px)`},center:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:m,delay:h,ease:p}},exit:{opacity:0,y:-6,filter:`blur(4px)`,transition:{duration:g,ease:p}}},v={enter:{opacity:0,scale:.6},center:{opacity:1,scale:1,transition:{duration:m,delay:h,ease:p}},exit:{opacity:0,scale:.6,transition:{duration:g,ease:p}}};function y(){let{kind:e,asset:t,headline:n,subline:p}=o(`DepositStatusBanner.Hero`);return l(s,{children:[l(`span`,{"data-stridge-slot":i.logo,...u.props(a.logo),children:[c(r,{size:32,symbol:t.symbol,...typeof t.chainId==`number`?{chainId:t.chainId}:{},...t.address?{address:t.address}:{},...t.isNative===void 0?{}:{isNative:t.isNative},...t.logoUrl?{logoUrl:t.logoUrl}:{},hideChainBadge:!0}),c(`span`,{"aria-hidden":!0,"data-stridge-slot":i.badge,...u.props(a.badge,e===`succeeded`&&a.badgeSucceeded,e===`failed`&&a.badgeFailed,e===`pending`&&a.badgePending),children:c(d,{mode:`wait`,initial:!1,children:c(f.span,{variants:v,initial:`enter`,animate:`center`,exit:`exit`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:c(b,{kind:e})},e)})})]}),c(`div`,{"data-stridge-slot":i.text,...u.props(a.text),children:c(d,{mode:`wait`,initial:!1,children:l(f.div,{variants:_,initial:`enter`,animate:`center`,exit:`exit`,style:{display:`flex`,flexDirection:`column`,gap:`2px`,minWidth:0},children:[c(`span`,{"data-stridge-slot":i.headline,...u.props(a.headline),children:n}),c(`span`,{"data-stridge-slot":i.subline,...u.props(a.subline),children:p})]},e)})})]})}function b({kind:r}){let i=u.props(a.badgeIcon);return c(r===`succeeded`?n:r===`failed`?e:t,{"aria-hidden":!0,...i})}export{y as DepositStatusBannerHero};
1
+ "use client";import{AlertIcon as e}from"../../../../../../shared/icons/AlertIcon.js";import{ArrowDownIcon as t}from"../../../../../../shared/icons/ArrowDownIcon.js";import{CheckIcon as n}from"../../../../../../shared/icons/CheckIcon.js";import"../../../../../../icons/index.js";import{TokenLogo as r}from"../../../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../../../shared/ui/TokenLogo/index.js";import{DEPOSIT_STATUS_BANNER_SLOTS as i}from"../DepositStatusBanner.slots.js";import{styles as a}from"../DepositStatusBanner.styles.js";import{useDepositStatusBannerContext as o}from"../context.js";import{Fragment as s,jsx as c,jsxs as l}from"react/jsx-runtime";import{AnimatePresence as u,m as d}from"motion/react";import*as f from"@stylexjs/stylex";const p=[.16,1,.3,1],m=.22,h=.08,g=.14,_={enter:{opacity:0,y:6,filter:`blur(4px)`},center:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:m,delay:h,ease:p}},exit:{opacity:0,y:-6,filter:`blur(4px)`,transition:{duration:g,ease:p}}},v={enter:{opacity:0,scale:.6},center:{opacity:1,scale:1,transition:{duration:m,delay:h,ease:p}},exit:{opacity:0,scale:.6,transition:{duration:g,ease:p}}};function y(){let{kind:e,asset:t,headline:n,subline:p}=o(`DepositStatusBanner.Hero`);return l(s,{children:[l(`span`,{"data-stridge-slot":i.logo,...f.props(a.logo),children:[c(r,{size:32,symbol:t.symbol,...typeof t.chainId==`number`?{chainId:t.chainId}:{},...t.address?{address:t.address}:{},...t.isNative===void 0?{}:{isNative:t.isNative},...t.logoUrl?{logoUrl:t.logoUrl}:{},hideChainBadge:!0}),c(`span`,{"aria-hidden":!0,"data-stridge-slot":i.badge,...f.props(a.badge,e===`succeeded`&&a.badgeSucceeded,e===`failed`&&a.badgeFailed,e===`pending`&&a.badgePending),children:c(u,{mode:`wait`,initial:!1,children:c(d.span,{variants:v,initial:`enter`,animate:`center`,exit:`exit`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:c(b,{kind:e})},e)})})]}),c(`div`,{"data-stridge-slot":i.text,...f.props(a.text),children:c(u,{mode:`wait`,initial:!1,children:l(d.div,{variants:_,initial:`enter`,animate:`center`,exit:`exit`,style:{display:`flex`,flexDirection:`column`,gap:`2px`,minWidth:0},children:[c(`span`,{"data-stridge-slot":i.headline,...f.props(a.headline),children:n}),c(`span`,{"data-stridge-slot":i.subline,...f.props(a.subline),children:p})]},e)})})]})}function b({kind:r}){let i=f.props(a.badgeIcon);return c(r===`succeeded`?n:r===`failed`?e:t,{"aria-hidden":!0,...i})}export{y as DepositStatusBannerHero};
@@ -1 +1 @@
1
- "use client";import{useLingui as e}from"../../../../../../shared/i18n/useLingui.js";import"../../../../../../i18n/index.js";import{ChevronRightIcon as t}from"../../../../../../shared/icons/ChevronRightIcon.js";import"../../../../../../icons/index.js";import{Button as n}from"../../../../../../shared/ui/Button/Button.js";import"../../../../../../shared/ui/Button/index.js";import{DEPOSIT_STATUS_BANNER_SLOTS as r}from"../DepositStatusBanner.slots.js";import{useDepositStatusBannerContext as i}from"../context.js";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{AnimatePresence as s,motion as c}from"motion/react";const l=[.16,1,.3,1],u={enter:{opacity:0,y:`60%`},center:{opacity:1,y:`0%`,transition:{duration:.22,ease:l}},exit:{opacity:0,y:`-60%`,transition:{duration:.18,ease:l}}};function d({onClick:l,label:d}={}){let f=i(`DepositStatusBanner.PrimaryAction`),{kind:p}=f,m=l??f.onPrimaryAction,{_:h}=e();if(!m)return null;let g=d??h(p===`succeeded`?{id:`AO44G_`,message:`View receipt`}:p===`failed`?{id:`2Eoi_a`,message:`View details`}:{id:`Oi8TiZ`,message:`View progress`}),_=d??[h({id:`Oi8TiZ`,message:`View progress`}),h({id:`AO44G_`,message:`View receipt`}),h({id:`2Eoi_a`,message:`View details`})].reduce((e,t)=>t.length>e.length?t:e);return a(n,{type:`button`,onClick:m,variant:`default`,size:`sm`,suffix:a(t,{"aria-hidden":!0}),"data-stridge-slot":r.primaryAction,children:o(`span`,{style:{position:`relative`,display:`inline-flex`,alignItems:`center`,overflow:`hidden`},children:[a(`span`,{"aria-hidden":!0,style:{visibility:`hidden`,whiteSpace:`nowrap`},children:_}),a(s,{mode:`popLayout`,initial:!1,children:a(c.span,{variants:u,initial:`enter`,animate:`center`,exit:`exit`,style:{position:`absolute`,insetInlineStart:0,insetBlockStart:0,width:`100%`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,whiteSpace:`nowrap`},children:g},g)})]})})}export{d as DepositStatusBannerPrimaryAction};
1
+ "use client";import{useLingui as e}from"../../../../../../shared/i18n/useLingui.js";import"../../../../../../i18n/index.js";import{ChevronRightIcon as t}from"../../../../../../shared/icons/ChevronRightIcon.js";import"../../../../../../icons/index.js";import{Button as n}from"../../../../../../shared/ui/Button/Button.js";import"../../../../../../shared/ui/Button/index.js";import{DEPOSIT_STATUS_BANNER_SLOTS as r}from"../DepositStatusBanner.slots.js";import{useDepositStatusBannerContext as i}from"../context.js";import{jsx as a,jsxs as o}from"react/jsx-runtime";import{AnimatePresence as s,m as c}from"motion/react";const l=[.16,1,.3,1],u={enter:{opacity:0,y:`60%`},center:{opacity:1,y:`0%`,transition:{duration:.22,ease:l}},exit:{opacity:0,y:`-60%`,transition:{duration:.18,ease:l}}};function d({onClick:l,label:d}={}){let f=i(`DepositStatusBanner.PrimaryAction`),{kind:p}=f,m=l??f.onPrimaryAction,{_:h}=e();if(!m)return null;let g=d??h(p===`succeeded`?{id:`AO44G_`,message:`View receipt`}:p===`failed`?{id:`2Eoi_a`,message:`View details`}:{id:`Oi8TiZ`,message:`View progress`}),_=d??[h({id:`Oi8TiZ`,message:`View progress`}),h({id:`AO44G_`,message:`View receipt`}),h({id:`2Eoi_a`,message:`View details`})].reduce((e,t)=>t.length>e.length?t:e);return a(n,{type:`button`,onClick:m,variant:`default`,size:`sm`,suffix:a(t,{"aria-hidden":!0}),"data-stridge-slot":r.primaryAction,children:o(`span`,{style:{position:`relative`,display:`inline-flex`,alignItems:`center`,overflow:`hidden`},children:[a(`span`,{"aria-hidden":!0,style:{visibility:`hidden`,whiteSpace:`nowrap`},children:_}),a(s,{mode:`popLayout`,initial:!1,children:a(c.span,{variants:u,initial:`enter`,animate:`center`,exit:`exit`,style:{position:`absolute`,insetInlineStart:0,insetBlockStart:0,width:`100%`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,whiteSpace:`nowrap`},children:g},g)})]})})}export{d as DepositStatusBannerPrimaryAction};
@@ -1 +1 @@
1
- "use client";import{useLingui as e}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as t}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as n}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as r}from"../../../shared/orchestrator/useEffectiveState.js";import{useSettlementWatcher as i}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useWithdrawBindingsRef as a}from"../bindings/WithdrawBindings.js";import"../bindings/index.js";import{useWithdrawDriverInstance as o}from"../driver/context.js";import{initialState as s,reducer as c}from"./reducer.js";import{createContext as l,use as u,useCallback as d,useMemo as f,useReducer as p,useRef as m}from"react";import{jsx as h}from"react/jsx-runtime";const g={id:`ldK3jJ`,message:`Failed to submit withdrawal.`},_={id:`kUFhUv`,message:`Withdrawal failed.`},v=l(null);v.displayName=`WithdrawControllerContext`;function y(){let e=u(v);if(!e)throw Error(`useWithdraw / WithdrawControllerProvider must be used inside <KitProvider withdraw={…} />. Mount KitProvider once at the host's app root with a withdraw driver.`);return e}function b(){return y().state}function x(){return y().effectiveState}function S(){return y().actions}function C({children:e}){let t=o(),[n,a]=p(c,s),l=T(n,a,t),u=n.name===`inProgress`?{form:n.ctx.input,submittedAt:n.ctx.submittedAt,...n.ctx.tx?{tx:n.ctx.tx}:{}}:void 0;i(t,u,u?`${u.submittedAt}|${u.tx?.hash??``}`:void 0),E(n,a,t);let d=r(n),m=w(a,l);return h(v,{value:f(()=>({state:n,effectiveState:d,dispatch:a,controller:m,actions:l}),[n,d,m,l]),children:e})}function w(e,t){let n=d(()=>{e({type:`OPEN`})},[e]),r=d(()=>{e({type:`CLOSE`})},[e]);return f(()=>({open:n,close:r,actions:t}),[n,r,t])}function T(n,r,i){let o=m(n);o.current=n;let s=m(i);s.current=i;let c=m(r);c.current=r;let{i18n:l}=e(),u=m(l);u.current=l;let p=a(),h=d(e=>{let n=s.current;c.current({type:`SUBMIT`,input:e});let r=new AbortController,i={sourceAssetSymbol:e.sourceAssetSymbol,sourceChainId:e.sourceChainId,amount:e.amount,receiveTokenSymbol:e.receiveTokenSymbol,receiveChainId:e.receiveChainId,recipientAddress:e.recipientAddress},a={beginProcessing(e){c.current({type:`BEGIN_PROCESSING`,submittedAt:Date.now(),...e?{tx:e}:{}})},setTxHash(e){c.current({type:`SET_TX_HASH`,tx:e,submittedAt:Date.now()})},fail(e){c.current({type:`MARK_FAILED`,...e?{failure:e}:{}})},succeed(){c.current({type:`MARK_SUCCEEDED`})}};n.prepareWithdrawal(i,r.signal).then(i=>{if(r.signal.aborted)return;let o=p.current.onSubmit;if(!o){c.current({type:`SUBMIT_FAILED`,failure:t(Error(`WithdrawDialog onSubmit is missing.`),u.current._(g)),input:e});return}let s=n.getSnapshot().quote,l=s.status===`ready`||s.status===`stale`?s.payload:void 0;try{let n=o({form:e,depositTarget:i.depositTarget,correlation:i.correlation,...l?{quote:l}:{}},a,r.signal);n&&typeof n.catch==`function`&&n.catch(n=>{r.signal.aborted||c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})})}catch(n){if(r.signal.aborted)return;c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})}}).catch(n=>{r.signal.aborted||c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})})},[]),_=d(()=>{c.current({type:`CLOSE`})},[]),v=d(()=>{c.current({type:`RESET`})},[]),y=d(()=>{c.current({type:`CLEAR_NOTICE`})},[]);return f(()=>({submit:h,close:_,reset:v,clearNotice:y}),[h,_,v,y])}function E(t,r,i){let a=m(t);a.current=t;let{i18n:o}=e(),s=m(o);s.current=o,n(i,(e,t)=>{if(a.current.name===`inProgress`){if(e===`succeeded`){r({type:`SETTLEMENT_SUCCEEDED`});return}if(e===`failed`){let e=t.settlement,n=e.status===`ready`||e.status===`stale`?e.payload:null,i=n&&n.kind===`failed`?{reason:s.current._(_),code:n.failureKind}:void 0;r({type:`SETTLEMENT_FAILED`,...i?{failure:i}:{}})}}})}export{C as WithdrawControllerProvider,y as useControllerContext,S as useWithdrawActions,x as useWithdrawEffectiveState,b as useWithdrawState};
1
+ "use client";import{useLingui as e}from"../../../shared/i18n/useLingui.js";import"../../../i18n/index.js";import{toFailure as t}from"../../../shared/orchestrator/toFailure.js";import{useDriverSettlementListener as n}from"../../../shared/orchestrator/useDriverSettlementListener.js";import{useEffectiveState as r}from"../../../shared/orchestrator/useEffectiveState.js";import{useSettlementWatcher as i}from"../../../shared/orchestrator/useSettlementWatcher.js";import"../../../shared/orchestrator/index.js";import{useWithdrawBindingsRef as a}from"../bindings/WithdrawBindings.js";import"../bindings/index.js";import{useWithdrawDriverInstance as o}from"../driver/context.js";import{initialState as s,reducer as c}from"./reducer.js";import{createContext as l,use as u,useCallback as d,useMemo as f,useReducer as p,useRef as m}from"react";import{jsx as h}from"react/jsx-runtime";const g={id:`ldK3jJ`,message:`Failed to submit withdrawal.`},_={id:`kUFhUv`,message:`Withdrawal failed.`},v=l(null);v.displayName=`WithdrawControllerContext`;function y(){let e=u(v);if(!e)throw Error(`useWithdraw / WithdrawControllerProvider must be used inside <KitProvider withdraw={…} />. Mount KitProvider once at the host's app root with a withdraw driver.`);return e}function b(){return u(v)}function x(){return y().state}function S(){return y().effectiveState}function C(){return y().actions}function w({children:e}){let t=o(),[n,a]=p(c,s),l=E(n,a,t),u=n.name===`inProgress`?{form:n.ctx.input,submittedAt:n.ctx.submittedAt,...n.ctx.tx?{tx:n.ctx.tx}:{}}:void 0;i(t,u,u?`${u.submittedAt}|${u.tx?.hash??``}`:void 0),D(n,a,t);let d=r(n),m=T(a,l);return h(v,{value:f(()=>({state:n,effectiveState:d,dispatch:a,controller:m,actions:l}),[n,d,m,l]),children:e})}function T(e,t){let n=d(()=>{e({type:`OPEN`})},[e]),r=d(()=>{e({type:`CLOSE`})},[e]);return f(()=>({open:n,close:r,actions:t}),[n,r,t])}function E(n,r,i){let o=m(n);o.current=n;let s=m(i);s.current=i;let c=m(r);c.current=r;let{i18n:l}=e(),u=m(l);u.current=l;let p=a(),h=d(e=>{let n=s.current;c.current({type:`SUBMIT`,input:e});let r=new AbortController,i={sourceAssetSymbol:e.sourceAssetSymbol,sourceChainId:e.sourceChainId,amount:e.amount,receiveTokenSymbol:e.receiveTokenSymbol,receiveChainId:e.receiveChainId,recipientAddress:e.recipientAddress},a={beginProcessing(e){c.current({type:`BEGIN_PROCESSING`,submittedAt:Date.now(),...e?{tx:e}:{}})},setTxHash(e){c.current({type:`SET_TX_HASH`,tx:e,submittedAt:Date.now()})},fail(e){c.current({type:`MARK_FAILED`,...e?{failure:e}:{}})},succeed(){c.current({type:`MARK_SUCCEEDED`})}};n.prepareWithdrawal(i,r.signal).then(i=>{if(r.signal.aborted)return;let o=p.current.onSubmit;if(!o){c.current({type:`SUBMIT_FAILED`,failure:t(Error(`WithdrawDialog onSubmit is missing.`),u.current._(g)),input:e});return}let s=n.getSnapshot().quote,l=s.status===`ready`||s.status===`stale`?s.payload:void 0;try{let n=o({form:e,depositTarget:i.depositTarget,correlation:i.correlation,...l?{quote:l}:{}},a,r.signal);n&&typeof n.catch==`function`&&n.catch(n=>{r.signal.aborted||c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})})}catch(n){if(r.signal.aborted)return;c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})}}).catch(n=>{r.signal.aborted||c.current({type:`SUBMIT_FAILED`,failure:t(n,u.current._(g)),input:e})})},[]),_=d(()=>{c.current({type:`CLOSE`})},[]),v=d(()=>{c.current({type:`RESET`})},[]),y=d(()=>{c.current({type:`CLEAR_NOTICE`})},[]);return f(()=>({submit:h,close:_,reset:v,clearNotice:y}),[h,_,v,y])}function D(t,r,i){let a=m(t);a.current=t;let{i18n:o}=e(),s=m(o);s.current=o,n(i,(e,t)=>{if(a.current.name===`inProgress`){if(e===`succeeded`){r({type:`SETTLEMENT_SUCCEEDED`});return}if(e===`failed`){let e=t.settlement,n=e.status===`ready`||e.status===`stale`?e.payload:null,i=n&&n.kind===`failed`?{reason:s.current._(_),code:n.failureKind}:void 0;r({type:`SETTLEMENT_FAILED`,...i?{failure:i}:{}})}}})}export{w as WithdrawControllerProvider,y as useControllerContext,b as useOptionalControllerContext,C as useWithdrawActions,S as useWithdrawEffectiveState,x as useWithdrawState};
@@ -1,4 +1,4 @@
1
1
  import { FailureInfo } from "../../../shared/orchestrator/types.js";
2
2
  import { WithdrawActions, WithdrawController, WithdrawEvent, WithdrawState, WithdrawStateName, WithdrawalFormSnapshot } from "./types.js";
3
3
  import { useWithdrawState } from "./controller.js";
4
- import { useWithdraw } from "./useWithdraw.js";
4
+ import { useOptionalWithdraw, useWithdraw } from "./useWithdraw.js";
@@ -19,5 +19,22 @@ import { WithdrawController } from "./types.js";
19
19
  * ```
20
20
  */
21
21
  declare function useWithdraw(): WithdrawController;
22
+ /**
23
+ * Non-throwing variant of {@link useWithdraw} — returns `null` when called outside a
24
+ * `<KitProvider withdraw={…} />`. Lets hosts mount `<StridgeProvider />` conditionally
25
+ * (e.g. only after a wallet is connected) without descendants crashing the moment they render
26
+ * before the provider exists.
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * const withdraw = useOptionalWithdraw();
31
+ * return (
32
+ * <button onClick={() => withdraw?.open()} disabled={!withdraw}>
33
+ * Withdraw
34
+ * </button>
35
+ * );
36
+ * ```
37
+ */
38
+ declare function useOptionalWithdraw(): WithdrawController | null;
22
39
  //#endregion
23
- export { useWithdraw };
40
+ export { useOptionalWithdraw, useWithdraw };
@@ -1 +1 @@
1
- "use client";import{useControllerContext as e}from"./controller.js";function t(){return e().controller}export{t as useWithdraw};
1
+ "use client";import{useControllerContext as e,useOptionalControllerContext as t}from"./controller.js";function n(){return e().controller}function r(){return t()?.controller??null}export{r as useOptionalWithdraw,n as useWithdraw};
package/dist/index.d.ts CHANGED
@@ -21,9 +21,9 @@ import { ChainLogoInput, TokenLogoInput } from "./shared/utils/logos/types.js";
21
21
  import { LogosNamespace, logos } from "./shared/utils/logos/api.js";
22
22
  import { BannerAckBucket, bannerAckStorageKey, bucketFromSettlement, useBannerAck, useBannerAckForSettlement } from "./banners/useBannerAck.js";
23
23
  import { useDepositState } from "./flows/deposit/orchestrator/controller.js";
24
- import { useDeposit } from "./flows/deposit/orchestrator/useDeposit.js";
24
+ import { useDeposit, useOptionalDeposit } from "./flows/deposit/orchestrator/useDeposit.js";
25
25
  import { useWithdrawState } from "./flows/withdraw/orchestrator/controller.js";
26
- import { useWithdraw } from "./flows/withdraw/orchestrator/useWithdraw.js";
26
+ import { useOptionalWithdraw, useWithdraw } from "./flows/withdraw/orchestrator/useWithdraw.js";
27
27
  import { useOptionalStridge, useStridge } from "./stridge/StridgeContext.js";
28
28
  import { StridgeAppearance, StridgeAsset, StridgeDepositDestination, StridgeDepositFlowConfig, StridgeFlowOwner, StridgeProvider, StridgeStorageConfig, StridgeWithdrawFlowConfig } from "./stridge/StridgeProvider.js";
29
- export { type BannerAckBucket, type ChainLogoInput, type ChainLogoMeta, type ChainType, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositController, type DepositMethod, type OpenInput as DepositOpenInput, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, type IntercomMerchantContext, KitPortalScope, KitStorageProvider, type LogosNamespace, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeEnvironment, type StridgeFlowOwner, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type SupportConfig, type SupportOpenContext, type TokenLogoInput, type TxRef, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, isValidAddressForChainType, isValidEvmAddress, isValidTronAddress, logos, resolveStorageAdapter, toChainType, useBannerAck, useBannerAckForSettlement, useDeposit, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalStridge, useStridge, useWithdraw, useWithdrawBindings, useWithdrawSnapshot, useWithdrawState };
29
+ export { type BannerAckBucket, type ChainLogoInput, type ChainLogoMeta, type ChainType, DEFAULT_KIT_STORAGE_NAMESPACE, type DepositActions, type DepositController, type DepositMethod, type OpenInput as DepositOpenInput, type DepositSnapshot, type DepositState, type DepositStateName, type FailureInfo, type IntercomMerchantContext, KitPortalScope, KitStorageProvider, type LogosNamespace, type StridgeAppearance, type StridgeAsset, type StridgeDepositDestination, type StridgeDepositFlowConfig, type StridgeEnvironment, type StridgeFlowOwner, StridgeProvider, type StridgeStorageConfig, type StridgeWithdrawFlowConfig, type SupportConfig, type SupportOpenContext, type TokenLogoInput, type TxRef, type WithdrawActions, type WithdrawBalanceInput, type WithdrawBindings, type WithdrawController, type WithdrawSnapshot, type WithdrawState, type WithdrawStateName, type WithdrawSubmitActions, type WithdrawSubmitCallback, type WithdrawSubmitInput, type WithdrawSuggestedRecipient, type WithdrawalFormSnapshot, bannerAckStorageKey, bucketFromSettlement, createKitStorage, createLocalStorageAdapter, createMemoryStorageAdapter, createSessionStorageAdapter, isValidAddressForChainType, isValidEvmAddress, isValidTronAddress, logos, resolveStorageAdapter, toChainType, useBannerAck, useBannerAckForSettlement, useDeposit, useDepositSnapshot, useDepositState, useKitConfig, useKitStorage, useKitStorageValue, useOptionalDeposit, useOptionalStridge, useOptionalWithdraw, useStridge, useWithdraw, useWithdrawBindings, useWithdrawSnapshot, useWithdrawState };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{isValidAddressForChainType as e,isValidEvmAddress as t,isValidTronAddress as n,toChainType as r}from"./shared/chains/index.js";import{logos as i}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as a,createMemoryStorageAdapter as o,createSessionStorageAdapter as s,resolveStorageAdapter as c}from"./storage/adapters.js";import{createKitStorage as l}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as u,KitStorageProvider as d,useKitStorage as f,useKitStorageValue as p}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as m,bucketFromSettlement as h,useBannerAck as g,useBannerAckForSettlement as _}from"./banners/useBannerAck.js";import"./banners/index.js";import{useDepositSnapshot as v}from"./flows/deposit/driver/context.js";import{useDepositState as y}from"./flows/deposit/orchestrator/controller.js";import{useDeposit as b}from"./flows/deposit/orchestrator/useDeposit.js";import{useWithdrawBindings as x}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{useWithdrawSnapshot as S}from"./flows/withdraw/driver/context.js";import{useWithdrawState as C}from"./flows/withdraw/orchestrator/controller.js";import{useWithdraw as w}from"./flows/withdraw/orchestrator/useWithdraw.js";import"./flows/withdraw/orchestrator/index.js";import{useKitConfig as T}from"./scope/context.js";import{KitPortalScope as E}from"./scope/KitPortalScope.js";import{useOptionalStridge as D,useStridge as O}from"./stridge/StridgeContext.js";import{StridgeProvider as k}from"./stridge/StridgeProvider.js";export{u as DEFAULT_KIT_STORAGE_NAMESPACE,E as KitPortalScope,d as KitStorageProvider,k as StridgeProvider,m as bannerAckStorageKey,h as bucketFromSettlement,l as createKitStorage,a as createLocalStorageAdapter,o as createMemoryStorageAdapter,s as createSessionStorageAdapter,e as isValidAddressForChainType,t as isValidEvmAddress,n as isValidTronAddress,i as logos,c as resolveStorageAdapter,r as toChainType,g as useBannerAck,_ as useBannerAckForSettlement,b as useDeposit,v as useDepositSnapshot,y as useDepositState,T as useKitConfig,f as useKitStorage,p as useKitStorageValue,D as useOptionalStridge,O as useStridge,w as useWithdraw,x as useWithdrawBindings,S as useWithdrawSnapshot,C as useWithdrawState};
1
+ import{isValidAddressForChainType as e,isValidEvmAddress as t,isValidTronAddress as n,toChainType as r}from"./shared/chains/index.js";import{logos as i}from"./shared/utils/logos/api.js";import"./shared/utils/logos/index.js";import{createLocalStorageAdapter as a,createMemoryStorageAdapter as o,createSessionStorageAdapter as s,resolveStorageAdapter as c}from"./storage/adapters.js";import{createKitStorage as l}from"./storage/createKitStorage.js";import{DEFAULT_KIT_STORAGE_NAMESPACE as u,KitStorageProvider as d,useKitStorage as f,useKitStorageValue as p}from"./storage/context.js";import"./storage/index.js";import{bannerAckStorageKey as m,bucketFromSettlement as h,useBannerAck as g,useBannerAckForSettlement as _}from"./banners/useBannerAck.js";import"./banners/index.js";import{useDepositSnapshot as v}from"./flows/deposit/driver/context.js";import{useDepositState as y}from"./flows/deposit/orchestrator/controller.js";import{useDeposit as b,useOptionalDeposit as x}from"./flows/deposit/orchestrator/useDeposit.js";import{useWithdrawBindings as S}from"./flows/withdraw/bindings/WithdrawBindings.js";import"./flows/withdraw/bindings/index.js";import{useWithdrawSnapshot as C}from"./flows/withdraw/driver/context.js";import{useWithdrawState as w}from"./flows/withdraw/orchestrator/controller.js";import{useOptionalWithdraw as T,useWithdraw as E}from"./flows/withdraw/orchestrator/useWithdraw.js";import"./flows/withdraw/orchestrator/index.js";import{useKitConfig as D}from"./scope/context.js";import{KitPortalScope as O}from"./scope/KitPortalScope.js";import{useOptionalStridge as k,useStridge as A}from"./stridge/StridgeContext.js";import{StridgeProvider as j}from"./stridge/StridgeProvider.js";export{u as DEFAULT_KIT_STORAGE_NAMESPACE,O as KitPortalScope,d as KitStorageProvider,j as StridgeProvider,m as bannerAckStorageKey,h as bucketFromSettlement,l as createKitStorage,a as createLocalStorageAdapter,o as createMemoryStorageAdapter,s as createSessionStorageAdapter,e as isValidAddressForChainType,t as isValidEvmAddress,n as isValidTronAddress,i as logos,c as resolveStorageAdapter,r as toChainType,g as useBannerAck,_ as useBannerAckForSettlement,b as useDeposit,v as useDepositSnapshot,y as useDepositState,D as useKitConfig,f as useKitStorage,p as useKitStorageValue,x as useOptionalDeposit,k as useOptionalStridge,T as useOptionalWithdraw,A as useStridge,E as useWithdraw,S as useWithdrawBindings,C as useWithdrawSnapshot,w as useWithdrawState};
package/dist/package.js CHANGED
@@ -1 +1 @@
1
- var e=`0.1.0-alpha.26`;export{e as version};
1
+ var e=`0.1.0-alpha.27`;export{e as version};
@@ -1 +1 @@
1
- "use client";import{useEffect as e,useLayoutEffect as t,useRef as n}from"react";import{jsx as r}from"react/jsx-runtime";import{AnimatePresence as i,motion as a}from"motion/react";const o=[.3,0,.06,1],s={enter:e=>({opacity:0,x:e>=0?16:-16,filter:`blur(6px)`}),center:{opacity:1,x:0,filter:`blur(0px)`,transition:{duration:.22,delay:.12,ease:o}},exit:e=>({opacity:0,x:e>=0?-16:16,filter:`blur(6px)`,transition:{duration:.14,ease:o}})};function c({stateKey:o,children:c}){let l=n([]),u=n(null),d=l.current,f=d[d.length-1],p=0;o!==f&&(p=d.indexOf(o)>=0?-1:1);let m=n(null),h=n(o),g=n(null),_=n(null);return e(()=>{let e=l.current;if(e[e.length-1]===o)return;let t=e.indexOf(o);l.current=t>=0?e.slice(0,t+1):[...e,o]},[o]),t(()=>{let e=u.current;if(!e)return;let t=e.getBoundingClientRect().height;if(h.current===o){m.current=t;return}let n=m.current;if(h.current=o,m.current=t,n===null||n===t||document.visibilityState===`hidden`)return;let r=e.style.transition;e.style.transition=`none`,e.style.height=`${n}px`,e.offsetHeight,e.style.transition=r,_.current!==null&&window.cancelAnimationFrame(_.current),_.current=window.requestAnimationFrame(()=>{_.current=null,u.current&&(u.current.style.height=`${t}px`)}),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{g.current=null;let e=u.current;e&&(e.style.height=``)},320)}),e(()=>{let e=()=>{if(document.visibilityState!==`hidden`)return;_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),g.current!==null&&(window.clearTimeout(g.current),g.current=null);let e=u.current;e&&(e.style.height=``)};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),g.current!==null&&(window.clearTimeout(g.current),g.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)}},[]),r(`div`,{ref:u,style:{position:`relative`,overflow:`hidden`,transition:`height 260ms cubic-bezier(0.3, 0, 0.06, 1)`,flex:`0 1 auto`,minHeight:0,display:`flex`,flexDirection:`column`},children:r(i,{mode:`popLayout`,custom:p,initial:!1,children:r(a.div,{custom:p,variants:s,initial:`enter`,animate:`center`,exit:`exit`,tabIndex:-1,style:{display:`flex`,flexDirection:`column`,flex:`1 1 auto`,minHeight:0,outline:`none`},children:c},o)})})}export{c as StepTransition};
1
+ "use client";import{useEffect as e,useLayoutEffect as t,useRef as n}from"react";import{jsx as r}from"react/jsx-runtime";import{AnimatePresence as i,m as a}from"motion/react";const o=[.3,0,.06,1],s={enter:e=>({opacity:0,x:e>=0?16:-16,filter:`blur(6px)`}),center:{opacity:1,x:0,filter:`blur(0px)`,transition:{duration:.22,delay:.12,ease:o}},exit:e=>({opacity:0,x:e>=0?-16:16,filter:`blur(6px)`,transition:{duration:.14,ease:o}})};function c({stateKey:o,children:c}){let l=n([]),u=n(null),d=l.current,f=d[d.length-1],p=0;o!==f&&(p=d.indexOf(o)>=0?-1:1);let m=n(null),h=n(o),g=n(null),_=n(null);return e(()=>{let e=l.current;if(e[e.length-1]===o)return;let t=e.indexOf(o);l.current=t>=0?e.slice(0,t+1):[...e,o]},[o]),t(()=>{let e=u.current;if(!e)return;let t=e.getBoundingClientRect().height;if(h.current===o){m.current=t;return}let n=m.current;if(h.current=o,m.current=t,n===null||n===t||document.visibilityState===`hidden`)return;let r=e.style.transition;e.style.transition=`none`,e.style.height=`${n}px`,e.offsetHeight,e.style.transition=r,_.current!==null&&window.cancelAnimationFrame(_.current),_.current=window.requestAnimationFrame(()=>{_.current=null,u.current&&(u.current.style.height=`${t}px`)}),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{g.current=null;let e=u.current;e&&(e.style.height=``)},320)}),e(()=>{let e=()=>{if(document.visibilityState!==`hidden`)return;_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),g.current!==null&&(window.clearTimeout(g.current),g.current=null);let e=u.current;e&&(e.style.height=``)};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e),g.current!==null&&(window.clearTimeout(g.current),g.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null)}},[]),r(`div`,{ref:u,style:{position:`relative`,overflow:`hidden`,transition:`height 260ms cubic-bezier(0.3, 0, 0.06, 1)`,flex:`0 1 auto`,minHeight:0,display:`flex`,flexDirection:`column`},children:r(i,{mode:`popLayout`,custom:p,initial:!1,children:r(a.div,{custom:p,variants:s,initial:`enter`,animate:`center`,exit:`exit`,tabIndex:-1,style:{display:`flex`,flexDirection:`column`,flex:`1 1 auto`,minHeight:0,outline:`none`},children:c},o)})})}export{c as StepTransition};
@@ -1 +1 @@
1
- "use client";import{useLingui as e}from"../../../../../i18n/useLingui.js";import"../../../../../../i18n/index.js";import{ArrowRightLeftIcon as t}from"../../../../../icons/ArrowRightLeftIcon.js";import"../../../../../../icons/index.js";import{parseAmountInputValue as n}from"../../../../../ui/AmountInput/utils.js";import{AmountInput as r}from"../../../../../ui/AmountInput/AmountInput.js";import"../../../../../ui/AmountInput/index.js";import{AMOUNT_ENTRY_SLOTS as i}from"../../AmountEntry.slots.js";import{styles as a}from"../../AmountEntry.styles.js";import{useAmountEntryContext as o}from"../../context.js";import{detectAssetDecimals as s,formatAmountForBand as c,formatFiatLine as l,splitSubLine as u}from"./utils.js";import{StaticBand as ee}from"./StaticBand.js";import{ICON_TRANSITION as d,SWAP_TRANSITION as f,SYMBOL_TRANSITION as p,WIDTH_TRANSITION as te}from"./transitions.js";import{SwapBackdrop as m}from"./SwapBackdrop.js";import{useSwapState as h}from"./useSwapState.js";import{useCallback as g,useEffect as _,useId as v,useRef as y,useState as b}from"react";import{jsx as x,jsxs as S}from"react/jsx-runtime";import*as C from"@stylexjs/stylex";import{LayoutGroup as w,motion as T}from"motion/react";function E({currencySymbol:l,subLine:u,subLineAmount:E}={}){let D=o(`AmountEntry.Hero`),O=l??D.currencySymbol??`$`,k=u??D.subLine,A=E??D.subLineAmount,{_:j}=e(),M=typeof D.onAmountChange==`function`,N=v(),P=y(null),F=y(null),[I,re]=b(null);_(()=>{let e=F.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=window.getComputedStyle(e),n=(Number.parseFloat(t.paddingInlineStart)||0)+(Number.parseFloat(t.paddingInlineEnd)||0),r=e.clientWidth-n;re(e=>e===r||r<=0?e:r)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let L=D.format?.maximumFractionDigits??5,R=D.format?.useGrouping!==!1,z=s(A,L),B=g((e,t)=>c(e,t,{locale:D.locale,fiatFormat:D.format,fiatMaxDecimals:L,assetDecimals:z,useGrouping:R}),[D.locale,D.format,L,z,R]),{swapped:V,isAnimating:H,onSwap:U}=h({inputRef:P,onAfterSwap:g(e=>{D.amount!==null&&K(B(D.amount,e))},[D.amount,B])}),W=D.amount===null?``:B(D.amount,V),[G,K]=b(W);_(()=>{document.activeElement!==P.current&&K(W)},[W]);let q=e=>{K(e),D.onAmountChange?.(n(e,D.locale))},J=`${N}-fiat`,Y=`${N}-asset`,X=V?Y:J,Z=V?J:Y,Q=ne({swapped:V,ctx:D,currencySymbol:O,subLineAmount:A}),$=C.props(a.heroBlock),ie=I===null?void 0:{"--stridge-amt-available-width":`${I}px`};return x(w,{id:N,children:S(`div`,{ref:F,"data-stridge-slot":i.hero,className:$.className,style:$.style,children:[S(T.div,{layoutId:X,dir:`ltr`,transition:f,...C.props(a.bigSlot),children:[x(m,{active:H}),M?S(r,{"data-stridge-slot":i.heroBand,value:G,onValueChange:q,locale:D.locale??`en-US`,maxDecimals:V?z:L,useGrouping:R,placeholder:`0`,className:C.props(a.hero).className,style:{...C.props(a.hero).style,...ie},children:[!V&&x(r.Prefix,{...C.props(a.heroCurrency),children:O}),x(r.Field,{"aria-label":V?`Amount in ${D.receiveToken.symbol}`:`Amount in ${O}`,ref:P,autoFocus:!0,...C.props(a.heroAmount)})]}):x(ee,{swapped:V,ctx:D,currencySymbol:O,assetDecimals:z})]},X),k??S(`button`,{type:`button`,dir:`ltr`,"data-stridge-slot":i.heroSwap,"aria-label":j({id:`GwkmPx`,message:`Swap displayed amount`}),"aria-pressed":V,onClick:U,...C.props(a.swapToggle),children:[x(T.span,{"aria-hidden":!0,animate:{scaleY:V?-1:1},transition:d,...C.props(a.swapIcon),children:x(t,{width:`14`,height:`14`})}),S(T.span,{layout:!0,transition:te,...C.props(a.swapTextWrap),children:[S(T.span,{layoutId:Z,transition:f,...C.props(a.swapText),children:[Q.digits,x(m,{active:H})]},Z),Q.symbol&&x(T.span,{initial:{opacity:0},animate:{opacity:1},transition:p,...C.props(a.swapSymbol),children:Q.symbol},`symbol-${Q.symbol}`)]})]})]})})}function ne({swapped:e,ctx:t,currencySymbol:n,subLineAmount:r}){if(e)return{digits:l(t.amount,n,t.locale,t.format),symbol:null};let i=u(r);return{digits:i.digits||`${t.amount??0}`,symbol:i.symbol||` ${t.receiveToken.symbol}`}}export{E as AmountEntryHero};
1
+ "use client";import{useLingui as e}from"../../../../../i18n/useLingui.js";import"../../../../../../i18n/index.js";import{ArrowRightLeftIcon as t}from"../../../../../icons/ArrowRightLeftIcon.js";import"../../../../../../icons/index.js";import{parseAmountInputValue as n}from"../../../../../ui/AmountInput/utils.js";import{AmountInput as r}from"../../../../../ui/AmountInput/AmountInput.js";import"../../../../../ui/AmountInput/index.js";import{AMOUNT_ENTRY_SLOTS as i}from"../../AmountEntry.slots.js";import{styles as a}from"../../AmountEntry.styles.js";import{useAmountEntryContext as o}from"../../context.js";import{detectAssetDecimals as s,formatAmountForBand as c,formatFiatLine as l,splitSubLine as u}from"./utils.js";import{StaticBand as ee}from"./StaticBand.js";import{ICON_TRANSITION as d,SWAP_TRANSITION as f,SYMBOL_TRANSITION as p,WIDTH_TRANSITION as te}from"./transitions.js";import{SwapBackdrop as m}from"./SwapBackdrop.js";import{useSwapState as h}from"./useSwapState.js";import{useCallback as g,useEffect as _,useId as v,useRef as y,useState as b}from"react";import{jsx as x,jsxs as S}from"react/jsx-runtime";import{LayoutGroup as C,m as w}from"motion/react";import*as T from"@stylexjs/stylex";function E({currencySymbol:l,subLine:u,subLineAmount:E}={}){let D=o(`AmountEntry.Hero`),O=l??D.currencySymbol??`$`,k=u??D.subLine,A=E??D.subLineAmount,{_:j}=e(),M=typeof D.onAmountChange==`function`,N=v(),P=y(null),F=y(null),[I,re]=b(null);_(()=>{let e=F.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>{let t=window.getComputedStyle(e),n=(Number.parseFloat(t.paddingInlineStart)||0)+(Number.parseFloat(t.paddingInlineEnd)||0),r=e.clientWidth-n;re(e=>e===r||r<=0?e:r)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let L=D.format?.maximumFractionDigits??5,R=D.format?.useGrouping!==!1,z=s(A,L),B=g((e,t)=>c(e,t,{locale:D.locale,fiatFormat:D.format,fiatMaxDecimals:L,assetDecimals:z,useGrouping:R}),[D.locale,D.format,L,z,R]),{swapped:V,isAnimating:H,onSwap:U}=h({inputRef:P,onAfterSwap:g(e=>{D.amount!==null&&K(B(D.amount,e))},[D.amount,B])}),W=D.amount===null?``:B(D.amount,V),[G,K]=b(W);_(()=>{document.activeElement!==P.current&&K(W)},[W]);let q=e=>{K(e),D.onAmountChange?.(n(e,D.locale))},J=`${N}-fiat`,Y=`${N}-asset`,X=V?Y:J,Z=V?J:Y,Q=ne({swapped:V,ctx:D,currencySymbol:O,subLineAmount:A}),$=T.props(a.heroBlock),ie=I===null?void 0:{"--stridge-amt-available-width":`${I}px`};return x(C,{id:N,children:S(`div`,{ref:F,"data-stridge-slot":i.hero,className:$.className,style:$.style,children:[S(w.div,{layoutId:X,dir:`ltr`,transition:f,...T.props(a.bigSlot),children:[x(m,{active:H}),M?S(r,{"data-stridge-slot":i.heroBand,value:G,onValueChange:q,locale:D.locale??`en-US`,maxDecimals:V?z:L,useGrouping:R,placeholder:`0`,className:T.props(a.hero).className,style:{...T.props(a.hero).style,...ie},children:[!V&&x(r.Prefix,{...T.props(a.heroCurrency),children:O}),x(r.Field,{"aria-label":V?`Amount in ${D.receiveToken.symbol}`:`Amount in ${O}`,ref:P,autoFocus:!0,...T.props(a.heroAmount)})]}):x(ee,{swapped:V,ctx:D,currencySymbol:O,assetDecimals:z})]},X),k??S(`button`,{type:`button`,dir:`ltr`,"data-stridge-slot":i.heroSwap,"aria-label":j({id:`GwkmPx`,message:`Swap displayed amount`}),"aria-pressed":V,onClick:U,...T.props(a.swapToggle),children:[x(w.span,{"aria-hidden":!0,animate:{scaleY:V?-1:1},transition:d,...T.props(a.swapIcon),children:x(t,{width:`14`,height:`14`})}),S(w.span,{layout:!0,transition:te,...T.props(a.swapTextWrap),children:[S(w.span,{layoutId:Z,transition:f,...T.props(a.swapText),children:[Q.digits,x(m,{active:H})]},Z),Q.symbol&&x(w.span,{initial:{opacity:0},animate:{opacity:1},transition:p,...T.props(a.swapSymbol),children:Q.symbol},`symbol-${Q.symbol}`)]})]})]})})}function ne({swapped:e,ctx:t,currencySymbol:n,subLineAmount:r}){if(e)return{digits:l(t.amount,n,t.locale,t.format),symbol:null};let i=u(r);return{digits:i.digits||`${t.amount??0}`,symbol:i.symbol||` ${t.receiveToken.symbol}`}}export{E as AmountEntryHero};
@@ -1 +1 @@
1
- "use client";import{styles as e}from"../../AmountEntry.styles.js";import{SWAP_TRANSITION as t}from"./transitions.js";import{jsx as n}from"react/jsx-runtime";import*as r from"@stylexjs/stylex";import{motion as i}from"motion/react";function a({active:a}){return n(i.span,{"aria-hidden":!0,initial:{opacity:0},animate:{opacity:+!!a},transition:t,...r.props(e.swapBackdrop)})}export{a as SwapBackdrop};
1
+ "use client";import{styles as e}from"../../AmountEntry.styles.js";import{SWAP_TRANSITION as t}from"./transitions.js";import{jsx as n}from"react/jsx-runtime";import{m as r}from"motion/react";import*as i from"@stylexjs/stylex";function a({active:a}){return n(r.span,{"aria-hidden":!0,initial:{opacity:0},animate:{opacity:+!!a},transition:t,...i.props(e.swapBackdrop)})}export{a as SwapBackdrop};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stridge/kit",
3
- "version": "0.1.0-alpha.26",
3
+ "version": "0.1.0-alpha.27",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "files": [