@openzeppelin/ui-builder-adapter-evm 1.2.0 → 1.3.0

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.js CHANGED
@@ -1907,14 +1907,14 @@ var evmNetworks = [...evmMainnetNetworks, ...evmTestnetNetworks];
1907
1907
  import { Loader2 as Loader23 } from "lucide-react";
1908
1908
  import { useContext as useContext2, useEffect as useEffect4, useRef, useState as useState4 } from "react";
1909
1909
  import { Button as Button4 } from "@openzeppelin/ui-components";
1910
- import { cn as cn4, logger as logger8 } from "@openzeppelin/ui-utils";
1910
+ import { cn as cn4, getWalletButtonSizeProps as getWalletButtonSizeProps2, logger as logger8 } from "@openzeppelin/ui-utils";
1911
1911
 
1912
1912
  // src/wallet/components/connect/ConnectButton.tsx
1913
1913
  import { Loader2, Wallet } from "lucide-react";
1914
1914
  import { useEffect as useEffect3, useState as useState3 } from "react";
1915
1915
  import { Button as Button2 } from "@openzeppelin/ui-components";
1916
1916
  import { useDerivedAccountStatus as useDerivedAccountStatus2, useDerivedConnectStatus as useDerivedConnectStatus2 } from "@openzeppelin/ui-react";
1917
- import { cn } from "@openzeppelin/ui-utils";
1917
+ import { cn, getWalletButtonSizeProps } from "@openzeppelin/ui-utils";
1918
1918
 
1919
1919
  // src/wallet/utils/SafeWagmiComponent.tsx
1920
1920
  import { useEffect, useState } from "react";
