UNPKG

@etsoo/materialui

Version:

TypeScript Material-UI Implementation

26 lines (25 loc) 825 B
import { jsx as _jsx } from "react/jsx-runtime"; import { DateUtils } from "@etsoo/shared"; import Typography from "@mui/material/Typography"; /** * Date text * @param props Props * @returns Component */ export function DateText(props) { // Destruct const { nearDays, locale = "lookup", options, timeZone, value, ...rest } = props; // Format date const date = DateUtils.parse(value); // Formatted value const localValue = date == null ? undefined : DateUtils.format(value, locale, options, timeZone); if (nearDays != null && date != null && Math.abs(new Date().substract(date).totalDays) <= nearDays) { rest.color = "error"; } // Layout return (_jsx(Typography, { component: "span", fontSize: "inherit", ...rest, children: localValue })); }