UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

35 lines (34 loc) 1.25 kB
import { jsx, Fragment } from "react/jsx-runtime"; import { useDefaultProps } from "@hitachivantara/uikit-react-utils"; import { DEFAULT_LOCALE } from "../Calendar/utils.js"; import { fixedForwardRef } from "../types/generic.js"; import { useClasses } from "./TimeAgo.styles.js"; import { staticClasses } from "./TimeAgo.styles.js"; import useTimeAgo from "./useTimeAgo.js"; import { HvTypography } from "../Typography/Typography.js"; const HvTimeAgo = fixedForwardRef(function HvTimeAgo2(props, ref) { const { classes: classesProp, className, timestamp, locale = DEFAULT_LOCALE, 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 }); }); export { HvTimeAgo, staticClasses as timeAgoClasses };