@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
1 lines • 2.52 kB
Source Map (JSON)
{"version":3,"file":"simple-grid.cjs","names":["createComponent","simpleGridStyle","Grid"],"sources":["../../../../src/components/simple-grid/simple-grid.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n CSSProps,\n StyleValue,\n ThemeProps,\n WithoutThemeProps,\n} from \"../../core\"\nimport type { GridProps } from \"../grid\"\nimport type { SimpleGridStyle } from \"./simple-grid.style\"\nimport { useMemo } from \"react\"\nimport { createComponent } from \"../../core\"\nimport { replaceObject } from \"../../utils\"\nimport { Grid } from \"../grid\"\nimport { simpleGridStyle } from \"./simple-grid.style\"\n\nexport interface SimpleGridProps\n extends Omit<WithoutThemeProps<GridProps, SimpleGridStyle>, \"columns\">,\n ThemeProps<SimpleGridStyle> {\n /**\n * The number of columns.\n */\n columns?: StyleValue<number>\n /**\n * The width at which child elements will break into columns.\n * Pass a number for pixel values or a string for any other valid CSS length.\n */\n minChildWidth?: CSSProps[\"minWidth\"]\n}\n\nconst {\n PropsContext: SimpleGridPropsContext,\n usePropsContext: useSimpleGridPropsContext,\n withContext,\n} = createComponent<SimpleGridProps, SimpleGridStyle>(\n \"simple-grid\",\n simpleGridStyle,\n)\n\nexport { SimpleGridPropsContext, useSimpleGridPropsContext }\n\n/**\n * `SimpleGrid` is a component that makes `Grid` simpler and more user-friendly.\n *\n * @see https://yamada-ui.com/docs/components/simple-grid\n */\nexport const SimpleGrid = withContext<\"div\", SimpleGridProps>(Grid)(\n undefined,\n ({ columns, minChildWidth, ...rest }) => {\n const templateColumns = useMemo(() => {\n if (minChildWidth) {\n return replaceObject(minChildWidth, (value) => {\n return value != null\n ? `repeat(auto-fit, minmax({sizes.${value}, ${value}}, 1fr))`\n : undefined\n })\n } else {\n return replaceObject(columns, (value) =>\n value != null ? `repeat(${value}, minmax(0, 1fr))` : undefined,\n )\n }\n }, [minChildWidth, columns])\n\n return { templateColumns, ...rest }\n },\n)\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAM,EACJ,cAAc,wBACd,iBAAiB,2BACjB,gBACEA,yCACF,eACAC,0CACD;;;;;;AASD,MAAa,aAAa,YAAoCC,kBAAK,CACjE,SACC,EAAE,SAAS,cAAe,GAAG,WAAW;AAevC,QAAO;EAAE,0CAd6B;AACpC,OAAI,cACF,6DAAqB,gBAAgB,UAAU;AAC7C,WAAO,SAAS,OACZ,kCAAkC,MAAM,IAAI,MAAM,YAClD;KACJ;OAEF,6DAAqB,UAAU,UAC7B,SAAS,OAAO,UAAU,MAAM,qBAAqB,OACtD;KAEF,CAAC,eAAe,QAAQ,CAAC;EAEF,GAAG;EAAM;EAEtC"}