@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
81 lines (80 loc) • 3 kB
TypeScript
/**
* HTML Element
*
*/
import type { AnchorHTMLAttributes, ComponentType, HTMLProps, ReactNode, Ref } from 'react';
import type { IconIcon } from '../icon/Icon';
import type { SkeletonShow } from '../skeleton/Skeleton';
import type { DynamicElement, SpacingProps } from '../../shared/types';
type ReactRouterLink = Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> & {
to: string | {
pathname?: string;
search?: string;
has?: string;
};
};
export type AnchorProps = {
element?: DynamicElement<HTMLAnchorElement | AnchorAllProps> | ComponentType<ReactRouterLink & {
ref?: Ref<HTMLAnchorElement>;
}>;
href?: string;
to?: string;
targetBlankTitle?: string;
target?: string;
tooltip?: ReactNode;
icon?: IconIcon;
iconPosition?: 'left' | 'right';
skeleton?: SkeletonShow;
omitClass?: boolean;
ref?: Ref<HTMLAnchorElement>;
/**
* Removes animations if set to `true`. Defaults to `false`.
*/
noAnimation?: boolean;
/**
* Removes styling if set to `true`. Defaults to `false`.
*/
noStyle?: boolean;
/**
* Removes hover effects if set to `true`. Defaults to `false`.
*/
noHover?: boolean;
/**
* Removes underline if set to `true`. Defaults to `false`.
*/
noUnderline?: boolean;
/**
* Removes icons if set to `true`. Defaults to `false`.
*/
noIcon?: boolean;
/**
* Removes launch icon if set to `true`. Defaults to `false`.
*/
noLaunchIcon?: boolean;
/**
* Disables the Anchor (no navigation, no hover). Keep a short reason nearby (e.g. using the `tooltip` property).
*/
disabled?: boolean;
};
export type AnchorAllProps = AnchorProps & Omit<HTMLProps<HTMLAnchorElement>, 'ref'> & SpacingProps;
export declare function AnchorComponent(localProps: AnchorAllProps): import("react/jsx-runtime").JSX.Element;
declare function Anchor(props: AnchorAllProps): import("react/jsx-runtime").JSX.Element;
export default Anchor;
export declare function scrollToHash(hash: string): {
element: HTMLElement;
};
export declare function pickIcon(icon: any, className?: string): import("react").CElement<any, import("react").Component<any, any, any>>;
export declare const opensNewTab: (target: string, href: string) => boolean;
/**
* Returns true when the given href uses a script-executing protocol
* (`javascript:` or `vbscript:`). Browsers ignore leading control characters
* and whitespace (including tabs and newlines) when resolving the scheme, so
* those are stripped before testing to catch obfuscated values such as
* `java\tscript:alert(1)`.
*
* Only script-executing protocols are blocked. `data:` and `blob:` URLs are
* intentionally left untouched: they have legitimate uses (such as download
* links and inline media), and modern browsers already block top-level `data:`
* navigation triggered by a link click.
*/
export declare function isDangerousHref(href: unknown): boolean;