@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 2.56 kB
Source Map (JSON)
{"version":3,"file":"Text.mjs","sourceRoot":"","sources":["../../../src/jsx/components/Text.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AA0CnD,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAyB,IAAI,CAAC,CAAC","sourcesContent":["import type { StandardFormattingElement } from './formatting';\nimport type { IconElement } from './Icon';\nimport type { LinkElement } from './Link';\nimport type { SkeletonElement } from './Skeleton';\nimport { createSnapComponent } from '../component';\nimport type { SnapsChildren } from '../component';\n\n/**\n * The children of the {@link Text} component.\n */\nexport type TextChildren = SnapsChildren<\n | string\n | StandardFormattingElement\n | LinkElement\n | IconElement\n | SkeletonElement\n>;\n\n/**\n * The colors available to the Text {@link Text} component.\n */\nexport type TextColors =\n | 'default'\n | 'alternative'\n | 'muted'\n | 'error'\n | 'success'\n | 'warning';\n\n/**\n * The props of the {@link Text} component.\n *\n * @property children - The text to display.\n * @property alignment - The alignment of the text.\n * @property color - The color of the text.\n * @property size - The size of the text. Defaults to `md`.\n * @property fontWeight - The font weight of the text. Defaults to `regular`.\n */\nexport type TextProps = {\n children: TextChildren;\n alignment?: 'start' | 'center' | 'end' | undefined;\n color?: TextColors | undefined;\n size?: 'sm' | 'md' | undefined;\n fontWeight?: 'regular' | 'medium' | 'bold' | undefined;\n};\n\nconst TYPE = 'Text';\n\n/**\n * A text component, which is used to display text.\n *\n * @param props - The props of the component.\n * @param props.alignment - The alignment of the text.\n * @param props.color - The color of the text.\n * @param props.children - The text to display.\n * @param props.size - The size of the text. Defaults to `md`.\n * @param props.fontWeight - The font weight of the text. Defaults to `regular`.\n * @returns A text element.\n * @example\n * <Text>\n * Hello <Bold>world</Bold>!\n * </Text>\n * @example\n * <Text alignment=\"end\">\n * Hello <Bold>world</Bold>!\n * </Text>\n * @example\n * <Text size=\"sm\">\n * Hello <Bold>world</Bold>!\n * </Text>\n * @example\n * <Text fontWeight=\"medium\">\n * Hello <Bold>world</Bold>!\n * </Text>\n */\nexport const Text = createSnapComponent<TextProps, typeof TYPE>(TYPE);\n\n/**\n * A text element.\n *\n * @see Text\n */\nexport type TextElement = ReturnType<typeof Text>;\n"]}