calendar-set
Advanced tools
Comparing version 0.2.1 to 0.2.2
/*! | ||
* calendar-set v0.2.1 | ||
* calendar-set v0.2.2 | ||
* https://github.com/ktsn/calendar-set | ||
@@ -1074,3 +1074,3 @@ * | ||
function isHighlighted(hovered, targetIndex) { | ||
function isHighlighted(hovered, isSecond) { | ||
return function (target, selected) { | ||
@@ -1082,3 +1082,3 @@ var _arrayfy = arrayfy(selected), | ||
var list = [first, target, targetIndex === 0 ? second : hovered].filter(function (x) { | ||
var list = [first, target, isSecond ? hovered : second].filter(function (x) { | ||
return x; | ||
@@ -1092,3 +1092,3 @@ }).sort(compareDateAsc); | ||
return { | ||
targetIndex: 0 | ||
second: false | ||
}; | ||
@@ -1098,3 +1098,4 @@ } | ||
onSelect: function onSelect(date) { | ||
var index = this.get('targetIndex'); | ||
var isSecond = this.get('second'); | ||
var index = isSecond ? 1 : 0; | ||
var prevSelected = arrayfy(this.get('selected')); | ||
@@ -1104,3 +1105,3 @@ var selected = prevSelected.slice(0, index).concat(date).sort(compareDateAsc); | ||
selected: selected, | ||
targetIndex: 1 - index | ||
second: !isSecond | ||
}); | ||
@@ -1113,2 +1114,3 @@ this.fire('select', selected); | ||
}); | ||
this.fire('hover', date); | ||
} | ||
@@ -1122,5 +1124,6 @@ }; | ||
data: { | ||
current: state.current, | ||
selected: state.selected, | ||
locale: state.locale, | ||
isHighlighted: isHighlighted(state.hovered, state.targetIndex) | ||
isHighlighted: isHighlighted(state.hovered, state.second) | ||
} | ||
@@ -1143,5 +1146,6 @@ }); | ||
var datecalendar_changes = {}; | ||
if (changed.current) datecalendar_changes.current = state.current; | ||
if (changed.selected) datecalendar_changes.selected = state.selected; | ||
if (changed.locale) datecalendar_changes.locale = state.locale; | ||
if (changed.hovered || changed.targetIndex) datecalendar_changes.isHighlighted = isHighlighted(state.hovered, state.targetIndex); | ||
if (changed.hovered || changed.second) datecalendar_changes.isHighlighted = isHighlighted(state.hovered, state.second); | ||
@@ -1148,0 +1152,0 @@ datecalendar._set(datecalendar_changes); |
/*! | ||
* calendar-set v0.2.1 | ||
* calendar-set v0.2.2 | ||
* https://github.com/ktsn/calendar-set | ||
@@ -1070,3 +1070,3 @@ * | ||
function isHighlighted(hovered, targetIndex) { | ||
function isHighlighted(hovered, isSecond) { | ||
return function (target, selected) { | ||
@@ -1078,3 +1078,3 @@ var _arrayfy = arrayfy(selected), | ||
var list = [first, target, targetIndex === 0 ? second : hovered].filter(function (x) { | ||
var list = [first, target, isSecond ? hovered : second].filter(function (x) { | ||
return x; | ||
@@ -1088,3 +1088,3 @@ }).sort(compareDateAsc); | ||
return { | ||
targetIndex: 0 | ||
second: false | ||
}; | ||
@@ -1094,3 +1094,4 @@ } | ||
onSelect: function onSelect(date) { | ||
var index = this.get('targetIndex'); | ||
var isSecond = this.get('second'); | ||
var index = isSecond ? 1 : 0; | ||
var prevSelected = arrayfy(this.get('selected')); | ||
@@ -1100,3 +1101,3 @@ var selected = prevSelected.slice(0, index).concat(date).sort(compareDateAsc); | ||
selected: selected, | ||
targetIndex: 1 - index | ||
second: !isSecond | ||
}); | ||
@@ -1109,2 +1110,3 @@ this.fire('select', selected); | ||
}); | ||
this.fire('hover', date); | ||
} | ||
@@ -1118,5 +1120,6 @@ }; | ||
data: { | ||
current: state.current, | ||
selected: state.selected, | ||
locale: state.locale, | ||
isHighlighted: isHighlighted(state.hovered, state.targetIndex) | ||
isHighlighted: isHighlighted(state.hovered, state.second) | ||
} | ||
@@ -1139,5 +1142,6 @@ }); | ||
var datecalendar_changes = {}; | ||
if (changed.current) datecalendar_changes.current = state.current; | ||
if (changed.selected) datecalendar_changes.selected = state.selected; | ||
if (changed.locale) datecalendar_changes.locale = state.locale; | ||
if (changed.hovered || changed.targetIndex) datecalendar_changes.isHighlighted = isHighlighted(state.hovered, state.targetIndex); | ||
if (changed.hovered || changed.second) datecalendar_changes.isHighlighted = isHighlighted(state.hovered, state.second); | ||
@@ -1144,0 +1148,0 @@ datecalendar._set(datecalendar_changes); |
/*! | ||
* calendar-set v0.2.1 | ||
* calendar-set v0.2.2 | ||
* https://github.com/ktsn/calendar-set | ||
@@ -1076,3 +1076,3 @@ * | ||
function isHighlighted(hovered, targetIndex) { | ||
function isHighlighted(hovered, isSecond) { | ||
return function (target, selected) { | ||
@@ -1084,3 +1084,3 @@ var _arrayfy = arrayfy(selected), | ||
var list = [first, target, targetIndex === 0 ? second : hovered].filter(function (x) { | ||
var list = [first, target, isSecond ? hovered : second].filter(function (x) { | ||
return x; | ||
@@ -1094,3 +1094,3 @@ }).sort(compareDateAsc); | ||
return { | ||
targetIndex: 0 | ||
second: false | ||
}; | ||
@@ -1100,3 +1100,4 @@ } | ||
onSelect: function onSelect(date) { | ||
var index = this.get('targetIndex'); | ||
var isSecond = this.get('second'); | ||
var index = isSecond ? 1 : 0; | ||
var prevSelected = arrayfy(this.get('selected')); | ||
@@ -1106,3 +1107,3 @@ var selected = prevSelected.slice(0, index).concat(date).sort(compareDateAsc); | ||
selected: selected, | ||
targetIndex: 1 - index | ||
second: !isSecond | ||
}); | ||
@@ -1115,2 +1116,3 @@ this.fire('select', selected); | ||
}); | ||
this.fire('hover', date); | ||
} | ||
@@ -1124,5 +1126,6 @@ }; | ||
data: { | ||
current: state.current, | ||
selected: state.selected, | ||
locale: state.locale, | ||
isHighlighted: isHighlighted(state.hovered, state.targetIndex) | ||
isHighlighted: isHighlighted(state.hovered, state.second) | ||
} | ||
@@ -1145,5 +1148,6 @@ }); | ||
var datecalendar_changes = {}; | ||
if (changed.current) datecalendar_changes.current = state.current; | ||
if (changed.selected) datecalendar_changes.selected = state.selected; | ||
if (changed.locale) datecalendar_changes.locale = state.locale; | ||
if (changed.hovered || changed.targetIndex) datecalendar_changes.isHighlighted = isHighlighted(state.hovered, state.targetIndex); | ||
if (changed.hovered || changed.second) datecalendar_changes.isHighlighted = isHighlighted(state.hovered, state.second); | ||
@@ -1150,0 +1154,0 @@ datecalendar._set(datecalendar_changes); |
/*! | ||
* calendar-set v0.2.1 | ||
* calendar-set v0.2.2 | ||
* https://github.com/ktsn/calendar-set | ||
@@ -9,3 +9,3 @@ * | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.CalendarSet={})}(this,function(t){"use strict";function e(){}function n(t){for(var e,n,r=1,o=arguments.length;r<o;r++)for(e in n=arguments[r])t[e]=n[e];return t}function r(t,e){e.appendChild(t)}function o(t,e,n){e.insertBefore(t,n)}function i(t){t.parentNode.removeChild(t)}function a(t){for(var e=0;e<t.length;e+=1)t[e]&&t[e].d()}function c(t){return document.createElement(t)}function l(t){return document.createTextNode(t)}function u(t,e,n){t.addEventListener(e,n,!1)}function s(t,e,n){t.removeEventListener(e,n,!1)}function h(){return Object.create(null)}function f(t){this.destroy=e,this.fire("destroy"),this.set=this.get=e,!1!==t&&this._fragment.u(),this._fragment.d(),this._fragment=this._state=null}function d(t,e,n,r,o){for(var i in e)if(n[i]){var a=r[i],c=o[i],l=e[i];if(l)for(var u=0;u<l.length;u+=1){var s=l[u];s.__calling||(s.__calling=!0,s.call(t,a,c),s.__calling=!1)}}}function _(t,e){t._observers={pre:h(),post:h()},t._handlers=h(),t._bind=e._bind,t.options=e,t.root=e.root||t,t.store=t.root.store||e.store}function g(t){for(;t&&t.length;)t.shift()()}var v={destroy:f,get:function(t){return t?this._state[t]:this._state},fire:function(t,e){var n=t in this._handlers&&this._handlers[t].slice();if(n)for(var r=0;r<n.length;r+=1)n[r].call(this,e)},observe:function(t,e,n){var r=n&&n.defer?this._observers.post:this._observers.pre;return(r[t]||(r[t]=[])).push(e),n&&!1===n.init||(e.__calling=!0,e.call(this,this._state[t]),e.__calling=!1),{cancel:function(){var n=r[t].indexOf(e);~n&&r[t].splice(n,1)}}},on:function(t,e){if("teardown"===t)return this.on("destroy",e);var n=this._handlers[t]||(this._handlers[t]=[]);return n.push(e),{cancel:function(){var t=n.indexOf(e);~t&&n.splice(t,1)}}},set:function(t){this._set(n({},t)),this.root._lock||(this.root._lock=!0,g(this.root._beforecreate),g(this.root._oncreate),g(this.root._aftercreate),this.root._lock=!1)},teardown:f,_recompute:e,_set:function(t){var e=this._state,r={},o=!1;for(var i in t)this._differs(t[i],e[i])&&(r[i]=o=!0);o&&(this._state=n({},e,t),this._recompute(r,this._state),this._bind&&this._bind(r,this._state),this._fragment&&(d(this,this._observers.pre,r,this._state,e),this._fragment.p(r,this._state),d(this,this._observers.post,r,this._state,e)))},_mount:function(t,e){this._fragment[this._fragment.i?"i":"m"](t,e||null)},_unmount:function(){this._fragment&&this._fragment.u()},_differs:function(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}};function m(){return!1}function p(t){return null==t?[]:Array.isArray(t)?t:[t]}function y(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.replace(/\{(\d+)\}/g,function(t,e){var r=Number(e);return n[r]||""}).replace(/\\\{(\d+)\\\}/g,function(t,e){return"{"+e+"}"})}function w(t,e){return k(t)||function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=t[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(t,e)||x()}function b(t){return k(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||x()}function k(t){if(Array.isArray(t))return t}function x(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var D=7,C=0;function H(t,e){var n=new Date(t,e,1),r=C-n.getDay();return function(t,e){for(var n,r=[],o=0;e(n,o);)n=t(n,o),r.push(n),o++;return r}(function(n,o){var i,a=D*o;return(i=D,Array.apply(null,Array(i)).map(function(t,e){return e})).map(function(n){var o=new Date(t,e,r+a+n+1);return N(o,t,e)?o:void 0})},function(n){if(!n)return!0;var r=n[D-1];return!!r&&N(new Date(j(r),O(r),S(r)+1),t,e)})}function N(t,e,n){return j(t)===e&&O(t)===n}function A(t,e){return function t(e,n,r){if(0===r.length)return 0;var o=b(r),i=o[0],a=o.slice(1),c=function(t,e){return t<e?-1:t>e?1:0}(i(e),i(n));return 0===c?t(e,n,a):c}(t,e,[j,O,S])}function j(t){return t.getFullYear()}function O(t){return t.getMonth()}function S(t){return t.getDate()}function I(t,e){var n=[];return t&&n.push("selected"),e&&n.push("highlighted"),n.join(" ")}function M(t){_(this,t),this._state=n({},t.data),this._slotted=t.slots||{},this.slots={},this._fragment=function(t,e){var n,a,l=t._slotted.default;function h(e){t.fire("click",e)}function f(e){t.fire("mouseenter",e)}return{c:function(){n=c("button"),this.h()},h:function(){n.className=a="calendar-cell-button "+I(e.selected,e.highlighted)+" svelte-15crlep",u(n,"click",h),u(n,"mouseenter",f)},m:function(t,e){o(n,t,e),l&&r(l,n)},p:function(t,e){(t.selected||t.highlighted)&&a!==(a="calendar-cell-button "+I(e.selected,e.highlighted)+" svelte-15crlep")&&(n.className=a)},u:function(){i(n),l&&function(t,e){for(;t.firstChild;)e.appendChild(t.firstChild)}(n,l)},d:function(){s(n,"click",h),s(n,"mouseenter",f)}}}(this,this._state),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor))}function F(t,e){return p(e).reduce(function(e,n){return e||0===A(t,n)},!1)}function L(t){return 0===t?"sunday":6===t?"saturday":""}n(M.prototype,v);var E=function(t){t.setLocale=function(e){t.locale=e}};function T(t,n){var a,u,s=n.weekDay,h=(n.each_value,n.i),f=y(s);return{c:function(){a=c("th"),u=l(f),this.h()},h:function(){a.scope="col",a.className="calendar-cell heading "+L(h)},m:function(t,e){o(a,t,e),r(u,a)},p:function(t,e){s=e.weekDay,e.each_value,h=e.i,t.locale&&f!==(f=y(s))&&(u.data=f)},u:function(){i(a)},d:e}}function J(t,e){for(var r,l=e.row,u=(e.each_value_1,e.row_index,l),s=[],h=0;h<u.length;h+=1)s[h]=W(t,n({},e,{each_value_2:u,cell:u[h],i:h}));return{c:function(){r=c("tr");for(var t=0;t<s.length;t+=1)s[t].c()},m:function(t,e){o(r,t,e);for(var n=0;n<s.length;n+=1)s[n].m(r,null)},p:function(e,o){l=o.row,o.each_value_1,o.row_index;var i=l;if(e.calendar||e.selected||e.isHighlighted){for(var a=0;a<i.length;a+=1){var c=n({},o,{each_value_2:i,cell:i[a],i:a});s[a]?s[a].p(e,c):(s[a]=W(t,c),s[a].c(),s[a].m(r,null))}for(;a<s.length;a+=1)s[a].u(),s[a].d();s.length=i.length}},u:function(){i(r);for(var t=0;t<s.length;t+=1)s[t].u()},d:function(){a(s)}}}function W(t,e){e.row,e.each_value_1,e.row_index;var n,r=e.cell,a=(e.each_value_2,e.i),l=r&&Y(t,e);return{c:function(){n=c("td"),l&&l.c(),this.h()},h:function(){n.className="calendar-cell "+L(a)},m:function(t,e){o(n,t,e),l&&l.m(n,null)},p:function(e,o){o.row,o.each_value_1,o.row_index,r=o.cell,o.each_value_2,a=o.i,r?l?l.p(e,o):((l=Y(t,o)).c(),l.m(n,null)):l&&(l.u(),l.d(),l=null)},u:function(){i(n),l&&l.u()},d:function(){l&&l.d()}}}function Y(t,e){e.row,e.each_value_1,e.row_index;var n,o,i,a=e.cell,c=(e.each_value_2,e.i,a.getDate()),u=new M({root:t.root,slots:{default:document.createDocumentFragment()},data:{selected:F(a,e.selected),highlighted:e.isHighlighted(a,e.selected)}});return u.on("click",function(e){t.onClickCell(a)}),u.on("mouseenter",function(e){t.onHoverCell(a)}),{c:function(){n=l("\n "),o=l(c),i=l("\n "),u._fragment.c()},m:function(t,e){r(n,u._slotted.default),r(o,u._slotted.default),r(i,u._slotted.default),u._mount(t,e)},p:function(t,e){e.row,e.each_value_1,e.row_index,a=e.cell,e.each_value_2,e.i,t.calendar&&c!==(c=a.getDate())&&(o.data=c);var n={};(t.calendar||t.selected)&&(n.selected=F(a,e.selected)),(t.isHighlighted||t.calendar||t.selected)&&(n.highlighted=e.isHighlighted(a,e.selected)),u._set(n)},u:function(){u._unmount()},d:function(){u.destroy(!1)}}}function q(t,e){for(var h,f,d,_,g,v,m,p,w,b,k,x,D=y(e.locale.year,e.current.year),C=y(e.locale.months[e.current.month]),H=e.locale.weekDays,N=[],A=0;A<H.length;A+=1)N[A]=T(0,n({},e,{each_value:H,weekDay:H[A],i:A}));var j=e.calendar,O=[];for(A=0;A<j.length;A+=1)O[A]=J(t,n({},e,{each_value_1:j,row:j[A],row_index:A}));function S(e){t.onHoverOut()}return{c:function(){h=c("p"),f=c("span"),d=l(D),_=l("\n "),g=c("span"),v=l(C),m=l("\n\n "),p=c("table"),w=c("thead"),b=c("tr");for(var t=0;t<N.length;t+=1)N[t].c();k=l("\n\n "),x=c("tbody");for(t=0;t<O.length;t+=1)O[t].c();this.h()},h:function(){f.className="calendar-year",g.className="calendar-month",h.className="calendar-header",u(x,"mouseleave",S),p.className="calendar-table"},m:function(t,e){o(h,t,e),r(f,h),r(d,f),r(_,h),r(g,h),r(v,g),o(m,t,e),o(p,t,e),r(w,p),r(b,w);for(var n=0;n<N.length;n+=1)N[n].m(b,null);r(k,p),r(x,p);for(n=0;n<O.length;n+=1)O[n].m(x,null)},p:function(e,r){(e.locale||e.current)&&D!==(D=y(r.locale.year,r.current.year))&&(d.data=D),(e.locale||e.current)&&C!==(C=y(r.locale.months[r.current.month]))&&(v.data=C);var o=r.locale.weekDays;if(e.locale){for(var i=0;i<o.length;i+=1){var a=n({},r,{each_value:o,weekDay:o[i],i:i});N[i]?N[i].p(e,a):(N[i]=T(0,a),N[i].c(),N[i].m(b,null))}for(;i<N.length;i+=1)N[i].u(),N[i].d();N.length=o.length}var c=r.calendar;if(e.calendar||e.selected||e.isHighlighted){for(i=0;i<c.length;i+=1){var l=n({},r,{each_value_1:c,row:c[i],row_index:i});O[i]?O[i].p(e,l):(O[i]=J(t,l),O[i].c(),O[i].m(x,null))}for(;i<O.length;i+=1)O[i].u(),O[i].d();O.length=c.length}},u:function(){i(h),i(m),i(p);for(var t=0;t<N.length;t+=1)N[t].u();for(t=0;t<O.length;t+=1)O[t].u()},d:function(){a(N),a(O),s(x,"mouseleave",S)}}}function B(t){var e;_(this,t),this._state=n({current:{year:(e=new Date).getFullYear(),month:e.getMonth()},isHighlighted:m},t.data),this._recompute({current:1},this._state);var r,a,l,u,s=function(){this.get("locale")||this.set({locale:this.constructor.locale})}.bind(this);t.root||(this._oncreate=[],this._beforecreate=[],this._aftercreate=[]),this._fragment=(r=this,a=this._state,u=a.locale&&q(r,a),{c:function(){l=c("div"),u&&u.c(),this.h()},h:function(){l.className="calendar svelte-1qlxfod"},m:function(t,e){o(l,t,e),u&&u.m(l,null)},p:function(t,e){e.locale?u?u.p(t,e):((u=q(r,e)).c(),u.m(l,null)):u&&(u.u(),u.d(),u=null)},u:function(){i(l),u&&u.u()},d:function(){u&&u.d()}}),this.root._oncreate.push(s),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor),this._lock=!0,g(this._beforecreate),g(this._oncreate),g(this._aftercreate),this._lock=!1)}function P(t,e){return function(n,r){var o=w(p(r),2),i=o[0],a=o[1],c=[i,n,0===e?a:t].filter(function(t){return t}).sort(A);return 3===c.length&&c[1]===n}}n(B.prototype,{onClickCell:function(t){t&&this.fire("select",t)},onHoverCell:function(t){this.fire("hover",t)},onHoverOut:function(){this.fire("hover",null)}},v),B.prototype._recompute=function(t,e){var n;t.current&&this._differs(e.calendar,e.calendar=H((n=e.current).year,n.month))&&(t.calendar=!0)},E(B);var R,z={onSelect:function(t){var e=this.get("targetIndex"),n=p(this.get("selected")).slice(0,e).concat(t).sort(A);this.set({selected:n,targetIndex:1-e}),this.fire("select",n)},onHover:function(t){this.set({hovered:t})}},G=(R=B,function(t){t.setLocale=function(t){R.setLocale(t)}});function K(t){var e,r,o;_(this,t),this._state=n({targetIndex:0},t.data),t.root||(this._oncreate=[],this._beforecreate=[],this._aftercreate=[]),this._fragment=(e=this,r=this._state,(o=new B({root:e.root,data:{selected:r.selected,locale:r.locale,isHighlighted:P(r.hovered,r.targetIndex)}})).on("select",function(t){e.onSelect(t)}),o.on("hover",function(t){e.onHover(t)}),{c:function(){o._fragment.c()},m:function(t,e){o._mount(t,e)},p:function(t,e){var n={};t.selected&&(n.selected=e.selected),t.locale&&(n.locale=e.locale),(t.hovered||t.targetIndex)&&(n.isHighlighted=P(e.hovered,e.targetIndex)),o._set(n)},u:function(){o._unmount()},d:function(){o.destroy(!1)}}),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor),this._lock=!0,g(this._beforecreate),g(this._oncreate),g(this._aftercreate),this._lock=!1)}n(K.prototype,z,v),G(K),t.en={weekDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],week:"{0}W",months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],year:"{0}"},t.ja={weekDays:["日","月","火","水","木","金","土"],week:"{0}W",months:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],year:"{0}年"},t.DateCalendar=B,t.DateRangeCalendar=K,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.CalendarSet={})}(this,function(e){"use strict";function t(){}function n(e){for(var t,n,r=1,o=arguments.length;r<o;r++)for(t in n=arguments[r])e[t]=n[t];return e}function r(e,t){t.appendChild(e)}function o(e,t,n){t.insertBefore(e,n)}function i(e){e.parentNode.removeChild(e)}function c(e){for(var t=0;t<e.length;t+=1)e[t]&&e[t].d()}function a(e){return document.createElement(e)}function l(e){return document.createTextNode(e)}function u(e,t,n){e.addEventListener(t,n,!1)}function s(e,t,n){e.removeEventListener(t,n,!1)}function h(){return Object.create(null)}function f(e){this.destroy=t,this.fire("destroy"),this.set=this.get=t,!1!==e&&this._fragment.u(),this._fragment.d(),this._fragment=this._state=null}function d(e,t,n,r,o){for(var i in t)if(n[i]){var c=r[i],a=o[i],l=t[i];if(l)for(var u=0;u<l.length;u+=1){var s=l[u];s.__calling||(s.__calling=!0,s.call(e,c,a),s.__calling=!1)}}}function _(e,t){e._observers={pre:h(),post:h()},e._handlers=h(),e._bind=t._bind,e.options=t,e.root=t.root||e,e.store=e.root.store||t.store}function v(e){for(;e&&e.length;)e.shift()()}var g={destroy:f,get:function(e){return e?this._state[e]:this._state},fire:function(e,t){var n=e in this._handlers&&this._handlers[e].slice();if(n)for(var r=0;r<n.length;r+=1)n[r].call(this,t)},observe:function(e,t,n){var r=n&&n.defer?this._observers.post:this._observers.pre;return(r[e]||(r[e]=[])).push(t),n&&!1===n.init||(t.__calling=!0,t.call(this,this._state[e]),t.__calling=!1),{cancel:function(){var n=r[e].indexOf(t);~n&&r[e].splice(n,1)}}},on:function(e,t){if("teardown"===e)return this.on("destroy",t);var n=this._handlers[e]||(this._handlers[e]=[]);return n.push(t),{cancel:function(){var e=n.indexOf(t);~e&&n.splice(e,1)}}},set:function(e){this._set(n({},e)),this.root._lock||(this.root._lock=!0,v(this.root._beforecreate),v(this.root._oncreate),v(this.root._aftercreate),this.root._lock=!1)},teardown:f,_recompute:t,_set:function(e){var t=this._state,r={},o=!1;for(var i in e)this._differs(e[i],t[i])&&(r[i]=o=!0);o&&(this._state=n({},t,e),this._recompute(r,this._state),this._bind&&this._bind(r,this._state),this._fragment&&(d(this,this._observers.pre,r,this._state,t),this._fragment.p(r,this._state),d(this,this._observers.post,r,this._state,t)))},_mount:function(e,t){this._fragment[this._fragment.i?"i":"m"](e,t||null)},_unmount:function(){this._fragment&&this._fragment.u()},_differs:function(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}};function m(){return!1}function p(e){return null==e?[]:Array.isArray(e)?e:[e]}function y(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return e.replace(/\{(\d+)\}/g,function(e,t){var r=Number(t);return n[r]||""}).replace(/\\\{(\d+)\\\}/g,function(e,t){return"{"+t+"}"})}function w(e,t){return k(e)||function(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var c,a=e[Symbol.iterator]();!(r=(c=a.next()).done)&&(n.push(c.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(e,t)||D()}function b(e){return k(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||D()}function k(e){if(Array.isArray(e))return e}function D(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var x=7,C=0;function H(e,t){var n=new Date(e,t,1),r=C-n.getDay();return function(e,t){for(var n,r=[],o=0;t(n,o);)n=e(n,o),r.push(n),o++;return r}(function(n,o){var i,c=x*o;return(i=x,Array.apply(null,Array(i)).map(function(e,t){return t})).map(function(n){var o=new Date(e,t,r+c+n+1);return N(o,e,t)?o:void 0})},function(n){if(!n)return!0;var r=n[x-1];return!!r&&N(new Date(j(r),O(r),S(r)+1),e,t)})}function N(e,t,n){return j(e)===t&&O(e)===n}function A(e,t){return function e(t,n,r){if(0===r.length)return 0;var o=b(r),i=o[0],c=o.slice(1),a=function(e,t){return e<t?-1:e>t?1:0}(i(t),i(n));return 0===a?e(t,n,c):a}(e,t,[j,O,S])}function j(e){return e.getFullYear()}function O(e){return e.getMonth()}function S(e){return e.getDate()}function M(e,t){var n=[];return e&&n.push("selected"),t&&n.push("highlighted"),n.join(" ")}function F(e){_(this,e),this._state=n({},e.data),this._slotted=e.slots||{},this.slots={},this._fragment=function(e,t){var n,c,l=e._slotted.default;function h(t){e.fire("click",t)}function f(t){e.fire("mouseenter",t)}return{c:function(){n=a("button"),this.h()},h:function(){n.className=c="calendar-cell-button "+M(t.selected,t.highlighted)+" svelte-15crlep",u(n,"click",h),u(n,"mouseenter",f)},m:function(e,t){o(n,e,t),l&&r(l,n)},p:function(e,t){(e.selected||e.highlighted)&&c!==(c="calendar-cell-button "+M(t.selected,t.highlighted)+" svelte-15crlep")&&(n.className=c)},u:function(){i(n),l&&function(e,t){for(;e.firstChild;)t.appendChild(e.firstChild)}(n,l)},d:function(){s(n,"click",h),s(n,"mouseenter",f)}}}(this,this._state),e.target&&(this._fragment.c(),this._mount(e.target,e.anchor))}function L(e,t){return p(t).reduce(function(t,n){return t||0===A(e,n)},!1)}function E(e){return 0===e?"sunday":6===e?"saturday":""}n(F.prototype,g);var T=function(e){e.setLocale=function(t){e.locale=t}};function J(e,n){var c,u,s=n.weekDay,h=(n.each_value,n.i),f=y(s);return{c:function(){c=a("th"),u=l(f),this.h()},h:function(){c.scope="col",c.className="calendar-cell heading "+E(h)},m:function(e,t){o(c,e,t),r(u,c)},p:function(e,t){s=t.weekDay,t.each_value,h=t.i,e.locale&&f!==(f=y(s))&&(u.data=f)},u:function(){i(c)},d:t}}function W(e,t){for(var r,l=t.row,u=(t.each_value_1,t.row_index,l),s=[],h=0;h<u.length;h+=1)s[h]=Y(e,n({},t,{each_value_2:u,cell:u[h],i:h}));return{c:function(){r=a("tr");for(var e=0;e<s.length;e+=1)s[e].c()},m:function(e,t){o(r,e,t);for(var n=0;n<s.length;n+=1)s[n].m(r,null)},p:function(t,o){l=o.row,o.each_value_1,o.row_index;var i=l;if(t.calendar||t.selected||t.isHighlighted){for(var c=0;c<i.length;c+=1){var a=n({},o,{each_value_2:i,cell:i[c],i:c});s[c]?s[c].p(t,a):(s[c]=Y(e,a),s[c].c(),s[c].m(r,null))}for(;c<s.length;c+=1)s[c].u(),s[c].d();s.length=i.length}},u:function(){i(r);for(var e=0;e<s.length;e+=1)s[e].u()},d:function(){c(s)}}}function Y(e,t){t.row,t.each_value_1,t.row_index;var n,r=t.cell,c=(t.each_value_2,t.i),l=r&&q(e,t);return{c:function(){n=a("td"),l&&l.c(),this.h()},h:function(){n.className="calendar-cell "+E(c)},m:function(e,t){o(n,e,t),l&&l.m(n,null)},p:function(t,o){o.row,o.each_value_1,o.row_index,r=o.cell,o.each_value_2,c=o.i,r?l?l.p(t,o):((l=q(e,o)).c(),l.m(n,null)):l&&(l.u(),l.d(),l=null)},u:function(){i(n),l&&l.u()},d:function(){l&&l.d()}}}function q(e,t){t.row,t.each_value_1,t.row_index;var n,o,i,c=t.cell,a=(t.each_value_2,t.i,c.getDate()),u=new F({root:e.root,slots:{default:document.createDocumentFragment()},data:{selected:L(c,t.selected),highlighted:t.isHighlighted(c,t.selected)}});return u.on("click",function(t){e.onClickCell(c)}),u.on("mouseenter",function(t){e.onHoverCell(c)}),{c:function(){n=l("\n "),o=l(a),i=l("\n "),u._fragment.c()},m:function(e,t){r(n,u._slotted.default),r(o,u._slotted.default),r(i,u._slotted.default),u._mount(e,t)},p:function(e,t){t.row,t.each_value_1,t.row_index,c=t.cell,t.each_value_2,t.i,e.calendar&&a!==(a=c.getDate())&&(o.data=a);var n={};(e.calendar||e.selected)&&(n.selected=L(c,t.selected)),(e.isHighlighted||e.calendar||e.selected)&&(n.highlighted=t.isHighlighted(c,t.selected)),u._set(n)},u:function(){u._unmount()},d:function(){u.destroy(!1)}}}function B(e,t){for(var h,f,d,_,v,g,m,p,w,b,k,D,x=y(t.locale.year,t.current.year),C=y(t.locale.months[t.current.month]),H=t.locale.weekDays,N=[],A=0;A<H.length;A+=1)N[A]=J(0,n({},t,{each_value:H,weekDay:H[A],i:A}));var j=t.calendar,O=[];for(A=0;A<j.length;A+=1)O[A]=W(e,n({},t,{each_value_1:j,row:j[A],row_index:A}));function S(t){e.onHoverOut()}return{c:function(){h=a("p"),f=a("span"),d=l(x),_=l("\n "),v=a("span"),g=l(C),m=l("\n\n "),p=a("table"),w=a("thead"),b=a("tr");for(var e=0;e<N.length;e+=1)N[e].c();k=l("\n\n "),D=a("tbody");for(e=0;e<O.length;e+=1)O[e].c();this.h()},h:function(){f.className="calendar-year",v.className="calendar-month",h.className="calendar-header",u(D,"mouseleave",S),p.className="calendar-table"},m:function(e,t){o(h,e,t),r(f,h),r(d,f),r(_,h),r(v,h),r(g,v),o(m,e,t),o(p,e,t),r(w,p),r(b,w);for(var n=0;n<N.length;n+=1)N[n].m(b,null);r(k,p),r(D,p);for(n=0;n<O.length;n+=1)O[n].m(D,null)},p:function(t,r){(t.locale||t.current)&&x!==(x=y(r.locale.year,r.current.year))&&(d.data=x),(t.locale||t.current)&&C!==(C=y(r.locale.months[r.current.month]))&&(g.data=C);var o=r.locale.weekDays;if(t.locale){for(var i=0;i<o.length;i+=1){var c=n({},r,{each_value:o,weekDay:o[i],i:i});N[i]?N[i].p(t,c):(N[i]=J(0,c),N[i].c(),N[i].m(b,null))}for(;i<N.length;i+=1)N[i].u(),N[i].d();N.length=o.length}var a=r.calendar;if(t.calendar||t.selected||t.isHighlighted){for(i=0;i<a.length;i+=1){var l=n({},r,{each_value_1:a,row:a[i],row_index:i});O[i]?O[i].p(t,l):(O[i]=W(e,l),O[i].c(),O[i].m(D,null))}for(;i<O.length;i+=1)O[i].u(),O[i].d();O.length=a.length}},u:function(){i(h),i(m),i(p);for(var e=0;e<N.length;e+=1)N[e].u();for(e=0;e<O.length;e+=1)O[e].u()},d:function(){c(N),c(O),s(D,"mouseleave",S)}}}function I(e){var t;_(this,e),this._state=n({current:{year:(t=new Date).getFullYear(),month:t.getMonth()},isHighlighted:m},e.data),this._recompute({current:1},this._state);var r,c,l,u,s=function(){this.get("locale")||this.set({locale:this.constructor.locale})}.bind(this);e.root||(this._oncreate=[],this._beforecreate=[],this._aftercreate=[]),this._fragment=(r=this,c=this._state,u=c.locale&&B(r,c),{c:function(){l=a("div"),u&&u.c(),this.h()},h:function(){l.className="calendar svelte-1qlxfod"},m:function(e,t){o(l,e,t),u&&u.m(l,null)},p:function(e,t){t.locale?u?u.p(e,t):((u=B(r,t)).c(),u.m(l,null)):u&&(u.u(),u.d(),u=null)},u:function(){i(l),u&&u.u()},d:function(){u&&u.d()}}),this.root._oncreate.push(s),e.target&&(this._fragment.c(),this._mount(e.target,e.anchor),this._lock=!0,v(this._beforecreate),v(this._oncreate),v(this._aftercreate),this._lock=!1)}function P(e,t){return function(n,r){var o=w(p(r),2),i=o[0],c=o[1],a=[i,n,t?e:c].filter(function(e){return e}).sort(A);return 3===a.length&&a[1]===n}}n(I.prototype,{onClickCell:function(e){e&&this.fire("select",e)},onHoverCell:function(e){this.fire("hover",e)},onHoverOut:function(){this.fire("hover",null)}},g),I.prototype._recompute=function(e,t){var n;e.current&&this._differs(t.calendar,t.calendar=H((n=t.current).year,n.month))&&(e.calendar=!0)},T(I);var R,z={onSelect:function(e){var t=this.get("second"),n=t?1:0,r=p(this.get("selected")).slice(0,n).concat(e).sort(A);this.set({selected:r,second:!t}),this.fire("select",r)},onHover:function(e){this.set({hovered:e}),this.fire("hover",e)}},G=(R=I,function(e){e.setLocale=function(e){R.setLocale(e)}});function K(e){var t,r,o;_(this,e),this._state=n({second:!1},e.data),e.root||(this._oncreate=[],this._beforecreate=[],this._aftercreate=[]),this._fragment=(t=this,r=this._state,(o=new I({root:t.root,data:{current:r.current,selected:r.selected,locale:r.locale,isHighlighted:P(r.hovered,r.second)}})).on("select",function(e){t.onSelect(e)}),o.on("hover",function(e){t.onHover(e)}),{c:function(){o._fragment.c()},m:function(e,t){o._mount(e,t)},p:function(e,t){var n={};e.current&&(n.current=t.current),e.selected&&(n.selected=t.selected),e.locale&&(n.locale=t.locale),(e.hovered||e.second)&&(n.isHighlighted=P(t.hovered,t.second)),o._set(n)},u:function(){o._unmount()},d:function(){o.destroy(!1)}}),e.target&&(this._fragment.c(),this._mount(e.target,e.anchor),this._lock=!0,v(this._beforecreate),v(this._oncreate),v(this._aftercreate),this._lock=!1)}n(K.prototype,z,g),G(K),e.en={weekDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],week:"{0}W",months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],year:"{0}"},e.ja={weekDays:["日","月","火","水","木","金","土"],week:"{0}W",months:["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],year:"{0}年"},e.DateCalendar=I,e.DateRangeCalendar=K,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=calendar-set.min.js.map |
{ | ||
"name": "calendar-set", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Framework agnostic calendar components", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -50,2 +50,4 @@ # calendar-set | ||
selected: Date | Date[] | undefined | ||
hovered: Date | undefined | ||
second: boolean // `true` if it is going to select the second date | ||
locale: Locale | ||
@@ -58,2 +60,3 @@ } | ||
* `fire('select', selectedDate)`: `selectedDate` is an array and always sorted with ASC order by date. | ||
* `fire('hover', hoveredDate)` | ||
@@ -60,0 +63,0 @@ ## Styles |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
149459
3097
90
0