@swype-org/react-sdk 0.1.180 → 0.1.182

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/index.d.cts CHANGED
@@ -797,8 +797,10 @@ interface TokenPickerScreenProps {
797
797
  onSelectAuthorized: (walletId: string, tokenSymbol: string) => void;
798
798
  onAuthorizeToken: (walletId: string, tokenAddress: string, chainId: number, tokenSymbol: string) => void;
799
799
  onBack: () => void;
800
+ /** Deposit amount for the context card at top */
801
+ depositAmount?: number;
800
802
  }
801
- declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
803
+ declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, depositAmount, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
802
804
 
803
805
  type FlowPhase = 'link' | 'deposit';
804
806
 
package/dist/index.d.ts CHANGED
@@ -797,8 +797,10 @@ interface TokenPickerScreenProps {
797
797
  onSelectAuthorized: (walletId: string, tokenSymbol: string) => void;
798
798
  onAuthorizeToken: (walletId: string, tokenAddress: string, chainId: number, tokenSymbol: string) => void;
799
799
  onBack: () => void;
800
+ /** Deposit amount for the context card at top */
801
+ depositAmount?: number;
800
802
  }
801
- declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
803
+ declare function TokenPickerScreen({ account, chains, onSelectAuthorized, onAuthorizeToken, onBack, depositAmount, }: TokenPickerScreenProps): react_jsx_runtime.JSX.Element;
802
804
 
803
805
  type FlowPhase = 'link' | 'deposit';
804
806
 
