@chakra-ui/layout
Version:
Chakra UI layout components that give you massive speed
1 lines • 2.35 kB
Source Map (JSON)
{"version":3,"sources":["../src/box.tsx"],"sourcesContent":["import {\n chakra,\n forwardRef,\n SystemStyleObject,\n HTMLChakraProps,\n} from \"@chakra-ui/system\"\n\nexport interface BoxProps extends HTMLChakraProps<\"div\"> {}\n\n/**\n * Box is the most abstract component on top of which other chakra\n * components are built. It renders a `div` element by default.\n *\n * @see Docs https://chakra-ui.com/box\n */\nexport const Box = chakra(\"div\")\n\nBox.displayName = \"Box\"\n\n/**\n * As a constraint, you can't pass size related props\n * Only `size` would be allowed\n */\ntype Omitted = \"size\" | \"boxSize\" | \"width\" | \"height\" | \"w\" | \"h\"\n\nexport interface SquareProps extends Omit<BoxProps, Omitted> {\n /**\n * The size (width and height) of the square\n */\n size?: BoxProps[\"width\"]\n /**\n * If `true`, the content will be centered in the square\n *\n * @default false\n */\n centerContent?: boolean\n}\n\nexport const Square = forwardRef<SquareProps, \"div\">(function Square(\n props,\n ref,\n) {\n const { size, centerContent = true, ...rest } = props\n\n const styles: SystemStyleObject = centerContent\n ? { display: \"flex\", alignItems: \"center\", justifyContent: \"center\" }\n : {}\n\n return (\n <Box\n ref={ref}\n boxSize={size}\n __css={{\n ...styles,\n flexShrink: 0,\n flexGrow: 0,\n }}\n {...rest}\n />\n )\n})\n\nSquare.displayName = \"Square\"\n\nexport const Circle = forwardRef<SquareProps, \"div\">(function Circle(\n props,\n ref,\n) {\n const { size, ...rest } = props\n return <Square size={size} ref={ref} borderRadius=\"9999px\" {...rest} />\n})\n\nCircle.displayName = \"Circle\"\n"],"mappings":";;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AA4CH;AAlCG,IAAM,MAAM,OAAO,KAAK;AAE/B,IAAI,cAAc;AAqBX,IAAM,SAAS,WAA+B,SAASA,QAC5D,OACA,KACA;AACA,QAAM,EAAE,MAAM,gBAAgB,MAAM,GAAG,KAAK,IAAI;AAEhD,QAAM,SAA4B,gBAC9B,EAAE,SAAS,QAAQ,YAAY,UAAU,gBAAgB,SAAS,IAClE,CAAC;AAEL,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,SAAS;AAAA,MACT,OAAO;AAAA,QACL,GAAG;AAAA,QACH,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ,CAAC;AAED,OAAO,cAAc;AAEd,IAAM,SAAS,WAA+B,SAASC,QAC5D,OACA,KACA;AACA,QAAM,EAAE,MAAM,GAAG,KAAK,IAAI;AAC1B,SAAO,oBAAC,UAAO,MAAY,KAAU,cAAa,UAAU,GAAG,MAAM;AACvE,CAAC;AAED,OAAO,cAAc;","names":["Square","Circle"]}