@aurora-is-near/intents-swap-widget 2.24.2 → 2.25.1

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/config.d.ts CHANGED
@@ -45,6 +45,7 @@ export declare const useConfig: () => {
45
45
  readonly fetchTargetTokens?: (() => Promise<import('./types/token').SimpleToken[]>) | undefined;
46
46
  readonly alchemyApiKey?: string | undefined;
47
47
  readonly tonCenterApiKey?: string | undefined;
48
+ readonly hideSendAddress?: boolean | undefined;
48
49
  };
49
50
  export declare const WidgetConfigProvider: ({ children, config: userConfig, localisation, rpcs, }: Props) => import("react/jsx-runtime").JSX.Element;
50
51
  export {};
@@ -7,5 +7,5 @@ type Props = {
7
7
  className?: string;
8
8
  onMsg: (msg: Msg) => void;
9
9
  };
10
- export declare const SendAddress: ({ error, className, onMsg }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const SendAddress: ({ error, className, onMsg }: Props) => import("react/jsx-runtime").JSX.Element | null;
11
11
  export {};
@@ -1,42 +1,42 @@
1
- import { jsxs as n, jsx as r } from "react/jsx-runtime";
2
- import * as g from "lucide-react";
3
- import { useEffect as w, useMemo as x } from "react";
4
- import { useNotification as S } from "./useNotification.js";
5
- import { Card as A } from "../../components/Card.js";
6
- import { Input as C } from "../../components/Input.js";
7
- import { Banner as b } from "../../components/Banner.js";
8
- import { Badge as k } from "../../components/Badge.js";
9
- import { b as y, w as N } from "../../config-BfE-vfA3.js";
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
+ import * as w from "lucide-react";
3
+ import { useEffect as x, useMemo as S } from "react";
4
+ import { useNotification as A } from "./useNotification.js";
5
+ import { Card as C } from "../../components/Card.js";
6
+ import { Input as b } from "../../components/Input.js";
7
+ import { Banner as k } from "../../components/Banner.js";
8
+ import { Badge as y } from "../../components/Badge.js";
9
+ import { b as N, w as T } from "../../config-BfE-vfA3.js";
10
10
  import "ethers";
11
11
  import "../../machine/machine.js";
12
12
  import { fireEvent as o } from "../../machine/events/utils/fireEvent.js";
13
- import { useTypedTranslation as T } from "../../localisation.js";
13
+ import { useTypedTranslation as v } from "../../localisation.js";
14
14
  import "../../constants/chains.js";
15
15
  import "viem";
16
- import { cn as v } from "../../utils/cn.js";
17
- const J = ({ error: d, className: i, onMsg: l }) => {
18
- const { t: m } = T(), { ctx: e } = y(), { walletSupportedChains: c, sendAddress: t } = N(), s = S(d), p = e.targetToken && !e.sendAddress && c.includes(e.targetToken.blockchain), f = (h) => {
19
- const a = h.target.value;
20
- o("addressSet", a), l({ type: "on_change_send_address", address: a });
16
+ import { cn as B } from "../../utils/cn.js";
17
+ const K = ({ error: d, className: i, onMsg: l }) => {
18
+ const { t: m } = v(), { ctx: e } = N(), { walletSupportedChains: c, sendAddress: t, hideSendAddress: p } = T(), s = A(d), f = e.targetToken && !e.sendAddress && c.includes(e.targetToken.blockchain), u = (g) => {
19
+ const n = g.target.value;
20
+ o("addressSet", n), l({ type: "on_change_send_address", address: n });
21
21
  };
22
- w(() => {
22
+ x(() => {
23
23
  t && t !== e.sendAddress && o("addressSet", t);
24
24
  }, [t, e.sendAddress]);
25
- const u = x(() => t ? "fixed" : s?.state ?? "default", [s, t]);
26
- return /* @__PURE__ */ n(A, { className: v("gap-sw-lg flex flex-col", i), children: [
25
+ const h = S(() => t ? "fixed" : s?.state ?? "default", [s, t]);
26
+ return p ? null : /* @__PURE__ */ a(C, { className: B("gap-sw-lg flex flex-col", i), children: [
27
27
  /* @__PURE__ */ r("h5", { className: "text-sw-label-m text-sw-gray-50", children: "Send to" }),
28
28
  /* @__PURE__ */ r(
29
- C,
29
+ b,
30
30
  {
31
31
  defaultValue: e.sendAddress,
32
- state: u,
32
+ state: h,
33
33
  placeholder: m(
34
34
  "wallet.recipient.placeholder",
35
35
  "Enter recipient wallet address"
36
36
  ),
37
- onChange: f,
38
- children: !!p && /* @__PURE__ */ n(
39
- k,
37
+ onChange: u,
38
+ children: !!f && /* @__PURE__ */ a(
39
+ y,
40
40
  {
41
41
  isClickable: !0,
42
42
  size: "md",
@@ -44,17 +44,17 @@ const J = ({ error: d, className: i, onMsg: l }) => {
44
44
  className: "absolute right-0",
45
45
  onClick: () => o("addressSet", e.walletAddress ?? ""),
46
46
  children: [
47
- /* @__PURE__ */ r(g.Wand2, { size: 12 }),
47
+ /* @__PURE__ */ r(w.Wand2, { size: 12 }),
48
48
  "My wallet"
49
49
  ]
50
50
  }
51
51
  )
52
52
  }
53
53
  ),
54
- s && /* @__PURE__ */ r(b, { ...s })
54
+ s && /* @__PURE__ */ r(k, { ...s })
55
55
  ] });
56
56
  };
57
57
  export {
58
- J as SendAddress
58
+ K as SendAddress
59
59
  };
60
60
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/features/SendAddress/index.tsx"],"sourcesContent":["import * as Icons from 'lucide-react';\nimport { type ChangeEvent, useEffect, useMemo } from 'react';\n\nimport { useNotification } from './useNotification';\nimport { Card } from '@/components/Card';\nimport { Input } from '@/components/Input';\nimport { Banner } from '@/components/Banner';\nimport { Badge } from '@/components/Badge';\n\nimport { useConfig } from '@/config';\nimport { fireEvent } from '@/machine';\nimport { useTypedTranslation } from '@/localisation';\nimport { useUnsafeSnapshot } from '@/machine/snap';\nimport { cn } from '@/utils';\n\ntype Msg = { type: 'on_change_send_address'; address: string };\n\ntype Props = {\n error?: string;\n className?: string;\n onMsg: (msg: Msg) => void;\n};\n\nexport const SendAddress = ({ error, className, onMsg }: Props) => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n const { walletSupportedChains, sendAddress } = useConfig();\n\n const notification = useNotification(error);\n\n const showMagicButton =\n ctx.targetToken &&\n !ctx.sendAddress &&\n walletSupportedChains.includes(ctx.targetToken.blockchain);\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const address = e.target.value;\n\n fireEvent('addressSet', address);\n onMsg({ type: 'on_change_send_address', address });\n };\n\n // Sync fixed sendAddress with machine state\n useEffect(() => {\n if (sendAddress && sendAddress !== ctx.sendAddress) {\n fireEvent('addressSet', sendAddress);\n }\n }, [sendAddress, ctx.sendAddress]);\n\n const inputState = useMemo(() => {\n if (sendAddress) {\n return 'fixed' as const;\n }\n\n return notification?.state ?? 'default';\n }, [notification, sendAddress]);\n\n return (\n <Card className={cn('gap-sw-lg flex flex-col', className)}>\n <h5 className=\"text-sw-label-m text-sw-gray-50\">Send to</h5>\n <Input\n defaultValue={ctx.sendAddress}\n state={inputState}\n placeholder={t(\n 'wallet.recipient.placeholder',\n 'Enter recipient wallet address',\n )}\n onChange={onChange}>\n {!!showMagicButton && (\n <Badge\n isClickable\n size=\"md\"\n variant=\"primary\"\n className=\"absolute right-0\"\n onClick={() => fireEvent('addressSet', ctx.walletAddress ?? '')}>\n <Icons.Wand2 size={12} />\n My wallet\n </Badge>\n )}\n </Input>\n\n {notification && <Banner {...notification} />}\n </Card>\n );\n};\n"],"names":["SendAddress","error","className","onMsg","t","useTypedTranslation","ctx","useUnsafeSnapshot","walletSupportedChains","sendAddress","useConfig","notification","useNotification","showMagicButton","onChange","e","address","fireEvent","useEffect","inputState","useMemo","Card","cn","jsx","Input","jsxs","Badge","Icons","Banner"],"mappings":";;;;;;;;;;;;;;;;AAuBO,MAAMA,IAAc,CAAC,EAAE,OAAAC,GAAO,WAAAC,GAAW,OAAAC,QAAmB;AACjE,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACR,EAAE,KAAAC,EAAA,IAAQC,EAAA,GACV,EAAE,uBAAAC,GAAuB,aAAAC,EAAA,IAAgBC,EAAA,GAEzCC,IAAeC,EAAgBX,CAAK,GAEpCY,IACJP,EAAI,eACJ,CAACA,EAAI,eACLE,EAAsB,SAASF,EAAI,YAAY,UAAU,GAErDQ,IAAW,CAACC,MAAqC;AACrD,UAAMC,IAAUD,EAAE,OAAO;AAEzB,IAAAE,EAAU,cAAcD,CAAO,GAC/Bb,EAAM,EAAE,MAAM,0BAA0B,SAAAa,EAAA,CAAS;AAAA,EACnD;AAGA,EAAAE,EAAU,MAAM;AACd,IAAIT,KAAeA,MAAgBH,EAAI,eACrCW,EAAU,cAAcR,CAAW;AAAA,EAEvC,GAAG,CAACA,GAAaH,EAAI,WAAW,CAAC;AAEjC,QAAMa,IAAaC,EAAQ,MACrBX,IACK,UAGFE,GAAc,SAAS,WAC7B,CAACA,GAAcF,CAAW,CAAC;AAE9B,2BACGY,GAAA,EAAK,WAAWC,EAAG,2BAA2BpB,CAAS,GACtD,UAAA;AAAA,IAAA,gBAAAqB,EAAC,MAAA,EAAG,WAAU,mCAAkC,UAAA,WAAO;AAAA,IACvD,gBAAAA;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,cAAclB,EAAI;AAAA,QAClB,OAAOa;AAAA,QACP,aAAaf;AAAA,UACX;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,UAAAU;AAAA,QACC,UAAA,CAAC,CAACD,KACD,gBAAAY;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,aAAW;AAAA,YACX,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,SAAS,MAAMT,EAAU,cAAcX,EAAI,iBAAiB,EAAE;AAAA,YAC9D,UAAA;AAAA,cAAA,gBAAAiB,EAACI,EAAM,OAAN,EAAY,MAAM,GAAA,CAAI;AAAA,cAAE;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAE3B;AAAA,IAAA;AAAA,IAIHhB,KAAgB,gBAAAY,EAACK,GAAA,EAAQ,GAAGjB,EAAA,CAAc;AAAA,EAAA,GAC7C;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/features/SendAddress/index.tsx"],"sourcesContent":["import * as Icons from 'lucide-react';\nimport { type ChangeEvent, useEffect, useMemo } from 'react';\n\nimport { useNotification } from './useNotification';\nimport { Card } from '@/components/Card';\nimport { Input } from '@/components/Input';\nimport { Banner } from '@/components/Banner';\nimport { Badge } from '@/components/Badge';\n\nimport { useConfig } from '@/config';\nimport { fireEvent } from '@/machine';\nimport { useTypedTranslation } from '@/localisation';\nimport { useUnsafeSnapshot } from '@/machine/snap';\nimport { cn } from '@/utils';\n\ntype Msg = { type: 'on_change_send_address'; address: string };\n\ntype Props = {\n error?: string;\n className?: string;\n onMsg: (msg: Msg) => void;\n};\n\nexport const SendAddress = ({ error, className, onMsg }: Props) => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n const { walletSupportedChains, sendAddress, hideSendAddress } = useConfig();\n\n const notification = useNotification(error);\n\n const showMagicButton =\n ctx.targetToken &&\n !ctx.sendAddress &&\n walletSupportedChains.includes(ctx.targetToken.blockchain);\n\n const onChange = (e: ChangeEvent<HTMLInputElement>) => {\n const address = e.target.value;\n\n fireEvent('addressSet', address);\n onMsg({ type: 'on_change_send_address', address });\n };\n\n // Sync fixed sendAddress with machine state\n useEffect(() => {\n if (sendAddress && sendAddress !== ctx.sendAddress) {\n fireEvent('addressSet', sendAddress);\n }\n }, [sendAddress, ctx.sendAddress]);\n\n const inputState = useMemo(() => {\n if (sendAddress) {\n return 'fixed' as const;\n }\n\n return notification?.state ?? 'default';\n }, [notification, sendAddress]);\n\n if (hideSendAddress) {\n return null;\n }\n\n return (\n <Card className={cn('gap-sw-lg flex flex-col', className)}>\n <h5 className=\"text-sw-label-m text-sw-gray-50\">Send to</h5>\n <Input\n defaultValue={ctx.sendAddress}\n state={inputState}\n placeholder={t(\n 'wallet.recipient.placeholder',\n 'Enter recipient wallet address',\n )}\n onChange={onChange}>\n {!!showMagicButton && (\n <Badge\n isClickable\n size=\"md\"\n variant=\"primary\"\n className=\"absolute right-0\"\n onClick={() => fireEvent('addressSet', ctx.walletAddress ?? '')}>\n <Icons.Wand2 size={12} />\n My wallet\n </Badge>\n )}\n </Input>\n\n {notification && <Banner {...notification} />}\n </Card>\n );\n};\n"],"names":["SendAddress","error","className","onMsg","t","useTypedTranslation","ctx","useUnsafeSnapshot","walletSupportedChains","sendAddress","hideSendAddress","useConfig","notification","useNotification","showMagicButton","onChange","e","address","fireEvent","useEffect","inputState","useMemo","Card","cn","jsx","Input","jsxs","Badge","Icons","Banner"],"mappings":";;;;;;;;;;;;;;;;AAuBO,MAAMA,IAAc,CAAC,EAAE,OAAAC,GAAO,WAAAC,GAAW,OAAAC,QAAmB;AACjE,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACR,EAAE,KAAAC,EAAA,IAAQC,EAAA,GACV,EAAE,uBAAAC,GAAuB,aAAAC,GAAa,iBAAAC,EAAA,IAAoBC,EAAA,GAE1DC,IAAeC,EAAgBZ,CAAK,GAEpCa,IACJR,EAAI,eACJ,CAACA,EAAI,eACLE,EAAsB,SAASF,EAAI,YAAY,UAAU,GAErDS,IAAW,CAACC,MAAqC;AACrD,UAAMC,IAAUD,EAAE,OAAO;AAEzB,IAAAE,EAAU,cAAcD,CAAO,GAC/Bd,EAAM,EAAE,MAAM,0BAA0B,SAAAc,EAAA,CAAS;AAAA,EACnD;AAGA,EAAAE,EAAU,MAAM;AACd,IAAIV,KAAeA,MAAgBH,EAAI,eACrCY,EAAU,cAAcT,CAAW;AAAA,EAEvC,GAAG,CAACA,GAAaH,EAAI,WAAW,CAAC;AAEjC,QAAMc,IAAaC,EAAQ,MACrBZ,IACK,UAGFG,GAAc,SAAS,WAC7B,CAACA,GAAcH,CAAW,CAAC;AAE9B,SAAIC,IACK,yBAINY,GAAA,EAAK,WAAWC,EAAG,2BAA2BrB,CAAS,GACtD,UAAA;AAAA,IAAA,gBAAAsB,EAAC,MAAA,EAAG,WAAU,mCAAkC,UAAA,WAAO;AAAA,IACvD,gBAAAA;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,cAAcnB,EAAI;AAAA,QAClB,OAAOc;AAAA,QACP,aAAahB;AAAA,UACX;AAAA,UACA;AAAA,QAAA;AAAA,QAEF,UAAAW;AAAA,QACC,UAAA,CAAC,CAACD,KACD,gBAAAY;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,aAAW;AAAA,YACX,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,WAAU;AAAA,YACV,SAAS,MAAMT,EAAU,cAAcZ,EAAI,iBAAiB,EAAE;AAAA,YAC9D,UAAA;AAAA,cAAA,gBAAAkB,EAACI,EAAM,OAAN,EAAY,MAAM,GAAA,CAAI;AAAA,cAAE;AAAA,YAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAE3B;AAAA,IAAA;AAAA,IAIHhB,KAAgB,gBAAAY,EAACK,GAAA,EAAQ,GAAGjB,EAAA,CAAc;AAAA,EAAA,GAC7C;AAEJ;"}
@@ -29,4 +29,5 @@ export type WidgetConfig = {
29
29
  fetchTargetTokens?: () => Promise<SimpleToken[]>;
30
30
  alchemyApiKey?: string;
31
31
  tonCenterApiKey?: string;
32
+ hideSendAddress?: boolean;
32
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aurora-is-near/intents-swap-widget",
3
- "version": "2.24.2",
3
+ "version": "2.25.1",
4
4
  "description": "Provides components and hooks to build your own Intents swap widget",
5
5
  "author": "Maksim Vashchuk",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@ type Props = {
24
24
  export const SendAddress = ({ error, className, onMsg }: Props) => {
25
25
  const { t } = useTypedTranslation();
26
26
  const { ctx } = useUnsafeSnapshot();
27
- const { walletSupportedChains, sendAddress } = useConfig();
27
+ const { walletSupportedChains, sendAddress, hideSendAddress } = useConfig();
28
28
 
29
29
  const notification = useNotification(error);
30
30
 
@@ -55,6 +55,10 @@ export const SendAddress = ({ error, className, onMsg }: Props) => {
55
55
  return notification?.state ?? 'default';
56
56
  }, [notification, sendAddress]);
57
57
 
58
+ if (hideSendAddress) {
59
+ return null;
60
+ }
61
+
58
62
  return (
59
63
  <Card className={cn('gap-sw-lg flex flex-col', className)}>
60
64
  <h5 className="text-sw-label-m text-sw-gray-50">Send to</h5>
@@ -45,4 +45,7 @@ export type WidgetConfig = {
45
45
  // Balance loading
46
46
  alchemyApiKey?: string;
47
47
  tonCenterApiKey?: string;
48
+
49
+ // UI
50
+ hideSendAddress?: boolean;
48
51
  };