@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
73 lines • 3.33 kB
JavaScript
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 } from "../utilities/css.js";
/**
* Foundational Layout-primitive for generic encapsulation & styling.
* @deprecated Deprecated in v8. Use `Box` from '@navikt/ds-react/Box' instead (with same props).
*
* **Run `npx @navikt/aksel@latest codemod v8-box-new` to migrate.**
*
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/box)
* @see 🏷️ {@link BoxProps}
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
*
* @example
* <Box padding="space-16">
* <BodyShort>Hei</BodyShort>
* </Box>
*
* @example
* <Box padding={{xs: 'space-8', sm: 'space-12', md: 'space-16', lg: 'space-20', xl: 'space-24'}}>
* <BodyShort>Hei</BodyShort>
* </Box>
*
* @example
* <VStack gap="space-32">
* <Box padding="space-16">
* <BodyShort>Hei</BodyShort>
* </Box>
* <Box padding="space-16">
* <BodyShort>Hei</BodyShort>
* </Box>
* </VStack>
*/
export const BoxNew = forwardRef((_a, ref) => {
var { children, className, as: Component = "div", background, borderColor, borderWidth, borderRadius, shadow, style: _style, asChild } = _a, rest = __rest(_a, ["children", "className", "as", "background", "borderColor", "borderWidth", "borderRadius", "shadow", "style", "asChild"]);
const style = Object.assign(Object.assign(Object.assign({}, _style), { "--__axc-box-background": background
? `var(--ax-bg-${background})`
: undefined, "--__axc-box-shadow": shadow ? `var(--ax-shadow-${shadow})` : undefined, "--__axc-box-border-color": borderColor
? `var(--ax-border-${borderColor})`
: undefined, "--__axc-box-border-width": borderWidth
? borderWidth
.split(" ")
.map((x) => `${x}px`)
.join(" ")
: undefined }), getResponsiveProps("box", "radius", "radius", borderRadius, false, [
"0",
]));
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-box", className, {
"aksel-box-bg": background,
"aksel-box-border-color": borderColor,
"aksel-box-border-width": borderWidth,
"aksel-box-radius": borderRadius,
"aksel-box-shadow": shadow,
}) }), children)));
});
export default BoxNew;
//# sourceMappingURL=Box.darkside.js.map