vue-timeago3
Advanced tools
Comparing version 2.3.0 to 2.3.1
import { defineComponent, ref, onBeforeMount, onBeforeUnmount, watch, h } from "vue"; | ||
function _typeof(obj) { | ||
"@babel/helpers - typeof"; | ||
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) { | ||
return typeof obj2; | ||
} : function(obj2) { | ||
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2; | ||
}, _typeof(obj); | ||
} | ||
function toInteger(dirtyNumber) { | ||
@@ -20,3 +28,3 @@ if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) { | ||
var argStr = Object.prototype.toString.call(argument); | ||
if (argument instanceof Date || typeof argument === "object" && argStr === "[object Date]") { | ||
if (argument instanceof Date || _typeof(argument) === "object" && argStr === "[object Date]") { | ||
return new Date(argument.getTime()); | ||
@@ -27,3 +35,3 @@ } else if (typeof argument === "number" || argStr === "[object Number]") { | ||
if ((typeof argument === "string" || argStr === "[object String]") && typeof console !== "undefined") { | ||
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"); | ||
console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"); | ||
console.warn(new Error().stack); | ||
@@ -34,2 +42,6 @@ } | ||
} | ||
var defaultOptions = {}; | ||
function getDefaultOptions() { | ||
return defaultOptions; | ||
} | ||
function getTimezoneOffsetInMilliseconds(date) { | ||
@@ -71,3 +83,3 @@ var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds())); | ||
floor: Math.floor, | ||
trunc: function(value) { | ||
trunc: function trunc(value) { | ||
return value < 0 ? Math.ceil(value) : Math.floor(value); | ||
@@ -189,3 +201,3 @@ } | ||
}; | ||
var formatDistance$1 = function(token, count, options) { | ||
var formatDistance$1 = function formatDistance(token, count, options) { | ||
var result; | ||
@@ -259,3 +271,3 @@ var tokenValue = formatDistanceLocale[token]; | ||
}; | ||
var formatRelative = function(token, _date, _baseDate, _options) { | ||
var formatRelative = function formatRelative2(token, _date, _baseDate, _options) { | ||
return formatRelativeLocale[token]; | ||
@@ -265,13 +277,12 @@ }; | ||
function buildLocalizeFn(args) { | ||
return function(dirtyIndex, dirtyOptions) { | ||
var options = dirtyOptions || {}; | ||
var context = options.context ? String(options.context) : "standalone"; | ||
return function(dirtyIndex, options) { | ||
var context = options !== null && options !== void 0 && options.context ? String(options.context) : "standalone"; | ||
var valuesArray; | ||
if (context === "formatting" && args.formattingValues) { | ||
var defaultWidth = args.defaultFormattingWidth || args.defaultWidth; | ||
var width = options.width ? String(options.width) : defaultWidth; | ||
var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth; | ||
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; | ||
} else { | ||
var _defaultWidth = args.defaultWidth; | ||
var _width = options.width ? String(options.width) : args.defaultWidth; | ||
var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth; | ||
valuesArray = args.values[_width] || args.values[_defaultWidth]; | ||
@@ -368,3 +379,3 @@ } | ||
}; | ||
var ordinalNumber = function(dirtyNumber, _options) { | ||
var ordinalNumber = function ordinalNumber2(dirtyNumber, _options) { | ||
var number = Number(dirtyNumber); | ||
@@ -393,3 +404,3 @@ var rem100 = number % 100; | ||
defaultWidth: "wide", | ||
argumentCallback: function(quarter) { | ||
argumentCallback: function argumentCallback(quarter) { | ||
return quarter - 1; | ||
@@ -532,3 +543,3 @@ } | ||
parsePattern: parseOrdinalNumberPattern, | ||
valueCallback: function(value) { | ||
valueCallback: function valueCallback(value) { | ||
return parseInt(value, 10); | ||
@@ -548,3 +559,3 @@ } | ||
defaultParseWidth: "any", | ||
valueCallback: function(index) { | ||
valueCallback: function valueCallback2(index) { | ||
return index + 1; | ||
@@ -586,10 +597,9 @@ } | ||
var defaultLocale = locale; | ||
function assign(target, dirtyObject) { | ||
function assign(target, object) { | ||
if (target == null) { | ||
throw new TypeError("assign requires that input parameter not be null or undefined"); | ||
} | ||
dirtyObject = dirtyObject || {}; | ||
for (var property in dirtyObject) { | ||
if (Object.prototype.hasOwnProperty.call(dirtyObject, property)) { | ||
target[property] = dirtyObject[property]; | ||
for (var property in object) { | ||
if (Object.prototype.hasOwnProperty.call(object, property)) { | ||
target[property] = object[property]; | ||
} | ||
@@ -599,4 +609,4 @@ } | ||
} | ||
function cloneObject(dirtyObject) { | ||
return assign({}, dirtyObject); | ||
function cloneObject(object) { | ||
return assign({}, object); | ||
} | ||
@@ -607,6 +617,7 @@ var MINUTES_IN_DAY$1 = 1440; | ||
var MINUTES_IN_TWO_MONTHS = 86400; | ||
function formatDistance(dirtyDate, dirtyBaseDate) { | ||
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
function formatDistance2(dirtyDate, dirtyBaseDate, options) { | ||
var _ref, _options$locale; | ||
requiredArgs(2, arguments); | ||
var locale2 = options.locale || defaultLocale; | ||
var defaultOptions2 = getDefaultOptions(); | ||
var locale2 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions2.locale) !== null && _ref !== void 0 ? _ref : defaultLocale; | ||
if (!locale2.formatDistance) { | ||
@@ -619,5 +630,6 @@ throw new RangeError("locale must contain formatDistance property"); | ||
} | ||
var localizeOptions = cloneObject(options); | ||
localizeOptions.addSuffix = Boolean(options.addSuffix); | ||
localizeOptions.comparison = comparison; | ||
var localizeOptions = assign(cloneObject(options), { | ||
addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix), | ||
comparison | ||
}); | ||
var dateLeft; | ||
@@ -637,3 +649,3 @@ var dateRight; | ||
if (minutes < 2) { | ||
if (options.includeSeconds) { | ||
if (options !== null && options !== void 0 && options.includeSeconds) { | ||
if (seconds < 5) { | ||
@@ -646,3 +658,3 @@ return locale2.formatDistance("lessThanXSeconds", 5, localizeOptions); | ||
} else if (seconds < 40) { | ||
return locale2.formatDistance("halfAMinute", null, localizeOptions); | ||
return locale2.formatDistance("halfAMinute", 0, localizeOptions); | ||
} else if (seconds < 60) { | ||
@@ -696,6 +708,7 @@ return locale2.formatDistance("lessThanXMinutes", 1, localizeOptions); | ||
var MINUTES_IN_YEAR = MINUTES_IN_DAY * 365; | ||
function formatDistanceStrict(dirtyDate, dirtyBaseDate) { | ||
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; | ||
function formatDistanceStrict(dirtyDate, dirtyBaseDate, options) { | ||
var _ref, _options$locale, _options$roundingMeth; | ||
requiredArgs(2, arguments); | ||
var locale2 = options.locale || defaultLocale; | ||
var defaultOptions2 = getDefaultOptions(); | ||
var locale2 = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions2.locale) !== null && _ref !== void 0 ? _ref : defaultLocale; | ||
if (!locale2.formatDistance) { | ||
@@ -708,5 +721,6 @@ throw new RangeError("locale must contain localize.formatDistance property"); | ||
} | ||
var localizeOptions = cloneObject(options); | ||
localizeOptions.addSuffix = Boolean(options.addSuffix); | ||
localizeOptions.comparison = comparison; | ||
var localizeOptions = assign(cloneObject(options), { | ||
addSuffix: Boolean(options === null || options === void 0 ? void 0 : options.addSuffix), | ||
comparison | ||
}); | ||
var dateLeft; | ||
@@ -721,3 +735,3 @@ var dateRight; | ||
} | ||
var roundingMethod = options.roundingMethod == null ? "round" : String(options.roundingMethod); | ||
var roundingMethod = String((_options$roundingMeth = options === null || options === void 0 ? void 0 : options.roundingMethod) !== null && _options$roundingMeth !== void 0 ? _options$roundingMeth : "round"); | ||
var roundingMethodFn; | ||
@@ -737,4 +751,5 @@ if (roundingMethod === "floor") { | ||
var dstNormalizedMinutes = (milliseconds - timezoneOffset) / MILLISECONDS_IN_MINUTE; | ||
var defaultUnit = options === null || options === void 0 ? void 0 : options.unit; | ||
var unit; | ||
if (options.unit == null) { | ||
if (!defaultUnit) { | ||
if (minutes < 1) { | ||
@@ -754,3 +769,3 @@ unit = "second"; | ||
} else { | ||
unit = String(options.unit); | ||
unit = String(defaultUnit); | ||
} | ||
@@ -771,3 +786,3 @@ if (unit === "second") { | ||
var months = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_MONTH); | ||
return months === 12 && options.unit !== "month" ? locale2.formatDistance("xYears", 1, localizeOptions) : locale2.formatDistance("xMonths", months, localizeOptions); | ||
return months === 12 && defaultUnit !== "month" ? locale2.formatDistance("xYears", 1, localizeOptions) : locale2.formatDistance("xMonths", months, localizeOptions); | ||
} else if (unit === "year") { | ||
@@ -779,14 +794,14 @@ var years = roundingMethodFn(dstNormalizedMinutes / MINUTES_IN_YEAR); | ||
} | ||
function formatDistanceToNow(dirtyDate, dirtyOptions) { | ||
function formatDistanceToNow(dirtyDate, options) { | ||
requiredArgs(1, arguments); | ||
return formatDistance(dirtyDate, Date.now(), dirtyOptions); | ||
return formatDistance2(dirtyDate, Date.now(), options); | ||
} | ||
function formatDistanceToNowStrict(dirtyDate, dirtyOptions) { | ||
function formatDistanceToNowStrict(dirtyDate, options) { | ||
requiredArgs(1, arguments); | ||
return formatDistanceStrict(dirtyDate, Date.now(), dirtyOptions); | ||
return formatDistanceStrict(dirtyDate, Date.now(), options); | ||
} | ||
function parseISO(argument, dirtyOptions) { | ||
function parseISO(argument, options) { | ||
var _options$additionalDi; | ||
requiredArgs(1, arguments); | ||
var options = dirtyOptions || {}; | ||
var additionalDigits = options.additionalDigits == null ? 2 : toInteger(options.additionalDigits); | ||
var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2); | ||
if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) { | ||
@@ -1033,3 +1048,7 @@ throw new RangeError("additionalDigits must be 0, 1 or 2"); | ||
const converter = props.converter || defaultConverter; | ||
return converter(datetime || props.datetime, props.converterOptions || opts.converterOptions, props.locale || opts.locale); | ||
return converter( | ||
datetime || props.datetime, | ||
props.converterOptions || opts.converterOptions, | ||
props.locale || opts.locale | ||
); | ||
}; | ||
@@ -1054,25 +1073,39 @@ const timeago = ref(getTimeago()); | ||
}; | ||
watch(() => props.autoUpdate, (newValue) => { | ||
stopUpdater(); | ||
if (newValue) { | ||
startUpdater(); | ||
watch( | ||
() => props.autoUpdate, | ||
(newValue) => { | ||
stopUpdater(); | ||
if (newValue) { | ||
startUpdater(); | ||
} | ||
} | ||
}); | ||
watch(() => [props.datetime, props.converter], () => { | ||
convert(); | ||
}); | ||
watch(() => props.converterOptions, () => { | ||
convert(); | ||
}, { | ||
deep: true | ||
}); | ||
); | ||
watch( | ||
() => [props.datetime, props.converter], | ||
() => { | ||
convert(); | ||
} | ||
); | ||
watch( | ||
() => props.converterOptions, | ||
() => { | ||
convert(); | ||
}, | ||
{ | ||
deep: true | ||
} | ||
); | ||
return { timeago, updateTimer }; | ||
}, | ||
render() { | ||
return h("timeago", { | ||
attrs: { | ||
datetime: new Date(this.datetime).toISOString(), | ||
title: typeof this.title === "string" ? this.title : this.title === false ? null : this.timeago | ||
} | ||
}, [this.timeago]); | ||
return h( | ||
"timeago", | ||
{ | ||
attrs: { | ||
datetime: new Date(this.datetime).toISOString(), | ||
title: typeof this.title === "string" ? this.title : this.title === false ? null : this.timeago | ||
} | ||
}, | ||
[this.timeago] | ||
); | ||
} | ||
@@ -1087,3 +1120,5 @@ }); | ||
if (version < 3) { | ||
console.warn("[vue-timeago3] This plugin requires at least Vue version 3.0"); | ||
console.warn( | ||
"[vue-timeago3] This plugin requires at least Vue version 3.0" | ||
); | ||
} | ||
@@ -1090,0 +1125,0 @@ const Component = createTimeago(options); |
@@ -1,1 +0,1 @@ | ||
(function(g,v){typeof exports=="object"&&typeof module!="undefined"?v(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],v):(g=typeof globalThis!="undefined"?globalThis:g||self,v(g.VueTimeago3={},g.Vue))})(this,function(g,v){"use strict";function X(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function h(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function d(e){h(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function T(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function p(e,t){h(2,arguments);var n=d(e),a=d(t),i=n.getTime()-a.getTime();return i<0?-1:i>0?1:i}var U=6e4,O=36e5;function q(e,t){h(2,arguments);var n=d(e),a=d(t),i=n.getFullYear()-a.getFullYear(),r=n.getMonth()-a.getMonth();return i*12+r}function L(e,t){return h(2,arguments),d(e).getTime()-d(t).getTime()}var F={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(e){return e<0?Math.ceil(e):Math.floor(e)}},H="trunc";function V(e){return e?F[e]:F[H]}function $(e){h(1,arguments);var t=d(e);return t.setHours(23,59,59,999),t}function J(e){h(1,arguments);var t=d(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function Q(e){h(1,arguments);var t=d(e);return $(t).getTime()===J(t).getTime()}function Z(e,t){h(2,arguments);var n=d(e),a=d(t),i=p(n,a),r=Math.abs(q(n,a)),o;if(r<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*r);var l=p(n,a)===-i;Q(d(e))&&r===1&&p(e,a)===1&&(l=!1),o=i*(r-Number(l))}return o===0?0:o}function B(e,t,n){h(2,arguments);var a=L(e,t)/1e3;return V(n==null?void 0:n.roundingMethod)(a)}var K={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},G=function(e,t,n){var a,i=K[e];return typeof i=="string"?a=i:t===1?a=i.one:a=i.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+a:a+" ago":a},ee=G;function x(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=t.width?String(t.width):e.defaultWidth,a=e.formats[n]||e.formats[e.defaultWidth];return a}}var te={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ne={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ae={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},re={date:x({formats:te,defaultWidth:"full"}),time:x({formats:ne,defaultWidth:"full"}),dateTime:x({formats:ae,defaultWidth:"full"})},ie=re,oe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ue=function(e,t,n,a){return oe[e]},se=ue;function w(e){return function(t,n){var a=n||{},i=a.context?String(a.context):"standalone",r;if(i==="formatting"&&e.formattingValues){var o=e.defaultFormattingWidth||e.defaultWidth,l=a.width?String(a.width):o;r=e.formattingValues[l]||e.formattingValues[o]}else{var f=e.defaultWidth,u=a.width?String(a.width):e.defaultWidth;r=e.values[u]||e.values[f]}var s=e.argumentCallback?e.argumentCallback(t):t;return r[s]}}var le={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},fe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},de={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},me={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ce={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},he={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ve=function(e,t){var n=Number(e),a=n%100;if(a>20||a<10)switch(a%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},ge={ordinalNumber:ve,era:w({values:le,defaultWidth:"wide"}),quarter:w({values:fe,defaultWidth:"wide",argumentCallback:function(e){return e-1}}),month:w({values:de,defaultWidth:"wide"}),day:w({values:me,defaultWidth:"wide"}),dayPeriod:w({values:ce,defaultWidth:"wide",formattingValues:he,defaultFormattingWidth:"wide"})},Me=ge;function b(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.width,i=a&&e.matchPatterns[a]||e.matchPatterns[e.defaultMatchWidth],r=t.match(i);if(!r)return null;var o=r[0],l=a&&e.parsePatterns[a]||e.parsePatterns[e.defaultParseWidth],f=Array.isArray(l)?we(l,function(m){return m.test(o)}):pe(l,function(m){return m.test(o)}),u;u=e.valueCallback?e.valueCallback(f):f,u=n.valueCallback?n.valueCallback(u):u;var s=t.slice(o.length);return{value:u,rest:s}}}function pe(e,t){for(var n in e)if(e.hasOwnProperty(n)&&t(e[n]))return n}function we(e,t){for(var n=0;n<e.length;n++)if(t(e[n]))return n}function be(e){return function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=t.match(e.matchPattern);if(!a)return null;var i=a[0],r=t.match(e.parsePattern);if(!r)return null;var o=e.valueCallback?e.valueCallback(r[0]):r[0];o=n.valueCallback?n.valueCallback(o):o;var l=t.slice(i.length);return{value:o,rest:l}}}var De=/^(\d+)(th|st|nd|rd)?/i,ye=/\d+/i,Te={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Se={any:[/^b/i,/^(a|c)/i]},Ne={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Pe={any:[/1/i,/2/i,/3/i,/4/i]},xe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Ie={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},We={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Ce={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ue={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Oe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Fe={ordinalNumber:be({matchPattern:De,parsePattern:ye,valueCallback:function(e){return parseInt(e,10)}}),era:b({matchPatterns:Te,defaultMatchWidth:"wide",parsePatterns:Se,defaultParseWidth:"any"}),quarter:b({matchPatterns:Ne,defaultMatchWidth:"wide",parsePatterns:Pe,defaultParseWidth:"any",valueCallback:function(e){return e+1}}),month:b({matchPatterns:xe,defaultMatchWidth:"wide",parsePatterns:Ie,defaultParseWidth:"any"}),day:b({matchPatterns:We,defaultMatchWidth:"wide",parsePatterns:Ce,defaultParseWidth:"any"}),dayPeriod:b({matchPatterns:Ue,defaultMatchWidth:"any",parsePatterns:Oe,defaultParseWidth:"any"})},Ee=Fe,_e={code:"en-US",formatDistance:ee,formatLong:ie,formatRelative:se,localize:Me,match:Ee,options:{weekStartsOn:0,firstWeekContainsDate:1}},E=_e;function Ye(e,t){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");t=t||{};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function _(e){return Ye({},e)}var Y=1440,Re=2520,I=43200,ke=86400;function Ae(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(2,arguments);var a=n.locale||E;if(!a.formatDistance)throw new RangeError("locale must contain formatDistance property");var i=p(e,t);if(isNaN(i))throw new RangeError("Invalid time value");var r=_(n);r.addSuffix=Boolean(n.addSuffix),r.comparison=i;var o,l;i>0?(o=d(t),l=d(e)):(o=d(e),l=d(t));var f=B(l,o),u=(T(l)-T(o))/1e3,s=Math.round((f-u)/60),m;if(s<2)return n.includeSeconds?f<5?a.formatDistance("lessThanXSeconds",5,r):f<10?a.formatDistance("lessThanXSeconds",10,r):f<20?a.formatDistance("lessThanXSeconds",20,r):f<40?a.formatDistance("halfAMinute",null,r):f<60?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",1,r):s===0?a.formatDistance("lessThanXMinutes",1,r):a.formatDistance("xMinutes",s,r);if(s<45)return a.formatDistance("xMinutes",s,r);if(s<90)return a.formatDistance("aboutXHours",1,r);if(s<Y){var C=Math.round(s/60);return a.formatDistance("aboutXHours",C,r)}else{if(s<Re)return a.formatDistance("xDays",1,r);if(s<I){var M=Math.round(s/Y);return a.formatDistance("xDays",M,r)}else if(s<ke)return m=Math.round(s/I),a.formatDistance("aboutXMonths",m,r)}if(m=Z(l,o),m<12){var c=Math.round(s/I);return a.formatDistance("xMonths",c,r)}else{var P=m%12,y=Math.floor(m/12);return P<3?a.formatDistance("aboutXYears",y,r):P<9?a.formatDistance("overXYears",y,r):a.formatDistance("almostXYears",y+1,r)}}var R=1e3*60,S=60*24,k=S*30,A=S*365;function ze(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};h(2,arguments);var a=n.locale||E;if(!a.formatDistance)throw new RangeError("locale must contain localize.formatDistance property");var i=p(e,t);if(isNaN(i))throw new RangeError("Invalid time value");var r=_(n);r.addSuffix=Boolean(n.addSuffix),r.comparison=i;var o,l;i>0?(o=d(t),l=d(e)):(o=d(e),l=d(t));var f=n.roundingMethod==null?"round":String(n.roundingMethod),u;if(f==="floor")u=Math.floor;else if(f==="ceil")u=Math.ceil;else if(f==="round")u=Math.round;else throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'");var s=l.getTime()-o.getTime(),m=s/R,C=T(l)-T(o),M=(s-C)/R,c;if(n.unit==null?m<1?c="second":m<60?c="minute":m<S?c="hour":M<k?c="day":M<A?c="month":c="year":c=String(n.unit),c==="second"){var P=u(s/1e3);return a.formatDistance("xSeconds",P,r)}else if(c==="minute"){var y=u(m);return a.formatDistance("xMinutes",y,r)}else if(c==="hour"){var st=u(m/60);return a.formatDistance("xHours",st,r)}else if(c==="day"){var lt=u(M/S);return a.formatDistance("xDays",lt,r)}else if(c==="month"){var j=u(M/k);return j===12&&n.unit!=="month"?a.formatDistance("xYears",1,r):a.formatDistance("xMonths",j,r)}else if(c==="year"){var ft=u(M/A);return a.formatDistance("xYears",ft,r)}throw new RangeError("unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'")}function je(e,t){return h(1,arguments),Ae(e,Date.now(),t)}function Xe(e,t){return h(1,arguments),ze(e,Date.now(),t)}function qe(e,t){h(1,arguments);var n=t||{},a=n.additionalDigits==null?2:X(n.additionalDigits);if(a!==2&&a!==1&&a!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var i=$e(e),r;if(i.date){var o=Je(i.date,a);r=Qe(o.restDateString,o.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);var l=r.getTime(),f=0,u;if(i.time&&(f=Ze(i.time),isNaN(f)))return new Date(NaN);if(i.timezone){if(u=Be(i.timezone),isNaN(u))return new Date(NaN)}else{var s=new Date(l+f),m=new Date(0);return m.setFullYear(s.getUTCFullYear(),s.getUTCMonth(),s.getUTCDate()),m.setHours(s.getUTCHours(),s.getUTCMinutes(),s.getUTCSeconds(),s.getUTCMilliseconds()),m}return new Date(l+f+u)}var N={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Le=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,He=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Ve=/^([+-])(\d{2})(?::?(\d{2}))?$/;function $e(e){var t={},n=e.split(N.dateTimeDelimiter),a;if(n.length>2)return t;if(/:/.test(n[0])?a=n[0]:(t.date=n[0],a=n[1],N.timeZoneDelimiter.test(t.date)&&(t.date=e.split(N.timeZoneDelimiter)[0],a=e.substr(t.date.length,e.length))),a){var i=N.timezone.exec(a);i?(t.time=a.replace(i[1],""),t.timezone=i[1]):t.time=a}return t}function Je(e,t){var n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),a=e.match(n);if(!a)return{year:NaN,restDateString:""};var i=a[1]?parseInt(a[1]):null,r=a[2]?parseInt(a[2]):null;return{year:r===null?i:r*100,restDateString:e.slice((a[1]||a[2]).length)}}function Qe(e,t){if(t===null)return new Date(NaN);var n=e.match(Le);if(!n)return new Date(NaN);var a=!!n[4],i=D(n[1]),r=D(n[2])-1,o=D(n[3]),l=D(n[4]),f=D(n[5])-1;if(a)return nt(t,l,f)?Ke(t,l,f):new Date(NaN);var u=new Date(0);return!et(t,r,o)||!tt(t,i)?new Date(NaN):(u.setUTCFullYear(t,r,Math.max(i,o)),u)}function D(e){return e?parseInt(e):1}function Ze(e){var t=e.match(He);if(!t)return NaN;var n=W(t[1]),a=W(t[2]),i=W(t[3]);return at(n,a,i)?n*O+a*U+i*1e3:NaN}function W(e){return e&&parseFloat(e.replace(",","."))||0}function Be(e){if(e==="Z")return 0;var t=e.match(Ve);if(!t)return 0;var n=t[1]==="+"?-1:1,a=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return rt(a,i)?n*(a*O+i*U):NaN}function Ke(e,t,n){var a=new Date(0);a.setUTCFullYear(e,0,4);var i=a.getUTCDay()||7,r=(t-1)*7+n+1-i;return a.setUTCDate(a.getUTCDate()+r),a}var Ge=[31,null,31,30,31,30,31,31,30,31,30,31];function z(e){return e%400===0||e%4===0&&e%100!==0}function et(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(Ge[t]||(z(e)?29:28))}function tt(e,t){return t>=1&&t<=(z(e)?366:365)}function nt(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function at(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function rt(e,t){return t>=0&&t<=59}var it=(e,t={},n)=>{var a,i;return typeof e=="string"&&(e=qe(e)),t.useStrict?Xe(e,{addSuffix:(a=t.addSuffix)!=null?a:!0,locale:n,unit:t.unit,roundingMethod:t.roundingMethod}):je(e,{includeSeconds:t.includeSeconds,addSuffix:(i=t.addSuffix)!=null?i:!0,locale:n})};const ot=(e={})=>{const t=e.name||"Timeago";return v.defineComponent({name:t,props:{datetime:{type:[String,Number,Date],required:!0},title:{type:[String,Boolean],required:!1,default:null},autoUpdate:{type:[Number,Boolean],required:!1,default:null},converter:{type:Function,required:!1,default:null},converterOptions:{type:Object,required:!1,default:null},locale:{type:Object,required:!1,default:null}},setup(n){const a=v.ref();v.onBeforeMount(()=>{l()}),v.onBeforeUnmount(()=>{f()});const i=u=>(n.converter||it)(u||n.datetime,n.converterOptions||e.converterOptions,n.locale||e.locale),r=v.ref(i()),o=u=>{r.value=i(u)},l=()=>{if(n.autoUpdate){const u=n.autoUpdate===!0?60:n.autoUpdate;a.value=setInterval(()=>{o(n.datetime)},u*1e3)}},f=()=>{a.value&&(clearInterval(a.value),a.value=void 0)};return v.watch(()=>n.autoUpdate,u=>{f(),u&&l()}),v.watch(()=>[n.datetime,n.converter],()=>{o()}),v.watch(()=>n.converterOptions,()=>{o()},{deep:!0}),{timeago:r,updateTimer:a}},render(){return v.h("timeago",{attrs:{datetime:new Date(this.datetime).toISOString(),title:typeof this.title=="string"?this.title:this.title===!1?null:this.timeago}},[this.timeago])}})};var ut=(e,t)=>{if(e.config.globalProperties.$timeago)return;Number(e.version.split(".")[0])<3&&console.warn("[vue-timeago3] This plugin requires at least Vue version 3.0");const a=ot(t);e.component(a.name,a)};g.default=ut,Object.defineProperty(g,"__esModule",{value:!0}),g[Symbol.toStringTag]="Module"}); | ||
(function(b,g){typeof exports=="object"&&typeof module!="undefined"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):(b=typeof globalThis!="undefined"?globalThis:b||self,g(b.VueTimeago3={},b.Vue))})(this,function(b,g){"use strict";function O(e){return O=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},O(e)}function J(e){if(e===null||e===!0||e===!1)return NaN;var t=Number(e);return isNaN(t)?t:t<0?Math.ceil(t):Math.floor(t)}function h(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}function m(e){h(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||O(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):((typeof e=="string"||t==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn(new Error().stack)),new Date(NaN))}var Q={};function k(){return Q}function x(e){var t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),e.getTime()-t.getTime()}function p(e,t){h(2,arguments);var a=m(e),n=m(t),r=a.getTime()-n.getTime();return r<0?-1:r>0?1:r}var R=6e4,Y=36e5;function Z(e,t){h(2,arguments);var a=m(e),n=m(t),r=a.getFullYear()-n.getFullYear(),o=a.getMonth()-n.getMonth();return r*12+o}function B(e,t){return h(2,arguments),m(e).getTime()-m(t).getTime()}var A={ceil:Math.ceil,round:Math.round,floor:Math.floor,trunc:function(t){return t<0?Math.ceil(t):Math.floor(t)}},G="trunc";function K(e){return e?A[e]:A[G]}function ee(e){h(1,arguments);var t=m(e);return t.setHours(23,59,59,999),t}function te(e){h(1,arguments);var t=m(e),a=t.getMonth();return t.setFullYear(t.getFullYear(),a+1,0),t.setHours(23,59,59,999),t}function ae(e){h(1,arguments);var t=m(e);return ee(t).getTime()===te(t).getTime()}function ne(e,t){h(2,arguments);var a=m(e),n=m(t),r=p(a,n),o=Math.abs(Z(a,n)),i;if(o<1)i=0;else{a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-r*o);var s=p(a,n)===-r;ae(m(e))&&o===1&&p(e,n)===1&&(s=!1),i=r*(o-Number(s))}return i===0?0:i}function re(e,t,a){h(2,arguments);var n=B(e,t)/1e3;return K(a==null?void 0:a.roundingMethod)(n)}var ie={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},oe=function(t,a,n){var r,o=ie[t];return typeof o=="string"?r=o:a===1?r=o.one:r=o.other.replace("{{count}}",a.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r},ue=oe;function C(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=t.width?String(t.width):e.defaultWidth,n=e.formats[a]||e.formats[e.defaultWidth];return n}}var le={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},se={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},fe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},de={date:C({formats:le,defaultWidth:"full"}),time:C({formats:se,defaultWidth:"full"}),dateTime:C({formats:fe,defaultWidth:"full"})},me=de,ce={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ve=function(t,a,n,r){return ce[t]},he=ve;function S(e){return function(t,a){var n=a!=null&&a.context?String(a.context):"standalone",r;if(n==="formatting"&&e.formattingValues){var o=e.defaultFormattingWidth||e.defaultWidth,i=a!=null&&a.width?String(a.width):o;r=e.formattingValues[i]||e.formattingValues[o]}else{var s=e.defaultWidth,u=a!=null&&a.width?String(a.width):e.defaultWidth;r=e.values[u]||e.values[s]}var l=e.argumentCallback?e.argumentCallback(t):t;return r[l]}}var ge={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Me={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},be={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},we={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},ye={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},De={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},pe=function(t,a){var n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Se={ordinalNumber:pe,era:S({values:ge,defaultWidth:"wide"}),quarter:S({values:Me,defaultWidth:"wide",argumentCallback:function(t){return t-1}}),month:S({values:be,defaultWidth:"wide"}),day:S({values:we,defaultWidth:"wide"}),dayPeriod:S({values:ye,defaultWidth:"wide",formattingValues:De,defaultFormattingWidth:"wide"})},Te=Se;function T(e){return function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=a.width,r=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],o=t.match(r);if(!o)return null;var i=o[0],s=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],u=Array.isArray(s)?Pe(s,function(c){return c.test(i)}):Ne(s,function(c){return c.test(i)}),l;l=e.valueCallback?e.valueCallback(u):u,l=a.valueCallback?a.valueCallback(l):l;var d=t.slice(i.length);return{value:l,rest:d}}}function Ne(e,t){for(var a in e)if(e.hasOwnProperty(a)&&t(e[a]))return a}function Pe(e,t){for(var a=0;a<e.length;a++)if(t(e[a]))return a}function xe(e){return function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.match(e.matchPattern);if(!n)return null;var r=n[0],o=t.match(e.parsePattern);if(!o)return null;var i=e.valueCallback?e.valueCallback(o[0]):o[0];i=a.valueCallback?a.valueCallback(i):i;var s=t.slice(r.length);return{value:i,rest:s}}}var Ie=/^(\d+)(th|st|nd|rd)?/i,We=/\d+/i,Oe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Ce={any:[/^b/i,/^(a|c)/i]},Ue={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},_e={any:[/1/i,/2/i,/3/i,/4/i]},Fe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Ee={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},ke={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Re={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ye={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ae={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ze={ordinalNumber:xe({matchPattern:Ie,parsePattern:We,valueCallback:function(t){return parseInt(t,10)}}),era:T({matchPatterns:Oe,defaultMatchWidth:"wide",parsePatterns:Ce,defaultParseWidth:"any"}),quarter:T({matchPatterns:Ue,defaultMatchWidth:"wide",parsePatterns:_e,defaultParseWidth:"any",valueCallback:function(t){return t+1}}),month:T({matchPatterns:Fe,defaultMatchWidth:"wide",parsePatterns:Ee,defaultParseWidth:"any"}),day:T({matchPatterns:ke,defaultMatchWidth:"wide",parsePatterns:Re,defaultParseWidth:"any"}),dayPeriod:T({matchPatterns:Ye,defaultMatchWidth:"any",parsePatterns:Ae,defaultParseWidth:"any"})},je=ze,Xe={code:"en-US",formatDistance:ue,formatLong:me,formatRelative:he,localize:Te,match:je,options:{weekStartsOn:0,firstWeekContainsDate:1}},z=Xe;function U(e,t){if(e==null)throw new TypeError("assign requires that input parameter not be null or undefined");for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}function j(e){return U({},e)}var X=1440,qe=2520,_=43200,$e=86400;function Le(e,t,a){var n,r;h(2,arguments);var o=k(),i=(n=(r=a==null?void 0:a.locale)!==null&&r!==void 0?r:o.locale)!==null&&n!==void 0?n:z;if(!i.formatDistance)throw new RangeError("locale must contain formatDistance property");var s=p(e,t);if(isNaN(s))throw new RangeError("Invalid time value");var u=U(j(a),{addSuffix:Boolean(a==null?void 0:a.addSuffix),comparison:s}),l,d;s>0?(l=m(t),d=m(e)):(l=m(e),d=m(t));var c=re(d,l),P=(x(d)-x(l))/1e3,f=Math.round((c-P)/60),M;if(f<2)return a!=null&&a.includeSeconds?c<5?i.formatDistance("lessThanXSeconds",5,u):c<10?i.formatDistance("lessThanXSeconds",10,u):c<20?i.formatDistance("lessThanXSeconds",20,u):c<40?i.formatDistance("halfAMinute",0,u):c<60?i.formatDistance("lessThanXMinutes",1,u):i.formatDistance("xMinutes",1,u):f===0?i.formatDistance("lessThanXMinutes",1,u):i.formatDistance("xMinutes",f,u);if(f<45)return i.formatDistance("xMinutes",f,u);if(f<90)return i.formatDistance("aboutXHours",1,u);if(f<X){var w=Math.round(f/60);return i.formatDistance("aboutXHours",w,u)}else{if(f<qe)return i.formatDistance("xDays",1,u);if(f<_){var E=Math.round(f/X);return i.formatDistance("xDays",E,u)}else if(f<$e)return M=Math.round(f/_),i.formatDistance("aboutXMonths",M,u)}if(M=ne(d,l),M<12){var y=Math.round(f/_);return i.formatDistance("xMonths",y,u)}else{var D=M%12,v=Math.floor(M/12);return D<3?i.formatDistance("aboutXYears",v,u):D<9?i.formatDistance("overXYears",v,u):i.formatDistance("almostXYears",v+1,u)}}var q=1e3*60,I=60*24,$=I*30,L=I*365;function He(e,t,a){var n,r,o;h(2,arguments);var i=k(),s=(n=(r=a==null?void 0:a.locale)!==null&&r!==void 0?r:i.locale)!==null&&n!==void 0?n:z;if(!s.formatDistance)throw new RangeError("locale must contain localize.formatDistance property");var u=p(e,t);if(isNaN(u))throw new RangeError("Invalid time value");var l=U(j(a),{addSuffix:Boolean(a==null?void 0:a.addSuffix),comparison:u}),d,c;u>0?(d=m(t),c=m(e)):(d=m(e),c=m(t));var P=String((o=a==null?void 0:a.roundingMethod)!==null&&o!==void 0?o:"round"),f;if(P==="floor")f=Math.floor;else if(P==="ceil")f=Math.ceil;else if(P==="round")f=Math.round;else throw new RangeError("roundingMethod must be 'floor', 'ceil' or 'round'");var M=c.getTime()-d.getTime(),w=M/q,E=x(c)-x(d),y=(M-E)/q,D=a==null?void 0:a.unit,v;if(D?v=String(D):w<1?v="second":w<60?v="minute":w<I?v="hour":y<$?v="day":y<L?v="month":v="year",v==="second"){var vt=f(M/1e3);return s.formatDistance("xSeconds",vt,l)}else if(v==="minute"){var ht=f(w);return s.formatDistance("xMinutes",ht,l)}else if(v==="hour"){var gt=f(w/60);return s.formatDistance("xHours",gt,l)}else if(v==="day"){var Mt=f(y/I);return s.formatDistance("xDays",Mt,l)}else if(v==="month"){var V=f(y/$);return V===12&&D!=="month"?s.formatDistance("xYears",1,l):s.formatDistance("xMonths",V,l)}else if(v==="year"){var bt=f(y/L);return s.formatDistance("xYears",bt,l)}throw new RangeError("unit must be 'second', 'minute', 'hour', 'day', 'month' or 'year'")}function Ve(e,t){return h(1,arguments),Le(e,Date.now(),t)}function Je(e,t){return h(1,arguments),He(e,Date.now(),t)}function Qe(e,t){var a;h(1,arguments);var n=J((a=t==null?void 0:t.additionalDigits)!==null&&a!==void 0?a:2);if(n!==2&&n!==1&&n!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var r=Ke(e),o;if(r.date){var i=et(r.date,n);o=tt(i.restDateString,i.year)}if(!o||isNaN(o.getTime()))return new Date(NaN);var s=o.getTime(),u=0,l;if(r.time&&(u=at(r.time),isNaN(u)))return new Date(NaN);if(r.timezone){if(l=nt(r.timezone),isNaN(l))return new Date(NaN)}else{var d=new Date(s+u),c=new Date(0);return c.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),c.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),c}return new Date(s+u+l)}var W={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Ze=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,Be=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Ge=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ke(e){var t={},a=e.split(W.dateTimeDelimiter),n;if(a.length>2)return t;if(/:/.test(a[0])?n=a[0]:(t.date=a[0],n=a[1],W.timeZoneDelimiter.test(t.date)&&(t.date=e.split(W.timeZoneDelimiter)[0],n=e.substr(t.date.length,e.length))),n){var r=W.timezone.exec(n);r?(t.time=n.replace(r[1],""),t.timezone=r[1]):t.time=n}return t}function et(e,t){var a=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),n=e.match(a);if(!n)return{year:NaN,restDateString:""};var r=n[1]?parseInt(n[1]):null,o=n[2]?parseInt(n[2]):null;return{year:o===null?r:o*100,restDateString:e.slice((n[1]||n[2]).length)}}function tt(e,t){if(t===null)return new Date(NaN);var a=e.match(Ze);if(!a)return new Date(NaN);var n=!!a[4],r=N(a[1]),o=N(a[2])-1,i=N(a[3]),s=N(a[4]),u=N(a[5])-1;if(n)return lt(t,s,u)?rt(t,s,u):new Date(NaN);var l=new Date(0);return!ot(t,o,i)||!ut(t,r)?new Date(NaN):(l.setUTCFullYear(t,o,Math.max(r,i)),l)}function N(e){return e?parseInt(e):1}function at(e){var t=e.match(Be);if(!t)return NaN;var a=F(t[1]),n=F(t[2]),r=F(t[3]);return st(a,n,r)?a*Y+n*R+r*1e3:NaN}function F(e){return e&&parseFloat(e.replace(",","."))||0}function nt(e){if(e==="Z")return 0;var t=e.match(Ge);if(!t)return 0;var a=t[1]==="+"?-1:1,n=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return ft(n,r)?a*(n*Y+r*R):NaN}function rt(e,t,a){var n=new Date(0);n.setUTCFullYear(e,0,4);var r=n.getUTCDay()||7,o=(t-1)*7+a+1-r;return n.setUTCDate(n.getUTCDate()+o),n}var it=[31,null,31,30,31,30,31,31,30,31,30,31];function H(e){return e%400===0||e%4===0&&e%100!==0}function ot(e,t,a){return t>=0&&t<=11&&a>=1&&a<=(it[t]||(H(e)?29:28))}function ut(e,t){return t>=1&&t<=(H(e)?366:365)}function lt(e,t,a){return t>=1&&t<=53&&a>=0&&a<=6}function st(e,t,a){return e===24?t===0&&a===0:a>=0&&a<60&&t>=0&&t<60&&e>=0&&e<25}function ft(e,t){return t>=0&&t<=59}var dt=(e,t={},a)=>{var n,r;return typeof e=="string"&&(e=Qe(e)),t.useStrict?Je(e,{addSuffix:(n=t.addSuffix)!=null?n:!0,locale:a,unit:t.unit,roundingMethod:t.roundingMethod}):Ve(e,{includeSeconds:t.includeSeconds,addSuffix:(r=t.addSuffix)!=null?r:!0,locale:a})};const mt=(e={})=>{const t=e.name||"Timeago";return g.defineComponent({name:t,props:{datetime:{type:[String,Number,Date],required:!0},title:{type:[String,Boolean],required:!1,default:null},autoUpdate:{type:[Number,Boolean],required:!1,default:null},converter:{type:Function,required:!1,default:null},converterOptions:{type:Object,required:!1,default:null},locale:{type:Object,required:!1,default:null}},setup(a){const n=g.ref();g.onBeforeMount(()=>{s()}),g.onBeforeUnmount(()=>{u()});const r=l=>(a.converter||dt)(l||a.datetime,a.converterOptions||e.converterOptions,a.locale||e.locale),o=g.ref(r()),i=l=>{o.value=r(l)},s=()=>{if(a.autoUpdate){const l=a.autoUpdate===!0?60:a.autoUpdate;n.value=setInterval(()=>{i(a.datetime)},l*1e3)}},u=()=>{n.value&&(clearInterval(n.value),n.value=void 0)};return g.watch(()=>a.autoUpdate,l=>{u(),l&&s()}),g.watch(()=>[a.datetime,a.converter],()=>{i()}),g.watch(()=>a.converterOptions,()=>{i()},{deep:!0}),{timeago:o,updateTimer:n}},render(){return g.h("timeago",{attrs:{datetime:new Date(this.datetime).toISOString(),title:typeof this.title=="string"?this.title:this.title===!1?null:this.timeago}},[this.timeago])}})};var ct=(e,t)=>{if(e.config.globalProperties.$timeago)return;Number(e.version.split(".")[0])<3&&console.warn("[vue-timeago3] This plugin requires at least Vue version 3.0");const n=mt(t);e.component(n.name,n)};b.default=ct,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); |
{ | ||
"name": "vue-timeago3", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"files": [ | ||
@@ -57,3 +57,3 @@ "dist" | ||
"@types/jest": "^27.5.0", | ||
"@types/node": "^17.0.42", | ||
"@types/node": "^20.1.1", | ||
"@typescript-eslint/eslint-plugin": "^5.27.1", | ||
@@ -68,3 +68,3 @@ "@typescript-eslint/parser": "^5.27.1", | ||
"jest": "^27.5.1", | ||
"prettier": "2.6.2", | ||
"prettier": "2.8.8", | ||
"release-it": "^15.0.0", | ||
@@ -77,3 +77,3 @@ "ts-jest": "^27.1.4", | ||
"vue-eslint-parser": "^9.0.2", | ||
"vue-tsc": "^0.37.3" | ||
"vue-tsc": "^1.0.9" | ||
}, | ||
@@ -80,0 +80,0 @@ "description": "vue-timeago3 is a tiny component for Vue.js 3, to show the time passed since a specific date. You simply pass a date and get somewhat like 10 seconds ago, 3 weeks ago, ... printed by the component", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67063
1169