@stridge/kit 0.1.0-alpha.55 → 0.1.0-alpha.56
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/dist/KitProvider.js +1 -1
- package/dist/_internal/deposit/driver/index.d.ts +2 -2
- package/dist/deposit/compound/index.d.ts +11 -5
- package/dist/deposit/compound/index.js +1 -1
- package/dist/deposit/widgets/index.d.ts +3 -1
- package/dist/deposit/widgets/index.js +1 -1
- package/dist/drivers/stridge/createStridgeDepositDriver.js +1 -1
- package/dist/drivers/stridge-mock/createStridgeMockDriver.js +1 -1
- package/dist/drivers/stridge-mock/fixtures.js +1 -1
- package/dist/events/emit/useDepositEmissions.js +1 -1
- package/dist/flows/deposit/bindings/DepositBindings.d.ts +87 -0
- package/dist/flows/deposit/bindings/DepositBindings.js +1 -0
- package/dist/flows/deposit/bindings/index.d.ts +1 -0
- package/dist/flows/deposit/bindings/index.js +1 -0
- package/dist/flows/deposit/dialog/DepositDialog.js +1 -1
- package/dist/flows/deposit/driver/payloads.d.ts +35 -1
- package/dist/flows/deposit/driver/types.d.ts +10 -1
- package/dist/flows/deposit/orchestrator/controller.js +1 -1
- package/dist/flows/deposit/orchestrator/index.d.ts +5 -0
- package/dist/flows/deposit/orchestrator/reducer.d.ts +1 -0
- package/dist/flows/deposit/orchestrator/reducer.js +1 -1
- package/dist/flows/deposit/orchestrator/types.d.ts +107 -2
- package/dist/flows/deposit/orchestrator/useDeposit.js +1 -1
- package/dist/flows/deposit/shared/cash.d.ts +20 -0
- package/dist/flows/deposit/shared/cash.js +1 -0
- package/dist/flows/deposit/widgets/amount-entry/AmountEntry.d.ts +1 -1
- package/dist/flows/deposit/widgets/amount-entry/AmountEntry.js +1 -1
- package/dist/flows/deposit/widgets/cash-amount-entry/CashAmountEntry.d.ts +71 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/CashAmountEntry.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.d.ts +69 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.slots.d.ts +16 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.slots.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/HeroLabel.d.ts +13 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/HeroLabel.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/MethodChip.d.ts +18 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/MethodChip.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/ReceiveChip.d.ts +14 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/components/ReceiveChip.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/context.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/index.d.ts +3 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/index.js +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/compound/types.d.ts +42 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/index.d.ts +1 -0
- package/dist/flows/deposit/widgets/cash-amount-entry/index.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/CashConfirm.d.ts +63 -0
- package/dist/flows/deposit/widgets/cash-confirm/CashConfirm.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.d.ts +54 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.slots.d.ts +33 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.slots.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/CashConfirm.styles.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/cashConfirmDimensions.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/ApplePayBody.d.ts +15 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/ApplePayBody.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/Body.d.ts +22 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/Body.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/BodyLabel.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardBody.d.ts +16 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardBody.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.icons.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.keys.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.state.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/CardInputRow.styles.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/GooglePayBody.d.ts +16 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/GooglePayBody.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/Header.d.ts +21 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/Header.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/Summary.d.ts +17 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/Summary.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/components/cardFormat.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/context.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/index.d.ts +3 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/index.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/compound/types.d.ts +66 -0
- package/dist/flows/deposit/widgets/cash-confirm/index.d.ts +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/index.js +1 -0
- package/dist/flows/deposit/widgets/cash-confirm/mocks.js +1 -0
- package/dist/flows/deposit/widgets/deposit/Deposit.d.ts +6 -0
- package/dist/flows/deposit/widgets/deposit/Deposit.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/Deposit.d.ts +26 -1
- package/dist/flows/deposit/widgets/deposit/compound/Deposit.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/Deposit.slots.d.ts +6 -0
- package/dist/flows/deposit/widgets/deposit/compound/Deposit.slots.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/Deposit.styles.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/components/Guards.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/components/Method.d.ts +1 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/Method.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/components/MethodSection.d.ts +40 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/MethodSection.js +1 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/Methods.d.ts +16 -9
- package/dist/flows/deposit/widgets/deposit/compound/components/Methods.js +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/components/Rail.d.ts +18 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/Rail.js +1 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/RailPicker.d.ts +43 -0
- package/dist/flows/deposit/widgets/deposit/compound/components/RailPicker.js +1 -0
- package/dist/flows/deposit/widgets/deposit/compound/index.d.ts +1 -1
- package/dist/flows/deposit/widgets/deposit/compound/types.d.ts +100 -1
- package/dist/flows/deposit/widgets/transfer-crypto/compound/components/QrCode.js +1 -1
- package/dist/flows/withdraw/orchestrator/reducer.js +1 -1
- package/dist/i18n/locales/ar.js +1 -1
- package/dist/i18n/locales/es.js +1 -1
- package/dist/i18n/locales/source-keys.d.ts +1 -1
- package/dist/icons/index.d.ts +10 -1
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -1
- package/dist/package.js +1 -1
- package/dist/shared/icons/AmexIcon.d.ts +14 -0
- package/dist/shared/icons/AmexIcon.js +1 -0
- package/dist/shared/icons/ApplePayIcon.d.ts +15 -0
- package/dist/shared/icons/ApplePayIcon.js +1 -0
- package/dist/shared/icons/BitcoinIcon.d.ts +17 -0
- package/dist/shared/icons/BitcoinIcon.js +1 -0
- package/dist/shared/icons/CardIcon.d.ts +16 -0
- package/dist/shared/icons/CardIcon.js +1 -0
- package/dist/shared/icons/CashIcon.d.ts +16 -0
- package/dist/shared/icons/CashIcon.js +1 -0
- package/dist/shared/icons/DiscoverIcon.d.ts +14 -0
- package/dist/shared/icons/DiscoverIcon.js +1 -0
- package/dist/shared/icons/GooglePayIcon.d.ts +15 -0
- package/dist/shared/icons/GooglePayIcon.js +1 -0
- package/dist/shared/icons/MastercardIcon.d.ts +16 -0
- package/dist/shared/icons/MastercardIcon.js +1 -0
- package/dist/shared/icons/VisaIcon.d.ts +15 -0
- package/dist/shared/icons/VisaIcon.js +1 -0
- package/dist/shared/ui/Tabs/Tabs.d.ts +79 -0
- package/dist/shared/ui/Tabs/Tabs.js +1 -0
- package/dist/shared/ui/Tabs/Tabs.slots.d.ts +11 -0
- package/dist/shared/ui/Tabs/Tabs.slots.js +1 -0
- package/dist/shared/ui/Tabs/Tabs.styles.js +1 -0
- package/dist/shared/ui/Tabs/index.d.ts +2 -0
- package/dist/shared/ui/Tabs/index.js +1 -0
- package/dist/shared/utils/assertNever.js +1 -0
- package/dist/shared/widgets/amount-entry/compound/AmountEntry.d.ts +7 -2
- package/dist/shared/widgets/amount-entry/compound/AmountEntry.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/AmountEntry.slots.d.ts +5 -0
- package/dist/shared/widgets/amount-entry/compound/AmountEntry.slots.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/AmountEntry.styles.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/components/Details.d.ts +34 -0
- package/dist/shared/widgets/amount-entry/compound/components/Details.js +1 -0
- package/dist/shared/widgets/amount-entry/compound/components/Footer.d.ts +2 -1
- package/dist/shared/widgets/amount-entry/compound/components/Footer.js +1 -1
- package/dist/shared/widgets/amount-entry/compound/index.d.ts +1 -1
- package/dist/shared/widgets/amount-entry/compound/types.d.ts +37 -1
- package/dist/shared/widgets/confirm-transfer/compound/components/Breakdown.js +1 -1
- package/dist/storage/context.d.ts +9 -1
- package/dist/storage/context.js +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/stridge/stubs.js +1 -1
- package/dist/styles/index.css +275 -2
- package/dist/types.d.ts +3 -3
- package/dist/ui/index.d.ts +3 -1
- package/dist/ui/index.js +1 -1
- package/dist/withdraw/compound/index.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useOptionalActivityDriverInstance as e}from"../../activity/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{useDepositDriverInstance as s}from"../driver/context.js";import{initialState as c,reducer as l}from"./reducer.js";import{resolveAssetById as u}from"./resolveAssetById.js";import{createContext as d,use as f,useCallback as p,useEffect as m,useMemo as h,useReducer as g,useRef as _}from"react";import{jsx as v}from"react/jsx-runtime";const y={id:`ELhVSL`,message:`Failed to submit deposit.`},b={id:`Ej5HL9`,message:`Signature declined. Please try again.`},x=d(null);x.displayName=`
|
|
1
|
+
"use client";import{useOptionalActivityDriverInstance as e}from"../../activity/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{useDepositDriverInstance as s}from"../driver/context.js";import{initialState as c,reducer as l}from"./reducer.js";import{resolveAssetById as u}from"./resolveAssetById.js";import{createContext as d,use as f,useCallback as p,useEffect as m,useMemo as h,useReducer as g,useRef as _}from"react";import{jsx as v}from"react/jsx-runtime";const y={id:`ELhVSL`,message:`Failed to submit deposit.`},b={id:`Ej5HL9`,message:`Signature declined. Please try again.`},x=d(null);x.displayName=`GatewayControllerStateContext`;const S=d(null);S.displayName=`GatewayControllerStableContext`;function C(){let e=f(x),t=f(S);if(!e||!t)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return{...e,...t}}function w(){let e=f(S);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e}function T(){return f(S)}const E=d(void 0);E.displayName=`DepositMethodsConfigContext`;function D(){return f(E)}function O(e){let t=D();return h(()=>t?e.filter(e=>e.value===`cash`?t.cashRail?.disabled!==!0:!0):e,[e,t])}function k(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.state}function A(){let e=f(x);if(!e)throw Error(`useDeposit / GatewayController must be used inside <KitProvider deposit={…} />. Mount KitProvider once at the host's app root.`);return e.effectiveState}function j(){return w().actions}function M({methodsConfig:t,children:n}){let r=s(),a=e(),[o,u]=g(l,c),d=P(o,u,r,a);F(o,u,r),I(o,u,r,a);let f=i(o),p=N(o,u,r,d,t);return v(E,{value:t,children:v(S,{value:h(()=>({dispatch:u,controller:p,actions:d}),[u,p,d]),children:v(x,{value:h(()=>({state:o,effectiveState:f}),[o,f]),children:n})})})}function N(e,t,n,r,i){let a=_(n);a.current=n;let o=_(i);o.current=i;let s=p(e=>{if(!e)return a.current.arm(),t({type:`OPEN`,input:void 0}),!0;if(o.current?.[e.method]?.disabled)return!1;if(e.method===`transfer`)return a.current.arm(),t({type:`OPEN`,input:{method:`transfer`}}),!0;if(e.method===`wallet`&&e.assetId!==void 0){let n=u(a.current.getSnapshot(),e.assetId);return a.current.arm(),n?(t({type:`OPEN`,input:{method:`wallet`,asset:n}}),!0):(t({type:`OPEN`,input:{method:`wallet`}}),!0)}return a.current.arm(),t({type:`OPEN`,input:{method:`wallet`}}),!0},[t]),c=p(()=>{t({type:`CLOSE`})},[t]);return h(()=>({open:s,close:c,actions:r}),[s,c,r])}function P(e,r,i,o){let s=_(e);s.current=e;let c=_(i);c.current=i;let l=_(o);l.current=o;let u=_(r);u.current=r;let{i18n:d}=t(),f=_(d);f.current=d;let m=p((e,t)=>{let r=c.current,i=new AbortController,o=R(e,t);r.submitDeposit(o,i.signal).then(e=>{if(!i.signal.aborted){try{r.invalidateBalances?.()}catch{}try{l.current?.invalidateActivity?.()}catch{}u.current({type:`DEPOSIT_SUBMITTED`,tx:e})}}).catch(e=>{if(i.signal.aborted)return;let t=n(e,f.current._(y));if(a(t)){u.current({type:`DEPOSIT_SIGNATURE_DECLINED`,notice:f.current._(b)});return}u.current({type:`DEPOSIT_SUBMISSION_FAILED`,failure:t})})},[]),g=p(e=>{u.current({type:`DEPOSIT_METHOD_SELECTED`,method:e})},[]),v=p(e=>{u.current({type:`CASH_METHOD_SELECTED`,cashMethod:e})},[]),x=p(e=>{u.current({type:`CASH_AMOUNT_CONFIRMED`,amount:e})},[]),S=p(()=>{u.current({type:`CASH_METHOD_READY`})},[]),C=p(e=>{u.current({type:`ASSET_CONFIRMED`,asset:e})},[]),w=p(e=>{s.current.name===`amountEntry`&&u.current({type:`AMOUNT_CONFIRMED`,amount:e})},[]),T=p(()=>{let e=s.current;if(e.name!==`confirmDeposit`)return;let t=e.ctx.phase;if(t.kind===`failed`){u.current({type:`QUOTE_RETRY`});return}if(t.kind!==`ready`)return;let{asset:n,amount:r}=e.ctx;u.current({type:`DEPOSIT_CONFIRMED`}),m(n,r)},[m]),E=p(()=>{u.current({type:`BACK`})},[]),D=p(()=>{u.current({type:`CLOSE`})},[]),O=p(()=>{u.current({type:`SUCCESS_DONE`})},[]),k=p(()=>{u.current({type:`ERROR_TRY_AGAIN`})},[]),A=p((e,t)=>{u.current({type:`RESUME_TO_PROCESSING`,method:e,tx:t})},[]),j=p((e,t)=>{u.current({type:`RESUME_TO_SUCCESS`,method:e,tx:t})},[]),M=p(e=>{u.current({type:`RESUME_TO_ERROR`,...e?{tx:e}:{}})},[]),N=p(()=>{if(l.current==null){process.env.NODE_ENV!==`production`&&console.warn("[@stridge/kit] useDepositActions().openActivity() was called but no activity driver is mounted. Wrap the host with `<KitProvider activity={…}>` (or `<StridgeProvider>` with any flow enabled) to enable the activity surface.");return}let e=s.current;e.name!==`deposit`&&e.name!==`assetPicker`&&e.name!==`amountEntry`&&e.name!==`transferCrypto`||u.current({type:`OPEN_ACTIVITY`})},[]),P=p(e=>{u.current({type:`SELECT_SETTLEMENT`,settlementId:e})},[]);return h(()=>({selectMethod:g,selectCashMethod:v,confirmCashAmount:x,cashMethodReady:S,confirmAsset:C,confirmAmount:w,confirmDeposit:T,back:E,close:D,successDone:O,tryAgain:k,resumeToProcessing:A,resumeToSuccess:j,resumeToError:M,openActivity:N,selectSettlement:P}),[g,v,x,S,C,w,T,E,D,O,k,A,j,M,N,P])}function F(e,t,r){m(()=>{if(e.name!==`confirmDeposit`||e.ctx.phase.kind!==`loading`&&e.ctx.phase.kind!==`regenerating`)return;let i=new AbortController,a=L(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]),m(()=>{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 I(e,t,n,i){let a=_(i);a.current=i;let s=e.name===`processing`?e.ctx.tx:void 0;o(n,s?{tx:s}:void 0,s?.hash),m(()=>{if(e.name!==`transferCrypto`||!n.watchSourceTx)return;let t=new AbortController,r;return n.watchSourceTx({},e=>{if(!t.signal.aborted&&!r){r=new AbortController,n.watchSettlement({tx:e},()=>{},r.signal);try{a.current?.invalidateActivity?.()}catch{}}},t.signal),()=>{t.abort(),r?.abort()}},[e.name,n]);let c=e.name===`activityList`||e.name===`activityDetail`;m(()=>{if(!c||!i)return;let e=new AbortController;return i.watchActivity(e.signal),()=>e.abort()},[c,i]),m(()=>{if(e.name===`closed`||e.name===`transferCrypto`||e.name===`processing`||c||!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,c,n]);let l=_(e);l.current=e,r(n,e=>{if(e===`pending`||e===`succeeded`||e===`failed`)try{n.invalidateBalances?.()}catch{}l.current.name===`processing`&&(e===`succeeded`?t({type:`PROCESSING_SUCCEEDED`}):e===`failed`&&t({type:`PROCESSING_FAILED`}))});let u=_(null);m(()=>{let e=()=>{let e=n.getSnapshot(),r=l.current,i=e.quote;i.status!==u.current&&(u.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 L(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 R(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{M as GatewayController,C as useControllerContext,j as useDepositActions,A as useDepositEffectiveState,D as useDepositMethodsConfig,k as useDepositState,O as useEnabledRails,T as useOptionalStableControllerContext,w as useStableControllerContext};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FailureInfo } from "../../../shared/orchestrator/types.js";
|
|
2
|
+
import { CashConfirmPhase, CashMethodId, ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositMethodConfig, DepositMethodsConfig, DepositRailConfig, DepositState, DepositStateName, GatewayEvent, OpenInput, ResolvedOpenInput, RetryTargetSpec } from "./types.js";
|
|
3
|
+
import { useDepositState } from "./controller.js";
|
|
4
|
+
import { STEPS_WITH_OWN_SETTLEMENT_VIEW, stepRendersSettlement } from "./steps.js";
|
|
5
|
+
import { useDeposit } from "./useDeposit.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createActivityReducers as e}from"../../../shared/orchestrator/createActivityReducers.js";import"../../../shared/orchestrator/index.js";const
|
|
1
|
+
import{createActivityReducers as e}from"../../../shared/orchestrator/createActivityReducers.js";import"../../../shared/orchestrator/index.js";import{assertNever as t}from"../../../shared/utils/assertNever.js";const n={name:`closed`},{reduceFromActivityList:r,reduceFromActivityDetail:i}=e({activityList:e=>({name:`activityList`,ctx:{backTarget:e}}),activityDetail:(e,t,n)=>({name:`activityDetail`,ctx:{settlementId:e,backTarget:t,viaList:n}}),closed:()=>({name:`closed`}),restoreFromBackTarget:e=>_(e)});function a(e,n){if(n.type===`RESUME_TO_PROCESSING`)return e.name===`closed`?e:{name:`processing`,ctx:{method:n.method,tx:n.tx,retryTargetForFailure:{kind:`fresh`}}};if(n.type===`RESUME_TO_SUCCESS`)return e.name===`closed`?e:{name:`success`,ctx:{method:n.method,tx:n.tx}};if(n.type===`RESUME_TO_ERROR`)return e.name===`closed`?e:{name:`error`,ctx:{retryTarget:{kind:`fresh`},...n.tx?{tx:n.tx}:{}}};switch(e.name){case`closed`:return o(n);case`deposit`:return s(e,n);case`assetPicker`:return c(e,n);case`amountEntry`:return l(e,n);case`cashAmountEntry`:return u(e,n);case`cashConfirm`:return d(e,n);case`confirmDeposit`:return f(e,n);case`transferCrypto`:return p(e,n);case`processing`:return m(e,n);case`success`:return h(e,n);case`error`:return g(e,n);case`activityList`:return r(e,n);case`activityDetail`:return i(e,n);default:return t(e)}}function o(e){if(e.type!==`OPEN`)return{name:`closed`};let t=e.input;return t?t.method===`transfer`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`closed`}}:t.asset?{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`closed`}}:{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`closed`}}:{name:`deposit`,ctx:{backTarget:`closed`}}}function s(e,t){switch(t.type){case`DEPOSIT_METHOD_SELECTED`:return t.method===`wallet`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:`deposit`}};case`CASH_METHOD_SELECTED`:return{name:`cashAmountEntry`,ctx:{method:`cash`,cashMethod:t.cashMethod,backTarget:`deposit`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`deposit`,backTarget:`closed`}}};case`BACK`:case`CLOSE`:return{name:`closed`};default:return e}}function c(e,t){switch(t.type){case`ASSET_CONFIRMED`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:t.asset,backTarget:`assetPicker`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`assetPicker`,method:`wallet`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function l(e,t){switch(t.type){case`AMOUNT_CONFIRMED`:return{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.ctx.asset,amount:t.amount,phase:{kind:`loading`},backTarget:`amountEntry`}};case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`amountEntry`,method:`wallet`,asset:e.ctx.asset,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:`deposit`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function u(e,t){switch(t.type){case`CASH_AMOUNT_CONFIRMED`:return{name:`cashConfirm`,ctx:{method:`cash`,cashMethod:e.ctx.cashMethod,amount:t.amount,phase:{kind:`loading`},backTarget:`cashAmountEntry`}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function d(e,t){let n=e.ctx.phase;switch(t.type){case`CASH_METHOD_READY`:return n.kind===`loading`?{...e,ctx:{...e.ctx,phase:{kind:`ready`}}}:e;case`BACK`:return{name:`cashAmountEntry`,ctx:{method:`cash`,cashMethod:e.ctx.cashMethod,backTarget:`deposit`,amount:e.ctx.amount}};case`CLOSE`:return{name:`closed`};default:return e}}function f(e,t){let n=e.ctx.phase;switch(t.type){case`QUOTE_RESOLVED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`ready`,quoteExpiresAt:t.expiresAt}}}:e;case`QUOTE_FAILED`:return n.kind===`loading`||n.kind===`regenerating`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`quote`}}}:e;case`QUOTE_RETRY`:return n.kind===`failed`?{...e,ctx:{...e.ctx,phase:{kind:`loading`}}}:e;case`QUOTE_EXPIRED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`}}}:e;case`DEPOSIT_CONFIRMED`:return n.kind===`ready`?{...e,ctx:{...e.ctx,phase:{kind:`submitting`}}}:e;case`DEPOSIT_SUBMITTED`:if(n.kind===`submitting`){let n={kind:`confirmDepositReady`,method:`wallet`,asset:e.ctx.asset,amount:e.ctx.amount};return{name:`processing`,ctx:{method:`wallet`,tx:t.tx,retryTargetForFailure:n}}}return e;case`DEPOSIT_SUBMISSION_FAILED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`failed`,failure:t.failure,recoverFrom:`submission`}}}:e;case`DEPOSIT_SIGNATURE_DECLINED`:return n.kind===`submitting`?{...e,ctx:{...e.ctx,phase:{kind:`regenerating`,...t.notice?{notice:t.notice}:{}}}}:e;case`BACK`:return{name:`amountEntry`,ctx:{method:`wallet`,asset:e.ctx.asset,backTarget:`assetPicker`}};case`CLOSE`:return{name:`closed`};default:return e}}function p(e,t){switch(t.type){case`OPEN_ACTIVITY`:return{name:`activityList`,ctx:{backTarget:{kind:`transferCrypto`,method:`transfer`,backTarget:e.ctx.backTarget}}};case`BACK`:return e.ctx.backTarget===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:{name:`closed`};case`CLOSE`:return{name:`closed`};default:return e}}function m(e,t){switch(t.type){case`PROCESSING_SUCCEEDED`:return{name:`success`,ctx:{method:e.ctx.method,tx:e.ctx.tx}};case`PROCESSING_FAILED`:return{name:`error`,ctx:{retryTarget:e.ctx.retryTargetForFailure,tx:e.ctx.tx}};case`CLOSE`:return{name:`closed`};default:return e}}function h(e,t){return t.type===`SUCCESS_DONE`||t.type===`CLOSE`?{name:`closed`}:e}function g(e,t){return t.type===`ERROR_TRY_AGAIN`?v(e.ctx.retryTarget):t.type===`CLOSE`?{name:`closed`}:e}function _(e){return e.kind===`deposit`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`assetPicker`?{name:`assetPicker`,ctx:{method:`wallet`,backTarget:e.backTarget}}:e.kind===`amountEntry`?{name:`amountEntry`,ctx:{method:`wallet`,asset:e.asset,backTarget:e.backTarget}}:{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}}function v(e){return e.kind===`fresh`?{name:`deposit`,ctx:{backTarget:`closed`}}:e.kind===`transferCrypto`?{name:`transferCrypto`,ctx:{method:`transfer`,backTarget:e.backTarget}}:{name:`confirmDeposit`,ctx:{method:`wallet`,asset:e.asset,amount:e.amount,phase:{kind:`loading`},backTarget:`amountEntry`}}}export{n as initialState,a as reducer};
|
|
@@ -8,6 +8,14 @@ import { FailureInfo } from "../../../shared/orchestrator/types.js";
|
|
|
8
8
|
* (transfer-crypto → process).
|
|
9
9
|
*/
|
|
10
10
|
type DepositMethod = "wallet" | "transfer";
|
|
11
|
+
/**
|
|
12
|
+
* Cash-rail method id. Mirrors the keys on `CashMethodsPayload` (`card` / `applePay` / `googlePay`)
|
|
13
|
+
* so the picker tile, the chosen-method chip, and the FSM ctx all share one vocabulary. Routed
|
|
14
|
+
* through its own `CASH_METHOD_SELECTED` reducer event (separate from `DEPOSIT_METHOD_SELECTED`)
|
|
15
|
+
* because the cash rail lands in a method-specific amount-entry surface today and per-method
|
|
16
|
+
* confirm forms tomorrow.
|
|
17
|
+
*/
|
|
18
|
+
type CashMethodId = "card" | "applePay" | "googlePay";
|
|
11
19
|
/**
|
|
12
20
|
* Host-supplied disable lever for a single payment method on the deposit-method picker. The host
|
|
13
21
|
* decides eligibility — the kit ships no per-host inference (embedded vs. external wallet,
|
|
@@ -28,14 +36,51 @@ interface DepositMethodConfig {
|
|
|
28
36
|
*/
|
|
29
37
|
disabledHint?: string;
|
|
30
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Per-rail host configuration for the deposit picker. Distinct from
|
|
41
|
+
* {@link DepositMethodConfig} — a rail toggle removes the rail tab entirely
|
|
42
|
+
* from the `RailPicker` rather than disabling a single tile, so there is no
|
|
43
|
+
* `disabledHint` slot (there is no tile to surface the hint on). When only
|
|
44
|
+
* one rail remains after filtering, the orchestrated widget's default
|
|
45
|
+
* composition collapses the `RailPicker` chrome and renders the surviving
|
|
46
|
+
* rail's content directly at the body root.
|
|
47
|
+
*/
|
|
48
|
+
interface DepositRailConfig {
|
|
49
|
+
/**
|
|
50
|
+
* Opt-IN gate for the rail. The cash rail is hidden by default — hosts that want
|
|
51
|
+
* the `Use Cash` tab in their picker must set `enabled: true` and have a driver that
|
|
52
|
+
* surfaces the matching entity (e.g. `cashMethods`). Crypto-only integrators upgrade
|
|
53
|
+
* transparently because the default is `enabled !== true`. Set explicitly to `false`
|
|
54
|
+
* is equivalent to leaving it unset.
|
|
55
|
+
*/
|
|
56
|
+
enabled?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Legacy opt-OUT toggle. Kept for back-compatibility with the brief window where the
|
|
59
|
+
* rail shipped on by default and integrators had to set this to hide it. New code
|
|
60
|
+
* should prefer {@link DepositRailConfig.enabled}; setting `disabled: true` continues
|
|
61
|
+
* to hide the rail regardless of `enabled`.
|
|
62
|
+
*/
|
|
63
|
+
disabled?: boolean;
|
|
64
|
+
}
|
|
31
65
|
/**
|
|
32
66
|
* Per-method host configuration for the deposit picker. Omitting a method (or the whole object)
|
|
33
67
|
* keeps default behavior; supply `{ disabled: true, disabledHint: "…" }` to mark an option as
|
|
34
|
-
* unavailable for the current user.
|
|
68
|
+
* unavailable for the current user. `cashRail` is a rail-level toggle — see
|
|
69
|
+
* {@link DepositRailConfig}.
|
|
70
|
+
*
|
|
71
|
+
* Cash-method keys (`card`, `applePay`, `googlePay`) are additive flat keys that mirror the
|
|
72
|
+
* crypto methods' shape so existing integrators upgrade without touching their config. A future
|
|
73
|
+
* version may restructure to nested-by-rail (`{ crypto: { wallet, transfer }, cash: { … } }`);
|
|
74
|
+
* that restructure is a breaking-change PR and is intentionally deferred until cash methods
|
|
75
|
+
* stabilize.
|
|
35
76
|
*/
|
|
36
77
|
interface DepositMethodsConfig {
|
|
37
78
|
wallet?: DepositMethodConfig;
|
|
38
79
|
transfer?: DepositMethodConfig;
|
|
80
|
+
card?: DepositMethodConfig;
|
|
81
|
+
applePay?: DepositMethodConfig;
|
|
82
|
+
googlePay?: DepositMethodConfig;
|
|
83
|
+
cashRail?: DepositRailConfig;
|
|
39
84
|
}
|
|
40
85
|
/**
|
|
41
86
|
* Confirm-deposit phase sub-union. Drives the confirm-deposit widget's hero / footer chrome.
|
|
@@ -56,6 +101,17 @@ type ConfirmDepositPhase = {
|
|
|
56
101
|
failure: FailureInfo;
|
|
57
102
|
recoverFrom: "quote" | "submission";
|
|
58
103
|
};
|
|
104
|
+
/**
|
|
105
|
+
* Cash-confirm phase sub-union. Drives the per-method cash confirm widget's body slot — `loading`
|
|
106
|
+
* paints the skeleton placeholder, `ready` renders the filled card form / QR / pay button. Phase
|
|
107
|
+
* is pure navigation; the actual card data / QR payload / pay button content lives in the widget's
|
|
108
|
+
* mocks today and will surface through a future `cashConfirm` driver entity.
|
|
109
|
+
*/
|
|
110
|
+
type CashConfirmPhase = {
|
|
111
|
+
kind: "loading";
|
|
112
|
+
} | {
|
|
113
|
+
kind: "ready";
|
|
114
|
+
};
|
|
59
115
|
/**
|
|
60
116
|
* Where `ERROR_TRY_AGAIN` lands. Encoded once at error-entry time so retry is deterministic.
|
|
61
117
|
*/
|
|
@@ -130,6 +186,28 @@ type DepositState = {
|
|
|
130
186
|
asset: BalanceItemPayload;
|
|
131
187
|
backTarget: "closed" | "assetPicker";
|
|
132
188
|
};
|
|
189
|
+
} | {
|
|
190
|
+
name: "cashAmountEntry";
|
|
191
|
+
ctx: {
|
|
192
|
+
method: "cash";
|
|
193
|
+
cashMethod: CashMethodId;
|
|
194
|
+
backTarget: "closed" | "deposit";
|
|
195
|
+
/**
|
|
196
|
+
* Optional initial amount, restored when the user backs out of `cashConfirm` so the
|
|
197
|
+
* fiat band keeps the value they entered before continuing. Absent on first entry
|
|
198
|
+
* (the widget falls back to the first preset).
|
|
199
|
+
*/
|
|
200
|
+
amount?: number;
|
|
201
|
+
};
|
|
202
|
+
} | {
|
|
203
|
+
name: "cashConfirm";
|
|
204
|
+
ctx: {
|
|
205
|
+
method: "cash";
|
|
206
|
+
cashMethod: CashMethodId;
|
|
207
|
+
amount: number;
|
|
208
|
+
phase: CashConfirmPhase;
|
|
209
|
+
backTarget: "cashAmountEntry";
|
|
210
|
+
};
|
|
133
211
|
} | {
|
|
134
212
|
name: "confirmDeposit";
|
|
135
213
|
ctx: {
|
|
@@ -222,6 +300,14 @@ type GatewayEvent = {
|
|
|
222
300
|
} | {
|
|
223
301
|
type: "DEPOSIT_METHOD_SELECTED";
|
|
224
302
|
method: DepositMethod;
|
|
303
|
+
} | {
|
|
304
|
+
type: "CASH_METHOD_SELECTED";
|
|
305
|
+
cashMethod: CashMethodId;
|
|
306
|
+
} | {
|
|
307
|
+
type: "CASH_AMOUNT_CONFIRMED";
|
|
308
|
+
amount: number;
|
|
309
|
+
} | {
|
|
310
|
+
type: "CASH_METHOD_READY";
|
|
225
311
|
} | {
|
|
226
312
|
type: "ASSET_CONFIRMED";
|
|
227
313
|
asset: BalanceItemPayload;
|
|
@@ -350,6 +436,25 @@ interface DepositController {
|
|
|
350
436
|
*/
|
|
351
437
|
interface DepositActions {
|
|
352
438
|
selectMethod(method: DepositMethod): void;
|
|
439
|
+
/**
|
|
440
|
+
* Promotes the FSM from `deposit` (method picker) into `cashAmountEntry` for the chosen cash
|
|
441
|
+
* method. Distinct from {@link selectMethod} because cash methods route to a method-specific
|
|
442
|
+
* surface today (and per-method confirm forms tomorrow), while {@link selectMethod} stays
|
|
443
|
+
* scoped to the crypto rail's two methods.
|
|
444
|
+
*/
|
|
445
|
+
selectCashMethod(cashMethod: CashMethodId): void;
|
|
446
|
+
/**
|
|
447
|
+
* Promotes the FSM from `cashAmountEntry` into `cashConfirm{loading}` carrying the entered
|
|
448
|
+
* fiat amount. The cash-confirm widget mounts in its loading state, schedules its own
|
|
449
|
+
* `cashMethodReady` dispatch after the mock load delay, and re-renders with the filled body.
|
|
450
|
+
*/
|
|
451
|
+
confirmCashAmount(amount: number): void;
|
|
452
|
+
/**
|
|
453
|
+
* Flips `cashConfirm{loading}` → `cashConfirm{ready}`. Dispatched by the cash-confirm widget
|
|
454
|
+
* itself once its mock loading timer elapses. Real card-form / Apple Pay / Google Pay
|
|
455
|
+
* lifecycles will replace this with bindings-driven signals.
|
|
456
|
+
*/
|
|
457
|
+
cashMethodReady(): void;
|
|
353
458
|
confirmAsset(asset: BalanceItemPayload): void;
|
|
354
459
|
confirmAmount(amount: number): void;
|
|
355
460
|
confirmDeposit(): void;
|
|
@@ -379,4 +484,4 @@ interface DepositActions {
|
|
|
379
484
|
selectSettlement(settlementId: string): void;
|
|
380
485
|
}
|
|
381
486
|
//#endregion
|
|
382
|
-
export { ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositMethodConfig, DepositMethodsConfig, DepositState, DepositStateName, GatewayEvent, OpenInput, ResolvedOpenInput, RetryTargetSpec };
|
|
487
|
+
export { CashConfirmPhase, CashMethodId, ConfirmDepositPhase, DepositActions, DepositController, DepositMethod, DepositMethodConfig, DepositMethodsConfig, DepositRailConfig, DepositState, DepositStateName, GatewayEvent, OpenInput, ResolvedOpenInput, RetryTargetSpec };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useDepositDriverInstance as e}from"../driver/context.js";import{
|
|
1
|
+
"use client";import{useDepositDriverInstance as e}from"../driver/context.js";import{useOptionalStableControllerContext as t,useStableControllerContext as n}from"./controller.js";import{useCallback as r}from"react";function i(){return n().controller}function a(){return t()?.controller??null}function o(){let t=e();return r(()=>{t.arm()},[t])}export{i as useDeposit,a as useOptionalDeposit,o as usePrefetchDeposit};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/flows/deposit/shared/cash.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Mock breakdown computed in-widget from the entered amount + chosen cash method. Returns the
|
|
4
|
+
* same shape the future `cashQuote` driver entity will surface, so the widget only swaps its
|
|
5
|
+
* source from this helper to `useDepositSnapshot().cashQuote` when the backend ships.
|
|
6
|
+
*/
|
|
7
|
+
interface CashAmountBreakdown {
|
|
8
|
+
/** USD amount the user is paying — surfaced on the Amount row and the hero band. */
|
|
9
|
+
amountUsd: number;
|
|
10
|
+
/** USDC the user receives after fees. Drives the Receive chip + hero sub-line. */
|
|
11
|
+
receiveAmount: number;
|
|
12
|
+
/** USDC quoted-per-USD rate. Drives the Crypto price row. */
|
|
13
|
+
rate: number;
|
|
14
|
+
/** Processing fee charged by the cash method (USD, deducted from amount). */
|
|
15
|
+
processingFeeUsd: number;
|
|
16
|
+
/** Network fee paid to settle on-chain (USD, deducted from amount). */
|
|
17
|
+
networkFeeUsd: number;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { CashAmountBreakdown };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={symbol:`USDC`,chainId:1,address:`0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`},t=[{value:200,label:`$200`},{value:500,label:`$500`},{value:1e3,label:`$1k`},{value:2e3,label:`$2k`}],n={card:.029,applePay:.025,googlePay:.025};function r(e,t){let r=e??0,i=+(r*n[t]).toFixed(2),a=.4;return{amountUsd:r,receiveAmount:Math.max(0,r-i-a)/1,rate:1,processingFeeUsd:i,networkFeeUsd:a}}export{t as MOCK_CASH_PRESETS,e as MOCK_RECEIVE_TOKEN,r as computeMockCashBreakdown};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DialogShellControls } from "../../../../shared/dialog/DialogShell.js";
|
|
2
2
|
import { AmountEntryBodyProps } from "../../../../shared/widgets/amount-entry/compound/types.js";
|
|
3
|
+
import { AmountEntryHeader } from "../../../../shared/widgets/amount-entry/compound/components/Header.js";
|
|
3
4
|
import { AmountEntryFlow } from "../../../../shared/widgets/amount-entry/compound/components/Flow.js";
|
|
4
5
|
import { AmountEntryFooter } from "../../../../shared/widgets/amount-entry/compound/components/Footer.js";
|
|
5
|
-
import { AmountEntryHeader } from "../../../../shared/widgets/amount-entry/compound/components/Header.js";
|
|
6
6
|
import { AmountEntryHero } from "../../../../shared/widgets/amount-entry/compound/components/Hero/Hero.js";
|
|
7
7
|
import { AmountEntryNotice } from "../../../../shared/widgets/amount-entry/compound/components/Notice.js";
|
|
8
8
|
import { AmountEntryPills } from "../../../../shared/widgets/amount-entry/compound/components/Pills.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useOptionalActivityDriverInstance as e}from"../../../activity/driver/context.js";import{useKitI18n as t}from"../../../../shared/i18n/useKitI18n.js";import{Trans as n}from"../../../../shared/i18n/Trans.js";import{useLingui as r}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as i}from"../../driver/context.js";import{useDepositActions as a,useDepositEffectiveState as ee}from"../../orchestrator/controller.js";import{formatTokenAmount as o}from"../../../../shared/format/formatTokenAmount.js";import{useKitEmitter as s}from"../../../../events/emit/useKitEmitter.js";import"../../../../events/emit/index.js";import{DialogShell as c}from"../../../../shared/dialog/DialogShell.js";import{
|
|
1
|
+
"use client";import{useOptionalActivityDriverInstance as e}from"../../../activity/driver/context.js";import{useKitI18n as t}from"../../../../shared/i18n/useKitI18n.js";import{Trans as n}from"../../../../shared/i18n/Trans.js";import{useLingui as r}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as i}from"../../driver/context.js";import{useDepositActions as a,useDepositEffectiveState as ee}from"../../orchestrator/controller.js";import{formatTokenAmount as o}from"../../../../shared/format/formatTokenAmount.js";import{useKitEmitter as s}from"../../../../events/emit/useKitEmitter.js";import"../../../../events/emit/index.js";import{DialogShell as c}from"../../../../shared/dialog/DialogShell.js";import{AmountEntry as l}from"../../../../shared/widgets/amount-entry/compound/AmountEntry.js";import"../../../../shared/widgets/amount-entry/compound/index.js";import{ActivityTrigger as u}from"../../../../shared/widgets/activity/ActivityTrigger.js";import"../../../../shared/widgets/activity/index.js";import{toAssetDescriptor as d}from"../../../../shared/widgets/asset-descriptor.js";import{effectiveMaxUsd as f,resolveFooterIntent as te}from"./footerIntent.js";import{useEffect as p,useRef as m,useState as h}from"react";import{Fragment as g,jsx as _,jsxs as v}from"react/jsx-runtime";const y=[{value:`25`,label:`25%`},{value:`50`,label:`50%`},{value:`75`,label:`75%`},{value:`max`,label:`Max`}];function b({children:n,...c}){let b=i(),C=ee(),{confirmAmount:w,back:T,openActivity:E}=a(),D=e()!==null,{_:O}=r(),k=t(),A=b.target,j=A.status===`ready`||A.status===`stale`?A.payload:void 0,M=C.name===`amountEntry`?C.ctx.asset:void 0,N=M?.amountUsd?.value??0,P=j?.minAmountUsd?.value,F=j?.minAmountUsd?.formatted,I=j?.maxAmountUsd?.value,L=j?.maxAmountUsd?.formatted,R=f(N,I),z=M?.priceUsd,[B,V]=h(P??null),[H,U]=h(),W=s(),G=e=>{W({type:`deposit.amount.changed`,flow:`deposit`,tier:`ui`,payload:{raw:e===null?``:String(e),numeric:e}})},K=m(void 0),q=M?`${M.eip155Id??``}:${M.address??``}`:void 0;p(()=>{q&&K.current!==q&&(K.current=q,typeof P==`number`&&(V(P),U(void 0)))},[q,P]);let J=e=>{U(e);let t=e===`max`?1:Number.parseInt(e,10)/100;if(Number.isFinite(t)){let n=R*t;V(n),G(n),e===`max`&&W({type:`deposit.max.clicked`,flow:`deposit`,tier:`ui`,payload:{}})}},Y=e=>{V(e),U(void 0),G(e)},X=te({amount:B,...P===void 0?{}:{minAmountUsd:P},...I===void 0?{}:{maxAmountUsd:I},walletBalanceUsd:N}),Z=()=>{if(X===`aboveBalance`||X===`aboveCap`){V(R),U(`max`);return}if(X===`belowMin`&&typeof P==`number`){V(P),U(void 0);return}B!==null&&w(z&&z>0?B/z:B)};if(C.name!==`amountEntry`||!M||!j)return null;let Q=C.ctx.backTarget===`closed`?void 0:T,ne=d(M)??{symbol:M.symbol},re=d(j)??{symbol:j.symbol},ie=`${o((B??0)/1,k,{maxDecimals:5})} ${j.symbol}`,$=x(X,{updateOrder:O({id:`bOZXx5`,message:`Update order`}),depositMax:O({id:`9cCjMJ`,message:`Deposit max balance`})}),ae=S(X,L,F);return _(l,{...c,amount:B,sendToken:ne,receiveToken:re,max:R,...P===void 0?{}:{min:P},onAmountChange:Y,...Q?{onBack:Q}:{},subLineAmount:ie,presets:y,...H===void 0?{}:{activePreset:H},onPresetSelect:J,...$===void 0?{}:{footerLabel:$},onContinue:Z,notice:ae,...D?{headerTrailing:_(u,{onOpen:E})}:{},children:n??v(g,{children:[_(l.Header,{}),v(l.Body,{children:[_(l.Hero,{}),_(l.Pills,{}),_(l.Flow,{}),_(l.Notice,{})]}),_(l.Footer,{})]})})}function x(e,t){if(e===`aboveCap`||e===`belowMin`)return t.updateOrder;if(e===`aboveBalance`)return t.depositMax}function S(e,t,r){if(e===`aboveCap`&&t)return _(n,{id:`-I_tc5`,message:`Max {formattedCap}`,values:{formattedCap:t}});if(e===`aboveBalance`)return _(n,{id:`znqB4T`,message:`Insufficient balance`});if(e===`belowMin`&&r)return _(n,{id:`3eKjkO`,message:`{formattedMin} minimum deposit`,values:{formattedMin:r}})}function C({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return _(c,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:_(b,{...i})})}(function(e){e.Dialog=C,e.Header=l.Header,e.Body=l.Body,e.Hero=l.Hero,e.Pills=l.Pills,e.Flow=l.Flow,e.Footer=l.Footer,e.Notice=l.Notice})(b||={});export{b as AmountEntry};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { DialogShellControls } from "../../../../shared/dialog/DialogShell.js";
|
|
2
|
+
import { AmountEntryBodyProps } from "../../../../shared/widgets/amount-entry/compound/types.js";
|
|
3
|
+
import { AmountEntryHeader } from "../../../../shared/widgets/amount-entry/compound/components/Header.js";
|
|
4
|
+
import { AmountEntryDetails, AmountEntryDetailsRow } from "../../../../shared/widgets/amount-entry/compound/components/Details.js";
|
|
5
|
+
import { AmountEntryFlow } from "../../../../shared/widgets/amount-entry/compound/components/Flow.js";
|
|
6
|
+
import { AmountEntryFooter } from "../../../../shared/widgets/amount-entry/compound/components/Footer.js";
|
|
7
|
+
import { AmountEntryHero } from "../../../../shared/widgets/amount-entry/compound/components/Hero/Hero.js";
|
|
8
|
+
import { AmountEntryNotice } from "../../../../shared/widgets/amount-entry/compound/components/Notice.js";
|
|
9
|
+
import { AmountEntryPills } from "../../../../shared/widgets/amount-entry/compound/components/Pills.js";
|
|
10
|
+
import { CashAmountEntryHeroLabel } from "./compound/components/HeroLabel.js";
|
|
11
|
+
import { CashAmountEntryMethodChip } from "./compound/components/MethodChip.js";
|
|
12
|
+
import { CashAmountEntryReceiveChip } from "./compound/components/ReceiveChip.js";
|
|
13
|
+
import { ComponentProps, ReactNode } from "react";
|
|
14
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
15
|
+
|
|
16
|
+
//#region src/flows/deposit/widgets/cash-amount-entry/CashAmountEntry.d.ts
|
|
17
|
+
interface CashAmountEntryProps extends ComponentProps<"div"> {
|
|
18
|
+
/**
|
|
19
|
+
* Optional custom composition. When omitted, the canonical default composition renders —
|
|
20
|
+
* `<Header />` + `<Body>` with method chip + YOU PAY label + Hero (Receive chip subLine) +
|
|
21
|
+
* fiat-absolute Pills + Details breakdown + Notice + `<Footer />`. Pass children to interleave
|
|
22
|
+
* your own elements between compound parts or replace the composition entirely.
|
|
23
|
+
*/
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Orchestrated `CashAmountEntry` widget — the screen between the cash-method picker and the
|
|
28
|
+
* per-method confirmation form. Reads the chosen cash method from the FSM's `cashAmountEntry.ctx`,
|
|
29
|
+
* the per-method limit from the driver's `cashMethods` entity, and computes the fee breakdown
|
|
30
|
+
* from the mock fixture in {@link computeMockCashBreakdown}. The `cashQuote` driver entity that
|
|
31
|
+
* backs this in production is deferred.
|
|
32
|
+
*
|
|
33
|
+
* Renders nothing on any other FSM state — the dialog routes it under
|
|
34
|
+
* `<Deposit.Step name="cashAmountEntry">`, and the guard inside this component is a belt-and-
|
|
35
|
+
* braces check against host compositions that don't honour the step routing.
|
|
36
|
+
*/
|
|
37
|
+
declare function CashAmountEntry({
|
|
38
|
+
children,
|
|
39
|
+
...props
|
|
40
|
+
}: CashAmountEntryProps): _$react_jsx_runtime0.JSX.Element | null;
|
|
41
|
+
declare function CashAmountEntryDialog({
|
|
42
|
+
open,
|
|
43
|
+
defaultOpen,
|
|
44
|
+
onOpenChange,
|
|
45
|
+
trigger,
|
|
46
|
+
...rootProps
|
|
47
|
+
}: CashAmountEntry.DialogProps): _$react_jsx_runtime0.JSX.Element;
|
|
48
|
+
declare namespace CashAmountEntry {
|
|
49
|
+
type Props = CashAmountEntryProps;
|
|
50
|
+
type DialogProps = CashAmountEntryProps & DialogShellControls;
|
|
51
|
+
const Dialog: typeof CashAmountEntryDialog;
|
|
52
|
+
/**
|
|
53
|
+
* Compound sub-parts aliased on the orchestrated widget so consumers can compose without
|
|
54
|
+
* importing the headless compound separately. Identity-equal to the parts on the compound
|
|
55
|
+
* exported from `@stridge/kit/deposit/compound`.
|
|
56
|
+
*/
|
|
57
|
+
const MethodChip: typeof CashAmountEntryMethodChip;
|
|
58
|
+
const HeroLabel: typeof CashAmountEntryHeroLabel;
|
|
59
|
+
const ReceiveChip: typeof CashAmountEntryReceiveChip;
|
|
60
|
+
const Header: typeof AmountEntryHeader;
|
|
61
|
+
const Body: (props: AmountEntryBodyProps) => _$react_jsx_runtime0.JSX.Element;
|
|
62
|
+
const Hero: typeof AmountEntryHero;
|
|
63
|
+
const Pills: typeof AmountEntryPills;
|
|
64
|
+
const Flow: typeof AmountEntryFlow;
|
|
65
|
+
const Footer: typeof AmountEntryFooter;
|
|
66
|
+
const Notice: typeof AmountEntryNotice;
|
|
67
|
+
const Details: typeof AmountEntryDetails;
|
|
68
|
+
const DetailsRow: typeof AmountEntryDetailsRow;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { CashAmountEntry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useKitI18n as e}from"../../../../shared/i18n/useKitI18n.js";import{Trans as t}from"../../../../shared/i18n/Trans.js";import{useLingui as n}from"../../../../shared/i18n/useLingui.js";import"../../../../i18n/index.js";import{useDepositSnapshot as r}from"../../driver/context.js";import{useDepositActions as i,useDepositEffectiveState as a}from"../../orchestrator/controller.js";import{formatTokenAmount as o}from"../../../../shared/format/formatTokenAmount.js";import{formatUsd as s}from"../../../../shared/format/formatUsd.js";import{DialogShell as c}from"../../../../shared/dialog/DialogShell.js";import{MOCK_CASH_PRESETS as l,MOCK_RECEIVE_TOKEN as u,computeMockCashBreakdown as d}from"../../shared/cash.js";import{CashAmountEntry as f}from"./compound/CashAmountEntry.js";import"./compound/index.js";import{useEffect as p,useMemo as m,useRef as h,useState as g}from"react";import{Fragment as _,jsx as v,jsxs as y}from"react/jsx-runtime";function b({children:c,...b}){let x=r(),S=a(),{back:C,confirmCashAmount:w}=i(),{_:T}=n(),E=e(),D=S.name===`cashAmountEntry`?S.ctx.cashMethod:void 0,O=S.name===`cashAmountEntry`?S.ctx.amount:void 0,k=x.cashMethods,A=k?.status===`ready`||k?.status===`stale`?k.payload:void 0,j=D?A?.[D]?.limit?.value:void 0,M=D?A?.[D]?.limit?.formatted:void 0,N=l[0]?.value??0,P=O??N,[F,I]=g(P),[L,R]=g(()=>{let e=l.find(e=>e.value===P);return e?String(e.value):void 0}),z=h(D);p(()=>{D&&z.current!==D&&(z.current=D,I(N),R(String(N)))},[D,N]);let B=m(()=>l.map(e=>({value:String(e.value),label:e.label})),[]),V=e=>{let t=Number.parseInt(e,10);Number.isFinite(t)&&(I(t),R(e))},H=e=>{I(e),R(void 0)},U=j===0,W=()=>{if(!U){if(typeof j==`number`&&F!==null&&F>j){I(j),R(void 0);return}F===null||F<=0||!D||w(F)}};if(S.name!==`cashAmountEntry`||!D)return null;let G=!U&&typeof j==`number`&&F!==null&&F>j,K=U?v(t,{id:`FWbwx6`,message:`Cash deposit unavailable for your account`}):G&&M?v(t,{id:`GXkBas`,message:`Max {formattedLimit}`,values:{formattedLimit:M}}):void 0,q=G?T({id:`wkskq5`,message:`Use max`}):void 0,J=d(F,D),Y=o(J.receiveAmount,E,{maxDecimals:2,useGrouping:!0}),X=S.ctx.backTarget===`closed`?void 0:C;return v(f,{...b,cashMethod:D,breakdown:J,formattedReceive:Y,...X?{onChangeMethod:X}:{},amount:F,sendToken:{symbol:`USD`},receiveToken:u,...typeof j==`number`?{max:j}:{},headerTitle:T({id:`kj3M8S`,message:`Deposit`}),currencySymbol:`$`,onAmountChange:H,...X?{onBack:X}:{},presets:B,...L===void 0?{}:{activePreset:L},onPresetSelect:V,...q===void 0?{}:{footerLabel:q},...U?{}:{onContinue:W},notice:K,children:c??y(_,{children:[v(f.Header,{}),y(f.Body,{children:[v(f.MethodChip,{}),v(f.HeroLabel,{children:v(t,{id:`VAxOSg`,message:`You pay`})}),v(f.Hero,{}),v(f.Pills,{}),y(f.Details,{children:[v(f.DetailsRow,{label:v(t,{id:`hehnjM`,message:`Amount`}),children:s(J.amountUsd,E,{showSmallValueClamp:!1})}),v(f.DetailsRow,{label:v(t,{id:`vepIdX`,message:`Crypto price`}),children:v(t,{id:`eUbBqz`,message:`1 {0} = {1}`,values:{0:u.symbol,1:s(J.rate,E,{showSmallValueClamp:!1})}})}),y(f.DetailsRow,{label:v(t,{id:`QFwptY`,message:`Processing fee`}),info:v(t,{id:`C7cyXd`,message:`The processing fee covers the cost of processing your payment through the selected payment method.`}),children:[`− `,s(J.processingFeeUsd,E,{showSmallValueClamp:!1})]}),y(f.DetailsRow,{label:v(t,{id:`y62Dys`,message:`Network fee`}),info:v(t,{id:`f-nEg4`,message:`The network fee is paid to miners and validators of the blockchain to make sure the transaction is processed and confirmed.`}),children:[`− `,s(J.networkFeeUsd,E,{showSmallValueClamp:!1})]})]})]}),v(f.Footer,{children:v(f.Notice,{})})]})})}function x({open:e,defaultOpen:t,onOpenChange:n,trigger:r,...i}){return v(c,{open:e,defaultOpen:t,onOpenChange:n,trigger:r,children:v(b,{...i})})}(function(e){e.Dialog=x,e.MethodChip=f.MethodChip,e.HeroLabel=f.HeroLabel,e.ReceiveChip=f.ReceiveChip,e.Header=f.Header,e.Body=f.Body,e.Hero=f.Hero,e.Pills=f.Pills,e.Flow=f.Flow,e.Footer=f.Footer,e.Notice=f.Notice,e.Details=f.Details,e.DetailsRow=f.DetailsRow})(b||={});export{b as CashAmountEntry};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AmountEntryBodyProps } from "../../../../../shared/widgets/amount-entry/compound/types.js";
|
|
2
|
+
import { AmountEntryHeader } from "../../../../../shared/widgets/amount-entry/compound/components/Header.js";
|
|
3
|
+
import { AmountEntryDetails, AmountEntryDetailsRow } from "../../../../../shared/widgets/amount-entry/compound/components/Details.js";
|
|
4
|
+
import { AmountEntryFlow } from "../../../../../shared/widgets/amount-entry/compound/components/Flow.js";
|
|
5
|
+
import { AmountEntryFooter } from "../../../../../shared/widgets/amount-entry/compound/components/Footer.js";
|
|
6
|
+
import { AmountEntryHero } from "../../../../../shared/widgets/amount-entry/compound/components/Hero/Hero.js";
|
|
7
|
+
import { AmountEntryNotice } from "../../../../../shared/widgets/amount-entry/compound/components/Notice.js";
|
|
8
|
+
import { AmountEntryPills } from "../../../../../shared/widgets/amount-entry/compound/components/Pills.js";
|
|
9
|
+
import { CashAmountEntryDialogProps, CashAmountEntryHeroLabelProps, CashAmountEntryMethodChipProps, CashAmountEntryProps } from "./types.js";
|
|
10
|
+
import { CashAmountEntryHeroLabel } from "./components/HeroLabel.js";
|
|
11
|
+
import { CashAmountEntryMethodChip } from "./components/MethodChip.js";
|
|
12
|
+
import { CashAmountEntryReceiveChip } from "./components/ReceiveChip.js";
|
|
13
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
14
|
+
|
|
15
|
+
//#region src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Root of the CashAmountEntry compound. Wraps the shared {@link AmountEntryCompound} and provides
|
|
18
|
+
* cash-flow-specific context (cashMethod, breakdown, formattedReceive, onChangeMethod) to the
|
|
19
|
+
* three cash-flow-internal sub-parts (`MethodChip`, `HeroLabel`, `ReceiveChip`) so children render
|
|
20
|
+
* without prop-drilling from the host.
|
|
21
|
+
*
|
|
22
|
+
* Defaults the `subLine` slot to a `<CashAmountEntry.ReceiveChip />` when the host doesn't provide
|
|
23
|
+
* one explicitly — that's the canonical Paper composition. Pass `subLine={…}` to override.
|
|
24
|
+
*
|
|
25
|
+
* Parts:
|
|
26
|
+
* - {@link CashAmountEntry.MethodChip}
|
|
27
|
+
* - {@link CashAmountEntry.HeroLabel}
|
|
28
|
+
* - {@link CashAmountEntry.ReceiveChip}
|
|
29
|
+
*
|
|
30
|
+
* The AmountEntry compound parts (`Header`, `Body`, `Hero`, `Pills`, `Details`, `DetailsRow`,
|
|
31
|
+
* `Notice`, `Footer`) are re-exposed off the namespace too so consumers can compose the full tree
|
|
32
|
+
* without importing two compounds. Identity-equal to the parts on
|
|
33
|
+
* {@link AmountEntryCompound}.
|
|
34
|
+
*
|
|
35
|
+
* Dialog form: {@link CashAmountEntry.Dialog} pre-composes the widget into a
|
|
36
|
+
* `Dialog.Root + Dialog.Trigger + Dialog.Content` shell.
|
|
37
|
+
*/
|
|
38
|
+
declare function CashAmountEntry(props: CashAmountEntryProps): _$react_jsx_runtime0.JSX.Element;
|
|
39
|
+
declare function CashAmountEntryDialog({
|
|
40
|
+
open,
|
|
41
|
+
defaultOpen,
|
|
42
|
+
onOpenChange,
|
|
43
|
+
trigger,
|
|
44
|
+
children,
|
|
45
|
+
...rootProps
|
|
46
|
+
}: CashAmountEntryDialogProps): _$react_jsx_runtime0.JSX.Element;
|
|
47
|
+
declare namespace CashAmountEntry {
|
|
48
|
+
type Props = CashAmountEntryProps;
|
|
49
|
+
type MethodChipProps = CashAmountEntryMethodChipProps;
|
|
50
|
+
type HeroLabelProps = CashAmountEntryHeroLabelProps;
|
|
51
|
+
type DialogProps = CashAmountEntryDialogProps;
|
|
52
|
+
/** Cash-flow-specific sub-parts. */
|
|
53
|
+
const MethodChip: typeof CashAmountEntryMethodChip;
|
|
54
|
+
const HeroLabel: typeof CashAmountEntryHeroLabel;
|
|
55
|
+
const ReceiveChip: typeof CashAmountEntryReceiveChip;
|
|
56
|
+
/** AmountEntry compound parts re-exposed for one-stop composition. */
|
|
57
|
+
const Header: typeof AmountEntryHeader;
|
|
58
|
+
const Body: (props: AmountEntryBodyProps) => _$react_jsx_runtime0.JSX.Element;
|
|
59
|
+
const Hero: typeof AmountEntryHero;
|
|
60
|
+
const Pills: typeof AmountEntryPills;
|
|
61
|
+
const Flow: typeof AmountEntryFlow;
|
|
62
|
+
const Footer: typeof AmountEntryFooter;
|
|
63
|
+
const Notice: typeof AmountEntryNotice;
|
|
64
|
+
const Details: typeof AmountEntryDetails;
|
|
65
|
+
const DetailsRow: typeof AmountEntryDetailsRow;
|
|
66
|
+
const Dialog: typeof CashAmountEntryDialog;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { CashAmountEntry };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{DialogShell as e}from"../../../../../shared/dialog/DialogShell.js";import{AmountEntry as t}from"../../../../../shared/widgets/amount-entry/compound/AmountEntry.js";import"../../../../../shared/widgets/amount-entry/compound/index.js";import{CashAmountEntryHeroLabel as n}from"./components/HeroLabel.js";import{CashAmountEntryContext as r}from"./context.js";import{CashAmountEntryMethodChip as i}from"./components/MethodChip.js";import{CashAmountEntryReceiveChip as a}from"./components/ReceiveChip.js";import{useMemo as o}from"react";import{jsx as s}from"react/jsx-runtime";const c=s(a,{});function l(e){let{cashMethod:n,breakdown:i,formattedReceive:a,onChangeMethod:l,subLine:u,children:d,...f}=e;return s(r,{value:o(()=>({cashMethod:n,breakdown:i,formattedReceive:a,...l?{onChangeMethod:l}:{}}),[n,i,a,l]),children:s(t,{...f,subLine:u??c,children:d})})}function u({open:t,defaultOpen:n,onOpenChange:r,trigger:i,children:a,...o}){return s(e,{open:t,defaultOpen:n,onOpenChange:r,trigger:i,children:s(l,{...o,children:a})})}(function(e){e.MethodChip=i,e.HeroLabel=n,e.ReceiveChip=a,e.Header=t.Header,e.Body=t.Body,e.Hero=t.Hero,e.Pills=t.Pills,e.Flow=t.Flow,e.Footer=t.Footer,e.Notice=t.Notice,e.Details=t.Details,e.DetailsRow=t.DetailsRow,e.Dialog=u})(l||={});export{l as CashAmountEntry};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.slots.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* `data-stridge-slot` constants for the cash-amount-entry widget's cash-flow-internal sub-parts
|
|
4
|
+
* (method chip, hero label, receive chip). The amount-input chrome itself stamps the shared
|
|
5
|
+
* `AMOUNT_ENTRY_SLOTS` from `#/shared/widgets/amount-entry`; this file only covers the cash
|
|
6
|
+
* additions.
|
|
7
|
+
*/
|
|
8
|
+
declare const CASH_AMOUNT_ENTRY_SLOTS: {
|
|
9
|
+
readonly methodChip: "cash-amount-entry-method-chip";
|
|
10
|
+
readonly methodChipChange: "cash-amount-entry-method-chip-change";
|
|
11
|
+
readonly heroLabel: "cash-amount-entry-hero-label";
|
|
12
|
+
readonly receiveChip: "cash-amount-entry-receive-chip";
|
|
13
|
+
};
|
|
14
|
+
type CashAmountEntrySlot = (typeof CASH_AMOUNT_ENTRY_SLOTS)[keyof typeof CASH_AMOUNT_ENTRY_SLOTS];
|
|
15
|
+
//#endregion
|
|
16
|
+
export { CASH_AMOUNT_ENTRY_SLOTS, CashAmountEntrySlot };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={methodChip:`cash-amount-entry-method-chip`,methodChipChange:`cash-amount-entry-method-chip-change`,heroLabel:`cash-amount-entry-hero-label`,receiveChip:`cash-amount-entry-receive-chip`};export{e as CASH_AMOUNT_ENTRY_SLOTS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={heroLabelWrap:{"CashAmountEntry__styles.heroLabelWrap":`CashAmountEntry__styles.heroLabelWrap`,"display-k1xSpc":`x78zum5`,"justifyContent-kjj79g":`xl56j7k`,"paddingInlineEnd-kwRFfy":`x1o5r3ls`,"paddingInlineStart-kZCmMZ":`xz7312c`,"paddingTop-kLKAdn":`xyamay9`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:12`},heroLabel:{"CashAmountEntry__styles.heroLabel":`CashAmountEntry__styles.heroLabel`,"margin-kogj98":`x1ghz6dp`,"letterSpacing-kb6lSQ":`x1labic3`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:19`},methodChipWrap:{"CashAmountEntry__styles.methodChipWrap":`CashAmountEntry__styles.methodChipWrap`,"display-k1xSpc":`x78zum5`,"justifyContent-kjj79g":`xl56j7k`,"paddingTop-kLKAdn":`xyamay9`,"paddingInlineEnd-kwRFfy":`x1o5r3ls`,"paddingInlineStart-kZCmMZ":`xz7312c`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:24`},methodChip:{"CashAmountEntry__styles.methodChip":`CashAmountEntry__styles.methodChip`,"display-k1xSpc":`x3nfvp2`,"alignItems-kGNEyG":`x6s0dn4`,"gap-kOIVth":`x167g77z`,"paddingBlock-k8WAf4":`x1t0vds8`,"paddingInlineStart-kZCmMZ":`x25sj25`,"paddingInlineEnd-kwRFfy":`xpdmqnj`,"borderRadius-kaIpWk":`x1npxkrn`,"backgroundColor-kWkggS":`x1qkydf4`,"borderColor-kVAM5u":`x12c9lpl`,"borderStyle-ksu8eU":`x1y0btm7`,"borderWidth-kMzoRj":`xmkeg23`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:31`},methodChipIcon:{"CashAmountEntry__styles.methodChipIcon":`CashAmountEntry__styles.methodChipIcon`,"display-k1xSpc":`x3nfvp2`,"alignItems-kGNEyG":`x6s0dn4`,"justifyContent-kjj79g":`xl56j7k`,"width-kzqmXN":`x17z2i9w`,"height-kZKoxP":`x17rw0jw`,"flexShrink-kmuXW":`x2lah0s`,"color-kMwMTN":`xzn0pkc`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:44`},methodChipLabel:{"CashAmountEntry__styles.methodChipLabel":`CashAmountEntry__styles.methodChipLabel`,"margin-kogj98":`x1ghz6dp`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:53`},methodChipChange:{"CashAmountEntry__styles.methodChipChange":`CashAmountEntry__styles.methodChipChange`,"appearance-kysU6D":`xjyslct`,"margin-kogj98":`x1ghz6dp`,"padding-kmVPX3":`x1717udv`,"font-kVVagm":`xln7xf2`,"color-kMwMTN":`xi96bwj`,"cursor-kkrTdU":`x1ypdohk`,":hover_color-kDPRdz":`xpscirx`,":focus-visible_outline-k3Woio":`x67ar3w`,":focus-visible_outlineOffset-kiEn40":`x7s97pk`,":focus-visible_borderRadius-k7aC84":`x63abuj`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:56`},receiveLine:{"CashAmountEntry__styles.receiveLine":`CashAmountEntry__styles.receiveLine`,"display-k1xSpc":`x3nfvp2`,"alignItems-kGNEyG":`x6s0dn4`,"gap-kOIVth":`x167g77z`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:76`},receiveLabel:{"CashAmountEntry__styles.receiveLabel":`CashAmountEntry__styles.receiveLabel`,"margin-kogj98":`x1ghz6dp`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:81`},receiveChip:{"CashAmountEntry__styles.receiveChip":`CashAmountEntry__styles.receiveChip`,"display-k1xSpc":`x3nfvp2`,"alignItems-kGNEyG":`x6s0dn4`,"gap-kOIVth":`x17d4w8g`,"paddingBlock-k8WAf4":`x12ulsxz`,"paddingInlineStart-kZCmMZ":`x25sj25`,"paddingInlineEnd-kwRFfy":`x2vl965`,"borderRadius-kaIpWk":`x1npxkrn`,"backgroundColor-kWkggS":`xvaq5cg`,"borderColor-kVAM5u":`x12c9lpl`,"borderStyle-ksu8eU":`x1y0btm7`,"borderWidth-kMzoRj":`xmkeg23`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:84`},receiveChipAmount:{"CashAmountEntry__styles.receiveChipAmount":`CashAmountEntry__styles.receiveChipAmount`,"margin-kogj98":`x1ghz6dp`,$$css:`@stridge/kit:src/flows/deposit/widgets/cash-amount-entry/compound/CashAmountEntry.styles.ts:97`}};export{e as styles};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CashAmountEntryHeroLabelProps } from "../types.js";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/flows/deposit/widgets/cash-amount-entry/compound/components/HeroLabel.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Small uppercase label rendered above the hero band on cash amount-entry. Mirrors the Paper
|
|
7
|
+
* design's "YOU PAY" reading. Cash-flow-internal — the wallet path doesn't use a hero label.
|
|
8
|
+
*/
|
|
9
|
+
declare function CashAmountEntryHeroLabel({
|
|
10
|
+
children
|
|
11
|
+
}: CashAmountEntryHeroLabelProps): _$react_jsx_runtime0.JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { CashAmountEntryHeroLabel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{text as e}from"../../../../../../shared/ui/Text/Text.js";import"../../../../../../ui/index.js";import{CASH_AMOUNT_ENTRY_SLOTS as t}from"../CashAmountEntry.slots.js";import{styles as n}from"../CashAmountEntry.styles.js";import{jsx as r}from"react/jsx-runtime";import*as i from"@stylexjs/stylex";function a({children:a}){return r(`div`,{...i.props(n.heroLabelWrap),children:r(e.span,{size:`meta`,fontWeight:`medium`,leading:`tight`,color:`subdued`,transform:`uppercase`,"data-stridge-slot":t.heroLabel,...i.props(n.heroLabel),children:a})})}export{a as CashAmountEntryHeroLabel};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CashAmountEntryMethodChipProps } from "../types.js";
|
|
2
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/flows/deposit/widgets/cash-amount-entry/compound/components/MethodChip.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Compact chip above the hero showing which cash method the user picked, with a `Change` link
|
|
7
|
+
* that takes them back to the method picker. Cash-flow-internal — the crypto path has no equivalent
|
|
8
|
+
* (the asset picker fills the same "what's selected, change it" role inline on the deposit method
|
|
9
|
+
* tile).
|
|
10
|
+
*
|
|
11
|
+
* Reads `cashMethod` and `onChangeMethod` from context. Pass `onChange={null}` to suppress the
|
|
12
|
+
* `Change` link even when context supplies a callback; pass an explicit function to override.
|
|
13
|
+
*/
|
|
14
|
+
declare function CashAmountEntryMethodChip({
|
|
15
|
+
onChange
|
|
16
|
+
}?: CashAmountEntryMethodChipProps): _$react_jsx_runtime0.JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { CashAmountEntryMethodChip };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{Trans as e}from"../../../../../../shared/i18n/Trans.js";import"../../../../../../i18n/index.js";import{ApplePayIcon as t}from"../../../../../../shared/icons/ApplePayIcon.js";import{CardIcon as n}from"../../../../../../shared/icons/CardIcon.js";import{GooglePayIcon as r}from"../../../../../../shared/icons/GooglePayIcon.js";import"../../../../../../icons/index.js";import{text as i}from"../../../../../../shared/ui/Text/Text.js";import"../../../../../../ui/index.js";import{CASH_AMOUNT_ENTRY_SLOTS as a}from"../CashAmountEntry.slots.js";import{styles as o}from"../CashAmountEntry.styles.js";import{useCashAmountEntryContext as s}from"../context.js";import{jsx as c,jsxs as l}from"react/jsx-runtime";import*as u from"@stylexjs/stylex";const d={width:13,height:13,"aria-hidden":!0};function f({onChange:t}={}){let n=s(`CashAmountEntry.MethodChip`),r=t===null?void 0:t??n.onChangeMethod;return c(`div`,{...u.props(o.methodChipWrap),children:l(`div`,{"data-stridge-slot":a.methodChip,...u.props(o.methodChip),children:[c(`span`,{...u.props(o.methodChipIcon),children:p(n.cashMethod)}),c(i.span,{size:`sm`,fontWeight:`medium`,leading:`tight`,...u.props(o.methodChipLabel),children:m(n.cashMethod)}),r?c(`button`,{type:`button`,onClick:r,"data-stridge-slot":a.methodChipChange,...u.props(o.methodChipChange),children:c(i.span,{size:`sm`,fontWeight:`medium`,leading:`tight`,color:`inherit`,children:c(e,{id:`o-XJ9D`,message:`Change`})})}):null]})})}function p(e){return c(e===`applePay`?t:e===`googlePay`?r:n,{...d})}function m(t){return t===`applePay`?c(e,{id:`TMA5Ot`,message:`Paying with Apple Pay`}):t===`googlePay`?c(e,{id:`FkAVbF`,message:`Paying with Google Pay`}):c(e,{id:`tInLgk`,message:`Paying with Card`})}export{f as CashAmountEntryMethodChip};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/flows/deposit/widgets/cash-amount-entry/compound/components/ReceiveChip.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Read-only receive chip slotted into the hero's `subLine` for cash amount-entry. Mirrors the
|
|
6
|
+
* Paper design's "Receive [USDC logo] 24.21 USDC" reading. Cash-flow-internal — the wallet path's
|
|
7
|
+
* Hero uses the swap toggle in this slot, not a static chip.
|
|
8
|
+
*
|
|
9
|
+
* Reads `formattedReceive` from context. The token is sourced from
|
|
10
|
+
* {@link MOCK_RECEIVE_TOKEN} while the cash backend is mocked.
|
|
11
|
+
*/
|
|
12
|
+
declare function CashAmountEntryReceiveChip(): _$react_jsx_runtime0.JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { CashAmountEntryReceiveChip };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{Trans as e}from"../../../../../../shared/i18n/Trans.js";import"../../../../../../i18n/index.js";import{text as t}from"../../../../../../shared/ui/Text/Text.js";import{TokenLogo as n}from"../../../../../../shared/ui/TokenLogo/TokenLogo.js";import"../../../../../../shared/ui/TokenLogo/index.js";import"../../../../../../ui/index.js";import{CASH_AMOUNT_ENTRY_SLOTS as r}from"../CashAmountEntry.slots.js";import{styles as i}from"../CashAmountEntry.styles.js";import{useCashAmountEntryContext as a}from"../context.js";import{MOCK_RECEIVE_TOKEN as o}from"../../../../shared/cash.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";import*as l from"@stylexjs/stylex";function u(){let{formattedReceive:u}=a(`CashAmountEntry.ReceiveChip`),d=o;return c(`span`,{...l.props(i.receiveLine),children:[s(t.span,{size:`sm`,leading:`tight`,color:`subdued`,...l.props(i.receiveLabel),children:s(e,{id:`lDgVWA`,message:`Receive`})}),c(`span`,{"data-stridge-slot":r.receiveChip,...l.props(i.receiveChip),children:[s(n,{size:18,symbol:d.symbol,...d.chainId===void 0?{}:{chainId:d.chainId},...d.address===void 0?{}:{address:d.address},...d.isNative===void 0?{}:{isNative:d.isNative},...d.logoUrl===void 0?{}:{logoUrl:d.logoUrl},hideChainBadge:!0}),c(t.span,{size:`sm`,fontWeight:`medium`,leading:`tight`,...l.props(i.receiveChipAmount),children:[u,` `,d.symbol]})]})]})}export{u as CashAmountEntryReceiveChip};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{createContext as e,use as t}from"react";const n=e(null);function r(e){let r=t(n);if(!r)throw Error(`${e} must be rendered inside <CashAmountEntry>.`);return r}export{n as CashAmountEntryContext,r as useCashAmountEntryContext};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CashAmountEntryDialogProps, CashAmountEntryHeroLabelProps, CashAmountEntryMethodChipProps, CashAmountEntryProps } from "./types.js";
|
|
2
|
+
import { CashAmountEntry } from "./CashAmountEntry.js";
|
|
3
|
+
import { CASH_AMOUNT_ENTRY_SLOTS, CashAmountEntrySlot } from "./CashAmountEntry.slots.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./CashAmountEntry.slots.js";import"./CashAmountEntry.js";
|