@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 1.81 kB
Source Map (JSON)
{"version":3,"file":"Tooltip.cjs","sourceRoot":"","sources":["../../../src/jsx/components/Tooltip.ts"],"names":[],"mappings":";;;AAKA,gDAAmD;AA2BnD,MAAM,IAAI,GAAG,SAAS,CAAC;AAEvB;;;;;;;;;;;;;;;GAeG;AACU,QAAA,OAAO,GAAG,IAAA,+BAAmB,EAA4B,IAAI,CAAC,CAAC","sourcesContent":["import type { StandardFormattingElement } from './formatting';\nimport type { IconElement } from './Icon';\nimport type { ImageElement } from './Image';\nimport type { LinkElement } from './Link';\nimport type { TextElement } from './Text';\nimport { createSnapComponent } from '../component';\n\nexport type TooltipChildren =\n | TextElement\n | StandardFormattingElement\n | LinkElement\n | ImageElement\n | IconElement\n | boolean\n | null;\n\n/**\n * The props of the {@link Tooltip} component.\n *\n * @property children - The children of the box.\n * @property content - The text to display in the tooltip.\n */\nexport type TooltipProps = {\n children: TooltipChildren;\n content:\n | TextElement\n | StandardFormattingElement\n | LinkElement\n | IconElement\n | string;\n};\n\nconst TYPE = 'Tooltip';\n\n/**\n * A tooltip component, which is used to display text in a tooltip.\n *\n * @param props - The props of the component.\n * @param props.children - The children of the tooltip.\n * @param props.content - The text to display in the tooltip.\n * @returns A tooltip element.\n * @example\n * <Tooltip content=\"Tooltip text\">\n * <Text>Hello world!</Text>\n * </Tooltip>\n * @example\n * <Tooltip content={<Text>Text with <Bold>formatting</Bold></Text>}>\n * <Text>Hello world!</Text>\n * </Tooltip>\n */\nexport const Tooltip = createSnapComponent<TooltipProps, typeof TYPE>(TYPE);\n\n/**\n * A tooltip element.\n *\n * @see Tooltip\n */\nexport type TooltipElement = ReturnType<typeof Tooltip>;\n"]}