UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

37 lines 2.38 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 { Slot } from "../../slot/Slot.js"; import { useRenameCSS, useThemeInternal } from "../../theme/Theme.js"; import { omit } from "../../util/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 themeContext = useThemeInternal(false); const prefix = (themeContext === null || themeContext === void 0 ? void 0 : themeContext.isDarkside) ? "ax" : "a"; const { cn } = useRenameCSS(); const style = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, _style), getResponsiveProps(prefix, `stack`, "gap", "spacing", gap)), getResponsiveValue(prefix, `stack`, "direction", direction)), getResponsiveValue(prefix, `stack`, "align", align)), getResponsiveValue(prefix, `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: cn("navds-stack", className, { "navds-vstack": direction === "column", "navds-hstack": direction === "row", "navds-stack-gap": gap, "navds-stack-align": align, "navds-stack-justify": justify, "navds-stack-direction": direction, "navds-stack-wrap": wrap, }) }), children))); }); export default Stack; //# sourceMappingURL=Stack.js.map