@@ -2091,27 +2091,44 @@ var ConnectorDialogContent = ({ open, onOpenChange }) => {
2091
2091
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
2092
2092
  var CustomConnectButton = ({
2093
2093
  className,
2094
+ size,
2095
+ variant,
2096
+ fullWidth,
2094
2097
  hideWhenConnected = true
2095
2098
  }) => {
2096
2099
  const [dialogOpen, setDialogOpen] = useState3(false);
2097
- const unavailableButton = /* @__PURE__ */ jsx3("div", { className: cn("flex items-center", className), children: /* @__PURE__ */ jsxs2(Button2, { disabled: true, variant: "outline", size: "sm", className: "h-8 px-2 text-xs", children: [
2098
- /* @__PURE__ */ jsx3(Wallet, { className: "size-3.5 mr-1" }),
2099
- "Wallet Unavailable"
2100
- ] }) });
2100
+ const sizeProps = getWalletButtonSizeProps(size);
2101
+ const unavailableButton = /* @__PURE__ */ jsx3("div", { className: cn("flex items-center", fullWidth && "w-full", className), children: /* @__PURE__ */ jsxs2(
2102
+ Button2,
2103
+ {
2104
+ disabled: true,
2105
+ variant: variant || "outline",
2106
+ size: sizeProps.size,
2107
+ className: cn(sizeProps.className, fullWidth && "w-full"),
2108
+ children: [
2109
+ /* @__PURE__ */ jsx3(Wallet, { className: cn(sizeProps.iconSize, "mr-1") }),
2110
+ "Wallet Unavailable"
2111
+ ]
2112
+ }
2113
+ ) });
2101
2114
  return /* @__PURE__ */ jsx3(SafeWagmiComponent, { fallback: unavailableButton, children: /* @__PURE__ */ jsx3(
2102
2115
  ConnectButtonContent,
2103
2116
  {
2104
2117
  className,
2118
+ size,
2119
+ variant,
2120
+ fullWidth,
2105
2121
  dialogOpen,
2106
2122
  setDialogOpen,
2107
2123
  hideWhenConnected
2108
2124
  }
2109
2125
  ) });
2110
2126
  };
2111
- var ConnectButtonContent = ({ className, dialogOpen, setDialogOpen, hideWhenConnected }) => {
2127
+ var ConnectButtonContent = ({ className, size, variant, fullWidth, dialogOpen, setDialogOpen, hideWhenConnected }) => {
2112
2128
  const { isConnected } = useDerivedAccountStatus2();
2113
2129
  const { isConnecting: isHookConnecting, error: connectError } = useDerivedConnectStatus2();
2114
2130
  const [isManuallyInitiated, setIsManuallyInitiated] = useState3(false);
2131
+ const sizeProps = getWalletButtonSizeProps(size);
2115
2132
  useEffect3(() => {
2116
2133
  if (isConnected && hideWhenConnected) {
2117
2134
  setDialogOpen(false);
@@ -2138,18 +2155,18 @@ var ConnectButtonContent = ({ className, dialogOpen, setDialogOpen, hideWhenConn
2138
2155
  return null;
2139
2156
  }
2140
2157
  const showButtonLoading = isHookConnecting || isManuallyInitiated;
2141
- return /* @__PURE__ */ jsxs2("div", { className: cn("flex items-center", className), children: [
2158
+ return /* @__PURE__ */ jsxs2("div", { className: cn("flex items-center", fullWidth && "w-full", className), children: [
2142
2159
  /* @__PURE__ */ jsxs2(
2143
2160
  Button2,
2144
2161
  {
2145
2162
  onClick: handleConnectClick,
2146
2163
  disabled: showButtonLoading || isConnected,
2147
- variant: "outline",
2148
- size: "sm",
2149
- className: "h-8 px-2 text-xs",
2164
+ variant: variant || "outline",
2165
+ size: sizeProps.size,
2166
+ className: cn(sizeProps.className, fullWidth && "w-full"),
2150
2167
  title: isConnected ? "Connected" : connectError?.message || "Connect Wallet",
2151
2168
  children: [
2152
- showButtonLoading ? /* @__PURE__ */ jsx3(Loader2, { className: "size-3.5 animate-spin mr-1" }) : /* @__PURE__ */ jsx3(Wallet, { className: "size-3.5 mr-1" }),
2169
+ showButtonLoading ? /* @__PURE__ */ jsx3(Loader2, { className: cn(sizeProps.iconSize, "animate-spin mr-1") }) : /* @__PURE__ */ jsx3(Wallet, { className: cn(sizeProps.iconSize, "mr-1") }),
2153
2170
  showButtonLoading ? "Connecting..." : "Connect Wallet"
2154
2171
  ]
2155
2172
  }
@@ -2173,31 +2190,50 @@ var ConnectButtonContent = ({ className, dialogOpen, setDialogOpen, hideWhenConn
2173
2190
  import { LogOut } from "lucide-react";
2174
2191
  import { Button as Button3 } from "@openzeppelin/ui-components";
2175
2192
  import { useDerivedAccountStatus as useDerivedAccountStatus3, useDerivedDisconnect } from "@openzeppelin/ui-react";
2176
- import { cn as cn2, truncateMiddle } from "@openzeppelin/ui-utils";
2193
+ import { cn as cn2, getWalletAccountDisplaySizeProps, truncateMiddle } from "@openzeppelin/ui-utils";
2177
2194
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
2178
- var CustomAccountDisplay = ({ className }) => {
2179
- return /* @__PURE__ */ jsx4(SafeWagmiComponent, { fallback: null, children: /* @__PURE__ */ jsx4(AccountDisplayContent, { className }) });
2195
+ var CustomAccountDisplay = ({
2196
+ className,
2197
+ size,
2198
+ variant,
2199
+ fullWidth
2200
+ }) => {
2201
+ return /* @__PURE__ */ jsx4(SafeWagmiComponent, { fallback: null, children: /* @__PURE__ */ jsx4(
2202
+ AccountDisplayContent,
2203
+ {
2204
+ className,
2205
+ size,
2206
+ variant,
2207
+ fullWidth
2208
+ }
2209
+ ) });
2180
2210
  };
2181
- var AccountDisplayContent = ({ className }) => {
2211
+ var AccountDisplayContent = ({
2212
+ className,
2213
+ size,
2214
+ variant,
2215
+ fullWidth
2216
+ }) => {
2182
2217
  const { isConnected, address, chainId } = useDerivedAccountStatus3();
2183
2218
  const { disconnect: disconnect2 } = useDerivedDisconnect();
2219
+ const sizeProps = getWalletAccountDisplaySizeProps(size);
2184
2220
  if (!isConnected || !address || !disconnect2) {
2185
2221
  return null;
2186
2222
  }
2187
- return /* @__PURE__ */ jsxs3("div", { className: cn2("flex items-center gap-2", className), children: [
2188
- /* @__PURE__ */ jsxs3("div", { className: "flex flex-col", children: [
2189
- /* @__PURE__ */ jsx4("span", { className: "text-xs font-medium", children: truncateMiddle(address, 4, 4) }),
2190
- /* @__PURE__ */ jsx4("span", { className: "text-[9px] text-muted-foreground -mt-0.5", children: chainId ? `Chain ID: ${chainId}` : "Chain ID: N/A" })
2223
+ return /* @__PURE__ */ jsxs3("div", { className: cn2("flex items-center gap-2", fullWidth && "w-full", className), children: [
2224
+ /* @__PURE__ */ jsxs3("div", { className: cn2("flex flex-col", fullWidth && "flex-1"), children: [
2225
+ /* @__PURE__ */ jsx4("span", { className: cn2(sizeProps.textSize, "font-medium"), children: truncateMiddle(address, 4, 4) }),
2226
+ /* @__PURE__ */ jsx4("span", { className: cn2(sizeProps.subTextSize, "text-muted-foreground -mt-0.5"), children: chainId ? `Chain ID: ${chainId}` : "Chain ID: N/A" })
2191
2227
  ] }),
2192
2228
  /* @__PURE__ */ jsx4(
2193
2229
  Button3,
2194
2230
  {
2195
2231
  onClick: () => disconnect2(),
2196
- variant: "ghost",
2232
+ variant: variant || "ghost",
2197
2233
  size: "icon",
2198
- className: "size-6 p-0",
2234
+ className: cn2(sizeProps.iconButtonSize, "p-0"),
2199
2235
  title: "Disconnect wallet",
2200
- children: /* @__PURE__ */ jsx4(LogOut, { className: "size-3.5" })
2236
+ children: /* @__PURE__ */ jsx4(LogOut, { className: sizeProps.iconSize })
2201
2237
  }
2202
2238
  )
2203
2239
  ] });
@@ -2217,15 +2253,39 @@ import {
2217
2253
  useDerivedChainInfo,
2218
2254
  useDerivedSwitchChainStatus
2219
2255
  } from "@openzeppelin/ui-react";
2220
- import { cn as cn3 } from "@openzeppelin/ui-utils";
2256
+ import {
2257
+ cn as cn3,
2258
+ getWalletNetworkSwitcherSizeProps,
2259
+ getWalletNetworkSwitcherVariantClassName
2260
+ } from "@openzeppelin/ui-utils";
2221
2261
  import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
2222
- var CustomNetworkSwitcher = ({ className }) => {
2223
- return /* @__PURE__ */ jsx5(SafeWagmiComponent, { fallback: null, children: /* @__PURE__ */ jsx5(NetworkSwitcherContent, { className }) });
2262
+ var CustomNetworkSwitcher = ({
2263
+ className,
2264
+ size,
2265
+ variant,
2266
+ fullWidth
2267
+ }) => {
2268
+ return /* @__PURE__ */ jsx5(SafeWagmiComponent, { fallback: null, children: /* @__PURE__ */ jsx5(
2269
+ NetworkSwitcherContent,
2270
+ {
2271
+ className,
2272
+ size,
2273
+ variant,
2274
+ fullWidth
2275
+ }
2276
+ ) });
2224
2277
  };
2225
- var NetworkSwitcherContent = ({ className }) => {
2278
+ var NetworkSwitcherContent = ({
2279
+ className,
2280
+ size,
2281
+ variant,
2282
+ fullWidth
2283
+ }) => {
2226
2284
  const { isConnected } = useDerivedAccountStatus4();
2227
2285
  const { currentChainId, availableChains: unknownChains } = useDerivedChainInfo();
2228
2286
  const { switchChain: switchChain2, isSwitching: isPending, error } = useDerivedSwitchChainStatus();
2287
+ const sizeProps = getWalletNetworkSwitcherSizeProps(size);
2288
+ const variantClassName = getWalletNetworkSwitcherVariantClassName(variant);
2229
2289
  const typedAvailableChains = unknownChains;
2230
2290
  if (!isConnected || !switchChain2 || typedAvailableChains.length === 0) {
2231
2291
  return null;
@@ -2237,7 +2297,7 @@ var NetworkSwitcherContent = ({ className }) => {
2237
2297
  };
2238
2298
  const currentChain = typedAvailableChains.find((chain) => chain.id === currentChainId);
2239
2299
  const currentChainName = currentChain?.name || "Network";
2240
- return /* @__PURE__ */ jsxs4("div", { className: cn3("flex items-center", className), children: [
2300
+ return /* @__PURE__ */ jsxs4("div", { className: cn3("flex items-center", fullWidth && "w-full", className), children: [
2241
2301
  /* @__PURE__ */ jsxs4(
2242
2302
  Select,
2243
2303
  {
@@ -2245,7 +2305,17 @@ var NetworkSwitcherContent = ({ className }) => {
2245
2305
  onValueChange: (value) => handleNetworkChange(Number(value)),
2246
2306
  disabled: isPending || typedAvailableChains.length === 0,
2247
2307
  children: [
2248
- /* @__PURE__ */ jsx5(SelectTrigger, { className: "h-8 text-xs px-2 min-w-[90px] max-w-[120px]", children: /* @__PURE__ */ jsx5(SelectValue, { placeholder: "Network", children: currentChainName }) }),
2308
+ /* @__PURE__ */ jsx5(
2309
+ SelectTrigger,
2310
+ {
2311
+ className: cn3(
2312
+ sizeProps.triggerClassName,
2313
+ variantClassName,
2314
+ fullWidth && "w-full max-w-none"
2315
+ ),
2316
+ children: /* @__PURE__ */ jsx5(SelectValue, { placeholder: "Network", children: currentChainName })
2317
+ }
2318
+ ),
2249
2319
  /* @__PURE__ */ jsx5(
2250
2320
  SelectContent,
2251
2321
  {
@@ -2253,13 +2323,21 @@ var NetworkSwitcherContent = ({ className }) => {
2253
2323
  sideOffset: 5,
2254
2324
  align: "start",
2255
2325
  className: "w-auto min-w-[160px] max-h-[300px]",
2256
- children: typedAvailableChains.map((chain) => /* @__PURE__ */ jsx5(SelectItem, { value: chain.id.toString(), className: "text-xs py-1.5", children: chain.name }, chain.id))
2326
+ children: typedAvailableChains.map((chain) => /* @__PURE__ */ jsx5(
2327
+ SelectItem,
2328
+ {
2329
+ value: chain.id.toString(),
2330
+ className: sizeProps.itemClassName,
2331
+ children: chain.name
2332
+ },
2333
+ chain.id
2334
+ ))
2257
2335
  }
2258
2336
  )
2259
2337
  ]
2260
2338
  }
2261
2339
  ),
2262
- isPending && /* @__PURE__ */ jsx5("span", { className: "text-xs text-muted-foreground ml-2", children: /* @__PURE__ */ jsx5(Loader22, { className: "h-3 w-3 animate-spin" }) }),
2340
+ isPending && /* @__PURE__ */ jsx5("span", { className: "text-muted-foreground ml-2", children: /* @__PURE__ */ jsx5(Loader22, { className: cn3(sizeProps.loaderSize, "animate-spin") }) }),
2263
2341
  error && /* @__PURE__ */ jsx5("span", { className: "text-xs text-red-500 ml-2", children: "!" })
2264
2342
  ] });
2265
2343
  };
@@ -2329,15 +2407,16 @@ var RainbowKitConnectButton = (props) => {
2329
2407
  }
2330
2408
  };
2331
2409
  }, []);
2410
+ const sizeProps = getWalletButtonSizeProps2(props.size);
2332
2411
  const renderLoadingPlaceholder = (message) => /* @__PURE__ */ jsxs5(
2333
2412
  Button4,
2334
2413
  {
2335
2414
  disabled: true,
2336
- variant: "outline",
2337
- size: "sm",
2338
- className: cn4("h-8 px-2 text-xs", props.className),
2415
+ variant: props.variant || "outline",
2416
+ size: sizeProps.size,
2417
+ className: cn4(sizeProps.className, props.fullWidth && "w-full", props.className),
2339
2418
  children: [
2340
- /* @__PURE__ */ jsx6(Loader23, { className: "h-3.5 w-3.5 animate-spin mr-1.5" }),
2419
+ /* @__PURE__ */ jsx6(Loader23, { className: cn4(sizeProps.iconSize, "animate-spin mr-1.5") }),
2341
2420
  message
2342
2421
  ]
2343
2422
  }