1 | import { ComponentType } from 'react';
|
2 | import { AsElementType } from '@instructure/shared-types';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | interface PropsObject {
|
8 | as?: AsElementType;
|
9 | to?: string;
|
10 | href?: string | null;
|
11 | onClick?: ((...args: any) => any) | null;
|
12 | }
|
13 | /**
|
14 | * ---
|
15 | * category: utilities/react
|
16 | * ---
|
17 | * Get the React element type for a component. It uses the following logic:
|
18 | * 1. type defined by the `as` prop
|
19 | * 2. type returned by the `getDefault()` parameter
|
20 | * 3. `<a>` if it has a `href` or `to` prop
|
21 | * 4. `<button>` if it has an `onClick` prop
|
22 | * 5. the component's defaultProp's `as` field
|
23 | * 6. `<span>` if none of the above
|
24 | *
|
25 | * @module getElementType
|
26 | * @param {ComponentType} Component
|
27 | * @param {Object} props
|
28 | * @param {Function} getDefault an optional function that returns the default element type
|
29 | * @returns {String} the element type
|
30 | */
|
31 | declare function getElementType<T extends PropsObject>(Component: Omit<ComponentType<T>, 'propTypes'>, props: T, getDefault?: () => AsElementType<T>): "symbol" | "object" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquote" | "body" | "br" | "button" | "canvas" | "caption" | "center" | "cite" | "code" | "col" | "colgroup" | "data" | "datalist" | "dd" | "del" | "details" | "dfn" | "dialog" | "div" | "dl" | "dt" | "em" | "embed" | "fieldset" | "figcaption" | "figure" | "footer" | "form" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "head" | "header" | "hgroup" | "hr" | "html" | "i" | "iframe" | "img" | "input" | "ins" | "kbd" | "keygen" | "label" | "legend" | "li" | "link" | "main" | "map" | "mark" | "menu" | "menuitem" | "meta" | "meter" | "nav" | "noscript" | "ol" | "optgroup" | "option" | "output" | "p" | "param" | "picture" | "pre" | "progress" | "q" | "rp" | "rt" | "ruby" | "s" | "samp" | "search" | "slot" | "script" | "section" | "select" | "small" | "source" | "span" | "strong" | "style" | "sub" | "summary" | "sup" | "table" | "template" | "tbody" | "td" | "textarea" | "tfoot" | "th" | "thead" | "time" | "title" | "tr" | "track" | "u" | "ul" | "var" | "video" | "wbr" | "webview" | "animate" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "stop" | "svg" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | import("react").FunctionComponent<any> | import("react").ComponentClass<any, any> | "noindex" | "animateMotion" | "animateTransform" | "mpath" | import("react").ComponentClass<T, any> | import("react").FunctionComponent<T> | NonNullable<T["as"]>;
|
32 | export default getElementType;
|
33 | export { getElementType };
|
34 | //# sourceMappingURL=getElementType.d.ts.map |
\ | No newline at end of file |