package/dist/index.js CHANGED
@@ -2313,7 +2313,7 @@ var dotStyle = (color) => ({
2313
2313
  var lineStyle = (color) => ({
2314
2314
  width: 32,
2315
2315
  height: 0,
2316
- borderTop: `2px dashed ${color}`,
2316
+ borderTop: `2px solid ${color}`,
2317
2317
  opacity: 0.4,
2318
2318
  flexShrink: 0
2319
2319
  });
@@ -3844,7 +3844,7 @@ var continueRowStyle = (tokens) => ({
3844
3844
  padding: "10px 16px",
3845
3845
  fontSize: "0.84rem",
3846
3846
  fontWeight: 600,
3847
- color: tokens.accent,
3847
+ color: tokens.text,
3848
3848
  background: `${tokens.accent}0d`,
3849
3849
  borderTop: `1px solid ${tokens.accent}22`
3850
3850
  });
@@ -5351,10 +5351,10 @@ function TokenPickerScreen({
5351
5351
  chains,
5352
5352
  onSelectAuthorized,
5353
5353
  onAuthorizeToken,
5354
- onBack
5354
+ onBack,
5355
+ depositAmount
5355
5356
  }) {
5356
- const { tokens: themeTokens } = useSwypeConfig();
5357
- const [selectedIndex, setSelectedIndex] = useState(null);
5357
+ const { tokens: t } = useSwypeConfig();
5358
5358
  const entries = [];
5359
5359
  for (const wallet of account.wallets) {
5360
5360
  for (const source of wallet.sources) {
@@ -5369,213 +5369,214 @@ function TokenPickerScreen({
5369
5369
  });
5370
5370
  }
5371
5371
  }
5372
- const selected = selectedIndex != null ? entries[selectedIndex] : null;
5373
- const isAuthorized = selected?.status === "AUTHORIZED";
5374
- const handleConfirm = () => {
5375
- if (!selected) return;
5376
- if (isAuthorized) {
5377
- onSelectAuthorized(selected.walletId, selected.tokenSymbol);
5372
+ const handleSelect = (entry) => {
5373
+ if (entry.status === "AUTHORIZED") {
5374
+ onSelectAuthorized(entry.walletId, entry.tokenSymbol);
5378
5375
  } else {
5379
- const chain = chains.find((c) => c.name === selected.chainName);
5376
+ const chain = chains.find((c) => c.name === entry.chainName);
5380
5377
  const evmChainId = chain?.commonId;
5381
5378
  if (evmChainId == null) return;
5382
- onAuthorizeToken(selected.walletId, selected.tokenAddress, evmChainId, selected.tokenSymbol);
5379
+ onAuthorizeToken(entry.walletId, entry.tokenAddress, evmChainId, entry.tokenSymbol);
5383
5380
  }
5384
5381
  };
5385
- const chainGroups = /* @__PURE__ */ new Map();
5386
- for (const entry of entries) {
5387
- const group = chainGroups.get(entry.chainName);
5388
- if (group) {
5389
- group.push(entry);
5390
- } else {
5391
- chainGroups.set(entry.chainName, [entry]);
5392
- }
5393
- }
5394
- const [expandedChain, setExpandedChain] = useState(
5395
- entries.length > 0 ? entries[0].chainName : null
5396
- );
5397
- return /* @__PURE__ */ jsxs(
5398
- ScreenLayout,
5399
- {
5400
- footer: /* @__PURE__ */ jsxs(Fragment, { children: [
5401
- /* @__PURE__ */ jsx(
5402
- PrimaryButton,
5403
- {
5404
- onClick: handleConfirm,
5405
- disabled: selected == null,
5406
- children: selected == null ? "Select a token" : isAuthorized ? "Select Source" : "Authorize Token"
5407
- }
5408
- ),
5409
- /* @__PURE__ */ jsx(PoweredByFooter, {})
5410
- ] }),
5411
- children: [
5412
- /* @__PURE__ */ jsx(ScreenHeader, { title: "Select Token", onBack }),
5413
- /* @__PURE__ */ jsx("p", { style: subtitleStyle9(themeTokens.textSecondary), children: "Choose a token to deposit with. Tokens that haven't been authorized yet will require a one-time wallet approval." }),
5414
- /* @__PURE__ */ jsx("div", { style: chainListStyle2, children: [...chainGroups.entries()].map(([chainName, chainEntries]) => {
5415
- const isExpanded = expandedChain === chainName;
5416
- const chainTotal = chainEntries.reduce((sum, e) => sum + e.balance, 0);
5417
- return /* @__PURE__ */ jsxs("div", { style: chainCardStyle2(themeTokens), children: [
5418
- /* @__PURE__ */ jsxs(
5419
- "button",
5420
- {
5421
- type: "button",
5422
- onClick: () => setExpandedChain((prev) => prev === chainName ? null : chainName),
5423
- style: chainHeaderStyle2(themeTokens),
5424
- children: [
5425
- /* @__PURE__ */ jsxs("div", { style: chainHeaderLeftStyle2, children: [
5426
- /* @__PURE__ */ jsx("span", { style: chainNameStyle2(themeTokens.text), children: chainName }),
5427
- /* @__PURE__ */ jsxs("span", { style: chainBalanceStyle2(themeTokens.textMuted), children: [
5428
- "$",
5429
- chainTotal.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
5430
- ] })
5431
- ] }),
5432
- /* @__PURE__ */ jsx("span", { style: chevronStyle(themeTokens.textMuted), children: isExpanded ? "\u25BE" : "\u25B8" })
5433
- ]
5434
- }
5435
- ),
5436
- isExpanded && /* @__PURE__ */ jsx("div", { style: tokenListStyle2, children: chainEntries.map((entry) => {
5437
- const globalIdx = entries.indexOf(entry);
5438
- const isSelected = selectedIndex === globalIdx;
5439
- const authorized = entry.status === "AUTHORIZED";
5440
- return /* @__PURE__ */ jsxs(
5441
- "button",
5442
- {
5443
- type: "button",
5444
- onClick: () => setSelectedIndex(globalIdx),
5445
- style: tokenRowStyle2(themeTokens, isSelected),
5446
- children: [
5447
- /* @__PURE__ */ jsxs("div", { style: tokenInfoStyle2, children: [
5448
- /* @__PURE__ */ jsxs("div", { style: tokenHeaderRowStyle, children: [
5449
- /* @__PURE__ */ jsx("span", { style: tokenSymbolStyle2(themeTokens.text), children: entry.tokenSymbol }),
5450
- authorized ? /* @__PURE__ */ jsx("span", { style: statusBadgeStyle(themeTokens.success), children: "Authorized" }) : /* @__PURE__ */ jsx("span", { style: statusBadgeStyle(themeTokens.textMuted), children: "Not authorized" })
5451
- ] }),
5452
- /* @__PURE__ */ jsxs("span", { style: tokenBalStyle2(themeTokens.textMuted), children: [
5453
- "$",
5454
- entry.balance.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
5455
- ] })
5456
- ] }),
5457
- /* @__PURE__ */ jsx("div", { style: radioStyle3(themeTokens, isSelected), children: isSelected && /* @__PURE__ */ jsx("div", { style: radioDotStyle3(themeTokens.accent) }) })
5458
- ]
5459
- },
5460
- `${entry.walletId}-${entry.tokenSymbol}`
5461
- );
5462
- }) })
5463
- ] }, chainName);
5464
- }) })
5465
- ]
5466
- }
5467
- );
5382
+ return /* @__PURE__ */ jsxs(ScreenLayout, { footer: /* @__PURE__ */ jsx(PoweredByFooter, {}), children: [
5383
+ /* @__PURE__ */ jsx(ScreenHeader, { onBack }),
5384
+ /* @__PURE__ */ jsx("div", { style: mascotWrapStyle2, children: /* @__PURE__ */ jsx("img", { src: SWYPE_MASCOT, alt: "Swype", style: mascotImgStyle }) }),
5385
+ depositAmount != null && /* @__PURE__ */ jsxs("div", { style: depositCardStyle2(t), children: [
5386
+ /* @__PURE__ */ jsx("div", { style: depositLabelStyle2(t.textMuted), children: "Depositing" }),
5387
+ /* @__PURE__ */ jsxs("div", { style: depositAmountRowStyle, children: [
5388
+ /* @__PURE__ */ jsxs("div", { style: depositAmountStyle(t.text), children: [
5389
+ "$",
5390
+ depositAmount.toLocaleString("en-US", { minimumFractionDigits: 0, maximumFractionDigits: 2 })
5391
+ ] }),
5392
+ /* @__PURE__ */ jsxs("div", { style: tokenIconWrapStyle3, children: [
5393
+ /* @__PURE__ */ jsxs("svg", { width: "32", height: "32", viewBox: "0 0 36 36", fill: "none", children: [
5394
+ /* @__PURE__ */ jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#2DB84B" }),
5395
+ /* @__PURE__ */ jsx("text", { x: "18", y: "23", textAnchor: "middle", fontSize: "18", fill: "#fff", fontWeight: "700", children: "$" })
5396
+ ] }),
5397
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", style: checkBadgeStyle3, children: [
5398
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "8", fill: "#2775CA" }),
5399
+ /* @__PURE__ */ jsx("path", { d: "M5 8l2 2 4-4", stroke: "#fff", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" })
5400
+ ] })
5401
+ ] })
5402
+ ] })
5403
+ ] }),
5404
+ /* @__PURE__ */ jsx("div", { style: sectionLabelStyle(t.textMuted), children: "Choose token" }),
5405
+ /* @__PURE__ */ jsx("div", { style: tokenListStyle2, children: entries.map((entry) => {
5406
+ const authorized = entry.status === "AUTHORIZED";
5407
+ return /* @__PURE__ */ jsxs(
5408
+ "button",
5409
+ {
5410
+ type: "button",
5411
+ onClick: () => handleSelect(entry),
5412
+ style: tokenRowStyle2(t),
5413
+ children: [
5414
+ /* @__PURE__ */ jsx("div", { style: tokenIconCircleStyle(t), children: /* @__PURE__ */ jsx("span", { style: tokenIconTextStyle(t.textMuted), children: "$" }) }),
5415
+ /* @__PURE__ */ jsxs("div", { style: tokenInfoStyle2, children: [
5416
+ /* @__PURE__ */ jsxs("div", { style: tokenNameRowStyle, children: [
5417
+ /* @__PURE__ */ jsx("span", { style: tokenSymbolTextStyle(t.text), children: entry.tokenSymbol }),
5418
+ /* @__PURE__ */ jsx("span", { style: tokenChainDotStyle(t.textMuted), children: "\xB7" }),
5419
+ /* @__PURE__ */ jsx("span", { style: tokenChainTextStyle(t.textMuted), children: entry.chainName })
5420
+ ] }),
5421
+ /* @__PURE__ */ jsxs("div", { style: tokenBalanceRowStyle, children: [
5422
+ /* @__PURE__ */ jsxs("span", { style: tokenBalanceStyle(t.textMuted), children: [
5423
+ "$",
5424
+ entry.balance.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })
5425
+ ] }),
5426
+ !authorized && /* @__PURE__ */ jsx("span", { style: notAuthorizedStyle(t.textMuted), children: "Not authorized" })
5427
+ ] })
5428
+ ] }),
5429
+ /* @__PURE__ */ jsx("div", { style: authorized ? selectCircleSelectedStyle(t.accent) : selectCircleStyle(t.border), children: authorized && /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z", fill: "#fff" }) }) })
5430
+ ]
5431
+ },
5432
+ `${entry.walletId}-${entry.tokenSymbol}-${entry.chainName}`
5433
+ );
5434
+ }) })
5435
+ ] });
5468
5436
  }
5469
- var subtitleStyle9 = (color) => ({
5470
- fontSize: "0.86rem",
5471
- color,
5472
- margin: "0 0 20px",
5473
- lineHeight: 1.5
5474
- });
5475
- var chainListStyle2 = {
5437
+ var mascotWrapStyle2 = {
5476
5438
  display: "flex",
5477
- flexDirection: "column",
5478
- gap: 10
5439
+ justifyContent: "center",
5440
+ marginBottom: 16
5441
+ };
5442
+ var mascotImgStyle = {
5443
+ width: 36,
5444
+ height: 36
5479
5445
  };
5480
- var chainCardStyle2 = (tokens) => ({
5446
+ var depositCardStyle2 = (tokens) => ({
5447
+ background: tokens.bgInput,
5481
5448
  border: `1px solid ${tokens.border}`,
5482
- borderRadius: 14,
5483
- overflow: "hidden",
5484
- background: tokens.bgInput
5449
+ borderRadius: tokens.radiusLg,
5450
+ padding: "16px 20px",
5451
+ marginBottom: 24
5485
5452
  });
5486
- var chainHeaderStyle2 = (tokens) => ({
5487
- display: "flex",
5488
- alignItems: "center",
5489
- justifyContent: "space-between",
5490
- width: "100%",
5491
- padding: "14px 16px",
5492
- background: tokens.bgInput,
5493
- border: "none",
5494
- cursor: "pointer",
5495
- fontFamily: "inherit",
5496
- textAlign: "left"
5453
+ var depositLabelStyle2 = (color) => ({
5454
+ fontSize: "0.75rem",
5455
+ fontWeight: 500,
5456
+ color,
5457
+ marginBottom: 4
5497
5458
  });
5498
- var chainHeaderLeftStyle2 = {
5459
+ var depositAmountRowStyle = {
5499
5460
  display: "flex",
5500
- flexDirection: "column",
5501
- gap: 2
5461
+ alignItems: "center",
5462
+ justifyContent: "space-between"
5502
5463
  };
5503
- var chainNameStyle2 = (color) => ({
5504
- fontSize: "0.92rem",
5505
- fontWeight: 600,
5506
- color
5507
- });
5508
- var chainBalanceStyle2 = (color) => ({
5509
- fontSize: "0.76rem",
5464
+ var depositAmountStyle = (color) => ({
5465
+ fontSize: "2.2rem",
5466
+ fontWeight: 700,
5467
+ letterSpacing: "-0.02em",
5510
5468
  color
5511
5469
  });
5512
- var chevronStyle = (color) => ({
5513
- fontSize: "0.9rem",
5514
- color
5470
+ var tokenIconWrapStyle3 = {
5471
+ position: "relative",
5472
+ width: 32,
5473
+ height: 32,
5474
+ flexShrink: 0
5475
+ };
5476
+ var checkBadgeStyle3 = {
5477
+ position: "absolute",
5478
+ bottom: -1,
5479
+ right: -3
5480
+ };
5481
+ var sectionLabelStyle = (color) => ({
5482
+ fontSize: "0.84rem",
5483
+ fontWeight: 500,
5484
+ color,
5485
+ marginBottom: 12
5515
5486
  });
5516
5487
  var tokenListStyle2 = {
5517
- padding: "0 12px 12px",
5518
5488
  display: "flex",
5519
5489
  flexDirection: "column",
5520
- gap: 6
5490
+ gap: 10
5521
5491
  };
5522
- var tokenRowStyle2 = (tokens, selected) => ({
5492
+ var tokenRowStyle2 = (tokens) => ({
5523
5493
  display: "flex",
5524
5494
  alignItems: "center",
5525
- justifyContent: "space-between",
5526
- padding: "12px 14px",
5527
- background: tokens.bgCard,
5528
- border: `1.5px solid ${selected ? tokens.accent : tokens.border}`,
5529
- borderRadius: 10,
5495
+ gap: 14,
5496
+ padding: "14px 16px",
5497
+ background: tokens.bgInput,
5498
+ border: `1px solid ${tokens.border}`,
5499
+ borderRadius: 16,
5530
5500
  cursor: "pointer",
5531
5501
  fontFamily: "inherit",
5532
5502
  textAlign: "left",
5533
- transition: "border-color 0.15s ease"
5503
+ width: "100%"
5504
+ });
5505
+ var tokenIconCircleStyle = (tokens) => ({
5506
+ width: 36,
5507
+ height: 36,
5508
+ borderRadius: "50%",
5509
+ border: `1.5px solid ${tokens.border}`,
5510
+ display: "flex",
5511
+ alignItems: "center",
5512
+ justifyContent: "center",
5513
+ flexShrink: 0
5514
+ });
5515
+ var tokenIconTextStyle = (color) => ({
5516
+ fontSize: "1rem",
5517
+ fontWeight: 700,
5518
+ color
5534
5519
  });
5535
5520
  var tokenInfoStyle2 = {
5536
5521
  display: "flex",
5537
5522
  flexDirection: "column",
5538
- gap: 4,
5539
- flex: 1
5523
+ gap: 2,
5524
+ flex: 1,
5525
+ minWidth: 0
5540
5526
  };
5541
- var tokenHeaderRowStyle = {
5527
+ var tokenNameRowStyle = {
5542
5528
  display: "flex",
5543
5529
  alignItems: "center",
5544
- gap: 8
5530
+ gap: 4
5545
5531
  };
5546
- var tokenSymbolStyle2 = (color) => ({
5547
- fontSize: "0.88rem",
5532
+ var tokenSymbolTextStyle = (color) => ({
5533
+ fontSize: "0.92rem",
5548
5534
  fontWeight: 600,
5549
5535
  color
5550
5536
  });
5551
- var statusBadgeStyle = (color) => ({
5552
- fontSize: "0.65rem",
5553
- fontWeight: 600,
5554
- color,
5555
- border: `1px solid ${color}44`,
5556
- borderRadius: 999,
5557
- padding: "1px 7px",
5558
- letterSpacing: "0.02em"
5537
+ var tokenChainDotStyle = (color) => ({
5538
+ fontSize: "0.8rem",
5539
+ color
5559
5540
  });
5560
- var tokenBalStyle2 = (color) => ({
5561
- fontSize: "0.74rem",
5541
+ var tokenChainTextStyle = (color) => ({
5542
+ fontSize: "0.84rem",
5543
+ fontWeight: 400,
5562
5544
  color
5563
5545
  });
5564
- var radioStyle3 = (tokens, selected) => ({
5565
- width: 20,
5566
- height: 20,
5546
+ var tokenBalanceRowStyle = {
5547
+ display: "flex",
5548
+ alignItems: "center",
5549
+ gap: 8
5550
+ };
5551
+ var tokenBalanceStyle = (color) => ({
5552
+ fontSize: "0.78rem",
5553
+ color
5554
+ });
5555
+ var notAuthorizedStyle = (color) => ({
5556
+ fontSize: "0.7rem",
5557
+ fontWeight: 500,
5558
+ color
5559
+ });
5560
+ var selectCircleStyle = (borderColor) => ({
5561
+ width: 28,
5562
+ height: 28,
5567
5563
  borderRadius: "50%",
5568
- border: `2px solid ${selected ? tokens.accent : tokens.border}`,
5564
+ border: `2px solid ${borderColor}`,
5569
5565
  display: "flex",
5570
5566
  alignItems: "center",
5571
5567
  justifyContent: "center",
5572
5568
  flexShrink: 0
5573
5569
  });
5574
- var radioDotStyle3 = (color) => ({
5575
- width: 10,
5576
- height: 10,
5570
+ var selectCircleSelectedStyle = (color) => ({
5571
+ width: 28,
5572
+ height: 28,
5577
5573
  borderRadius: "50%",
5578
- background: color
5574
+ background: color,
5575
+ border: "none",
5576
+ display: "flex",
5577
+ alignItems: "center",
5578
+ justifyContent: "center",
5579
+ flexShrink: 0
5579
5580
  });
5580
5581
  var LINK_STEPS = /* @__PURE__ */ new Set([
5581
5582
  "create-passkey",
@@ -5831,7 +5832,8 @@ function StepRendererContent({
5831
5832
  chains: state.chains,
5832
5833
  onSelectAuthorized: handlers.onSelectAuthorizedToken,
5833
5834
  onAuthorizeToken: handlers.onAuthorizeToken,
5834
- onBack: () => handlers.onNavigate(state.previousStep === "setup" ? "setup" : "deposit")
5835
+ onBack: () => handlers.onNavigate(state.previousStep === "setup" ? "setup" : "deposit"),
5836
+ depositAmount: depositAmount ?? void 0
5835
5837
  }
5836
5838
  );
5837
5839
  }