UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

496 lines (495 loc) 21.9 kB
import React from 'react'; import { ContextProps } from '../../shared/Context'; import { SpacingProps } from '../../shared/types'; import { SkeletonShow } from '../Skeleton'; import { FormStatusIconTypes } from '../FormStatus'; export declare const DefaultIconSize = 16; export declare const DefaultIconSizes: { readonly default: 16; readonly medium: 24; }; export declare const ListDefaultIconSizes: Array<[ ValidIconType, ValidIconNumericSize ]>; export declare const ValidIconType: readonly ["small", "default", "medium", "large", "x-large", "xx-large"]; export type DefaultIconSizes = typeof DefaultIconSizes; export type ValidIconType = (typeof ValidIconType)[number]; export type ValidIconNumericSize = DefaultIconSizes[keyof DefaultIconSizes]; /** For internal usage */ type IconType = string | React.ReactElement<SVGElement> | ((props?: unknown) => JSX.Element) | false; /** For external usage */ export type IconIcon = IconType | FormStatusIconTypes | React.FC<unknown>; export type IconSize = ValidIconNumericSize | `${ValidIconNumericSize | number}` | ValidIconType | 'auto' | 'basis'; export type IconColor = string | number | { [key: string]: string | number; }; export type IconProps = { /** * A React SVG Component. */ icon?: IconIcon; /** * The dimension of the icon. This will be the `viewBox` and represent `width` and `height`. Defaults to `16`. You can use `small`,`medium`, `large` or `auto`. Auto will enable that the icon size gets inherited by the parent HTML element if it provides a `font-size`. */ size?: IconSize; /** * The color can be any valid color property, such as Hex, RGB or preferable – any CSS variable from the <a href="/uilib/usage/customisation/colors">colors table</a>, e.g. `var(--color-ocean-green)`. Default is no color, which means `--color-black-80`. */ color?: IconColor; /** * Defaults to `true`. Set to `false` if you do not want to inherit the color by `currentColor`. */ inheritColor?: boolean; /** @deprecated Use `inheritColor` instead */ inherit_color?: boolean; /** * The alternative label (text version) of the icon. Defaults to the imported icon name. */ alt?: string; /** * Use a title to provide extra information about the icon used. */ title?: string; /** * If set to `true`, an overlaying skeleton with animation will be shown. */ skeleton?: SkeletonShow; /** * Modifier class to define. Will result in: `dnb-icon--${modifier}`. */ modifier?: string; border?: boolean; width?: `${IconSize}` | `${number}%` | number; height?: `${IconSize}` | `${number}%` | number; children?: IconIcon; }; export type IconAllProps = IconProps & SpacingProps & Omit<React.HTMLProps<HTMLElement>, 'size' | 'children'>; declare function Icon(localProps: IconAllProps): import("react/jsx-runtime").JSX.Element; declare namespace Icon { var _supportsSpacingProps: boolean; } export default Icon; export declare function getIconNameFromComponent(icon: IconProps['icon']): string; export declare function calcSize(props: IconProps): { iconParams: { height?: number | `${number}` | "default" | "small" | "auto" | "medium" | "large" | "x-large" | "xx-large" | "basis" | `${number}%`; width?: number | `${number}` | "default" | "small" | "auto" | "medium" | "large" | "x-large" | "xx-large" | "basis" | `${number}%`; color?: IconColor; }; sizeAsInt: -1 | ValidIconNumericSize; sizeAsString: any; }; export declare function prepareIcon(props: IconAllProps, context: ContextProps): { icon: any; alt: string; iconParams: { height?: number | `${number}` | "default" | "small" | "auto" | "medium" | "large" | "x-large" | "xx-large" | "basis" | `${number}%`; width?: number | `${number}` | "default" | "small" | "auto" | "medium" | "large" | "x-large" | "xx-large" | "basis" | `${number}%`; color?: IconColor; }; wrapperParams: any; /** * The dimension of the icon. This will be the `viewBox` and represent `width` and `height`. Defaults to `16`. You can use `small`,`medium`, `large` or `auto`. Auto will enable that the icon size gets inherited by the parent HTML element if it provides a `font-size`. */ size?: IconSize; /** * The color can be any valid color property, such as Hex, RGB or preferable – any CSS variable from the <a href="/uilib/usage/customisation/colors">colors table</a>, e.g. `var(--color-ocean-green)`. Default is no color, which means `--color-black-80`. */ color?: IconColor & string; /** * Defaults to `true`. Set to `false` if you do not want to inherit the color by `currentColor`. */ inheritColor?: boolean; /** @deprecated Use `inheritColor` instead */ inherit_color?: boolean; /** * Use a title to provide extra information about the icon used. */ title?: string; /** * If set to `true`, an overlaying skeleton with animation will be shown. */ skeleton?: boolean; /** * Modifier class to define. Will result in: `dnb-icon--${modifier}`. */ modifier?: string; border?: boolean; width?: number | `${number}` | "default" | "small" | "auto" | "medium" | "large" | "x-large" | "xx-large" | "basis" | `${number}%`; height?: number | `${number}` | "default" | "small" | "auto" | "medium" | "large" | "x-large" | "xx-large" | "basis" | `${number}%`; children?: IconIcon; top?: import("../space/types").SpaceType; right?: import("../space/types").SpaceType; bottom?: import("../space/types").SpaceType; left?: import("../space/types").SpaceType; space?: import("../space/types").SpaceTypeAll; innerSpace?: import("../space/types").SpaceTypeAll | import("../space/types").SpaceTypeMedia; async?: boolean; default?: boolean; cite?: string; data?: string; form?: string; label?: string; slot?: string; span?: number; style?: React.CSSProperties; summary?: string; pattern?: string; dir?: string; role?: React.AriaRole; 'aria-hidden'?: boolean | "true" | "false"; accessKey?: string; key?: React.Key; value?: string | number | readonly string[]; 'aria-labelledby'?: string; 'aria-describedby'?: string; 'aria-details'?: string; 'aria-disabled'?: boolean | "true" | "false"; tabIndex?: number; ref?: React.LegacyRef<HTMLElement>; required?: boolean; defaultChecked?: boolean; defaultValue?: string | number | readonly string[]; suppressContentEditableWarning?: boolean; suppressHydrationWarning?: boolean; autoFocus?: boolean; className?: string; contentEditable?: "inherit" | (boolean | "true" | "false"); contextMenu?: string; draggable?: boolean | "true" | "false"; hidden?: boolean; id?: string; lang?: string; nonce?: string; placeholder?: string; spellCheck?: boolean | "true" | "false"; translate?: "yes" | "no"; radioGroup?: string; about?: string; content?: string; datatype?: string; inlist?: any; prefix?: string; property?: string; rel?: string; resource?: string; rev?: string; typeof?: string; vocab?: string; autoCapitalize?: string; autoCorrect?: string; autoSave?: string; itemProp?: string; itemScope?: boolean; itemType?: string; itemID?: string; itemRef?: string; results?: number; security?: string; unselectable?: "off" | "on"; inputMode?: "search" | "text" | "none" | "tel" | "url" | "email" | "numeric" | "decimal"; is?: string; 'aria-activedescendant'?: string; 'aria-atomic'?: boolean | "true" | "false"; 'aria-autocomplete'?: "none" | "list" | "inline" | "both"; 'aria-braillelabel'?: string; 'aria-brailleroledescription'?: string; 'aria-busy'?: boolean | "true" | "false"; 'aria-checked'?: boolean | "true" | "false" | "mixed"; 'aria-colcount'?: number; 'aria-colindex'?: number; 'aria-colindextext'?: string; 'aria-colspan'?: number; 'aria-controls'?: string; 'aria-current'?: boolean | "time" | "true" | "false" | "page" | "step" | "location" | "date"; 'aria-description'?: string; 'aria-dropeffect'?: "copy" | "link" | "none" | "execute" | "move" | "popup"; 'aria-errormessage'?: string; 'aria-expanded'?: boolean | "true" | "false"; 'aria-flowto'?: string; 'aria-grabbed'?: boolean | "true" | "false"; 'aria-haspopup'?: boolean | "dialog" | "menu" | "true" | "false" | "grid" | "listbox" | "tree"; 'aria-invalid'?: boolean | "true" | "false" | "grammar" | "spelling"; 'aria-keyshortcuts'?: string; 'aria-label'?: string; 'aria-level'?: number; 'aria-live'?: "off" | "assertive" | "polite"; 'aria-modal'?: boolean | "true" | "false"; 'aria-multiline'?: boolean | "true" | "false"; 'aria-multiselectable'?: boolean | "true" | "false"; 'aria-orientation'?: "horizontal" | "vertical"; 'aria-owns'?: string; 'aria-placeholder'?: string; 'aria-posinset'?: number; 'aria-pressed'?: boolean | "true" | "false" | "mixed"; 'aria-readonly'?: boolean | "true" | "false"; 'aria-relevant'?: "text" | "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals"; 'aria-required'?: boolean | "true" | "false"; 'aria-roledescription'?: string; 'aria-rowcount'?: number; 'aria-rowindex'?: number; 'aria-rowindextext'?: string; 'aria-rowspan'?: number; 'aria-selected'?: boolean | "true" | "false"; 'aria-setsize'?: number; 'aria-sort'?: "other" | "none" | "ascending" | "descending"; 'aria-valuemax'?: number; 'aria-valuemin'?: number; 'aria-valuenow'?: number; 'aria-valuetext'?: string; dangerouslySetInnerHTML?: { __html: string | TrustedHTML; }; onCopy?: React.ClipboardEventHandler<HTMLElement>; onCopyCapture?: React.ClipboardEventHandler<HTMLElement>; onCut?: React.ClipboardEventHandler<HTMLElement>; onCutCapture?: React.ClipboardEventHandler<HTMLElement>; onPaste?: React.ClipboardEventHandler<HTMLElement>; onPasteCapture?: React.ClipboardEventHandler<HTMLElement>; onCompositionEnd?: React.CompositionEventHandler<HTMLElement>; onCompositionEndCapture?: React.CompositionEventHandler<HTMLElement>; onCompositionStart?: React.CompositionEventHandler<HTMLElement>; onCompositionStartCapture?: React.CompositionEventHandler<HTMLElement>; onCompositionUpdate?: React.CompositionEventHandler<HTMLElement>; onCompositionUpdateCapture?: React.CompositionEventHandler<HTMLElement>; onFocus?: React.FocusEventHandler<HTMLElement>; onFocusCapture?: React.FocusEventHandler<HTMLElement>; onBlur?: React.FocusEventHandler<HTMLElement>; onBlurCapture?: React.FocusEventHandler<HTMLElement>; onChange?: React.FormEventHandler<HTMLElement>; onChangeCapture?: React.FormEventHandler<HTMLElement>; onBeforeInput?: React.FormEventHandler<HTMLElement>; onBeforeInputCapture?: React.FormEventHandler<HTMLElement>; onInput?: React.FormEventHandler<HTMLElement>; onInputCapture?: React.FormEventHandler<HTMLElement>; onReset?: React.FormEventHandler<HTMLElement>; onResetCapture?: React.FormEventHandler<HTMLElement>; onSubmit?: React.FormEventHandler<HTMLElement>; onSubmitCapture?: React.FormEventHandler<HTMLElement>; onInvalid?: React.FormEventHandler<HTMLElement>; onInvalidCapture?: React.FormEventHandler<HTMLElement>; onLoad?: React.ReactEventHandler<HTMLElement>; onLoadCapture?: React.ReactEventHandler<HTMLElement>; onError?: React.ReactEventHandler<HTMLElement>; onErrorCapture?: React.ReactEventHandler<HTMLElement>; onKeyDown?: React.KeyboardEventHandler<HTMLElement>; onKeyDownCapture?: React.KeyboardEventHandler<HTMLElement>; onKeyPress?: React.KeyboardEventHandler<HTMLElement>; onKeyPressCapture?: React.KeyboardEventHandler<HTMLElement>; onKeyUp?: React.KeyboardEventHandler<HTMLElement>; onKeyUpCapture?: React.KeyboardEventHandler<HTMLElement>; onAbort?: React.ReactEventHandler<HTMLElement>; onAbortCapture?: React.ReactEventHandler<HTMLElement>; onCanPlay?: React.ReactEventHandler<HTMLElement>; onCanPlayCapture?: React.ReactEventHandler<HTMLElement>; onCanPlayThrough?: React.ReactEventHandler<HTMLElement>; onCanPlayThroughCapture?: React.ReactEventHandler<HTMLElement>; onDurationChange?: React.ReactEventHandler<HTMLElement>; onDurationChangeCapture?: React.ReactEventHandler<HTMLElement>; onEmptied?: React.ReactEventHandler<HTMLElement>; onEmptiedCapture?: React.ReactEventHandler<HTMLElement>; onEncrypted?: React.ReactEventHandler<HTMLElement>; onEncryptedCapture?: React.ReactEventHandler<HTMLElement>; onEnded?: React.ReactEventHandler<HTMLElement>; onEndedCapture?: React.ReactEventHandler<HTMLElement>; onLoadedData?: React.ReactEventHandler<HTMLElement>; onLoadedDataCapture?: React.ReactEventHandler<HTMLElement>; onLoadedMetadata?: React.ReactEventHandler<HTMLElement>; onLoadedMetadataCapture?: React.ReactEventHandler<HTMLElement>; onLoadStart?: React.ReactEventHandler<HTMLElement>; onLoadStartCapture?: React.ReactEventHandler<HTMLElement>; onPause?: React.ReactEventHandler<HTMLElement>; onPauseCapture?: React.ReactEventHandler<HTMLElement>; onPlay?: React.ReactEventHandler<HTMLElement>; onPlayCapture?: React.ReactEventHandler<HTMLElement>; onPlaying?: React.ReactEventHandler<HTMLElement>; onPlayingCapture?: React.ReactEventHandler<HTMLElement>; onProgress?: React.ReactEventHandler<HTMLElement>; onProgressCapture?: React.ReactEventHandler<HTMLElement>; onRateChange?: React.ReactEventHandler<HTMLElement>; onRateChangeCapture?: React.ReactEventHandler<HTMLElement>; onResize?: React.ReactEventHandler<HTMLElement>; onResizeCapture?: React.ReactEventHandler<HTMLElement>; onSeeked?: React.ReactEventHandler<HTMLElement>; onSeekedCapture?: React.ReactEventHandler<HTMLElement>; onSeeking?: React.ReactEventHandler<HTMLElement>; onSeekingCapture?: React.ReactEventHandler<HTMLElement>; onStalled?: React.ReactEventHandler<HTMLElement>; onStalledCapture?: React.ReactEventHandler<HTMLElement>; onSuspend?: React.ReactEventHandler<HTMLElement>; onSuspendCapture?: React.ReactEventHandler<HTMLElement>; onTimeUpdate?: React.ReactEventHandler<HTMLElement>; onTimeUpdateCapture?: React.ReactEventHandler<HTMLElement>; onVolumeChange?: React.ReactEventHandler<HTMLElement>; onVolumeChangeCapture?: React.ReactEventHandler<HTMLElement>; onWaiting?: React.ReactEventHandler<HTMLElement>; onWaitingCapture?: React.ReactEventHandler<HTMLElement>; onAuxClick?: React.MouseEventHandler<HTMLElement>; onAuxClickCapture?: React.MouseEventHandler<HTMLElement>; onClick?: React.MouseEventHandler<HTMLElement>; onClickCapture?: React.MouseEventHandler<HTMLElement>; onContextMenu?: React.MouseEventHandler<HTMLElement>; onContextMenuCapture?: React.MouseEventHandler<HTMLElement>; onDoubleClick?: React.MouseEventHandler<HTMLElement>; onDoubleClickCapture?: React.MouseEventHandler<HTMLElement>; onDrag?: React.DragEventHandler<HTMLElement>; onDragCapture?: React.DragEventHandler<HTMLElement>; onDragEnd?: React.DragEventHandler<HTMLElement>; onDragEndCapture?: React.DragEventHandler<HTMLElement>; onDragEnter?: React.DragEventHandler<HTMLElement>; onDragEnterCapture?: React.DragEventHandler<HTMLElement>; onDragExit?: React.DragEventHandler<HTMLElement>; onDragExitCapture?: React.DragEventHandler<HTMLElement>; onDragLeave?: React.DragEventHandler<HTMLElement>; onDragLeaveCapture?: React.DragEventHandler<HTMLElement>; onDragOver?: React.DragEventHandler<HTMLElement>; onDragOverCapture?: React.DragEventHandler<HTMLElement>; onDragStart?: React.DragEventHandler<HTMLElement>; onDragStartCapture?: React.DragEventHandler<HTMLElement>; onDrop?: React.DragEventHandler<HTMLElement>; onDropCapture?: React.DragEventHandler<HTMLElement>; onMouseDown?: React.MouseEventHandler<HTMLElement>; onMouseDownCapture?: React.MouseEventHandler<HTMLElement>; onMouseEnter?: React.MouseEventHandler<HTMLElement>; onMouseLeave?: React.MouseEventHandler<HTMLElement>; onMouseMove?: React.MouseEventHandler<HTMLElement>; onMouseMoveCapture?: React.MouseEventHandler<HTMLElement>; onMouseOut?: React.MouseEventHandler<HTMLElement>; onMouseOutCapture?: React.MouseEventHandler<HTMLElement>; onMouseOver?: React.MouseEventHandler<HTMLElement>; onMouseOverCapture?: React.MouseEventHandler<HTMLElement>; onMouseUp?: React.MouseEventHandler<HTMLElement>; onMouseUpCapture?: React.MouseEventHandler<HTMLElement>; onSelect?: React.ReactEventHandler<HTMLElement>; onSelectCapture?: React.ReactEventHandler<HTMLElement>; onTouchCancel?: React.TouchEventHandler<HTMLElement>; onTouchCancelCapture?: React.TouchEventHandler<HTMLElement>; onTouchEnd?: React.TouchEventHandler<HTMLElement>; onTouchEndCapture?: React.TouchEventHandler<HTMLElement>; onTouchMove?: React.TouchEventHandler<HTMLElement>; onTouchMoveCapture?: React.TouchEventHandler<HTMLElement>; onTouchStart?: React.TouchEventHandler<HTMLElement>; onTouchStartCapture?: React.TouchEventHandler<HTMLElement>; onPointerDown?: React.PointerEventHandler<HTMLElement>; onPointerDownCapture?: React.PointerEventHandler<HTMLElement>; onPointerMove?: React.PointerEventHandler<HTMLElement>; onPointerMoveCapture?: React.PointerEventHandler<HTMLElement>; onPointerUp?: React.PointerEventHandler<HTMLElement>; onPointerUpCapture?: React.PointerEventHandler<HTMLElement>; onPointerCancel?: React.PointerEventHandler<HTMLElement>; onPointerCancelCapture?: React.PointerEventHandler<HTMLElement>; onPointerEnter?: React.PointerEventHandler<HTMLElement>; onPointerEnterCapture?: React.PointerEventHandler<HTMLElement>; onPointerLeave?: React.PointerEventHandler<HTMLElement>; onPointerLeaveCapture?: React.PointerEventHandler<HTMLElement>; onPointerOver?: React.PointerEventHandler<HTMLElement>; onPointerOverCapture?: React.PointerEventHandler<HTMLElement>; onPointerOut?: React.PointerEventHandler<HTMLElement>; onPointerOutCapture?: React.PointerEventHandler<HTMLElement>; onGotPointerCapture?: React.PointerEventHandler<HTMLElement>; onGotPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>; onLostPointerCapture?: React.PointerEventHandler<HTMLElement>; onLostPointerCaptureCapture?: React.PointerEventHandler<HTMLElement>; onScroll?: React.UIEventHandler<HTMLElement>; onScrollCapture?: React.UIEventHandler<HTMLElement>; onWheel?: React.WheelEventHandler<HTMLElement>; onWheelCapture?: React.WheelEventHandler<HTMLElement>; onAnimationStart?: React.AnimationEventHandler<HTMLElement>; onAnimationStartCapture?: React.AnimationEventHandler<HTMLElement>; onAnimationEnd?: React.AnimationEventHandler<HTMLElement>; onAnimationEndCapture?: React.AnimationEventHandler<HTMLElement>; onAnimationIteration?: React.AnimationEventHandler<HTMLElement>; onAnimationIterationCapture?: React.AnimationEventHandler<HTMLElement>; onTransitionEnd?: React.TransitionEventHandler<HTMLElement>; onTransitionEndCapture?: React.TransitionEventHandler<HTMLElement>; start?: number; list?: string; step?: string | number; shape?: string; as?: string; accept?: string; acceptCharset?: string; action?: string; allowFullScreen?: boolean; allowTransparency?: boolean; autoComplete?: string; autoPlay?: boolean; capture?: boolean | "user" | "environment"; cellPadding?: string | number; cellSpacing?: string | number; charSet?: string; challenge?: string; checked?: boolean; classID?: string; cols?: number; colSpan?: number; controls?: boolean; coords?: string; crossOrigin?: "" | "anonymous" | "use-credentials"; dateTime?: string; defer?: boolean; disabled?: boolean; download?: any; encType?: string; formAction?: string; formEncType?: string; formMethod?: string; formNoValidate?: boolean; formTarget?: string; frameBorder?: string | number; headers?: string; high?: number; href?: string; hrefLang?: string; htmlFor?: string; httpEquiv?: string; integrity?: string; keyParams?: string; keyType?: string; kind?: string; loop?: boolean; low?: number; manifest?: string; marginHeight?: number; marginWidth?: number; max?: string | number; maxLength?: number; media?: string; mediaGroup?: string; method?: string; min?: string | number; minLength?: number; multiple?: boolean; muted?: boolean; name?: string; noValidate?: boolean; open?: boolean; optimum?: number; playsInline?: boolean; poster?: string; preload?: string; readOnly?: boolean; reversed?: boolean; rows?: number; rowSpan?: number; sandbox?: string; scope?: string; scoped?: boolean; scrolling?: string; seamless?: boolean; selected?: boolean; sizes?: string; src?: string; srcDoc?: string; srcLang?: string; srcSet?: string; target?: string; type?: string; useMap?: string; wmode?: string; wrap?: string; }; export declare function prerenderIcon(props: IconProps & { listOfIcons?: Record<string, IconIcon>; }): any;