UNPKG

@hitachivantara/uikit-react-core

Version:
29 lines (28 loc) 1.18 kB
import { fixedForwardRef } from "../types/generic.js"; import { HvTypography } from "../Typography/Typography.js"; import { useClasses } from "./TimeAgo.styles.js"; import useTimeAgo from "./useTimeAgo.js"; import { useDefaultProps } from "@hitachivantara/uikit-react-utils"; import { Fragment, jsx } from "react/jsx-runtime"; //#region src/TimeAgo/TimeAgo.tsx /** * The HvTimeAgo component implements the Design System relative time format guidelines. */ var HvTimeAgo = fixedForwardRef(function HvTimeAgo(props, ref) { const { classes: classesProp, className, timestamp, locale = "en", component: Component = HvTypography, emptyElement = "—", disableRefresh = false, showSeconds = false, justText = false, ...others } = useDefaultProps("HvTimeAgo", props); const { classes, cx } = useClasses(classesProp); const timeAgo = useTimeAgo(timestamp, { locale, disableRefresh, showSeconds }); if (justText && timestamp) return /* @__PURE__ */ jsx(Fragment, { children: timeAgo }); return /* @__PURE__ */ jsx(Component, { ref, className: cx(classes.root, className), ...others, children: !timestamp ? emptyElement : timeAgo }); }); //#endregion export { HvTimeAgo };