@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 2.14 kB
Source Map (JSON)
{"version":3,"file":"Box.mjs","sourceRoot":"","sources":["../../../src/jsx/components/Box.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAqB;AA0BnD,MAAM,IAAI,GAAG,KAAK,CAAC;AAEnB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,mBAAmB,CAAwB,IAAI,CAAC,CAAC","sourcesContent":["import type { GenericSnapElement, SnapsChildren } from '../component';\nimport { createSnapComponent } from '../component';\n\n/**\n * The props of the {@link Box} component.\n *\n * @property children - The children of the box.\n * @property direction - The direction to stack the components within the box. Defaults to `vertical`.\n * @property alignment - The alignment mode to use within the box. Defaults to `start`.\n * @property crossAlignment - The cross alignment mode to use within the box.\n * @property center - Whether to center the children within the box. Defaults to `false`.\n */\nexport type BoxProps = {\n // We can't use `JSXElement` because it causes a circular reference.\n children: SnapsChildren<GenericSnapElement>;\n direction?: 'vertical' | 'horizontal' | undefined;\n alignment?:\n | 'start'\n | 'center'\n | 'end'\n | 'space-between'\n | 'space-around'\n | undefined;\n crossAlignment?: 'start' | 'center' | 'end';\n center?: boolean | undefined;\n};\n\nconst TYPE = 'Box';\n\n/**\n * A box component, which is used to group multiple components together.\n *\n * @param props - The props of the component.\n * @param props.children - The children of the box.\n * @param props.direction - The direction to stack the components within the box. Defaults to `vertical`.\n * @param props.alignment - The alignment mode to use within the box. Defaults to `start`.\n * @param props.crossAlignment - The cross alignment mode to use within the box.\n * @param props.center - Whether to center the children within the box. Defaults to `false`.\n * @returns A box element.\n * @example\n * <Box>\n * <Text>Hello world!</Text>\n * </Box>\n */\nexport const Box = createSnapComponent<BoxProps, typeof TYPE>(TYPE);\n\n/**\n * A box element.\n *\n * @see Box\n */\nexport type BoxElement = ReturnType<typeof Box>;\n"]}