UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

60 lines (59 loc) 2.2 kB
"use client"; import { getSpacing } from "../../core/utils/get-size/get-size.mjs"; import { createVarsResolver } from "../../core/styles-api/create-vars-resolver/create-vars-resolver.mjs"; import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs"; import { useStyles } from "../../core/styles-api/use-styles/use-styles.mjs"; import { factory } from "../../core/factory/factory.mjs"; import { Box } from "../../core/Box/Box.mjs"; import { filterFalsyChildren } from "./filter-falsy-children/filter-falsy-children.mjs"; import Group_module_default from "./Group.module.mjs"; import { jsx } from "react/jsx-runtime"; //#region packages/@mantine/core/src/components/Group/Group.tsx const defaultProps = { preventGrowOverflow: true, gap: "md", align: "center", justify: "flex-start", wrap: "wrap" }; const varsResolver = createVarsResolver((_, { grow, preventGrowOverflow, gap, align, justify, wrap }, { childWidth }) => ({ root: { "--group-child-width": grow && preventGrowOverflow ? childWidth : void 0, "--group-gap": getSpacing(gap), "--group-align": align, "--group-justify": justify, "--group-wrap": wrap } })); const Group = factory((_props) => { const props = useProps("Group", defaultProps, _props); const { classNames, className, style, styles, unstyled, children, gap, align, justify, wrap, grow, preventGrowOverflow, vars, variant, __size, mod, attributes, ...others } = props; const filteredChildren = filterFalsyChildren(children); const childrenCount = filteredChildren.length; const resolvedGap = getSpacing(gap ?? "md"); return /* @__PURE__ */ jsx(Box, { ...useStyles({ name: "Group", props, stylesCtx: { childWidth: `calc(${100 / childrenCount}% - (${resolvedGap} - ${resolvedGap} / ${childrenCount}))` }, className, style, classes: Group_module_default, classNames, styles, unstyled, attributes, vars, varsResolver })("root"), variant, mod: [{ grow }, mod], size: __size, ...others, children: filteredChildren }); }); Group.classes = Group_module_default; Group.varsResolver = varsResolver; Group.displayName = "@mantine/core/Group"; //#endregion export { Group }; //# sourceMappingURL=Group.mjs.map