@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
68 lines • 4.17 kB
JavaScript
import React from "react";
import { Slot } from "../../slot/Slot.js";
import { useRenameCSS, useThemeInternal } from "../../theme/Theme.js";
import { getResponsiveProps, getResponsiveValue } from "../utilities/css.js";
export const PRIMITIVE_PROPS = [
"className",
"padding",
"paddingInline",
"paddingBlock",
"margin",
"marginInline",
"marginBlock",
"width",
"minWidth",
"maxWidth",
"height",
"minHeight",
"maxHeight",
"position",
"inset",
"top",
"right",
"bottom",
"left",
"overflow",
"overflowX",
"overflowY",
"flexBasis",
"flexGrow",
"flexShrink",
"gridColumn",
];
export const BasePrimitive = ({ children, className, padding, paddingInline, paddingBlock, margin, marginInline, marginBlock, width, minWidth, maxWidth, height, minHeight, maxHeight, position, inset, top, right, left, bottom, overflow, overflowX, overflowY, flexBasis, flexGrow, flexShrink, gridColumn, }) => {
const themeContext = useThemeInternal(false);
const { cn } = useRenameCSS();
const prefix = (themeContext === null || themeContext === void 0 ? void 0 : themeContext.isDarkside) ? "ax" : "a";
const style = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, getResponsiveProps(prefix, "r", "p", "spacing", padding)), getResponsiveProps(prefix, "r", "pi", "spacing", paddingInline)), getResponsiveProps(prefix, "r", "pb", "spacing", paddingBlock)), getResponsiveProps(prefix, "r", "m", "spacing", margin)), getResponsiveProps(prefix, "r", "mi", "spacing", marginInline)), getResponsiveProps(prefix, "r", "mb", "spacing", marginBlock)), getResponsiveValue(prefix, "r", "w", width)), getResponsiveValue(prefix, "r", "minw", minWidth)), getResponsiveValue(prefix, "r", "maxw", maxWidth)), getResponsiveValue(prefix, "r", "h", height)), getResponsiveValue(prefix, "r", "minh", minHeight)), getResponsiveValue(prefix, "r", "maxh", maxHeight)), getResponsiveValue(prefix, "r", "position", position)), getResponsiveProps(prefix, "r", "inset", "spacing", inset)), getResponsiveProps(prefix, "r", "top", "spacing", top)), getResponsiveProps(prefix, "r", "right", "spacing", right)), getResponsiveProps(prefix, "r", "bottom", "spacing", bottom)), getResponsiveProps(prefix, "r", "left", "spacing", left)), getResponsiveValue(prefix, "r", "overflow", overflow)), getResponsiveValue(prefix, "r", "overflowx", overflowX)), getResponsiveValue(prefix, "r", "overflowy", overflowY)), getResponsiveValue(prefix, "r", "flex-basis", flexBasis)), getResponsiveValue(prefix, "r", "flex-grow", flexGrow)), getResponsiveValue(prefix, "r", "flex-shrink", flexShrink)), getResponsiveValue(prefix, "r", "grid-column", gridColumn));
return (React.createElement(Slot, { className: cn({
className,
"navds-r-p": padding,
"navds-r-pi": paddingInline,
"navds-r-pb": paddingBlock,
"navds-r-m": margin,
"navds-r-mi": marginInline,
"navds-r-mb": marginBlock,
"navds-r-w": width,
"navds-r-minw": minWidth,
"navds-r-maxw": maxWidth,
"navds-r-h": height,
"navds-r-minh": minHeight,
"navds-r-maxh": maxHeight,
"navds-r-position": position,
"navds-r-inset": inset,
"navds-r-top": top,
"navds-r-right": right,
"navds-r-bottom": bottom,
"navds-r-left": left,
"navds-r-overflow": overflow,
"navds-r-overflowx": overflowX,
"navds-r-overflowy": overflowY,
"navds-r-flex-basis": flexBasis,
"navds-r-flex-grow": flexGrow,
"navds-r-flex-shrink": flexShrink,
"navds-r-grid-column": gridColumn,
}), style: style }, children));
};
export default BasePrimitive;
//# sourceMappingURL=BasePrimitive.js.map