choo-taro-ui-vue3
Version:
Taro UI Rewritten in Vue 3.0
3,026 lines • 102 kB
JavaScript
import { defineComponent, computed, toRefs, renderList, Fragment, openBlock, createElementBlock, createCommentVNode, toDisplayString, createTextVNode, resolveComponent, withCtx, createVNode, createBlock, normalizeClass, ref, reactive, watch, onMounted, toRef, nextTick, normalizeStyle, mergeProps } from 'vue';
import Taro from '@tarojs/taro';
import { delayQuerySelector } from '../utils';
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
var dayjs_min = {exports: {}};
(function (module, exports) {
!function(t,e){module.exports=e();}(commonjsGlobal,function(){var t="millisecond",e="second",n="minute",r="hour",i="day",s="week",u="month",a="quarter",o="year",f="date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},$=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},l={s:$,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+$(r,2,"0")+":"+$(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,u),s=n-i<0,a=e.clone().add(r+(s?-1:1),u);return +(-(r+(n-i)/(s?i-a:a-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(h){return {M:u,y:o,w:s,d:i,D:f,h:r,m:n,s:e,ms:t,Q:a}[h]||String(h||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},y="en",M={};M[y]=d;var m=function(t){return t instanceof S},D=function(t,e,n){var r;if(!t)return y;if("string"==typeof t)M[t]&&(r=t),e&&(M[t]=e,r=t);else {var i=t.name;M[i]=t,r=i;}return !n&&r&&(y=r),r||!n&&y},v=function(t,e){if(m(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new S(n)},g=l;g.l=D,g.i=m,g.w=function(t,e){return v(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var S=function(){function d(t){this.$L=D(t.locale,null,!0),this.parse(t);}var $=d.prototype;return $.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(g.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(h);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init();},$.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},$.$utils=function(){return g},$.isValid=function(){return !("Invalid Date"===this.$d.toString())},$.isSame=function(t,e){var n=v(t);return this.startOf(e)<=n&&n<=this.endOf(e)},$.isAfter=function(t,e){return v(t)<this.startOf(e)},$.isBefore=function(t,e){return this.endOf(e)<v(t)},$.$g=function(t,e,n){return g.u(t)?this[e]:this.set(n,t)},$.unix=function(){return Math.floor(this.valueOf()/1e3)},$.valueOf=function(){return this.$d.getTime()},$.startOf=function(t,a){var h=this,c=!!g.u(a)||a,d=g.p(t),$=function(t,e){var n=g.w(h.$u?Date.UTC(h.$y,e,t):new Date(h.$y,e,t),h);return c?n:n.endOf(i)},l=function(t,e){return g.w(h.toDate()[t].apply(h.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),h)},y=this.$W,M=this.$M,m=this.$D,D="set"+(this.$u?"UTC":"");switch(d){case o:return c?$(1,0):$(31,11);case u:return c?$(1,M):$(0,M+1);case s:var v=this.$locale().weekStart||0,S=(y<v?y+7:y)-v;return $(c?m-S:m+(6-S),M);case i:case f:return l(D+"Hours",0);case r:return l(D+"Minutes",1);case n:return l(D+"Seconds",2);case e:return l(D+"Milliseconds",3);default:return this.clone()}},$.endOf=function(t){return this.startOf(t,!1)},$.$set=function(s,a){var h,c=g.p(s),d="set"+(this.$u?"UTC":""),$=(h={},h[i]=d+"Date",h[f]=d+"Date",h[u]=d+"Month",h[o]=d+"FullYear",h[r]=d+"Hours",h[n]=d+"Minutes",h[e]=d+"Seconds",h[t]=d+"Milliseconds",h)[c],l=c===i?this.$D+(a-this.$W):a;if(c===u||c===o){var y=this.clone().set(f,1);y.$d[$](l),y.init(),this.$d=y.set(f,Math.min(this.$D,y.daysInMonth())).$d;}else $&&this.$d[$](l);return this.init(),this},$.set=function(t,e){return this.clone().$set(t,e)},$.get=function(t){return this[g.p(t)]()},$.add=function(t,a){var f,h=this;t=Number(t);var c=g.p(a),d=function(e){var n=v(h);return g.w(n.date(n.date()+Math.round(e*t)),h)};if(c===u)return this.set(u,this.$M+t);if(c===o)return this.set(o,this.$y+t);if(c===i)return d(1);if(c===s)return d(7);var $=(f={},f[n]=6e4,f[r]=36e5,f[e]=1e3,f)[c]||1,l=this.$d.getTime()+t*$;return g.w(l,this)},$.subtract=function(t,e){return this.add(-1*t,e)},$.format=function(t){var e=this;if(!this.isValid())return "Invalid Date";var n=t||"YYYY-MM-DDTHH:mm:ssZ",r=g.z(this),i=this.$locale(),s=this.$H,u=this.$m,a=this.$M,o=i.weekdays,f=i.months,h=function(t,r,i,s){return t&&(t[r]||t(e,n))||i[r].substr(0,s)},d=function(t){return g.s(s%12||12,t,"0")},$=i.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:g.s(a+1,2,"0"),MMM:h(i.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:g.s(this.$D,2,"0"),d:String(this.$W),dd:h(i.weekdaysMin,this.$W,o,2),ddd:h(i.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:g.s(s,2,"0"),h:d(1),hh:d(2),a:$(s,u,!0),A:$(s,u,!1),m:String(u),mm:g.s(u,2,"0"),s:String(this.$s),ss:g.s(this.$s,2,"0"),SSS:g.s(this.$ms,3,"0"),Z:r};return n.replace(c,function(t,e){return e||l[t]||r.replace(":","")})},$.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},$.diff=function(t,f,h){var c,d=g.p(f),$=v(t),l=6e4*($.utcOffset()-this.utcOffset()),y=this-$,M=g.m(this,$);return M=(c={},c[o]=M/12,c[u]=M,c[a]=M/3,c[s]=(y-l)/6048e5,c[i]=(y-l)/864e5,c[r]=y/36e5,c[n]=y/6e4,c[e]=y/1e3,c)[d]||y,h?M:g.a(M)},$.daysInMonth=function(){return this.endOf(u).$D},$.$locale=function(){return M[this.$L]},$.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=D(t,e,!0);return r&&(n.$L=r),n},$.clone=function(){return g.w(this.$d,this)},$.toDate=function(){return new Date(this.valueOf())},$.toJSON=function(){return this.isValid()?this.toISOString():null},$.toISOString=function(){return this.$d.toISOString()},$.toString=function(){return this.$d.toUTCString()},d}(),p=S.prototype;return v.prototype=p,[["$ms",t],["$s",e],["$m",n],["$H",r],["$W",i],["$M",u],["$y",o],["$D",f]].forEach(function(t){p[t[1]]=function(e){return this.$g(e,t[0],t[1])};}),v.extend=function(t,e){return t.$i||(t(e,S,v),t.$i=!0),v},v.locale=D,v.isDayjs=m,v.unix=function(t){return v(1e3*t)},v.en=M[y],v.Ls=M,v.p={},v});
}(dayjs_min));
var dayjs$1 = dayjs_min.exports;
var SECONDS_A_MINUTE = 60;
var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
var MILLISECONDS_A_SECOND = 1e3;
var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND; // English locales
var MS = 'millisecond';
var S = 'second';
var MIN = 'minute';
var H = 'hour';
var D = 'day';
var W = 'week';
var M = 'month';
var Q = 'quarter';
var Y = 'year';
var DATE = 'date';
var FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ssZ';
var INVALID_DATE_STRING = 'Invalid Date'; // regex
var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
// English [en]
// We don't need weekdaysShort, weekdaysMin, monthsShort in en.js locale
var en = {
name: 'en',
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_')
};
var padStart = function padStart(string, length, pad) {
var s = String(string);
if (!s || s.length >= length) return string;
return "" + Array(length + 1 - s.length).join(pad) + string;
};
var padZoneStr = function padZoneStr(instance) {
var negMinutes = -instance.utcOffset();
var minutes = Math.abs(negMinutes);
var hourOffset = Math.floor(minutes / 60);
var minuteOffset = minutes % 60;
return "" + (negMinutes <= 0 ? '+' : '-') + padStart(hourOffset, 2, '0') + ":" + padStart(minuteOffset, 2, '0');
};
var monthDiff = function monthDiff(a, b) {
// function from moment.js in order to keep the same result
if (a.date() < b.date()) return -monthDiff(b, a);
var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month());
var anchor = a.clone().add(wholeMonthDiff, M);
var c = b - anchor < 0;
var anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), M);
return +(-(wholeMonthDiff + (b - anchor) / (c ? anchor - anchor2 : anchor2 - anchor)) || 0);
};
var absFloor = function absFloor(n) {
return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);
};
var prettyUnit = function prettyUnit(u) {
var special = {
M: M,
y: Y,
w: W,
d: D,
D: DATE,
h: H,
m: MIN,
s: S,
ms: MS,
Q: Q
};
return special[u] || String(u || '').toLowerCase().replace(/s$/, '');
};
var isUndefined = function isUndefined(s) {
return s === undefined;
};
var U = {
s: padStart,
z: padZoneStr,
m: monthDiff,
a: absFloor,
p: prettyUnit,
u: isUndefined
};
var L = 'en'; // global locale
var Ls = {}; // global loaded locale
Ls[L] = en;
var isDayjs = function isDayjs(d) {
return d instanceof Dayjs;
}; // eslint-disable-line no-use-before-define
var parseLocale = function parseLocale(preset, object, isLocal) {
var l;
if (!preset) return L;
if (typeof preset === 'string') {
if (Ls[preset]) {
l = preset;
}
if (object) {
Ls[preset] = object;
l = preset;
}
} else {
var name = preset.name;
Ls[name] = preset;
l = name;
}
if (!isLocal && l) L = l;
return l || !isLocal && L;
};
var dayjs = function dayjs(date, c) {
if (isDayjs(date)) {
return date.clone();
} // eslint-disable-next-line no-nested-ternary
var cfg = typeof c === 'object' ? c : {};
cfg.date = date;
cfg.args = arguments; // eslint-disable-line prefer-rest-params
return new Dayjs(cfg); // eslint-disable-line no-use-before-define
};
var wrapper = function wrapper(date, instance) {
return dayjs(date, {
locale: instance.$L,
utc: instance.$u,
x: instance.$x,
$offset: instance.$offset // todo: refactor; do not use this.$offset in you code
});
};
var Utils = U; // for plugin use
Utils.l = parseLocale;
Utils.i = isDayjs;
Utils.w = wrapper;
var parseDate = function parseDate(cfg) {
var date = cfg.date,
utc = cfg.utc;
if (date === null) return new Date(NaN); // null is invalid
if (Utils.u(date)) return new Date(); // today
if (date instanceof Date) return new Date(date);
if (typeof date === 'string' && !/Z$/i.test(date)) {
var d = date.match(REGEX_PARSE);
if (d) {
var m = d[2] - 1 || 0;
var ms = (d[7] || '0').substring(0, 3);
if (utc) {
return new Date(Date.UTC(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms));
}
return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
}
}
return new Date(date); // everything else
};
var Dayjs = /*#__PURE__*/function () {
function Dayjs(cfg) {
this.$L = parseLocale(cfg.locale, null, true);
this.parse(cfg); // for plugin
}
var _proto = Dayjs.prototype;
_proto.parse = function parse(cfg) {
this.$d = parseDate(cfg);
this.$x = cfg.x || {};
this.init();
};
_proto.init = function init() {
var $d = this.$d;
this.$y = $d.getFullYear();
this.$M = $d.getMonth();
this.$D = $d.getDate();
this.$W = $d.getDay();
this.$H = $d.getHours();
this.$m = $d.getMinutes();
this.$s = $d.getSeconds();
this.$ms = $d.getMilliseconds();
} // eslint-disable-next-line class-methods-use-this
;
_proto.$utils = function $utils() {
return Utils;
};
_proto.isValid = function isValid() {
return !(this.$d.toString() === INVALID_DATE_STRING);
};
_proto.isSame = function isSame(that, units) {
var other = dayjs(that);
return this.startOf(units) <= other && other <= this.endOf(units);
};
_proto.isAfter = function isAfter(that, units) {
return dayjs(that) < this.startOf(units);
};
_proto.isBefore = function isBefore(that, units) {
return this.endOf(units) < dayjs(that);
};
_proto.$g = function $g(input, get, set) {
if (Utils.u(input)) return this[get];
return this.set(set, input);
};
_proto.unix = function unix() {
return Math.floor(this.valueOf() / 1000);
};
_proto.valueOf = function valueOf() {
// timezone(hour) * 60 * 60 * 1000 => ms
return this.$d.getTime();
};
_proto.startOf = function startOf(units, _startOf) {
var _this = this;
// startOf -> endOf
var isStartOf = !Utils.u(_startOf) ? _startOf : true;
var unit = Utils.p(units);
var instanceFactory = function instanceFactory(d, m) {
var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m, d) : new Date(_this.$y, m, d), _this);
return isStartOf ? ins : ins.endOf(D);
};
var instanceFactorySet = function instanceFactorySet(method, slice) {
var argumentStart = [0, 0, 0, 0];
var argumentEnd = [23, 59, 59, 999];
return Utils.w(_this.toDate()[method].apply( // eslint-disable-line prefer-spread
_this.toDate('s'), (isStartOf ? argumentStart : argumentEnd).slice(slice)), _this);
};
var $W = this.$W,
$M = this.$M,
$D = this.$D;
var utcPad = "set" + (this.$u ? 'UTC' : '');
switch (unit) {
case Y:
return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);
case M:
return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);
case W:
{
var weekStart = this.$locale().weekStart || 0;
var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;
return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);
}
case D:
case DATE:
return instanceFactorySet(utcPad + "Hours", 0);
case H:
return instanceFactorySet(utcPad + "Minutes", 1);
case MIN:
return instanceFactorySet(utcPad + "Seconds", 2);
case S:
return instanceFactorySet(utcPad + "Milliseconds", 3);
default:
return this.clone();
}
};
_proto.endOf = function endOf(arg) {
return this.startOf(arg, false);
};
_proto.$set = function $set(units, _int) {
var _C$D$C$DATE$C$M$C$Y$C;
// private set
var unit = Utils.p(units);
var utcPad = "set" + (this.$u ? 'UTC' : '');
var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];
var arg = unit === D ? this.$D + (_int - this.$W) : _int;
if (unit === M || unit === Y) {
// clone is for badMutable plugin
var date = this.clone().set(DATE, 1);
date.$d[name](arg);
date.init();
this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d;
} else if (name) this.$d[name](arg);
this.init();
return this;
};
_proto.set = function set(string, _int2) {
return this.clone().$set(string, _int2);
};
_proto.get = function get(unit) {
return this[Utils.p(unit)]();
};
_proto.add = function add(number, units) {
var _this2 = this,
_C$MIN$C$H$C$S$unit;
number = Number(number); // eslint-disable-line no-param-reassign
var unit = Utils.p(units);
var instanceFactorySet = function instanceFactorySet(n) {
var d = dayjs(_this2);
return Utils.w(d.date(d.date() + Math.round(n * number)), _this2);
};
if (unit === M) {
return this.set(M, this.$M + number);
}
if (unit === Y) {
return this.set(Y, this.$y + number);
}
if (unit === D) {
return instanceFactorySet(1);
}
if (unit === W) {
return instanceFactorySet(7);
}
var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1; // ms
var nextTimeStamp = this.$d.getTime() + number * step;
return Utils.w(nextTimeStamp, this);
};
_proto.subtract = function subtract(number, string) {
return this.add(number * -1, string);
};
_proto.format = function format(formatStr) {
var _this3 = this;
if (!this.isValid()) return INVALID_DATE_STRING;
var str = formatStr || FORMAT_DEFAULT;
var zoneStr = Utils.z(this);
var locale = this.$locale();
var $H = this.$H,
$m = this.$m,
$M = this.$M;
var weekdays = locale.weekdays,
months = locale.months,
meridiem = locale.meridiem;
var getShort = function getShort(arr, index, full, length) {
return arr && (arr[index] || arr(_this3, str)) || full[index].substr(0, length);
};
var get$H = function get$H(num) {
return Utils.s($H % 12 || 12, num, '0');
};
var meridiemFunc = meridiem || function (hour, minute, isLowercase) {
var m = hour < 12 ? 'AM' : 'PM';
return isLowercase ? m.toLowerCase() : m;
};
var matches = {
YY: String(this.$y).slice(-2),
YYYY: this.$y,
M: $M + 1,
MM: Utils.s($M + 1, 2, '0'),
MMM: getShort(locale.monthsShort, $M, months, 3),
MMMM: getShort(months, $M),
D: this.$D,
DD: Utils.s(this.$D, 2, '0'),
d: String(this.$W),
dd: getShort(locale.weekdaysMin, this.$W, weekdays, 2),
ddd: getShort(locale.weekdaysShort, this.$W, weekdays, 3),
dddd: weekdays[this.$W],
H: String($H),
HH: Utils.s($H, 2, '0'),
h: get$H(1),
hh: get$H(2),
a: meridiemFunc($H, $m, true),
A: meridiemFunc($H, $m, false),
m: String($m),
mm: Utils.s($m, 2, '0'),
s: String(this.$s),
ss: Utils.s(this.$s, 2, '0'),
SSS: Utils.s(this.$ms, 3, '0'),
Z: zoneStr // 'ZZ' logic below
};
return str.replace(REGEX_FORMAT, function (match, $1) {
return $1 || matches[match] || zoneStr.replace(':', '');
}); // 'ZZ'
};
_proto.utcOffset = function utcOffset() {
// Because a bug at FF24, we're rounding the timezone offset around 15 minutes
// https://github.com/moment/moment/pull/1871
return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;
};
_proto.diff = function diff(input, units, _float) {
var _C$Y$C$M$C$Q$C$W$C$D$;
var unit = Utils.p(units);
var that = dayjs(input);
var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE;
var diff = this - that;
var result = Utils.m(this, that);
result = (_C$Y$C$M$C$Q$C$W$C$D$ = {}, _C$Y$C$M$C$Q$C$W$C$D$[Y] = result / 12, _C$Y$C$M$C$Q$C$W$C$D$[M] = result, _C$Y$C$M$C$Q$C$W$C$D$[Q] = result / 3, _C$Y$C$M$C$Q$C$W$C$D$[W] = (diff - zoneDelta) / MILLISECONDS_A_WEEK, _C$Y$C$M$C$Q$C$W$C$D$[D] = (diff - zoneDelta) / MILLISECONDS_A_DAY, _C$Y$C$M$C$Q$C$W$C$D$[H] = diff / MILLISECONDS_A_HOUR, _C$Y$C$M$C$Q$C$W$C$D$[MIN] = diff / MILLISECONDS_A_MINUTE, _C$Y$C$M$C$Q$C$W$C$D$[S] = diff / MILLISECONDS_A_SECOND, _C$Y$C$M$C$Q$C$W$C$D$)[unit] || diff; // milliseconds
return _float ? result : Utils.a(result);
};
_proto.daysInMonth = function daysInMonth() {
return this.endOf(M).$D;
};
_proto.$locale = function $locale() {
// get locale object
return Ls[this.$L];
};
_proto.locale = function locale(preset, object) {
if (!preset) return this.$L;
var that = this.clone();
var nextLocaleName = parseLocale(preset, object, true);
if (nextLocaleName) that.$L = nextLocaleName;
return that;
};
_proto.clone = function clone() {
return Utils.w(this.$d, this);
};
_proto.toDate = function toDate() {
return new Date(this.valueOf());
};
_proto.toJSON = function toJSON() {
return this.isValid() ? this.toISOString() : null;
};
_proto.toISOString = function toISOString() {
// ie 8 return
// new Dayjs(this.valueOf() + this.$d.getTimezoneOffset() * 60000)
// .format('YYYY-MM-DDTHH:mm:ss.SSS[Z]')
return this.$d.toISOString();
};
_proto.toString = function toString() {
return this.$d.toUTCString();
};
return Dayjs;
}();
var proto = Dayjs.prototype;
dayjs.prototype = proto;
[['$ms', MS], ['$s', S], ['$m', MIN], ['$H', H], ['$W', D], ['$M', M], ['$y', Y], ['$D', DATE]].forEach(function (g) {
proto[g[1]] = function (input) {
return this.$g(input, g[0], g[1]);
};
});
dayjs.extend = function (plugin, option) {
if (!plugin.$i) {
// install plugin only once
plugin(option, Dayjs, dayjs);
plugin.$i = true;
}
return dayjs;
};
dayjs.locale = parseLocale;
dayjs.isDayjs = isDayjs;
dayjs.unix = function (timestamp) {
return dayjs(timestamp * 1e3);
};
dayjs.en = Ls[L];
dayjs.Ls = Ls;
dayjs.p = {};
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
}
/** Built-in value references. */
var objectCreate = Object.create;
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
var baseCreate = (function() {
function object() {}
return function(proto) {
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
var result = new object;
object.prototype = undefined;
return result;
};
}());
/**
* The function whose prototype chain sequence wrappers inherit from.
*
* @private
*/
function baseLodash() {
// No operation performed.
}
/**
* The base constructor for creating `lodash` wrapper objects.
*
* @private
* @param {*} value The value to wrap.
* @param {boolean} [chainAll] Enable explicit method chain sequences.
*/
function LodashWrapper(value, chainAll) {
this.__wrapped__ = value;
this.__actions__ = [];
this.__chain__ = !!chainAll;
this.__index__ = 0;
this.__values__ = undefined;
}
LodashWrapper.prototype = baseCreate(baseLodash.prototype);
LodashWrapper.prototype.constructor = LodashWrapper;
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Built-in value references. */
var Symbol$1 = root.Symbol;
/** Used for built-in method references. */
var objectProto$8 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString$1 = objectProto$8.toString;
/** Built-in value references. */
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty$6.call(value, symToStringTag$1),
tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString$1.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$7 = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto$7.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/** `Object#toString` result references. */
var argsTag$1 = '[object Arguments]';
/**
* The base implementation of `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && baseGetTag(value) == argsTag$1;
}
/** Used for built-in method references. */
var objectProto$6 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
/** Built-in value references. */
var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
*
* _.isArguments([1, 2, 3]);
* // => false
*/
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty$5.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
/** Built-in value references. */
var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : undefined;
/**
* Checks if `value` is a flattenable `arguments` object or array.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenable(value) {
return isArray(value) || isArguments(value) ||
!!(spreadableSymbol && value && value[spreadableSymbol]);
}
/**
* The base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {Array} array The array to flatten.
* @param {number} depth The maximum recursion depth.
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, depth - 1, predicate, isStrict, result);
} else {
arrayPush(result, value);
}
} else if (!isStrict) {
result[result.length] = value;
}
}
return result;
}
/**
* Flattens `array` a single level deep.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
* _.flatten([1, [2, [3, [4]], 5]]);
* // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, 1) : [];
}
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
/**
* A specialized version of `baseRest` which transforms the rest array.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @param {Function} transform The rest array transform.
* @returns {Function} Returns the new function.
*/
function overRest(func, start, transform) {
start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
return function() {
var args = arguments,
index = -1,
length = nativeMax(args.length - start, 0),
array = Array(length);
while (++index < length) {
array[index] = args[start + index];
}
index = -1;
var otherArgs = Array(start + 1);
while (++index < start) {
otherArgs[index] = args[index];
}
otherArgs[start] = transform(array);
return apply(func, this, otherArgs);
};
}
/**
* Creates a function that returns `value`.
*
* @static
* @memberOf _
* @since 2.4.0
* @category Util
* @param {*} value The value to return from the new function.
* @returns {Function} Returns the new constant function.
* @example
*
* var objects = _.times(2, _.constant({ 'a': 1 }));
*
* console.log(objects);
* // => [{ 'a': 1 }, { 'a': 1 }]
*
* console.log(objects[0] === objects[1]);
* // => true
*/
function constant(value) {
return function() {
return value;
};
}
/** `Object#toString` result references. */
var asyncTag = '[object AsyncFunction]',
funcTag$1 = '[object Function]',
genTag = '[object GeneratorFunction]',
proxyTag = '[object Proxy]';
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var tag = baseGetTag(value);
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
}
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
}
/** Used for built-in method references. */
var funcProto$1 = Function.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString$1 = funcProto$1.toString;
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to convert.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString$1.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return '';
}
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
var funcProto = Function.prototype,
objectProto$5 = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
funcToString.call(hasOwnProperty$4).replace(reRegExpChar, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
var defineProperty = (function() {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}());
/**
* This method returns the first argument it receives.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {*} value Any value.
* @returns {*} Returns `value`.
* @example
*
* var object = { 'a': 1 };
*
* console.log(_.identity(object) === object);
* // => true
*/
function identity(value) {
return value;
}
/**
* The base implementation of `setToString` without support for hot loop shorting.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !defineProperty ? identity : function(func, string) {
return defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});
};
/** Used to detect hot functions by number of calls within a span of milliseconds. */
var HOT_COUNT = 800,
HOT_SPAN = 16;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeNow = Date.now;
/**
* Creates a function that'll short out and invoke `identity` instead
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
* milliseconds.
*
* @private
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new shortable function.
*/
function shortOut(func) {
var count = 0,
lastCalled = 0;
return function() {
var stamp = nativeNow(),
remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
return arguments[0];
}
} else {
count = 0;
}
return func.apply(undefined, arguments);
};
}
/**
* Sets the `toString` method of `func` to return `string`.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var setToString = shortOut(baseSetToString);
/**
* A specialized version of `baseRest` which flattens the rest array.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @returns {Function} Returns the new function.
*/
function flatRest(func) {
return setToString(overRest(func, undefined, flatten), func + '');
}
/* Built-in method references that are verified to be native. */
var WeakMap = getNative(root, 'WeakMap');
/** Used to store function metadata. */
var metaMap = WeakMap && new WeakMap;
/**
* This method returns `undefined`.
*
* @static
* @memberOf _
* @since 2.3.0
* @category Util
* @example
*
* _.times(2, _.noop);
* // => [undefined, undefined]
*/
function noop() {
// No operation performed.
}
/**
* Gets metadata for `func`.
*
* @private
* @param {Function} func The function to query.
* @returns {*} Returns the metadata for `func`.
*/
var getData = !metaMap ? noop : function(func) {
return metaMap.get(func);
};
/** Used to lookup unminified function names. */
var realNames = {};
/** Used for built-in method references. */
var objectProto$4 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
/**
* Gets the name of `func`.
*
* @private
* @param {Function} func The function to query.
* @returns {string} Returns the function name.
*/
function getFuncName(func) {
var result = (func.name + ''),
array = realNames[result],
length = hasOwnProperty$3.call(realNames, result) ? array.length : 0;
while (length--) {
var data = array[length],
otherFunc = data.func;
if (otherFunc == null || otherFunc == func) {
return data.name;
}
}
return result;
}
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295;
/**
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
*
* @private
* @constructor
* @param {*} value The value to wrap.
*/
function LazyWrapper(value) {
this.__wrapped__ = value;
this.__actions__ = [];
this.__dir__ = 1;
this.__filtered__ = false;
this.__iteratees__ = [];
this.__takeCount__ = MAX_ARRAY_LENGTH;
this.__views__ = [];
}
// Ensure `LazyWrapper` is an instance of `baseLodash`.
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper;
/**
* Copies the values of `source` to `array`.
*
* @private
* @param {Array} source The array to copy values from.
* @param {Array} [array=[]] The array to copy values to.
* @returns {Array} Returns `array`.
*/
function copyArray(source, array) {
var index = -1,
length = source.length;
array || (array = Array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
}
/**
* Creates a clone of `wrapper`.
*
* @private
* @param {Object} wrapper The wrapper to clone.
* @returns {Object} Returns the cloned wrapper.
*/
function wrapperClone(wrapper) {
if (wrapper instanceof LazyWrapper) {
return wrapper.clone();
}
var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
result.__actions__ = copyArray(wrapper.__actions__);
result.__index__ = wrapper.__index__;
result.__values__ = wrapper.__values__;
return result;
}
/** Used for built-in method references. */
var objectProto$3 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
/**
* Creates a `lodash` object which wraps `value` to enable implicit method
* chain sequences. Methods that operate on and return arrays, collections,
* and functions can be chained together. Methods that retrieve a single value
* or may return a primitive value will automatically end the chain sequence
* and return the unwrapped value. Otherwise, the value must be unwrapped
* with `_#value`.
*
* Explicit chain sequences, which must be unwrapped with `_#value`, may be
* enabled using `_.chain`.
*
* The execution of chained methods is lazy, that is, it's deferred until
* `_#value` is implicitly or explicitly called.
*
* Lazy evaluation allows several methods to support shortcut fusion.
* Shortcut fusion is an optimization to merge iteratee calls; this avoids
* the creation of intermediate arrays and can greatly reduce the number of
* iteratee executions. Sections of a chain sequence qualify for shortcut
* fusion if the section is applied to an array and iteratees accept only
* one argument. The heuristic for whether a section qualifies for shortcut
* fusion is subject to change.
*
* Chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
*
* In addition to lodash methods, wrappers have `Array` and `String` methods.
*
* The wrapper `Array` methods are:
* `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
*
* The wrapper `String` methods are:
* `replace` and `split`
*
* The wrapper methods that support shortcut fusion are:
* `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
* `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
*
* The chainable wrapper methods are:
* `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
* `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
* `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
* `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
* `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
* `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
* `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
* `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
* `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
* `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
* `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
* `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
* `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
* `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
* `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
* `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
* `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
* `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
* `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
* `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
* `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
* `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
* `zipObject`, `zipObjectDeep`, and `zipWith`
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
* `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
* `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
* `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
* `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
* `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
* `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
* `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
* `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
* `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
* `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
* `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
* `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
* `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
* `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
* `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
* `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
* `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
* `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
* `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
* `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
* `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
* `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
* `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
* `upperFirst`, `value`, and `words`
*
* @name _
* @constructor
* @category Seq
* @param {*} value The value to wrap in a `lodash` instance.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* function square(n) {
* return n * n;
* }
*
* var wrapped = _([1, 2, 3]);
*
* // Returns an unwrapped value.
* wrapped.reduce(_.add);
* // => 6
*
* // Returns a wrapped value.
* var squares = wrapped.map(square);
*
* _.isArray(squares);
* // => false
*
* _.isArray(squares.value());
* // => true
*/
function lodash(value) {
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
if (value instanceof LodashWrapper) {
return value;
}
if (hasOwnProperty$2.call(value, '__wrapped__')) {
return wrapperClone(value);
}
}
return new LodashWrapper(value);
}
// Ensure wrappers are instances of `baseLodash`.
lodash.prototype = baseLodash.prototype;
lodash.prototype.constructor = lodash;
/**
* Checks if `func` has a lazy counterpart.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` has a lazy counterpart,
* else `false`.
*/
function isLaziable(func) {
var funcName = getFuncName(func),
other = lodash[funcName];
if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
return false;
}
if (func === other) {
return true;
}
var data = getData(other);
return !!data && func === data[0];
}
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for function metadata. */
var WRAP_CURRY_FLAG = 8,
WRAP_PARTIAL_FLAG = 32,
WRAP_ARY_FLAG = 128,
WRAP_REARG_FLAG = 256;
/**
* Creates a `_.flow` or `_.flowRight` function.
*
* @private
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {Function} Returns the new flow function.
*/
function createFlow(fromRight) {
return flatRest(function(funcs) {
var length = funcs.length,
index = length,
prereq = LodashWrapper.prototype.thru;
if (fromRight) {
funcs.reverse();
}
while (index--) {
var func = funcs[index];
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
var wrapper = new LodashWrapper([], true);
}
}
index = wrapper ? index : length;
while (++index < length) {
func = funcs[index];
var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : undefined;
if (data && isLaziable(data[0]) &&
data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
!data[4].length && data[9] == 1
) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
} else {
wrapper = (func.length == 1 && isLaziable(func))
? wrapper[funcName]()
: wrapper.thru(func);
}
}
return function() {
var args = arguments,
value = args[0];
if (wrapper && args.length == 1 && isArray(value)) {
return wrapper.plant(value).value();
}
var index = 0,
result = length ? funcs[index].apply(this, args) : value;
while (++index < length) {
result = funcs[index].call(this, result);
}
return result;
};
});
}
/**
* Creates a function that returns the result of invoking the given functions
* with the `this` binding of the created function, where each successive
* invocation is supplied the return value of the previous.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Util
* @param {...(Function|Function[])} [funcs] The functions to invoke.
* @returns {Function} Returns the new composite function.
* @see _.flowRight
* @example
*
* function square(n) {
* return n * n;
* }
*
* var addSquare = _.flow([_.add, square]);
* addSquare(1, 2);
* // => 9
*/
var flow = createFlow();
const TYPE_PRE_MONTH = -1;
const TYPE_NOW_MONTH = 0;
const TYPE_NEXT_MONTH = 1;
/** Used for built-in method references. */
var objectProto$2 = Object.prototype;
/**
* Checks if `value` is likely a prototype object.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$2;
return value === proto;
}
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeKeys = overArg(Object.keys, Object);
/** Used for built-in method references. */
var objectProto$1 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
/**
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
if (!isPrototype(object)) {
return nativeKeys(object);
}
var result = [];
for (var key in Object(object)) {
if (hasOwnProperty$1.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
}
/* Built-in method references that are verified to be native. */
var DataView = getNative(root, 'DataView');
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map');
/* Built-in method references that are verified to be native. */
var Promise$1 = getNative(root, 'Promise');
/* Built-in method references that are verified to be native. */
var Set = getNative(root, 'Set');
/** `Object#toString` result references. */
var mapTag$2 = '[object Map]',
objectTag$1 = '[object Object]',
promiseTag = '[object Promise]',
setTag$2 = '[object Set]',
weakMapTag$1 = '[object WeakMap]';
var dataViewTag$1 = '[object DataView]';
/** Used to detect maps, sets, and weakmaps. */
var dataViewCtorString = toSource(DataView),
mapCtorString = toSource(Map),
promiseCtorString = toSource(Promise$1),
setCtorString = toSource(Set),
weakMapCtorString = toSource(WeakMap);
/**
* Gets the `toStringTag` of `value`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
var getTag = baseGetTag;
// Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
(Map && getTag(new Map) != mapTag$2) ||
(Promise$1 && getTag(Promise$1.resolve()) != promiseTag) ||
(Set && getTag(new Set) != setTag$2) ||
(WeakMap && getTag(new WeakMap) != weakMapTag$1)) {
getTag = function(value) {
var result = baseGetTag(value),
Ctor = result == objectTag$1 ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : '';
if (ctorString) {
switch (ctorString) {
case dataViewCtorString: return dataViewTag$1;
case mapCtorString: return mapTag$2;
case promiseCtorString: return promiseTag;
case setCtorString: return setTag$2;
case weakMapCtorString: return weakMapTag$1;
}
}
return result;
};
}
var getTag$1 = getTag;
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This method is loosely based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
* // => true
*
* _.isLength(Number.MIN_VALUE);
* // => false
*
* _.isLength(Infinity);
* // => false
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
return typeof value == 'number' &&
value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
/**
* Checks if `value` is array-like. A value is considered array-like if it's
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
* _.isArrayLike([1, 2, 3]);
* // => true
*
* _.isArrayLike(document.body.children);
* // => true
*
* _.isArrayLike('abc');
* // => true
*
* _.isArrayLike(_.noop);
* // => false
*/
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
/**
* This method returns `false`.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {boolean} Returns `false`.
* @example
*
* _.times(2, _.stubFalse);
* // => [false, false]
*/
function stubFalse() {
return false;
}
/** Detect free variable `exports`. */
var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
/** Built-in value references. */
var Buffer = moduleExports$1 ? root.Buffer : undefined;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = nativeIsBuffer || stubFalse;
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
arrayTag = '[object Array]',
boolTag = '[object Boolean]',
dateTag = '[object Date]',
errorTag = '[object Error]',
funcTag = '[object Function]',
mapTag$1 = '[object Map]',
numberTag = '[object Number]',
objectTag = '[object Object]',
regexpTag = '[object RegExp]',
setTag$1 = '[object Set]',
stringTag = '[object String]',
weakMapTag = '[object WeakMap]';
var arrayBufferTag = '[object ArrayBuffer]',
dataViewTag = '[object DataView]',
float32Tag = '[object Float32Array]',
float64Tag = '[object Float64Array]',
int8Tag = '[object Int8Array]',
int16Tag = '[object Int16Array]',
int32Tag = '[object Int32Array]',
uint8Tag = '[object Uint8Array]',
uint8ClampedTag = '[object Uint8ClampedArray]',
uint16Tag = '[object Uint16Array]',
uint32Tag = '[object Uint32Array]';
/** Used to identify `toStringTag` values of typed arrays. */
var typedArrayTags = {};
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
typedArrayTags[uint32Tag] = true;
typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
typedArrayTags[errorTag] = typedArrayTags[funcTag] =
typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
typedArrayTags[weakMapTag] = false;
/**
* The base implementation of `_.isTypedArray` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
*/
function baseIsTypedArray(value) {
return isObjectLike(value) &&
isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
}
/**
* The base implementation of `_.unary` without support for storing metadata.
*
* @private
* @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new capped function.
*/
function baseUnary(func) {
return function(value) {
return func(value);
};
}
/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
/** Detect free variable `process` from Node.js. */
var freeProcess = moduleExports && freeGlobal.process;
/** Used to access faster Node.js helpers. */
var nodeUtil = (function() {
try {
// Use `util.types` for Node.js 10+.
var types = freeModule && freeModule.require && freeModule.require('util').types;
if (types) {
return types;
}
// Legacy `process.binding('util')` for Node.js < 10.
return freeProcess && freeProcess.binding && freeProcess.binding('util');
} catch (e) {}
}());
/* Node.js helper references. */
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
/**
* Checks if `value` is classified as a typed array.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* _.isTypedArray(new Uint8Array);
* // => true
*
* _.isTypedArray([]);
* // => false
*/
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
/** `Object#toString` result references. */
var mapTag = '[object Map]',
setTag = '[object Set]';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Checks if `value` is an empty object, collection, map, or set.
*
* Objects are considered empty if they have no own enumerable string keyed
* properties.
*
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
* jQuery-like collections are considered empty if they have a `length` of `0`.
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
* @example
*
* _.isEmpty(null);
* // => true
*
* _.isEmpty(true);
* // => true
*
* _.isEmpty(1);
* // => true
*
* _.isEmpty([1, 2, 3]);
* // => false
*
* _.isEmpty({ 'a': 1 });
* // => false
*/
function isEmpty(value) {
if (value == null) {
return true;
}
if (isArrayLike(value) &&
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length;
}
var tag = getTag$1(value);
if (tag == mapTag || tag == setTag) {
return !value.size;
}
if (isPrototype(value)) {
return !baseKeys(value).length;
}
for (var key in value) {
if (hasOwnProperty.call(value, key)) {
return false;
}
}
return true;
}
function handleActive(args, item) {
const { selectedDate } = args;
const { _value } = item;
const { start, end } = selectedDate;
const dayjsEnd = dayjs(end);
const dayjsStart = start ? dayjs(start) : dayjsEnd;
item.isSelected = _value.isSame(dayjsEnd) || _value.isSame(dayjsStart) || _value.isAfter(dayjsStart) && _value.isBefore(dayjsEnd);
item.isSelectedHead = _value.isSame(dayjsStart);
item.isSelectedTail = _value.isSame(dayjsEnd);
item.isToday = _value.diff(dayjs(Date.now()).startOf("day"), "day") === 0;
return item;
}
function handleMarks(args, item) {
const { options } = args;
const { _value } = item;
const { marks } = options;
const markList = marks.filter((mark) => dayjs(mark.value).startOf("day").isSame(_value));
item.marks = markList.slice(0, 1);
return item;
}
function handleDisabled(args, item) {
const { options } = args;
const { _value } = item;
const { minDate, maxDate } = options;
const dayjsMinDate = dayjs(minDate);
const dayjsMaxDate = dayjs(maxDate);
item.isDisabled = !!(minDate && _value.isBefore(dayjsMinDate)) || !!(maxDate && _value.isAfter(dayjsMaxDate));
return item;
}
function handleValid(args, item) {
const { options } = args;
const { _value } = item;
const { validDates } = options;
if (!isEmpty(validDates)) {
const isInclude = validDates.some((date) => dayjs(date.value).startOf("day").isSame(_value));
item.isDisabled = !isInclude;
}
delete item._value;
return item;
}
var plugins = [handleActive, handleMarks, handleDisabled, handleValid];
const TOTAL = 7 * 6;
function getFullItem(item, options, selectedDate, isShowStatus) {
if (options.marks.find((x) => x.value === item.value)) {
item.marks = [{
value: item.value
}];
}
if (!isShowStatus)
return item;
const bindedPlugins = plugins.map((fn) => fn.bind(null, {
options,
selectedDate
}));
return flow(bindedPlugins)(item);
}
function generateCalendarGroup(options) {
return function(generateDate, selectedDate, isShowStatus) {
const date = dayjs(generateDate);
const { format } = options;
const firstDate = date.startOf("month");
const lastDate = date.endOf("month");
const preMonthDate = date.subtract(1, "month");
const list = [];
const nowMonthDays = date.daysInMonth();
const preMonthLastDay = preMonthDate.endOf("month").day();
for (let i2 = 1; i2 <= preMonthLastDay + 1; i2++) {
const thisDate = firstDate.subtract(i2, "day").startOf("day");
let item = {
marks: [],
_value: thisDate,
text: thisDate.date(),
type: TYPE_PRE_MONTH,
value: thisDate.format(format)
};
item = getFullItem(item, options, selectedDate, isShowStatus);
list.push(item);
}
list.reverse();
for (let i2 = 0; i2 < nowMonthDays; i2++) {
const thisDate = firstDate.add(i2, "day").startOf("day");
let item = {
marks: [],
_value: thisDate,
text: thisDate.date(),
type: TYPE_NOW_MONTH,
value: thisDate.format(format)
};
item = getFullItem(item, options, selectedDate, isShowStatus);
list.push(item);
}
let i = 1;
while (list.length < TOTAL) {
const thisDate = lastDate.add(i++, "day").startOf("day");
let item = {
marks: [],
_value: thisDate,
text: thisDate.date(),
type: TYPE_NEXT_MONTH,
value: thisDate.format(format)
};
item = getFullItem(item, options, selectedDate, isShowStatus);
list.push(item);
}
return {
list,
value: generateDate
};
};
}
const MAP = {
[TYPE_PRE_MONTH]: "pre",
[TYPE_NOW_MONTH]: "now",
[TYPE_NEXT_MONTH]: "next"
};
const AtCalendarList = defineComponent({
name: "AtCalendarList",
data: () => ({ addGlobalClass: true }),
emits: {
"click"(item) {
return !!(item && typeof item === "object");
},
"long-click"(item) {
return !!(item && typeof item === "object");
}
},
props: {
list: Array
},
setup(props, { emit }) {
const genFlexItemClasses = computed(() => (item) => [
"flex__item",
{
[`flex__item--${MAP[item.type]}`]: Boolean(MAP[item.type]),
"flex__item--today": item.isToday,
"flex__item--active": item.isActive,
"flex__item--selected": item.isSelected,
"flex__item--selected-head": item.isSelectedHead,
"flex__item--selected-tail": item.isSelectedTail,
"flex__item--blur": item.isDisabled || item.type === TYPE_PRE_MONTH || item.type === TYPE_NEXT_MONTH
}
]);
function handleClick(item) {
emit("click", item);
}
function handleLongClick(item) {
emit("long-click", item);
}
return {
...toRefs(props),
handleClick,
handleLongClick,
genFlexItemClasses
};
}
});
// Binding optimization for webpack code-split
const _renderList$2 = renderList, _Fragment$2 = Fragment, _openBlock$4 = openBlock, _createElementBlock$2 = createElementBlock, _createCommentVNode$2 = createCommentVNode, _toDisplayString$2 = toDisplayString, _createTextVNode$2 = createTextVNode, _resolveComponent$4 = resolveComponent, _withCtx$4 = withCtx, _createVNode$4 = createVNode, _createBlock$4 = createBlock, _normalizeClass$2 = normalizeClass;
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent$4("taro-view") : "view";
const _component_taro_text = process.env.TARO_ENV === "h5" ? _resolveComponent$4("taro-text") : "text";
return (_ctx.list && _ctx.list.length > 0)
? (_openBlock$4(), _createBlock$4(_component_taro_view, {
key: 0,
class: "at-calendar__list flex"
}, {
default: _withCtx$4(() => [
(_openBlock$4(true), _createElementBlock$2(_Fragment$2, null, _renderList$2(_ctx.list, (item, index) => {
return (_openBlock$4(), _createBlock$4(_component_taro_view, {
key: `list-item-${item.value}-${index}`,
class: _normalizeClass$2(_ctx.genFlexItemClasses(item)),
onTap: $event => (_ctx.handleClick(item)),
onLongpress: $event => (_ctx.handleLongClick(item))
}, {
default: _withCtx$4(() => [
_createCommentVNode$2(" date text "),
_createVNode$4(_component_taro_view, { class: "flex__item-container" }, {
default: _withCtx$4(() => [
_createVNode$4(_component_taro_view, { class: "container-text" }, {
default: _withCtx$4(() => [
_createTextVNode$2(_toDisplayString$2(item.text), 1 /* TEXT */)
]),
_: 2 /* DYNAMIC */
}, 1024 /* DYNAMIC_SLOTS */)
]),
_: 2 /* DYNAMIC */
}, 1024 /* DYNAMIC_SLOTS */),
_createCommentVNode$2(" extra marks "),
_createVNode$4(_component_taro_view, { class: "flex__item-extra extra" }, {
default: _withCtx$4(() => [
(item.marks && item.marks.length > 0)
? (_openBlock$4(), _createBlock$4(_component_taro_view, {
key: 0,
class: "extra-marks"
}, {
default: _withCtx$4(() => [
(_openBlock$4(true), _createElementBlock$2(_Fragment$2, null, _renderList$2(item.marks, (mark, key) => {
return (_openBlock$4(), _createBlock$4(_component_taro_text, {
key: key,
class: "mark"
}, {
default: _withCtx$4(() => [
_createTextVNode$2(_toDisplayString$2(mark.value), 1 /* TEXT */)
]),
_: 2 /* DYNAMIC */
}, 1024 /* DYNAMIC_SLOTS */))
}), 128 /* KEYED_FRAGMENT */))
]),
_: 2 /* DYNAMIC */
}, 1024 /* DYNAMIC_SLOTS */))
: _createCommentVNode$2("v-if", true)
]),
_: 2 /* DYNAMIC */
}, 1024 /* DYNAMIC_SLOTS */)
]),
_: 2 /* DYNAMIC */
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["class", "onTap", "onLongpress"]))
}), 128 /* KEYED_FRAGMENT */))
]),
_: 1 /* STABLE */
}))
: _createCommentVNode$2("v-if", true)
}
AtCalendarList.render = _sfc_render$4;
const AtCalendarHeader = defineComponent({
name: "AtCalendarHeader",
data: () => ({
addGlobalClass: true,
days: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"]
})
});
// Binding optimization for webpack code-split
const _renderList$1 = renderList, _Fragment$1 = Fragment, _openBlock$3 = openBlock, _createElementBlock$1 = createElementBlock, _toDisplayString$1 = toDisplayString, _createTextVNode$1 = createTextVNode, _resolveComponent$3 = resolveComponent, _withCtx$3 = withCtx, _createBlock$3 = createBlock, _createVNode$3 = createVNode;
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent$3("taro-view") : "view";
return (_openBlock$3(), _createBlock$3(_component_taro_view, { class: "header at-calendar__header" }, {
default: _withCtx$3(() => [
_createVNode$3(_component_taro_view, { class: "header__flex" }, {
default: _withCtx$3(() => [
(_openBlock$3(true), _createElementBlock$1(_Fragment$1, null, _renderList$1(_ctx.days, (day, index) => {
return (_openBlock$3(), _createBlock$3(_component_taro_view, {
key: index,
class: "header__flex-item"
}, {
default: _withCtx$3(() => [
_createTextVNode$1(_toDisplayString$1(day), 1 /* TEXT */)
]),
_: 2 /* DYNAMIC */
}, 1024 /* DYNAMIC_SLOTS */))
}), 128 /* KEYED_FRAGMENT */))
]),
_: 1 /* STABLE */
})
]),
_: 1 /* STABLE */
}))
}
AtCalendarHeader.render = _sfc_render$3;
const ANIMATE_DURATION = 300;
const AtCalendarBody = defineComponent({
name: "AtCalendarBody",
components: {
AtCalendarDayList: AtCalendarHeader,
AtCalendarDateList: AtCalendarList
},
emits: {
"day-click"(item) {
return !!(item && typeof item === "object");
},
"long-click"(item) {
return !!(item && typeof item === "object");
},
"swipe-month"(vectorCount) {
return !!(vectorCount && typeof vectorCount === "number");
}
},
data: () => ({ addGlobalClass: true }),
props: {
format: {
type: String,
default: "YYYY-MM-DD"
},
validDates: {
type: Array,
default: () => []
},
marks: {
type: Array,
default: () => []
},
minDate: [String, Number, Date],
maxDate: [String, Number, Date],
isSwiper: {
type: Boolean,
default: true
},
isVertical: Boolean,
generateDate: {
type: [Number, String],
default: Date.now()
},
selectedDate: {
type: Object,
default: () => ({ end: Date.now(), start: Date.now() })
},
selectedDates: {
type: Array,
default: () => []
}
},
setup(props, { emit }) {
const startX = ref(0);
const maxWidth = ref(0);
const changeCount = ref(0);
const swipeStartPoint = ref(0);
const currentSwiperIndex = ref(1);
const isPreMonth = ref(false);
const isWeb = ref(Taro.getEnv() === Taro.ENV_TYPE.WEB);
let generateFunc = generateCalendarGroup({
validDates: props.validDates,
format: props.format,
minDate: props.minDate,
maxDate: props.maxDate,
marks: props.marks,
selectedDates: props.selectedDates
});
const state = reactive({
listGroup: getGroups(props.generateDate, props.selectedDate),
offsetSize: 0,
isAnimate: false
});
const h5MainBodyStyle = computed(() => {
let style = {};
const transformStyle = props.isVertical ? `translateY(-100%) translate3d(0,${state.offsetSize}px,0)` : `translateX(-100%) translate3d(${state.offsetSize}px,0,0)`;
if (props.isSwiper) {
style.transform = transformStyle;
style.WebkitTransform = transformStyle;
if (props.isVertical) {
style.flexDirection = "column";
}
}
return style;
});
watch(() => [
props.validDates,
props.marks,
props.format,
props.minDate,
props.maxDate,
props.selectedDates,
props.generateDate,
props.selectedDate
], ([
validDates,
marks,
format,
minDate,
maxDate,
selectedDates,
generateDate,
selectedDate
]) => {
const options = {
validDates,
marks,
format,
selectedDates,
minDate,
maxDate
};
generateFunc = generateCalendarGroup(options);
state.offsetSize = 0;
state.listGroup = getGroups(generateDate, selectedDate);
});
function getGroups(generateDate, selectedDate) {
const dayjsDate = dayjs(generateDate);
const arr = [];
const preList = generateFunc(dayjsDate.subtract(1, "month").valueOf(), selectedDate);
const nowList = generateFunc(generateDate, selectedDate, true);
const nextList = generateFunc(dayjsDate.add(1, "month").valueOf(), selectedDate);
const preListIndex = currentSwiperIndex.value === 0 ? 2 : currentSwiperIndex.value - 1;
const nextListIndex = currentSwiperIndex.value === 2 ? 0 : currentSwiperIndex.value + 1;
arr[preListIndex] = preList;
arr[nextListIndex] = nextList;
arr[currentSwiperIndex.value] = nowList;
return arr;
}
function handleTouchStart(e) {
startX.value = props.isVertical ? e.touches[0].clientY : e.touches[0].clientX;
}
function handleTouchMove(e) {
const clientXorY = props.isVertical ? e.touches[0].clientY : e.touches[0].clientX;
state.offsetSize = clientXorY - startX.value;
e.preventDefault();
e.stopPropagation();
}
function animateMoveSlide(offset, callback) {
state.isAnimate = true;
nextTick(() => {
state.offsetSize = offset;
setTimeout(() => {
state.isAnimate = false;
nextTick(() => {
callback && callback();
});
}, ANIMATE_DURATION);
});
}
function handleTouchEnd() {
const isRight = state.offsetSize > 0;
const breakpoint = maxWidth.value / 2;
const absOffsetSize = Math.abs(state.offsetSize);
if (absOffsetSize > breakpoint) {
const res = isRight ? maxWidth.value : -maxWidth.value;
return animateMoveSlide(res, () => {
emit("swipe-month", isRight ? -1 : 1);
});
}
animateMoveSlide(0);
}
function handleChange(e) {
const { current, source } = e.detail;
if (source === "touch") {
currentSwiperIndex.value = current;
changeCount.value += 1;
}
}
function handleAnimationFinish() {
if (changeCount.value > 0) {
emit("swipe-month", isPreMonth.value ? -changeCount.value : changeCount.value);
changeCount.value = 0;
}
}
function handleSwipeTouchStart(e) {
const { clientX, clientY } = e.changedTouches[0];
swipeStartPoint.value = props.isVertical ? clientY : clientX;
}
function handleSwipeTouchEnd(e) {
const { clientX, clientY } = e.changedTouches[0];
isPreMonth.value = props.isVertical ? clientY - swipeStartPoint.value > 0 : clientX - swipeStartPoint.value > 0;
}
function handleSwipeTouchMove(e) {
e.preventDefault();
e.stopPropagation();
return;
}
onMounted(() => {
delayQuerySelector(this, ".at-calendar-slider__main", 100).then((res) => {
maxWidth.value = props.isVertical ? res[0].height : res[0].width;
});
});
return {
...toRefs(state),
isSwiper: toRef(props, "isSwiper"),
isWeb,
h5MainBodyStyle,
currentSwiperIndex,
handleChange,
handleTouchEnd,
handleTouchMove,
handleTouchStart,
handleAnimationFinish,
handleSwipeTouchEnd,
handleSwipeTouchMove,
handleSwipeTouchStart
};
}
});
// Binding optimization for webpack code-split
const _createCommentVNode$1 = createCommentVNode, _resolveComponent$2 = resolveComponent, _createVNode$2 = createVNode, _withCtx$2 = withCtx, _openBlock$2 = openBlock, _createBlock$2 = createBlock, _normalizeClass$1 = normalizeClass, _normalizeStyle = normalizeStyle, _Fragment = Fragment, _createElementBlock = createElementBlock, _renderList = renderList;
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
const _component_at_calendar_day_list = _resolveComponent$2("at-calendar-day-list");
const _component_at_calendar_date_list = _resolveComponent$2("at-calendar-date-list");
const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent$2("taro-view") : "view";
const _component_taro_swiper_item = process.env.TARO_ENV === "h5" ? _resolveComponent$2("taro-swiper-item") : "swiper-item";
const _component_taro_swiper = process.env.TARO_ENV === "h5" ? _resolveComponent$2("taro-swiper") : "swiper";
return (_openBlock$2(), _createElementBlock(_Fragment, null, [
_createCommentVNode$1(" not using swiper "),
(!_ctx.isSwiper)
? (_openBlock$2(), _createBlock$2(_component_taro_view, {
key: 0,
class: "main at-calendar-slider__main"
}, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_day_list),
_createVNode$2(_component_taro_view, { class: "main__body body" }, {
default: _withCtx$2(() => [
_createVNode$2(_component_taro_view, { class: "body__slider body__slider--now" }, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_date_list, {
list: _ctx.listGroup[1].list,
onClick: _cache[0] || (_cache[0] = $event => (_ctx.$emit('day-click', $event))),
onLongClick: _cache[1] || (_cache[1] = $event => (_ctx.$emit('long-click', $event)))
}, null, 8 /* PROPS */, ["list"])
]),
_: 1 /* STABLE */
})
]),
_: 1 /* STABLE */
})
]),
_: 1 /* STABLE */
}))
: (_ctx.isWeb)
? (_openBlock$2(), _createElementBlock(_Fragment, { key: 1 }, [
_createCommentVNode$1(" 需要 Taro 组件库维护 Swiper 使小程序和 H5 的表现保持一致 "),
_createVNode$2(_component_taro_view, {
class: "main at-calendar-slider__main",
onTouchend: _ctx.handleTouchEnd,
onTouchmove: _ctx.handleTouchMove,
onTouchstart: _ctx.handleTouchStart
}, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_day_list),
_createVNode$2(_component_taro_view, {
class: _normalizeClass$1(['body', 'main__body', {
'main__body--slider': _ctx.isSwiper,
'main__body--animate': _ctx.isAnimate
}]),
style: _normalizeStyle(_ctx.h5MainBodyStyle)
}, {
default: _withCtx$2(() => [
_createVNode$2(_component_taro_view, { class: "body__slider body__slider--pre" }, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_date_list, {
list: _ctx.listGroup[0].list
}, null, 8 /* PROPS */, ["list"])
]),
_: 1 /* STABLE */
}),
_createVNode$2(_component_taro_view, { class: "body__slider body__slider--now" }, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_date_list, {
list: _ctx.listGroup[1].list,
onClick: _cache[2] || (_cache[2] = $event => (_ctx.$emit('day-click', $event))),
onLongClick: _cache[3] || (_cache[3] = $event => (_ctx.$emit('long-click', $event)))
}, null, 8 /* PROPS */, ["list"])
]),
_: 1 /* STABLE */
}),
_createVNode$2(_component_taro_view, { class: "body__slider body__slider--next" }, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_date_list, {
list: _ctx.listGroup[2].list
}, null, 8 /* PROPS */, ["list"])
]),
_: 1 /* STABLE */
})
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["class", "style"])
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["onTouchend", "onTouchmove", "onTouchstart"])
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
: (_ctx.isSwiper && !_ctx.isWeb)
? (_openBlock$2(), _createElementBlock(_Fragment, { key: 2 }, [
_createCommentVNode$1(" using swiper "),
_createVNode$2(_component_taro_view, { class: "main at-calendar-slider__main" }, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_day_list),
_createVNode$2(_component_taro_swiper, {
class: "main__body",
circular: "",
"skip-hidden-item-layout": "",
catchMove: true,
vertical: _ctx.isVertical,
current: _ctx.currentSwiperIndex,
onChange: _ctx.handleChange,
onTouchend: _ctx.handleSwipeTouchEnd,
onTouchmove: _ctx.handleSwipeTouchMove,
onTouchstart: _ctx.handleSwipeTouchStart,
onAnimationfinish: _ctx.handleAnimationFinish
}, {
default: _withCtx$2(() => [
(_openBlock$2(true), _createElementBlock(_Fragment, null, _renderList(_ctx.listGroup, (item, key) => {
return (_openBlock$2(), _createBlock$2(_component_taro_swiper_item, {
key: key.toString(),
"item-id": key.toString()
}, {
default: _withCtx$2(() => [
_createVNode$2(_component_at_calendar_date_list, {
list: item.list,
onClick: _cache[4] || (_cache[4] = $event => (_ctx.$emit('day-click', $event))),
onLongClick: _cache[5] || (_cache[5] = $event => (_ctx.$emit('long-click', $event)))
}, null, 8 /* PROPS */, ["list"])
]),
_: 2 /* DYNAMIC */
}, 1032 /* PROPS, DYNAMIC_SLOTS */, ["item-id"]))
}), 128 /* KEYED_FRAGMENT */))
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["vertical", "current", "onChange", "onTouchend", "onTouchmove", "onTouchstart", "onAnimationfinish"])
]),
_: 1 /* STABLE */
})
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
: _createCommentVNode$1("v-if", true)
], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
}
AtCalendarBody.render = _sfc_render$2;
const AtCalendarController = defineComponent({
name: "AtCalendarController",
data: () => ({ addGlobalClass: true }),
emits: [
"pre-month",
"next-month",
"select-date"
],
props: {
generateDate: {
type: [String, Number, Date],
default: Date.now()
},
minDate: [String, Number, Date],
maxDate: [String, Number, Date],
hideArrow: Boolean,
monthFormat: {
type: String,
default: "YYYY \u5E74 MM \u6708"
}
},
setup(props) {
const dayjsDate = computed(() => dayjs(props.generateDate));
const dayjsMinDate = computed(() => !!props.minDate && dayjs(props.minDate));
const dayjsMaxDate = computed(() => !!props.maxDate && dayjs(props.maxDate));
const isMinMonth = computed(() => {
return dayjsMinDate.value && dayjsMinDate.value.startOf("month").isSame(dayjsDate.value);
});
const isMaxMonth = computed(() => {
return dayjsMaxDate.value && dayjsMaxDate.value.startOf("month").isSame(dayjsDate.value);
});
const minDateValue = computed(() => dayjsMinDate.value ? dayjsMinDate.value.format("YYYY-MM") : "");
const maxDateValue = computed(() => dayjsMaxDate.value ? dayjsMaxDate.value.format("YYYY-MM") : "");
const genArrowClasses = (direction, disabled) => ["controller__arrow", {
[`controller__arrow--${direction}`]: true,
"controller__arrow--disabled": disabled
}];
return {
...toRefs(props),
dayjsDate,
isMinMonth,
isMaxMonth,
minDateValue,
maxDateValue,
genArrowClasses
};
}
});
// Binding optimization for webpack code-split
const _createCommentVNode = createCommentVNode, _resolveComponent$1 = resolveComponent, _normalizeClass = normalizeClass, _openBlock$1 = openBlock, _createBlock$1 = createBlock, _toDisplayString = toDisplayString, _createTextVNode = createTextVNode, _withCtx$1 = withCtx, _createVNode$1 = createVNode;
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent$1("taro-view") : "view";
const _component_taro_text = process.env.TARO_ENV === "h5" ? _resolveComponent$1("taro-text") : "text";
const _component_taro_picker = process.env.TARO_ENV === "h5" ? _resolveComponent$1("taro-picker") : "picker";
return (_openBlock$1(), _createBlock$1(_component_taro_view, { class: "at-calendar__controller controller" }, {
default: _withCtx$1(() => [
_createCommentVNode(" left arrow "),
(!_ctx.hideArrow)
? (_openBlock$1(), _createBlock$1(_component_taro_view, {
key: 0,
class: _normalizeClass(_ctx.genArrowClasses('left', _ctx.isMinMonth)),
onTap: _cache[0] || (_cache[0] = $event => (_ctx.$emit('pre-month', _ctx.isMinMonth)))
}, null, 8 /* PROPS */, ["class"]))
: _createCommentVNode("v-if", true),
_createCommentVNode(" date picker "),
_createVNode$1(_component_taro_picker, {
mode: "date",
fields: "month",
end: _ctx.maxDateValue,
start: _ctx.minDateValue,
value: _ctx.dayjsDate.format('YYYY-MM'),
onChange: _cache[1] || (_cache[1] = $event => (_ctx.$emit('select-date', $event)))
}, {
default: _withCtx$1(() => [
_createVNode$1(_component_taro_text, { class: "controller__info" }, {
default: _withCtx$1(() => [
_createTextVNode(_toDisplayString(_ctx.dayjsDate.format(_ctx.monthFormat)), 1 /* TEXT */)
]),
_: 1 /* STABLE */
})
]),
_: 1 /* STABLE */
}, 8 /* PROPS */, ["end", "start", "value"]),
_createCommentVNode(" right arrow "),
(!_ctx.hideArrow)
? (_openBlock$1(), _createBlock$1(_component_taro_view, {
key: 1,
class: _normalizeClass(_ctx.genArrowClasses('right', _ctx.isMaxMonth)),
onTap: _cache[2] || (_cache[2] = $event => (_ctx.$emit('next-month', _ctx.isMaxMonth)))
}, null, 8 /* PROPS */, ["class"]))
: _createCommentVNode("v-if", true)
]),
_: 1 /* STABLE */
}))
}
AtCalendarController.render = _sfc_render$1;
const AtCalendar = defineComponent({
name: "AtCalendar",
components: {
AtCalendarBody,
AtCalendarController
},
emits: {
"click-pre-month": null,
"click-next-month": null,
"select-date"(item) {
return !!(item && item.value);
},
"day-click"(item) {
return !!(item && item.value);
},
"day-long-click"(item) {
return !!(item && item.value);
},
"month-change"(value) {
return !!(value && typeof value === "string");
}
},
data: () => ({ addGlobalClass: true }),
props: {
currentDate: {
type: [Number, String, Date, Object],
default: Date.now()
},
minDate: {
type: [String, Number, Date],
default: () => ""
},
maxDate: {
type: [String, Number, Date],
default: () => ""
},
isSwiper: {
type: Boolean,
default: true
},
marks: {
type: Array,
default: () => []
},
validDates: {
type: Array,
default: () => []
},
format: {
type: String,
default: "YYYY-MM-DD"
},
monthFormat: {
type: String,
default: "YYYY \u5E74 MM \u6708"
},
hideArrow: Boolean,
isVertical: Boolean,
isMultiSelect: Boolean,
selectedDates: {
type: Array,
default: () => []
}
},
setup(props, { emit }) {
const { currentDate, isMultiSelect } = toRefs(props);
let { generateDate, selectedDate } = getInitializedState(currentDate.value, isMultiSelect.value);
const state = reactive({
generateDate,
selectedDate
});
watch(() => [
props.currentDate,
props.isMultiSelect
], ([currentDate2, isMultiSelect2], [preCurrentDate, preIsMultiSelect]) => {
if (!currentDate2 || currentDate2 === preCurrentDate)
return;
if (isMultiSelect2 && preIsMultiSelect) {
const { start, end } = currentDate2;
const { start: preStart, end: preEnd } = preCurrentDate;
if (start === preStart && preEnd === end) {
return;
}
}
const stateValue = getInitializedState(currentDate2, isMultiSelect2);
Object.assign(state, stateValue);
});
function getSingleSelectedState(value) {
const stateValue = {
selectedDate: getSelectedDate(value.valueOf())
};
const dayjsGenerateDate = value.startOf("month");
const generateDateValue = dayjsGenerateDate.valueOf();
if (generateDateValue !== state.generateDate) {
triggerChangeDate(dayjsGenerateDate);
stateValue.generateDate = generateDateValue;
}
return stateValue;
}
function getMultiSelectedState(value) {
const { end, start } = state.selectedDate;
const valueUnix = value.valueOf();
const stateValue = {
selectedDate: state.selectedDate
};
if (end) {
stateValue.selectedDate = getSelectedDate(valueUnix, 0);
} else {
stateValue.selectedDate.end = Math.max(valueUnix, +start);
stateValue.selectedDate.start = Math.min(valueUnix, +start);
}
return stateValue;
}
function getInitializedState(currentDate2, isMultiSelect2) {
let end;
let start;
let generateDateValue;
if (!currentDate2) {
const dayjsStart = dayjs$1();
start = dayjsStart.startOf("day").valueOf();
generateDateValue = dayjsStart.startOf("month").valueOf();
return {
generateDate: generateDateValue,
selectedDate: {
start: ""
}
};
}
if (isMultiSelect2) {
const { start: cStart, end: cEnd } = currentDate2;
const dayjsStart = dayjs$1(cStart);
start = dayjsStart.startOf("day").valueOf();
generateDateValue = dayjsStart.startOf("month").valueOf();
end = cEnd ? dayjs$1(cEnd).startOf("day").valueOf() : start;
} else {
const dayjsStart = dayjs$1(currentDate2);
start = dayjsStart.startOf("day").valueOf();
generateDateValue = dayjsStart.startOf("month").valueOf();
end = start;
}
return {
generateDate: generateDateValue,
selectedDate: getSelectedDate(start, end)
};
}
function getSelectedDate(start, end) {
const stateValue = {
start,
end: start
};
if (typeof end !== "undefined") {
stateValue.end = end;
}
return stateValue;
}
function triggerChangeDate(value) {
emit("month-change", value.format(props.format));
}
function setMonth(vectorCount) {
const _generateDate = dayjs$1(state.generateDate).add(vectorCount, "month");
state.generateDate = _generateDate.valueOf();
if (vectorCount) {
emit("month-change", _generateDate.format(props.format));
}
}
function handleClickPreMonth(isMinMonth) {
if (isMinMonth === true)
return;
setMonth(-1);
emit("click-pre-month");
}
function handleClickNextMonth(isMaxMonth) {
if (isMaxMonth === true)
return;
setMonth(1);
emit("click-next-month");
}
function handleSelectDate(e) {
const { value } = e.detail;
const _generateDate = dayjs$1(value);
const _generateDateValue = _generateDate.valueOf();
if (state.generateDate === _generateDateValue)
return;
triggerChangeDate(_generateDate);
state.generateDate = _generateDateValue;
}
function handleDayClick(item) {
const { isDisabled, value } = item;
if (isDisabled)
return;
const dayjsDate = dayjs$1(value);
let stateValue = {};
stateValue = props.isMultiSelect ? getMultiSelectedState(dayjsDate) : getSingleSelectedState(dayjsDate);
Object.assign(state, stateValue);
nextTick(() => {
handleSelectedDate();
});
emit("day-click", { value: item.value });
}
function handleSelectedDate() {
const info = {
start: dayjs$1(state.selectedDate.start).format(props.format)
};
if (state.selectedDate.end) {
info.end = dayjs$1(state.selectedDate.end).format(props.format);
}
emit("select-date", { value: info });
}
function handleDayLongClick(item) {
emit("day-long-click", { value: item.value });
}
return {
...toRefs(state),
...toRefs(props),
setMonth,
handleDayClick,
handleSelectDate,
handleDayLongClick,
handleSelectedDate,
handleClickPreMonth,
handleClickNextMonth
};
}
});
// Binding optimization for webpack code-split
const _resolveComponent = resolveComponent, _createVNode = createVNode, _mergeProps = mergeProps, _withCtx = withCtx, _openBlock = openBlock, _createBlock = createBlock;
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_at_calendar_controller = _resolveComponent("at-calendar-controller");
const _component_at_calendar_body = _resolveComponent("at-calendar-body");
const _component_taro_view = process.env.TARO_ENV === "h5" ? _resolveComponent("taro-view") : "view";
return (_openBlock(), _createBlock(_component_taro_view, _mergeProps(_ctx.$attrs, { class: "at-calendar" }), {
default: _withCtx(() => [
_createVNode(_component_at_calendar_controller, {
"min-date": _ctx.minDate,
"max-date": _ctx.maxDate,
"hide-arrow": _ctx.hideArrow,
"month-format": _ctx.monthFormat,
"generate-date": _ctx.generateDate,
onSelectDate: _ctx.handleSelectDate,
onPreMonth: _ctx.handleClickPreMonth,
onNextMonth: _ctx.handleClickNextMonth
}, null, 8 /* PROPS */, ["min-date", "max-date", "hide-arrow", "month-format", "generate-date", "onSelectDate", "onPreMonth", "onNextMonth"]),
_createVNode(_component_at_calendar_body, {
marks: _ctx.marks,
format: _ctx.format,
"min-date": _ctx.minDate,
"max-date": _ctx.maxDate,
"is-swiper": _ctx.isSwiper,
"is-vertical": _ctx.isVertical,
"valid-dates": _ctx.validDates,
"selected-date": _ctx.selectedDate,
"selected-dates": _ctx.selectedDates,
"generate-date": _ctx.generateDate,
onSwipeMonth: _ctx.setMonth,
onDayClick: _ctx.handleDayClick,
onLongClick: _ctx.handleDayLongClick
}, null, 8 /* PROPS */, ["marks", "format", "min-date", "max-date", "is-swiper", "is-vertical", "valid-dates", "selected-date", "selected-dates", "generate-date", "onSwipeMonth", "onDayClick", "onLongClick"])
]),
_: 1 /* STABLE */
}, 16 /* FULL_PROPS */))
}
AtCalendar.render = _sfc_render;
export default AtCalendar;