{"version":3,"file":"Grid.cjs","sources":["../../../src/components/Grid/Grid.tsx"],"sourcesContent":["import {\n  Box,\n  BoxProps,\n  createVarsResolver,\n  ElementProps,\n  factory,\n  Factory,\n  RaikouSpacing,\n  StyleProp,\n  StylesApiProps,\n  useProps,\n  useRandomClassName,\n  useStyles,\n} from '../../core';\nimport { GridBreakpoints, GridProvider } from './Grid.context';\nimport { GridCol } from './GridCol/GridCol';\nimport { GridVariables } from './GridVariables';\nimport { GridColStyle, GridContainerStyle, GridInnerStyle, GridRootStyle } from './Grid.css';\n\nexport type GridStylesNames = 'root' | 'col' | 'inner' | 'container';\nexport type GridCssVariables = {\n  root: '--grid-justify' | '--grid-align' | '--grid-overflow';\n};\n\nexport interface GridProps extends BoxProps, StylesApiProps<GridFactory>, ElementProps<'div'> {\n  /** Gutter between columns, key of `theme.spacing` or any valid CSS value, `'md'` by default */\n  gutter?: StyleProp<RaikouSpacing>;\n\n  /** Determines whether columns in the last row should expand to fill all available space, `false` by default */\n  grow?: boolean;\n\n  /** Sets `justify-content`, `flex-start` by default */\n  justify?: React.CSSProperties['justifyContent'];\n\n  /** Sets `align-items`, `stretch` by default */\n  align?: React.CSSProperties['alignItems'];\n\n  /** Number of columns in each row, `12` by default */\n  columns?: number;\n\n  /** Sets `overflow` CSS property on the root element, `'visible'` by default */\n  overflow?: React.CSSProperties['overflow'];\n\n  /** Determines typeof of queries that are used for responsive styles, `'media'` by default */\n  type?: 'media' | 'container';\n\n  /** Breakpoints values, only applicable when `type=\"container\"` is set, ignored when `type` is not set or `type=\"media\"` is set. */\n  breakpoints?: GridBreakpoints;\n}\n\nexport type GridFactory = Factory<{\n  props: GridProps;\n  ref: HTMLDivElement;\n  stylesNames: GridStylesNames;\n  vars: GridCssVariables;\n  staticComponents: {\n    Col: typeof GridCol;\n  };\n}>;\n\nconst defaultProps: Partial<GridProps> = {\n  gutter: 'md',\n  grow: false,\n  columns: 12,\n};\n\nconst varsResolver = createVarsResolver<GridFactory>((_, { justify, align, overflow }) => ({\n  root: {\n    '--grid-justify': justify,\n    '--grid-align': align,\n    '--grid-overflow': overflow,\n  },\n}));\n\nexport const Grid = factory<GridFactory>((_props, ref) => {\n  const props = useProps('Grid', defaultProps, _props);\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    unstyled,\n    vars,\n    grow,\n    gutter,\n    columns,\n    align,\n    justify,\n    children,\n    breakpoints,\n    type,\n    ...others\n  } = props;\n\n  const getStyles = useStyles<GridFactory>({\n    name: 'Grid',\n    classes: {\n      root: GridRootStyle,\n      container: GridContainerStyle,\n      inner: GridInnerStyle,\n      col: GridColStyle,\n    },\n    props,\n    className,\n    style,\n    classNames,\n    styles,\n    unstyled,\n    vars,\n    varsResolver,\n  });\n\n  const responsiveClassName = useRandomClassName();\n\n  if (type === 'container' && breakpoints) {\n    return (\n      <GridProvider value={{ getStyles, grow, columns: columns || 12, breakpoints, type }}>\n        <GridVariables selector={`.${responsiveClassName}`} {...props} />\n        <div {...getStyles('container')}>\n          <Box ref={ref} {...getStyles('root', { className: responsiveClassName })} {...others}>\n            <div {...getStyles('inner')}>{children}</div>\n          </Box>\n        </div>\n      </GridProvider>\n    );\n  }\n\n  return (\n    <GridProvider value={{ getStyles, grow, columns: columns || 12, breakpoints, type }}>\n      <GridVariables selector={`.${responsiveClassName}`} {...props} />\n      <Box ref={ref} {...getStyles('root', { className: responsiveClassName })} {...others}>\n        <div {...getStyles('inner')}>{children}</div>\n      </Box>\n    </GridProvider>\n  );\n});\n\nGrid.displayName = '@raikou/core/Grid';\nGrid.Col = GridCol;\n"],"names":["createVarsResolver","factory","useProps","useStyles","GridRootStyle","GridContainerStyle","GridInnerStyle","GridColStyle","useRandomClassName","jsxs","GridProvider","jsx","GridVariables","Box","GridCol"],"mappings":";;;;;;;;;;;;;;;;;;AA4DA,MAAM,YAAmC,GAAA;AAAA,EACvC,MAAQ,EAAA,IAAA;AAAA,EACR,IAAM,EAAA,KAAA;AAAA,EACN,OAAS,EAAA;AACX,CAAA;AA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