Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calendar-set

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calendar-set - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

6

dist/calendar-set.cjs.js
/*!
* calendar-set v0.2.2
* calendar-set v0.2.3
* https://github.com/ktsn/calendar-set

@@ -464,3 +464,3 @@ *

h: function hydrate() {
button.className = button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-15crlep";
button.className = button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-acia7y";
addListener(button, "click", click_handler);

@@ -477,3 +477,3 @@ addListener(button, "mouseenter", mouseenter_handler);

p: function update(changed, state) {
if ((changed.selected || changed.highlighted) && button_class_value !== (button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-15crlep")) {
if ((changed.selected || changed.highlighted) && button_class_value !== (button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-acia7y")) {
button.className = button_class_value;

@@ -480,0 +480,0 @@ }

/*!
* calendar-set v0.2.2
* calendar-set v0.2.3
* https://github.com/ktsn/calendar-set

@@ -460,3 +460,3 @@ *

h: function hydrate() {
button.className = button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-15crlep";
button.className = button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-acia7y";
addListener(button, "click", click_handler);

@@ -473,3 +473,3 @@ addListener(button, "mouseenter", mouseenter_handler);

p: function update(changed, state) {
if ((changed.selected || changed.highlighted) && button_class_value !== (button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-15crlep")) {
if ((changed.selected || changed.highlighted) && button_class_value !== (button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-acia7y")) {
button.className = button_class_value;

@@ -476,0 +476,0 @@ }

/*!
* calendar-set v0.2.2
* calendar-set v0.2.3
* https://github.com/ktsn/calendar-set

@@ -466,3 +466,3 @@ *

h: function hydrate() {
button.className = button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-15crlep";
button.className = button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-acia7y";
addListener(button, "click", click_handler);

@@ -479,3 +479,3 @@ addListener(button, "mouseenter", mouseenter_handler);

p: function update(changed, state) {
if ((changed.selected || changed.highlighted) && button_class_value !== (button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-15crlep")) {
if ((changed.selected || changed.highlighted) && button_class_value !== (button_class_value = "calendar-cell-button " + stateClass(state.selected, state.highlighted) + " svelte-acia7y")) {
button.className = button_class_value;

@@ -482,0 +482,0 @@ }

/*!
* calendar-set v0.2.2
* calendar-set v0.2.3
* https://github.com/ktsn/calendar-set

@@ -9,3 +9,3 @@ *

*/
!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})});
!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 c(t){for(var e=0;e<t.length;e+=1)t[e]&&t[e].d()}function a(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 c=r[i],a=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,c,a),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 v(t){for(;t&&t.length;)t.shift()()}var g={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,v(this.root._beforecreate),v(this.root._oncreate),v(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 c,a=t[Symbol.iterator]();!(r=(c=a.next()).done)&&(n.push(c.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(t,e)||D()}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)||D()}function k(t){if(Array.isArray(t))return t}function D(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var x=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,c=x*o;return(i=x,Array.apply(null,Array(i)).map(function(t,e){return e})).map(function(n){var o=new Date(t,e,r+c+n+1);return N(o,t,e)?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),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],c=o.slice(1),a=function(t,e){return t<e?-1:t>e?1:0}(i(e),i(n));return 0===a?t(e,n,c):a}(t,e,[j,O,S])}function j(t){return t.getFullYear()}function O(t){return t.getMonth()}function S(t){return t.getDate()}function M(t,e){var n=[];return t&&n.push("selected"),e&&n.push("highlighted"),n.join(" ")}function F(t){_(this,t),this._state=n({},t.data),this._slotted=t.slots||{},this.slots={},this._fragment=function(t,e){var n,c,l=t._slotted.default;function h(e){t.fire("click",e)}function f(e){t.fire("mouseenter",e)}return{c:function(){n=a("button"),this.h()},h:function(){n.className=c="calendar-cell-button "+M(e.selected,e.highlighted)+" svelte-acia7y",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)&&c!==(c="calendar-cell-button "+M(e.selected,e.highlighted)+" svelte-acia7y")&&(n.className=c)},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 L(t,e){return p(e).reduce(function(e,n){return e||0===A(t,n)},!1)}function E(t){return 0===t?"sunday":6===t?"saturday":""}n(F.prototype,g);var T=function(t){t.setLocale=function(e){t.locale=e}};function J(t,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(t,e){o(c,t,e),r(u,c)},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(c)},d:e}}function W(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]=Y(t,n({},e,{each_value_2:u,cell:u[h],i:h}));return{c:function(){r=a("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 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(e,a):(s[c]=Y(t,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 t=0;t<s.length;t+=1)s[t].u()},d:function(){c(s)}}}function Y(t,e){e.row,e.each_value_1,e.row_index;var n,r=e.cell,c=(e.each_value_2,e.i),l=r&&q(t,e);return{c:function(){n=a("td"),l&&l.c(),this.h()},h:function(){n.className="calendar-cell "+E(c)},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,c=o.i,r?l?l.p(e,o):((l=q(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 q(t,e){e.row,e.each_value_1,e.row_index;var n,o,i,c=e.cell,a=(e.each_value_2,e.i,c.getDate()),u=new F({root:t.root,slots:{default:document.createDocumentFragment()},data:{selected:L(c,e.selected),highlighted:e.isHighlighted(c,e.selected)}});return u.on("click",function(e){t.onClickCell(c)}),u.on("mouseenter",function(e){t.onHoverCell(c)}),{c:function(){n=l("\n "),o=l(a),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,c=e.cell,e.each_value_2,e.i,t.calendar&&a!==(a=c.getDate())&&(o.data=a);var n={};(t.calendar||t.selected)&&(n.selected=L(c,e.selected)),(t.isHighlighted||t.calendar||t.selected)&&(n.highlighted=e.isHighlighted(c,e.selected)),u._set(n)},u:function(){u._unmount()},d:function(){u.destroy(!1)}}}function B(t,e){for(var h,f,d,_,v,g,m,p,w,b,k,D,x=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]=J(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]=W(t,n({},e,{each_value_1:j,row:j[A],row_index:A}));function S(e){t.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 t=0;t<N.length;t+=1)N[t].c();k=l("\n\n "),D=a("tbody");for(t=0;t<O.length;t+=1)O[t].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(t,e){o(h,t,e),r(f,h),r(d,f),r(_,h),r(v,h),r(g,v),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(D,p);for(n=0;n<O.length;n+=1)O[n].m(D,null)},p:function(e,r){(e.locale||e.current)&&x!==(x=y(r.locale.year,r.current.year))&&(d.data=x),(e.locale||e.current)&&C!==(C=y(r.locale.months[r.current.month]))&&(g.data=C);var o=r.locale.weekDays;if(e.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(e,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(e.calendar||e.selected||e.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(e,l):(O[i]=W(t,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 t=0;t<N.length;t+=1)N[t].u();for(t=0;t<O.length;t+=1)O[t].u()},d:function(){c(N),c(O),s(D,"mouseleave",S)}}}function I(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,c,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,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(t,e){o(l,t,e),u&&u.m(l,null)},p:function(t,e){e.locale?u?u.p(t,e):((u=B(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,v(this._beforecreate),v(this._oncreate),v(this._aftercreate),this._lock=!1)}function P(t,e){return function(n,r){var o=w(p(r),2),i=o[0],c=o[1],a=[i,n,e?t:c].filter(function(t){return t}).sort(A);return 3===a.length&&a[1]===n}}n(I.prototype,{onClickCell:function(t){t&&this.fire("select",t)},onHoverCell:function(t){this.fire("hover",t)},onHoverOut:function(){this.fire("hover",null)}},g),I.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)},T(I);var R,z={onSelect:function(t){var e=this.get("second"),n=e?1:0,r=p(this.get("selected")).slice(0,n).concat(t).sort(A);this.set({selected:r,second:!e}),this.fire("select",r)},onHover:function(t){this.set({hovered:t}),this.fire("hover",t)}},G=(R=I,function(t){t.setLocale=function(t){R.setLocale(t)}});function K(t){var e,r,o;_(this,t),this._state=n({second:!1},t.data),t.root||(this._oncreate=[],this._beforecreate=[],this._aftercreate=[]),this._fragment=(e=this,r=this._state,(o=new I({root:e.root,data:{current:r.current,selected:r.selected,locale:r.locale,isHighlighted:P(r.hovered,r.second)}})).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.current&&(n.current=e.current),t.selected&&(n.selected=e.selected),t.locale&&(n.locale=e.locale),(t.hovered||t.second)&&(n.isHighlighted=P(e.hovered,e.second)),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,v(this._beforecreate),v(this._oncreate),v(this._aftercreate),this._lock=!1)}n(K.prototype,z,g),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=I,t.DateRangeCalendar=K,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=calendar-set.min.js.map
{
"name": "calendar-set",
"version": "0.2.2",
"version": "0.2.3",
"description": "Framework agnostic calendar components",

@@ -31,3 +31,4 @@ "keywords": [

"test:watch": "jest --watch",
"examples": "webpack-dev-server --hot --open"
"examples": "webpack-dev-server --hot --open",
"examples:deploy": "webpack --mode production && ./examples/deploy.sh"
},

@@ -34,0 +35,0 @@ "jest": {

# calendar-set
Framework agnostic calendar components
Framework agnostic calendar components ([demo](https://ktsn.github.io/calendar-set/))
## Components
All components have a static method `setLocale` to specify localized string shown in the calendar. You need to call the method before instantiating components. `calendar-set` provides built in locales `en` and `ja`.
The components are implemented with [Svelte](https://svelte.technology/), so they can be used with [Svelte component API](https://svelte.technology/guide#component-api). The following is a simple example how you can use `DateCalendar` component.

@@ -14,4 +14,32 @@ ```js

DateCalendar.setLocale(en)
// Instantiate the calendar component
const calendar = new DateCalendar({
// Pass a DOM element which the component mount to
target: document.querySelector('#calendar'),
// Pass initial data of the component
data: {
selected: new Date()
}
})
// Observe calendar events
calendar.on('select', selected => {
console.log(selected)
})
// Set calendar data
calendar.set({
selected: new Date(2018, 0, 1)
})
// Destroy the component
calendar.destroy()
```
All components have a static method `setLocale` to specify localized string shown in the calendar. You need to call the method before instantiating components. `calendar-set` provides built in locales `en` and `ja`.
If you want to use with [Vue.js](https://vuejs.org/), you may interested in [vue-svelte-adapter](https://github.com/ktsn/vue-svelte-adapter).
### DateCalendar

@@ -18,0 +46,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc