UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

38 lines 2.06 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, useContext } from "react"; import { useRenameCSS } from "../theme/Theme.js"; import { BodyLong } from "../typography/index.js"; import { ListContext } from "./List.context.js"; /** * @see 🏷️ {@link ListItemProps} */ export const ListItem = forwardRef((_a, ref) => { var { className, children, title, icon } = _a, rest = __rest(_a, ["className", "children", "title", "icon"]); const { listType, size } = useContext(ListContext); const { cn } = useRenameCSS(); if (listType === "ol" && icon) { console.warn("<List />: Icon prop is not supported for ordered lists. Please remove the icon prop."); } return (React.createElement("li", Object.assign({}, rest, { ref: ref, className: cn("navds-list__item", className) }), listType === "ul" && (React.createElement("div", { className: cn("navds-list__item-marker", { "navds-list__item-marker--icon": icon, "navds-list__item-marker--bullet": !icon, }) }, icon ? (icon) : (React.createElement("svg", { viewBox: "0 0 6 6", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": true, focusable: false, role: "img" }, React.createElement("rect", { width: "6", height: "6", rx: "3", fill: "currentColor" }))))), React.createElement("div", null, title && (React.createElement(BodyLong, { as: "p", size: size, weight: "semibold" }, title)), children))); }); ListItem.displayName = "List.Item"; export default ListItem; //# sourceMappingURL=List.Item.js.map