@namroodinc/liquid-editorial 0.13.2 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/UPGRADING.md +2 -0
- package/dist/components/Avatar/style.css +1 -1
- package/dist/components/Time/index.cjs +1 -1
- package/dist/components/Time/index.cjs.map +1 -1
- package/dist/components/Time/index.js +4 -1
- package/dist/components/Time/index.js.map +1 -1
- package/dist/components/Time/style.css +1 -0
- package/package.json +1 -1
package/UPGRADING.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/mergeRefs-CZ-SArlE.cjs"),t=require("../../chunks/useTooltip-C7ON4nkV.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],o=6e4,s=60*o,c=24*s,l=7*c;function u(e){return String(e).padStart(2,`0`)}function d(e,t={}){let{hasYear:n=!0}=t,r=`${e.getDate()} ${a[e.getMonth()]}`;return n?`${r} ${e.getFullYear()}`:r}function f(e,t={}){let{hasTimeZone:n=!0}=t,r=`${d(e)}, ${u(e.getHours())}:${u(e.getMinutes())}`;if(!n)return r;let i=new Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value;return i?`${r} ${i}`:r}function p(e,t=new Date){let n=t.getTime()-e.getTime();if(n<0)return d(e,{hasYear:e.getFullYear()!==t.getFullYear()});if(n<o)return`Just now`;if(n<s)return`${Math.floor(n/o)}m ago`;if(n<c)return`${Math.floor(n/s)}h ago`;if(n<l){let e=Math.floor(n/c);return`${e} ${e===1?`day`:`days`} ago`}return d(e,{hasYear:e.getFullYear()!==t.getFullYear()})}var m=(0,n.forwardRef)(function({value:a,format:o=`auto`,hasTooltip:s=!0,hasTimeZone:c=!0,now:l,refreshInterval:u=3e4,className:m,tabIndex:h,title:g,onMouseEnter:_,onMouseLeave:v,onFocus:y,onBlur:b,"aria-describedby":x,...S},C){let w=a instanceof Date?a:new Date(a),T=!Number.isNaN(w.getTime()),[,E]=(0,n.useState)(0);(0,n.useEffect)(()=>{if(o===`absolute`||l)return;let e=window.setInterval(()=>E(e=>e+1),u);return()=>window.clearInterval(e)},[o,l,u]);let D=T?o===`absolute`?d(w):p(w,l??new Date):``,O=T?f(w,{hasTimeZone:c}):``,k=T&&s&&D!==O,{anchorRef:A,description:j,triggerProps:M,panel:N}=t.t(k&&O,{className:`ds-time-tooltip`}),P=(0,n.useMemo)(()=>e.t(A,C),[A,C]);return T?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`time`,{ref:P,dateTime:w.toISOString(),suppressHydrationWarning:!0,className:i(`ds-time`,!k&&`ds-time--plain`,m),tabIndex:h??(k?0:void 0),"aria-describedby":[x,j].filter(Boolean).join(` `)||void 0,title:g??(k?void 0:O),...M({onMouseEnter:_,onMouseLeave:v,onFocus:y,onBlur:b}),...S,children:D}),N]}):null});exports.Time=m,exports.formatAbsoluteDate=d,exports.formatAbsoluteTime=f,exports.formatRelativeTime=p;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/mergeRefs-CZ-SArlE.cjs"),t=require("../../chunks/useTooltip-C7ON4nkV.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],o=6e4,s=60*o,c=24*s,l=7*c;function u(e){return String(e).padStart(2,`0`)}function d(e,t={}){let{hasYear:n=!0}=t,r=`${e.getDate()} ${a[e.getMonth()]}`;return n?`${r} ${e.getFullYear()}`:r}function f(e,t={}){let{hasTimeZone:n=!0}=t,r=`${d(e)}, ${u(e.getHours())}:${u(e.getMinutes())}`;if(!n)return r;let i=new Intl.DateTimeFormat(void 0,{timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value;return i?`${r} ${i}`:r}function p(e,t=new Date){let n=t.getTime()-e.getTime();if(n<0)return d(e,{hasYear:e.getFullYear()!==t.getFullYear()});if(n<o)return`Just now`;if(n<s)return`${Math.floor(n/o)}m ago`;if(n<c)return`${Math.floor(n/s)}h ago`;if(n<l){let e=Math.floor(n/c);return`${e} ${e===1?`day`:`days`} ago`}return d(e,{hasYear:e.getFullYear()!==t.getFullYear()})}var m=(0,n.forwardRef)(function({value:a,format:o=`auto`,hasTooltip:s=!0,hasTimeZone:c=!0,now:l,refreshInterval:u=3e4,className:m,tabIndex:h,title:g,onMouseEnter:_,onMouseLeave:v,onFocus:y,onBlur:b,"aria-describedby":x,...S},C){let w=a instanceof Date?a:new Date(a),T=!Number.isNaN(w.getTime()),[,E]=(0,n.useState)(0);(0,n.useEffect)(()=>{if(o===`absolute`||l)return;let e=window.setInterval(()=>E(e=>e+1),u);return()=>window.clearInterval(e)},[o,l,u]);let D=T?o===`absolute`?d(w):p(w,l??new Date):``,O=T?f(w,{hasTimeZone:c}):``,k=T&&s&&D!==O,{anchorRef:A,description:j,triggerProps:M,panel:N}=t.t(k&&O,{placement:`top`,className:`ds-time-tooltip`}),P=(0,n.useMemo)(()=>e.t(A,C),[A,C]);return T?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`time`,{ref:P,dateTime:w.toISOString(),suppressHydrationWarning:!0,className:i(`ds-time`,!k&&`ds-time--plain`,m),tabIndex:h??(k?0:void 0),"aria-describedby":[x,j].filter(Boolean).join(` `)||void 0,title:g??(k?void 0:O),...M({onMouseEnter:_,onMouseLeave:v,onFocus:y,onBlur:b}),...S,children:D}),N]}):null});exports.Time=m,exports.formatAbsoluteDate=d,exports.formatAbsoluteTime=f,exports.formatRelativeTime=p;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useTooltip","useMemo","mergeRefs","_Fragment","require_mergeRefs","require_useTooltip","react","react_jsx_runtime","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","describedBy","rest","isValid","setTick","format","id","t","refreshInterval","label","isTipped","hasTooltip","timeRef","anchorRef","ref","className","tabIndex","description","title","triggerProps","panel"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useMemo, useState, type HTMLAttributes } from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) {\n return stamp;\n }\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) {\n return \"Just now\";\n }\n if (delta < HOUR) {\n return `${Math.floor(delta / MINUTE)}m ago`;\n }\n if (delta < DAY) {\n return `${Math.floor(delta / HOUR)}h ago`;\n }\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const isValid = !Number.isNaN(date.getTime());\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) {\n return;\n }\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n const reference = now ?? new Date();\n const label = !isValid\n ? \"\"\n : format === \"absolute\"\n ? formatAbsoluteDate(date)\n : formatRelativeTime(date, reference);\n const stamp = isValid ? formatAbsoluteTime(date, { hasTimeZone }) : \"\";\n const isTipped = isValid && hasTooltip && label !== stamp;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLTimeElement>(\n isTipped && stamp,\n { className: \"ds-time-tooltip\" },\n );\n const timeRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n\n if (!isValid) {\n return null;\n }\n\n return (\n <>\n <time\n ref={timeRef}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={[describedBy, description].filter(Boolean).join(\" \") || undefined}\n title={title ?? (isTipped ? undefined : stamp)}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n {...rest}\n >\n {label}\n </time>\n {panel}\n </>\n );\n});\n"],"mappings":"A,kOAKA,SAASU,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAEA,IAAMC,EAAS,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EAE5FC,EAAS,IACTC,EAAO,GAAKD,EACZE,EAAM,GAAKD,EACXE,EAAO,EAAID,EAEjB,SAASE,EAAI,EAAe,CAC1B,OAAO,OAAOC,CAAK,CAAC,CAAC,SAAS,EAAG,GAAG,CACtC,CAGA,SAAgBC,EAAmB,EAAY,EAAiC,CAAC,EAAG,CAClF,GAAM,CAAE,UAAU,IAASC,EACrBC,E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,OACT,aAAa,GACb,cAAc,GACd,MACA,kBAAkB,IAClB,YACA,WACA,QACA,eACA,eACA,UACA,SACA,mBAAoBkC,EACpB,GAAGC,GAEL,EACA,CACA,IAAMb,EAAOJ,aAAiB,KAAOA,EAAQ,IAAI,KAAKA,CAAK,EACrDkB,EAAU,CAAC,OAAO,MAAMd,EAAK,QAAQ,CAAC,EACtC,EAAGe,IAAA,EAAWpC,EAAAA,SAAAA,CAAS,CAAC,GAE9B,EAAAO,EAAA,UAAA,KAAgB,CACd,GAAI8B,IAAW,YAAcP,EAC3B,OAEF,IAAMQ,EAAK,OAAO,gBAAkBF,EAAS,GAAMG,EAAI,CAAC,EAAGC,CAAe,EAC1E,UAAa,OAAO,cAAcF,CAAE,CACtC,EAAG,CAACD,EAAQP,EAAKU,CAAe,CAAC,EAGjC,IAAMC,EAASN,EAEXE,IAAW,WACTnB,EAAmBG,CAAI,EACvBO,EAAmBP,EALPS,GAAO,IAAI,IAKW,EAHpC,GAIEN,EAAQW,EAAUZ,EAAmBF,EAAM,CAAE,aAAY,CAAC,EAAI,GAC9DqB,EAAWP,GAAWQ,GAAcF,IAAUjB,EAC9C,CAAE,YAAW,cAAa,eAAc,SAAUvB,EAAAA,EACtDyC,GAAYlB,EACZ,CAAE,UAAW,iBAAkB,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useTooltip","useMemo","mergeRefs","_Fragment","require_mergeRefs","require_useTooltip","react","react_jsx_runtime","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","describedBy","rest","isValid","setTick","format","id","t","refreshInterval","label","isTipped","hasTooltip","timeRef","anchorRef","ref","className","tabIndex","description","title","triggerProps","panel"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useMemo, useState, type HTMLAttributes } from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) {\n return stamp;\n }\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) {\n return \"Just now\";\n }\n if (delta < HOUR) {\n return `${Math.floor(delta / MINUTE)}m ago`;\n }\n if (delta < DAY) {\n return `${Math.floor(delta / HOUR)}h ago`;\n }\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const isValid = !Number.isNaN(date.getTime());\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) {\n return;\n }\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n const reference = now ?? new Date();\n const label = !isValid\n ? \"\"\n : format === \"absolute\"\n ? formatAbsoluteDate(date)\n : formatRelativeTime(date, reference);\n const stamp = isValid ? formatAbsoluteTime(date, { hasTimeZone }) : \"\";\n const isTipped = isValid && hasTooltip && label !== stamp;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLTimeElement>(\n isTipped && stamp,\n { placement: \"top\", className: \"ds-time-tooltip\" },\n );\n const timeRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n\n if (!isValid) {\n return null;\n }\n\n return (\n <>\n <time\n ref={timeRef}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={[describedBy, description].filter(Boolean).join(\" \") || undefined}\n title={title ?? (isTipped ? undefined : stamp)}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n {...rest}\n >\n {label}\n </time>\n {panel}\n </>\n );\n});\n"],"mappings":"A,kOAKA,SAASU,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAEA,IAAMC,EAAS,CAAC,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,MAAO,KAAK,EAE5FC,EAAS,IACTC,EAAO,GAAKD,EACZE,EAAM,GAAKD,EACXE,EAAO,EAAID,EAEjB,SAASE,EAAI,EAAe,CAC1B,OAAO,OAAOC,CAAK,CAAC,CAAC,SAAS,EAAG,GAAG,CACtC,CAGA,SAAgBC,EAAmB,EAAY,EAAiC,CAAC,EAAG,CAClF,GAAM,CAAE,UAAU,IAASC,EACrBC,EAAO,GAAGC,EAAK,QAAQ,EAAE,GAAGV,EAAOU,EAAK,SAAS,KACvD,OAAOC,EAAU,GAAGF,EAAK,GAAGC,EAAK,YAAY,IAAMD,CACrD,CAGA,SAAgBG,EAAmB,EAAY,EAAqC,CAAC,EAAG,CACtF,GAAM,CAAE,cAAc,IAASJ,EACzBK,EAAQ,GAAGN,EAAmBG,CAAI,EAAE,IAAIL,EAAIK,EAAK,SAAS,CAAC,EAAE,GAAGL,EAAIK,EAAK,WAAW,CAAC,IAC3F,GAAI,CAACI,EACH,OAAOD,EAET,IAAME,EAAO,IAAI,KAAK,eAAe,IAAA,GAAW,CAAE,aAAc,OAAQ,CAAC,CAAC,CACvE,cAA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UAAa,OAAO,cAAcF,CAAE,CACtC,EAAG,CAACD,EAAQP,EAAKU,CAAe,CAAC,EAGjC,IAAMC,EAASN,EAEXE,IAAW,WACTnB,EAAmBG,CAAI,EACvBO,EAAmBP,EALPS,GAAO,IAAI,IAKW,EAHpC,GAIEN,EAAQW,EAAUZ,EAAmBF,EAAM,CAAE,aAAY,CAAC,EAAI,GAC9DqB,EAAWP,GAAWQ,GAAcF,IAAUjB,EAC9C,CAAE,YAAW,cAAa,eAAc,SAAUvB,EAAAA,EACtDyC,GAAYlB,EACZ,CAAE,UAAW,MAAO,UAAW,iBAAkB,CACnD,EACMoB,GAAA,EAAU1C,EAAAA,QAAAA,KAAcC,EAAAA,EAAU0C,EAAWC,CAAG,EAAG,CAACD,EAAWC,CAAG,CAAC,EAMzE,OAJKX,GAKH,EAAA3B,EAAA,KAAA,CAAAJ,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAI,EAAA,IAAA,CAAC,OAAD,CACE,IAAKoC,EACL,SAAUvB,EAAK,YAAY,EAC3B,yBAAA,GACA,UAAWZ,EAAG,UAAW,CAACiC,GAAY,iBAAkBK,CAAS,EACjE,SAAUC,IAAaN,EAAW,EAAI,IAAA,IACtC,mBAAkB,CAACT,EAAagB,CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,GAAK,IAAA,GAC1E,MAAOC,IAAUR,EAAW,IAAA,GAAYlB,GACxC,GAAI2B,EAAa,CAAE,eAAc,eAAc,UAAS,QAAO,CAAC,EAChE,GAAIjB,EAEH,SAAAO,CACG,CAAA,EACLW,CACD,CAAA,CAAA,EAnBK,IAqBX,CAAC,E"}
|
|
@@ -56,7 +56,10 @@ var y = n(function({ value: n, format: u = "auto", hasTooltip: d = !0, hasTimeZo
|
|
|
56
56
|
p,
|
|
57
57
|
m
|
|
58
58
|
]);
|
|
59
|
-
let j = k ? u === "absolute" ? g(O) : v(O, p ?? /* @__PURE__ */ new Date()) : "", M = k ? _(O, { hasTimeZone: f }) : "", N = k && d && j !== M, { anchorRef: P, description: F, triggerProps: I, panel: L } = t(N && M, {
|
|
59
|
+
let j = k ? u === "absolute" ? g(O) : v(O, p ?? /* @__PURE__ */ new Date()) : "", M = k ? _(O, { hasTimeZone: f }) : "", N = k && d && j !== M, { anchorRef: P, description: F, triggerProps: I, panel: L } = t(N && M, {
|
|
60
|
+
placement: "top",
|
|
61
|
+
className: "ds-time-tooltip"
|
|
62
|
+
}), R = i(() => e(P, D), [P, D]);
|
|
60
63
|
return k ? /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ s("time", {
|
|
61
64
|
ref: R,
|
|
62
65
|
dateTime: O.toISOString(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Fragment","mergeRefs","Fragment$1","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","forwardRef","describedBy","rest","isValid","setTick","useState","format","id","t","refreshInterval","label","isTipped","hasTooltip","useTooltip","timeRef","useMemo","anchorRef","ref","className","tabIndex","description","title","triggerProps","panel"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useMemo, useState, type HTMLAttributes } from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) {\n return stamp;\n }\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) {\n return \"Just now\";\n }\n if (delta < HOUR) {\n return `${Math.floor(delta / MINUTE)}m ago`;\n }\n if (delta < DAY) {\n return `${Math.floor(delta / HOUR)}h ago`;\n }\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const isValid = !Number.isNaN(date.getTime());\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) {\n return;\n }\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n const reference = now ?? new Date();\n const label = !isValid\n ? \"\"\n : format === \"absolute\"\n ? formatAbsoluteDate(date)\n : formatRelativeTime(date, reference);\n const stamp = isValid ? formatAbsoluteTime(date, { hasTimeZone }) : \"\";\n const isTipped = isValid && hasTooltip && label !== stamp;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLTimeElement>(\n isTipped && stamp,\n { className: \"ds-time-tooltip\" },\n );\n const timeRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n\n if (!isValid) {\n return null;\n }\n\n return (\n <>\n <time\n ref={timeRef}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={[describedBy, description].filter(Boolean).join(\" \") || undefined}\n title={title ?? (isTipped ? undefined : stamp)}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n {...rest}\n >\n {label}\n </time>\n {panel}\n </>\n );\n});\n"],"mappings":";;;;;AAKA,SAASG,EAAG,GAAGC,GAAuC;CACpD,OA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,MAAMgB,IAAQjB,CAAM,EAAE;CAEvC,IAAIiB,IAAQf,GACV,OAAO,GAAG,KAAK,MAAMe,IAAQhB,CAAI,EAAE;CAErC,IAAIgB,IAAQd,GAAM;EAChB,IAAMgB,IAAO,KAAK,MAAMF,IAAQf,CAAG;EACnC,OAAO,GAAGiB,EAAK,GAAGA,MAAS,IAAI,QAAQ,OAAO;CAChD;CACA,OAAOb,EAAmBG,GAAM,EAAE,SAASA,EAAK,YAAY,MAAMS,EAAI,YAAY,EAAE,CAAC;AACvF;AAuBA,IAAaE,IAAOC,EAAuC,SACzD,EACE,UACA,YAAS,QACT,gBAAa,IACb,iBAAc,IACd,QACA,qBAAkB,KAClB,cACA,aACA,UACA,iBACA,iBACA,YACA,WACA,oBAAoBC,GACpB,GAAGC,KAEL,GACA;CACA,IAAMd,IAAOJ,aAAiB,OAAOA,IAAQ,IAAI,KAAKA,CAAK,GACrDmB,IAAU,CAAC,OAAO,MAAMf,EAAK,QAAQ,CAAC,GACtC,GAAGgB,KAAWC,EAAS,CAAC;CAE9B,QAAgB;EACd,IAAIC,MAAW,cAAcT,GAC3B;EAEF,IAAMU,IAAK,OAAO,kBAAkBH,GAAS,MAAMI,IAAI,CAAC,GAAGC,CAAe;EAC1E,aAAa,OAAO,cAAcF,CAAE;CACtC,GAAG;EAACD;EAAQT;EAAKY;CAAe,CAAC;CAGjC,IAAMC,IAASP,IAEXG,MAAW,aACTrB,EAAmBG,CAAI,IACvBO,EAAmBP,GALPS,qBAAO,IAAI,KAAK,CAKM,IAHpC,IAIEN,IAAQY,IAAUb,EAAmBF,GAAM,EAAE,eAAY,CAAC,IAAI,IAC9DuB,IAAWR,KAAWS,KAAcF,MAAUnB,GAC9C,EAAE,cAAW,gBAAa,iBAAc,aAAUsB,EACtDF,KAAYpB,GACZ
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","mergeRefs","Fragment$1","cx","parts","MONTHS","MINUTE","HOUR","DAY","WEEK","pad","value","formatAbsoluteDate","options","stem","date","hasYear","formatAbsoluteTime","stamp","hasTimeZone","zone","part","formatRelativeTime","delta","now","days","Time","forwardRef","describedBy","rest","isValid","setTick","useState","format","id","t","refreshInterval","label","isTipped","hasTooltip","useTooltip","timeRef","useMemo","anchorRef","ref","className","tabIndex","description","title","triggerProps","panel"],"sources":["../../../src/components/Time/index.tsx"],"sourcesContent":["import { forwardRef, useEffect, useMemo, useState, type HTMLAttributes } from \"react\";\nimport { mergeRefs } from \"../../internal/mergeRefs\";\nimport { useTooltip } from \"../Popover/useTooltip\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nconst MONTHS = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n\nconst MINUTE = 60_000;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\nconst WEEK = 7 * DAY;\n\nfunction pad(value: number) {\n return String(value).padStart(2, \"0\");\n}\n\n/** Day before month, one order everywhere: `12 Jun 2026`. */\nexport function formatAbsoluteDate(date: Date, options: { hasYear?: boolean } = {}) {\n const { hasYear = true } = options;\n const stem = `${date.getDate()} ${MONTHS[date.getMonth()]}`;\n return hasYear ? `${stem} ${date.getFullYear()}` : stem;\n}\n\n/** The tooltip form: `6 Aug 2026, 11:05`, with the reader's zone appended. */\nexport function formatAbsoluteTime(date: Date, options: { hasTimeZone?: boolean } = {}) {\n const { hasTimeZone = true } = options;\n const stamp = `${formatAbsoluteDate(date)}, ${pad(date.getHours())}:${pad(date.getMinutes())}`;\n if (!hasTimeZone) {\n return stamp;\n }\n const zone = new Intl.DateTimeFormat(undefined, { timeZoneName: \"short\" })\n .formatToParts(date)\n .find((part) => part.type === \"timeZoneName\")?.value;\n return zone ? `${stamp} ${zone}` : stamp;\n}\n\n/**\n * Relative up to a week, absolute after. Future dates are always absolute — a\n * scheduled publish reads `12 Jun`, never `in 3 days`.\n */\nexport function formatRelativeTime(date: Date, now: Date = new Date()) {\n const delta = now.getTime() - date.getTime();\n if (delta < 0) {\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n }\n if (delta < MINUTE) {\n return \"Just now\";\n }\n if (delta < HOUR) {\n return `${Math.floor(delta / MINUTE)}m ago`;\n }\n if (delta < DAY) {\n return `${Math.floor(delta / HOUR)}h ago`;\n }\n if (delta < WEEK) {\n const days = Math.floor(delta / DAY);\n return `${days} ${days === 1 ? \"day\" : \"days\"} ago`;\n }\n return formatAbsoluteDate(date, { hasYear: date.getFullYear() !== now.getFullYear() });\n}\n\nexport type TimeFormat = \"auto\" | \"relative\" | \"absolute\";\n\nexport interface TimeProps extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n /** The instant to print — Date, epoch ms, or an ISO string. */\n value: Date | string | number;\n /** `auto` ages the value; `absolute` always prints the date. */\n format?: TimeFormat;\n /** Show the absolute stamp on hover and focus. */\n hasTooltip?: boolean;\n /** Append the reader's time zone to the tooltip. */\n hasTimeZone?: boolean;\n /** Pin \"now\" — useful for tests and stories. */\n now?: Date;\n /** Re-render interval in ms while the value is still relative. */\n refreshInterval?: number;\n}\n\n/**\n * A machine-readable `<time>` that ages itself. One form per cell: relative or\n * absolute, never both side by side.\n */\nexport const Time = forwardRef<HTMLTimeElement, TimeProps>(function Time(\n {\n value,\n format = \"auto\",\n hasTooltip = true,\n hasTimeZone = true,\n now,\n refreshInterval = 30_000,\n className,\n tabIndex,\n title,\n onMouseEnter,\n onMouseLeave,\n onFocus,\n onBlur,\n \"aria-describedby\": describedBy,\n ...rest\n },\n ref,\n) {\n const date = value instanceof Date ? value : new Date(value);\n const isValid = !Number.isNaN(date.getTime());\n const [, setTick] = useState(0);\n\n useEffect(() => {\n if (format === \"absolute\" || now) {\n return;\n }\n const id = window.setInterval(() => setTick((t) => t + 1), refreshInterval);\n return () => window.clearInterval(id);\n }, [format, now, refreshInterval]);\n\n const reference = now ?? new Date();\n const label = !isValid\n ? \"\"\n : format === \"absolute\"\n ? formatAbsoluteDate(date)\n : formatRelativeTime(date, reference);\n const stamp = isValid ? formatAbsoluteTime(date, { hasTimeZone }) : \"\";\n const isTipped = isValid && hasTooltip && label !== stamp;\n const { anchorRef, description, triggerProps, panel } = useTooltip<HTMLTimeElement>(\n isTipped && stamp,\n { placement: \"top\", className: \"ds-time-tooltip\" },\n );\n const timeRef = useMemo(() => mergeRefs(anchorRef, ref), [anchorRef, ref]);\n\n if (!isValid) {\n return null;\n }\n\n return (\n <>\n <time\n ref={timeRef}\n dateTime={date.toISOString()}\n suppressHydrationWarning\n className={cx(\"ds-time\", !isTipped && \"ds-time--plain\", className)}\n tabIndex={tabIndex ?? (isTipped ? 0 : undefined)}\n aria-describedby={[describedBy, description].filter(Boolean).join(\" \") || undefined}\n title={title ?? (isTipped ? undefined : stamp)}\n {...triggerProps({ onMouseEnter, onMouseLeave, onFocus, onBlur })}\n {...rest}\n >\n {label}\n </time>\n {panel}\n </>\n );\n});\n"],"mappings":";;;;;AAKA,SAASG,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAEA,IAAMC,IAAS;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK,GAE5FC,IAAS,KACTC,IAAO,KAAKD,GACZE,IAAM,KAAKD,GACXE,IAAO,IAAID;AAEjB,SAASE,EAAI,GAAe;CAC1B,OAAO,OAAOC,CAAK,CAAC,CAAC,SAAS,GAAG,GAAG;AACtC;AAGA,SAAgBC,EAAmB,GAAY,IAAiC,CAAC,GAAG;CAClF,IAAM,EAAE,aAAU,OAASC,GACrBC,IAAO,GAAGC,EAAK,QAAQ,EAAE,GAAGV,EAAOU,EAAK,SAAS;CACvD,OAAOC,IAAU,GAAGF,EAAK,GAAGC,EAAK,YAAY,MAAMD;AACrD;AAGA,SAAgBG,EAAm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