UNPKG

@coveord/plasma-mantine

Version:

A Plasma flavoured Mantine theme

51 lines (50 loc) 1.55 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { factory, Group, Text, useProps } from '@mantine/core'; import { useDidUpdate } from '@mantine/hooks'; import dayjs from 'dayjs'; import { useState } from 'react'; import { useTableContext } from '../TableContext'; const defaultProps = { label: 'Last update:' }; export const TableLastUpdated = factory((props, ref)=>{ const { table, getStyles } = useTableContext(); const { label, classNames, className, styles, style, vars, ...others } = useProps('PlasmaTableLastUpdated', defaultProps, props); const [time, setTime] = useState(new Date()); useDidUpdate(()=>{ setTime(new Date()); }, [ table.options.data ]); const stylesApiProps = { classNames, styles }; return /*#__PURE__*/ _jsx(Group, { px: "xl", justify: "right", ref: ref, ...getStyles('lastUpdatedRoot', { className, style, ...stylesApiProps }), ...others, children: /*#__PURE__*/ _jsxs(Text, { size: "xs", ...getStyles('lastUpdatedLabel', { className, style, ...stylesApiProps }), children: [ label, /*#__PURE__*/ _jsx("span", { role: "timer", children: dayjs(time).format('h:mm:ss A') }) ] }) }); }); //# sourceMappingURL=TableLastUpdated.js.map