import { defineComponent, h, onBeforeUnmount, onMounted } from "vue"; import { css, start } from "./client.ts"; export { default, describeTime, TIME_TAG } from "./index.ts"; export type { DescribeTimeOptions, TimeAttributes, TimeDescription, TimeMeta, TimeOptions, } from "./index.ts"; /** `:time` for `@comark/vue`. */ export const RelativeTime = defineComponent({ name: "RelativeTime", inheritAttrs: false, props: { id: String, datetime: String, mode: String, label: String, tip: String, locale: String, threshold: String, }, setup(props) { let stop: (() => void) | undefined; onMounted(() => (stop = start(css))); onBeforeUnmount(() => stop?.()); return () => props.datetime && props.label ? h( "time", { class: "ctm", datetime: props.datetime, lang: props.locale, "data-threshold": props.threshold, "data-mode": props.mode, tabindex: 0, "aria-describedby": props.id, }, [ props.label, h("span", { class: "ctm-tip", role: "tooltip", id: props.id }, [ h("span", { class: "ctm-pill" }, props.tip), ]), ], ) : null; }, }); /** Pass these as `components` to `@comark/vue`. */ export const components = { RelativeTime };