packageDocumentation module import * as React from "react" ; import { ConditionalStringValue } from "@itwin/appui-abstract" ; import { Icon } from "../icons/IconComponent" ; public export class IconHelper { public static get reactIconKey ( ) : string { return "#-react-iconspec-node-#" ; } param icon param internalData public static getIconReactNode ( icon , internalData ? ) { if ( ! icon ) return null ; if ( React . isValidElement ( icon ) ) return < Icon iconSpec = { icon } />; if ( ! ( icon instanceof ConditionalStringValue ) && typeof icon !== "string" ) return null ; const iconString = ConditionalStringValue . getValue ( icon ) ; if ( ! iconString ) return null ; if ( iconString === IconHelper . reactIconKey ) { if ( internalData ) return < Icon iconSpec = { internalData . get ( IconHelper . reactIconKey ) as React . ReactNode } />; return null ; } return < Icon iconSpec = { iconString } />; } param iconSpec param internalData public static getIconData ( iconSpec , internalData ? ) { const icon = ( React . isValidElement ( iconSpec ) ) ? IconHelper . reactIconKey : iconSpec ; if ( internalData && typeof icon === "string" && icon === IconHelper . reactIconKey ) { internalData . set ( IconHelper . reactIconKey , iconSpec ) ; } if ( typeof icon === "string" || icon instanceof ConditionalStringValue ) return icon ; return "" ; } }