@namehash/namehash-ui 1.4.0 → 1.5.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/index.d.ts CHANGED
@@ -1,5 +1,357 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ChainId, UnixTimestamp, Duration, Name, Identity, ENSNamespaceId as ENSNamespaceId$1, UnresolvedIdentity, NamedRegistrarAction } from '@ensnode/ensnode-sdk';
3
+ import * as React from 'react';
4
+ import React__default, { SVGProps, PropsWithChildren, ReactNode } from 'react';
5
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
6
+ import { LucideIcon } from 'lucide-react';
7
+ import { Address, Hash } from 'viem';
8
+ import { ENSNamespaceId } from '@ensnode/datasources';
9
+ import * as class_variance_authority_types from 'class-variance-authority/types';
10
+ import { VariantProps } from 'class-variance-authority';
2
11
 
3
- declare const Placeholder: () => react_jsx_runtime.JSX.Element;
12
+ interface ChainIconProps {
13
+ chainId: ChainId;
14
+ width?: number;
15
+ height?: number;
16
+ }
17
+ /**
18
+ * Renders an icon for the provided chain ID.
19
+ */
20
+ declare function ChainIcon({ chainId, width, height }: ChainIconProps): react_jsx_runtime.JSX.Element;
4
21
 
5
- export { Placeholder };
22
+ interface ChainNameProps {
23
+ chainId: ChainId;
24
+ className: string;
25
+ }
26
+ /**
27
+ * Renders a prettified chain name for the provided {@link ChainId}.
28
+ */
29
+ declare const ChainName: ({ chainId, className }: ChainNameProps) => react_jsx_runtime.JSX.Element;
30
+
31
+ /**
32
+ * Client-only absolute time component
33
+ */
34
+ declare function AbsoluteTime({ timestamp, options, }: {
35
+ timestamp: UnixTimestamp;
36
+ options: Intl.DateTimeFormatOptions;
37
+ }): react_jsx_runtime.JSX.Element;
38
+
39
+ /**
40
+ * Display Duration component
41
+ */
42
+ declare function DisplayDuration({ duration }: {
43
+ duration: Duration;
44
+ }): string;
45
+
46
+ declare function TooltipContent({ className, sideOffset, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime.JSX.Element;
47
+
48
+ /**
49
+ * Formats a Unix timestamp as its relative distance with now
50
+ *
51
+ * @param timestamp - the timestamp to format as a relative time
52
+ * @param enforcePast - if true, enforces that the return value won't relate to the future.
53
+ * Helpful for UI contexts where it's nonsensical for a value to relate to the future. Ex: how long ago an event happened.
54
+ * Note how different systems may have misaligned clocks. `enforcePast` aims to protect from UI confusion when
55
+ * the client's clock is set incorrectly in the past, such that events happening "now" might otherwise appear to
56
+ * be coming from the future.
57
+ * @param includeSeconds - if true includes seconds in the result
58
+ * @param conciseFormatting - if true removes special prefixes / suffixes such as "about ..." or "in almost ..."
59
+ * @param relativeTo - if defined represents the timestamp to compare with. Otherwise, the timestamp param is compared with the present.
60
+ */
61
+ declare function formatRelativeTime(timestamp: UnixTimestamp, enforcePast?: boolean, includeSeconds?: boolean, conciseFormatting?: boolean, relativeTo?: UnixTimestamp): string;
62
+ /**
63
+ * Client-only relative time component
64
+ */
65
+ declare function RelativeTime({ timestamp, enforcePast, includeSeconds, conciseFormatting, tooltipPosition, tooltipStyles, relativeTo, prefix, contentWrapper, }: {
66
+ timestamp: UnixTimestamp;
67
+ enforcePast?: boolean;
68
+ includeSeconds?: boolean;
69
+ conciseFormatting?: boolean;
70
+ tooltipPosition?: React.ComponentProps<typeof TooltipContent>["side"];
71
+ tooltipStyles?: string;
72
+ relativeTo?: UnixTimestamp;
73
+ prefix?: string;
74
+ /**
75
+ * A component to be rendered as a wrapper for the Relative Time component content.
76
+ */
77
+ contentWrapper?: ({ children }: React.PropsWithChildren) => React.ReactNode;
78
+ }): react_jsx_runtime.JSX.Element;
79
+
80
+ declare function Footer(): react_jsx_runtime.JSX.Element;
81
+
82
+ declare const ChainExplorerIcon: LucideIcon;
83
+
84
+ declare const EnsIcon: LucideIcon;
85
+
86
+ declare const EnsServiceProviderIcon: (props: React__default.SVGAttributes<SVGElement>) => react_jsx_runtime.JSX.Element;
87
+
88
+ declare const InfoIcon: (props: SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
89
+
90
+ declare const EfpIcon: (props: React__default.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
91
+
92
+ declare const EmailIcon: (props: React__default.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
93
+
94
+ declare const FarcasterIcon: (props: React__default.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
95
+
96
+ declare const GitHubIcon: (props: React__default.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
97
+
98
+ declare const TelegramIcon: (props: React__default.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
99
+
100
+ declare const TwitterIcon: (props: React__default.SVGProps<SVGSVGElement>) => react_jsx_runtime.JSX.Element;
101
+
102
+ interface AddressDisplayProps {
103
+ address: Address;
104
+ className?: string;
105
+ }
106
+ /**
107
+ * Displays a truncated checksummed address without any navigation.
108
+ * Pure display component for showing addresses.
109
+ */
110
+ declare function AddressDisplay({ address, className }: AddressDisplayProps): react_jsx_runtime.JSX.Element;
111
+
112
+ interface EnsAvatarProps {
113
+ name: Name;
114
+ namespaceId: ENSNamespaceId;
115
+ className?: string;
116
+ isSquare?: boolean;
117
+ }
118
+ declare const EnsAvatar: ({ name, namespaceId, className, isSquare }: EnsAvatarProps) => react_jsx_runtime.JSX.Element;
119
+
120
+ interface IdentityLinkDetails {
121
+ isExternal: boolean;
122
+ link: URL | null;
123
+ }
124
+ interface IdentityLinkProps {
125
+ linkDetails: IdentityLinkDetails;
126
+ className?: string;
127
+ }
128
+ /**
129
+ * Displays an identifier (address or name) with a link to the identity details URL.
130
+ * If the ENS namespace has a known ENS Manager App,
131
+ * includes a link to the view details of the address within that ENS namespace.
132
+ *
133
+ * Can take other components (ex.ChainIcon) as children
134
+ * and display them alongside the link as one common interaction area.
135
+ */
136
+ declare function IdentityLink({ linkDetails, className, children, }: PropsWithChildren<IdentityLinkProps>): react_jsx_runtime.JSX.Element;
137
+ interface IdentityTooltipProps {
138
+ identity: Identity;
139
+ namespaceId: ENSNamespaceId$1;
140
+ }
141
+ /**
142
+ * On hover displays details on how the primary name for
143
+ * the address of the identity was resolved.
144
+ */
145
+ declare const IdentityTooltip: ({ identity, namespaceId, children, }: PropsWithChildren<IdentityTooltipProps>) => string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
146
+
147
+ interface NameDisplayProps {
148
+ name: Name;
149
+ className?: string;
150
+ }
151
+ /**
152
+ * Displays an ENS name in beautified form.
153
+ *
154
+ * @param name - The name to display in beautified form.
155
+ *
156
+ */
157
+ declare function NameDisplay({ name, className }: NameDisplayProps): react_jsx_runtime.JSX.Element;
158
+
159
+ interface ResolveAndDisplayIdentityProps {
160
+ identity: UnresolvedIdentity;
161
+ namespaceId: ENSNamespaceId$1;
162
+ accelerate?: boolean;
163
+ withLink?: boolean;
164
+ identityLinkDetails?: IdentityLinkDetails;
165
+ withTooltip?: boolean;
166
+ withAvatar?: boolean;
167
+ withIdentifier?: boolean;
168
+ className?: string;
169
+ }
170
+ /**
171
+ * Resolves the provided `UnresolvedIdentity` through ENSNode and displays the result.
172
+ *
173
+ * @param identity - The `UnresolvedIdentity` to resolve and display.
174
+ * @param namespaceId - The ENSNamespace identifier (e.g. 'mainnet', 'sepolia', 'ens-test-env')
175
+ * @param accelerate - Whether to attempt Protocol Acceleration (default: false)
176
+ * when resolving the primary name.
177
+ * @param withLink - Whether to wrap the displayed identity in an `IdentityLink` component.
178
+ * @param identityLinkDetails - If the `withLink` is true, provides info on where should it lead and should it be an external link.
179
+ * @param withTooltip - Whether to wrap the displayed identity in an `IdentityInfoTooltip` component.
180
+ * @param withAvatar - Whether to display an avatar image.
181
+ * @param withIdentifier - Whether to display identity's textual identifier (address or name).
182
+ * @param className - The class name to apply to the displayed identity.
183
+ */
184
+ declare function ResolveAndDisplayIdentity({ identity, namespaceId, accelerate, withLink, identityLinkDetails, withTooltip, withAvatar, withIdentifier, className, }: ResolveAndDisplayIdentityProps): react_jsx_runtime.JSX.Element;
185
+ interface DisplayIdentityProps {
186
+ identity: Identity;
187
+ namespaceId: ENSNamespaceId$1;
188
+ withLink?: boolean;
189
+ identityLinkDetails?: IdentityLinkDetails;
190
+ withTooltip?: boolean;
191
+ withAvatar?: boolean;
192
+ withIdentifier?: boolean;
193
+ className?: string;
194
+ }
195
+ /**
196
+ * Displays the provided `Identity`.
197
+ *
198
+ * Performs _NO_ resolution if the provided `identity` is not already a `ResolvedIdentity`.
199
+ *
200
+ * @param identity - The identity to display. May be a `ResolvedIdentity` or an `UnresolvedIdentity`.
201
+ * If not a `ResolvedIdentity` (and therefore just an `UnresolvedIdentity`) then displays a loading state.
202
+ * @param namespaceId - The ENSNamespace identifier (e.g. 'mainnet', 'sepolia', 'ens-test-env')
203
+ * @param withLink - Whether to wrap the displayed identity in an `IdentityLink` component.
204
+ * @param identityLinkDetails - If the `withLink` is true, provides info on where should it lead and should it be an external link.
205
+ * @param withTooltip - Whether to wrap the displayed identity in an `IdentityInfoTooltip` component.
206
+ * @param withAvatar - Whether to display an avatar image.
207
+ * @param withIdentifier - Whether to display identity's textual identifier (address or name).
208
+ * @param className - The class name to apply to the displayed identity.
209
+ *
210
+ * @throws Error - if `withLink` is true, but no `identityLinkDetails` are provided.
211
+ */
212
+ declare function DisplayIdentity({ identity, namespaceId, withLink, identityLinkDetails, withTooltip, withAvatar, withIdentifier, className, }: DisplayIdentityProps): react_jsx_runtime.JSX.Element;
213
+
214
+ interface RegistrarActionCardLoadingProps {
215
+ showReferrer?: boolean;
216
+ showReferralProgramField?: boolean;
217
+ }
218
+ /**
219
+ * Display Registrar Action Card loading state
220
+ */
221
+ declare function RegistrarActionCardLoading({ showReferrer, showReferralProgramField, }: RegistrarActionCardLoadingProps): react_jsx_runtime.JSX.Element;
222
+ interface RegistrarActionCardProps {
223
+ namespaceId: ENSNamespaceId$1;
224
+ namedRegistrarAction: NamedRegistrarAction;
225
+ now: UnixTimestamp;
226
+ links: {
227
+ name: IdentityLinkDetails;
228
+ registrant: IdentityLinkDetails;
229
+ };
230
+ showReferrer?: boolean;
231
+ referralProgramField?: ReactNode;
232
+ }
233
+ /**
234
+ * Display a single Registrar Action
235
+ */
236
+ declare function RegistrarActionCard({ namespaceId, namedRegistrarAction, now, links, showReferrer, referralProgramField, }: RegistrarActionCardProps): react_jsx_runtime.JSX.Element;
237
+ declare const RegistrarActionCardMemo: React.MemoExoticComponent<typeof RegistrarActionCard>;
238
+
239
+ declare const buttonVariants: (props?: ({
240
+ variant?: "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
241
+ size?: "default" | "sm" | "lg" | "icon" | "icon-sm" | "icon-lg" | null | undefined;
242
+ } & class_variance_authority_types.ClassProp) | undefined) => string;
243
+ interface ButtonProps extends React.ComponentProps<"button">, VariantProps<typeof buttonVariants> {
244
+ asChild?: boolean;
245
+ }
246
+
247
+ interface CopyButtonProps extends Omit<ButtonProps, "onClick"> {
248
+ value: string;
249
+ message?: string;
250
+ showToast?: boolean;
251
+ icon?: React.ReactNode;
252
+ successIcon?: React.ReactNode;
253
+ }
254
+ declare function CopyButton({ value, message, variant, size, showToast, icon, successIcon, className, children, ...props }: CopyButtonProps): react_jsx_runtime.JSX.Element;
255
+
256
+ interface UseNowProps {
257
+ /**
258
+ * Duration after which time value will be refreshed.
259
+ *
260
+ * Defaults to {@link DEFAULT_TIME_TO_REFRESH}.
261
+ */
262
+ timeToRefresh?: Duration;
263
+ }
264
+ /**
265
+ * Use now
266
+ *
267
+ * This hook returns the current system time while following `timeToRefresh` param.
268
+ *
269
+ * @param timeToRefresh Duration after which time value will be refreshed.
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * // `now` will be updated each second (by default)
274
+ * const now = useNow();
275
+ * ```
276
+ * @example
277
+ * ```ts
278
+ * // `now` will be updated each 5 seconds
279
+ * const now = useNow({ timeToRefresh: 5 });
280
+ * ```
281
+ */
282
+ declare function useNow(props?: UseNowProps): UnixTimestamp;
283
+
284
+ /**
285
+ * Gets the "base" block explorer URL for a given {@link ChainId}
286
+ *
287
+ * @returns default block explorer URL for the chain with the provided id,
288
+ * or null if the referenced chain doesn't have a known block explorer
289
+ */
290
+ declare const getBlockExplorerUrl: (chainId: ChainId) => URL | null;
291
+ /**
292
+ * Gets the block explorer URL for a specific address on a specific chainId
293
+ *
294
+ * @returns complete block explorer URL for a specific address on a specific chainId,
295
+ * or null if the referenced chain doesn't have a known block explorer
296
+ */
297
+ declare const getBlockExplorerAddressDetailsUrl: (chainId: ChainId, address: Address) => URL | null;
298
+ /**
299
+ * Gets the block explorer URL for a specific transaction hash on a specific chainId
300
+ *
301
+ * @returns complete block explorer URL for a specific transaction hash on a specific chainId,
302
+ * or null if the referenced chain doesn't have a known block explorer
303
+ */
304
+ declare const getBlockExplorerTransactionDetailsUrl: (chainId: ChainId, transactionHash: Hash) => URL | null;
305
+ /**
306
+ * Gets the block explorer URL for a specific block on a specific chainId
307
+ *
308
+ * @returns complete block explorer URL for a specific block on a specific chainId,
309
+ * or null if the referenced chain doesn't have a known block explorer
310
+ */
311
+ declare const getBlockExplorerBlockUrl: (chainId: ChainId, blockNumber: number) => URL | null;
312
+
313
+ /**
314
+ * Returns a prettified chain name for the provided chain id.
315
+ */
316
+ declare function getChainName(chainId: ChainId): string;
317
+
318
+ /**
319
+ * Get the ENS Manager App URL for the provided namespace.
320
+ *
321
+ * @param {ENSNamespaceId} namespaceId - ENS Namespace identifier
322
+ * @returns ENS Manager App URL for the provided namespace, or null if the provided namespace
323
+ * doesn't have a known ENS Manager App
324
+ */
325
+ declare function getEnsManagerUrl(namespaceId: ENSNamespaceId): URL | null;
326
+ /**
327
+ * Builds the URL of the external ENS Manager App Profile page for a given name and ENS Namespace.
328
+ *
329
+ * @returns URL to the Profile page in the external ENS Manager App for a given name and ENS Namespace,
330
+ * or null if this URL is not known
331
+ */
332
+ declare function getEnsManagerNameDetailsUrl(name: Name, namespaceId: ENSNamespaceId): URL | null;
333
+ /**
334
+ * Get the URL of the address details page in ENS Manager App for a given address and ENS Namespace.
335
+ *
336
+ * @returns URL to the address details page in the ENS Manager App for a given address and ENS
337
+ * Namespace, or null if this URL is not known
338
+ */
339
+ declare function getEnsManagerAddressDetailsUrl(address: Address, namespaceId: ENSNamespaceId): URL | null;
340
+
341
+ /**
342
+ * Build the avatar image URL for a name on the given ENS Namespace that (once fetched) would
343
+ * load the avatar image for the given name from the ENS Metadata Service
344
+ * (https://metadata.ens.domains/docs).
345
+ *
346
+ * The returned URL is dynamically built based on the provided ENS namespace. Not all ENS
347
+ * namespaces are supported by the ENS Metadata Service. Therefore, the returned URL may
348
+ * be null.
349
+ *
350
+ * @param {Name} name - ENS name to build the avatar image URL for
351
+ * @param {ENSNamespaceId} namespaceId - ENS Namespace identifier
352
+ * @returns avatar image URL for the name on the given ENS Namespace, or null if the given
353
+ * ENS namespace is not supported by the ENS Metadata Service
354
+ */
355
+ declare function getEnsMetadataServiceAvatarUrl(name: Name, namespaceId: ENSNamespaceId): URL | null;
356
+
357
+ export { AbsoluteTime, AddressDisplay, ChainExplorerIcon, ChainIcon, type ChainIconProps, ChainName, type ChainNameProps, CopyButton, type CopyButtonProps, DisplayDuration, DisplayIdentity, EfpIcon, EmailIcon, EnsAvatar, EnsIcon, EnsServiceProviderIcon, FarcasterIcon, Footer, GitHubIcon, IdentityLink, type IdentityLinkDetails, IdentityTooltip, type IdentityTooltipProps, InfoIcon, NameDisplay, RegistrarActionCard, RegistrarActionCardLoading, type RegistrarActionCardLoadingProps, RegistrarActionCardMemo, type RegistrarActionCardProps, RelativeTime, ResolveAndDisplayIdentity, type ResolveAndDisplayIdentityProps, TelegramIcon, TwitterIcon, formatRelativeTime, getBlockExplorerAddressDetailsUrl, getBlockExplorerBlockUrl, getBlockExplorerTransactionDetailsUrl, getBlockExplorerUrl, getChainName, getEnsManagerAddressDetailsUrl, getEnsManagerNameDetailsUrl, getEnsManagerUrl, getEnsMetadataServiceAvatarUrl, useNow };