UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

34 lines 2.15 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React, { forwardRef } from "react"; import { omit } from "../../utils-external/index.js"; import { Slot } from "../../utils/components/slot/Slot.js"; import { cl } from "../../utils/helpers/index.js"; import BasePrimitive, { PRIMITIVE_PROPS, } from "../base/BasePrimitive.js"; import { getResponsiveProps, getResponsiveValue } from "../utilities/css.js"; export const Stack = forwardRef((_a, ref) => { var { children, className, as: Component = "div", align, justify, wrap = true, gap, style: _style, direction = "row", asChild } = _a, rest = __rest(_a, ["children", "className", "as", "align", "justify", "wrap", "gap", "style", "direction", "asChild"]); const style = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, _style), getResponsiveProps(`stack`, "gap", "space", gap)), getResponsiveValue(`stack`, "direction", direction)), getResponsiveValue(`stack`, "align", align)), getResponsiveValue(`stack`, "justify", justify)); const Comp = asChild ? Slot : Component; return (React.createElement(BasePrimitive, Object.assign({}, rest), React.createElement(Comp, Object.assign({}, omit(rest, PRIMITIVE_PROPS), { ref: ref, style: style, className: cl("aksel-stack", className, { "aksel-vstack": direction === "column", "aksel-hstack": direction === "row", "aksel-stack-gap": gap, "aksel-stack-align": align, "aksel-stack-justify": justify, "aksel-stack-direction": direction, "aksel-stack-wrap": wrap, }) }), children))); }); export default Stack; //# sourceMappingURL=Stack.js.map