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.4 to 0.3.0

706

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

@@ -335,2 +335,3 @@ *

var WEEK_DAYS_NUM = 7;
var MONTH_NUM = 12;
var SUNDAY = 0;

@@ -353,3 +354,3 @@ /**

}
function getMonthCalendar(year, month) {
function getDateCalendar(year, month) {
var target = new Date(year, month, 1);

@@ -371,7 +372,13 @@ var offsetOfFirstDate = SUNDAY - getWeekDay(target);

}
function getMonthCalendar(year) {
return range(MONTH_NUM).map(function (month) {
return new Date(year, month);
});
}
function equalsMonth(date, year, month) {
return getYear(date) === year && getMonth(date) === month;
}
function compareMonthAsc(a, b) {
return compareAscSeed(a, b, [getYear, getMonth]);
}
function equalsDate(a, b) {

@@ -381,21 +388,21 @@ return compareDateAsc(a, b) === 0;

function compareDateAsc(a, b) {
function loop(a, b, getters) {
if (getters.length === 0) {
return 0;
}
return compareAscSeed(a, b, [getYear, getMonth, getDate]);
}
var _getters = _toArray(getters),
getter = _getters[0],
tail = _getters.slice(1);
function compareAscSeed(a, b, getters) {
if (getters.length === 0) {
return 0;
}
var res = compareAsc(getter(a), getter(b));
var _getters = _toArray(getters),
getter = _getters[0],
tail = _getters.slice(1);
if (res === 0) {
return loop(a, b, tail);
} else {
return res;
}
var res = compareAsc(getter(a), getter(b));
if (res === 0) {
return compareAscSeed(a, b, tail);
} else {
return res;
}
return loop(a, b, [getYear, getMonth, getDate]);
}

@@ -515,2 +522,140 @@

/* src/CalendarHeader.html generated by Svelte v1.58.0 */
function create_main_fragment$1(component, state) {
var p, text;
var if_block = state.year != null && create_if_block(component, state);
var if_block_1 = state.month != null && create_if_block_1(component, state);
return {
c: function create() {
p = createElement("p");
if (if_block) if_block.c();
text = createText(" ");
if (if_block_1) if_block_1.c();
this.h();
},
h: function hydrate() {
p.className = "calendar-header svelte-itebfq";
},
m: function mount(target, anchor) {
insertNode(p, target, anchor);
if (if_block) if_block.m(p, null);
appendNode(text, p);
if (if_block_1) if_block_1.m(p, null);
},
p: function update(changed, state) {
if (state.year != null) {
if (if_block) {
if_block.p(changed, state);
} else {
if_block = create_if_block(component, state);
if_block.c();
if_block.m(p, text);
}
} else if (if_block) {
if_block.u();
if_block.d();
if_block = null;
}
if (state.month != null) {
if (if_block_1) {
if_block_1.p(changed, state);
} else {
if_block_1 = create_if_block_1(component, state);
if_block_1.c();
if_block_1.m(p, null);
}
} else if (if_block_1) {
if_block_1.u();
if_block_1.d();
if_block_1 = null;
}
},
u: function unmount() {
detachNode(p);
if (if_block) if_block.u();
if (if_block_1) if_block_1.u();
},
d: function destroy$$1() {
if (if_block) if_block.d();
if (if_block_1) if_block_1.d();
}
};
} // (2:2) {{#if year != null }}
function create_if_block(component, state) {
var span,
text_value = format(state.locale.year, state.year),
text;
return {
c: function create() {
span = createElement("span");
text = createText(text_value);
this.h();
},
h: function hydrate() {
span.className = "calendar-year";
},
m: function mount(target, anchor) {
insertNode(span, target, anchor);
appendNode(text, span);
},
p: function update(changed, state) {
if ((changed.locale || changed.year) && text_value !== (text_value = format(state.locale.year, state.year))) {
text.data = text_value;
}
},
u: function unmount() {
detachNode(span);
},
d: noop
};
} // (6:10) {{#if month != null }}
function create_if_block_1(component, state) {
var span,
text_value = format(state.locale.months[state.month]),
text;
return {
c: function create() {
span = createElement("span");
text = createText(text_value);
this.h();
},
h: function hydrate() {
span.className = "calendar-month";
},
m: function mount(target, anchor) {
insertNode(span, target, anchor);
appendNode(text, span);
},
p: function update(changed, state) {
if ((changed.locale || changed.month) && text_value !== (text_value = format(state.locale.months[state.month]))) {
text.data = text_value;
}
},
u: function unmount() {
detachNode(span);
},
d: noop
};
}
function CalendarHeader(options) {
init(this, options);
this._state = assign({}, options.data);
this._fragment = create_main_fragment$1(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
}
}
assign(CalendarHeader.prototype, proto);
/* src/DateCalendar.html generated by Svelte v1.58.0 */

@@ -537,3 +682,3 @@

function calendar(current) {
return getMonthCalendar(current.year, current.month);
return getDateCalendar(current.year, current.month);
}

@@ -575,5 +720,5 @@

function create_main_fragment$1(component, state) {
function create_main_fragment$2(component, state) {
var div;
var if_block = state.locale && create_if_block(component, state);
var if_block = state.locale && create_if_block$1(component, state);
return {

@@ -586,3 +731,3 @@ c: function create() {

h: function hydrate() {
div.className = "calendar svelte-1qlxfod";
div.className = "date-calendar svelte-ji3oj2";
},

@@ -598,3 +743,3 @@ m: function mount(target, anchor) {

} else {
if_block = create_if_block(component, state);
if_block = create_if_block$1(component, state);
if_block.c();

@@ -617,3 +762,3 @@ if_block.m(div, null);

};
} // (15:8) {{#each locale.weekDays as weekDay, i}}
} // (8:8) {{#each locale.weekDays as weekDay, i}}

@@ -637,3 +782,3 @@

th.scope = "col";
th.className = th_class_value = "calendar-cell heading " + weekClass(i);
th.className = th_class_value = "date-calendar-cell heading " + weekClass(i);
},

@@ -658,3 +803,3 @@ m: function mount(target, anchor) {

};
} // (24:6) {{#each calendar as row}}
} // (17:6) {{#each calendar as row}}

@@ -735,3 +880,3 @@

};
} // (26:8) {{#each row as cell, i}}
} // (19:8) {{#each row as cell, i}}

@@ -747,3 +892,3 @@

var td, td_class_value;
var if_block = cell && create_if_block_1(component, state);
var if_block = cell && create_if_block_1$1(component, state);
return {

@@ -756,3 +901,3 @@ c: function create() {

h: function hydrate() {
td.className = td_class_value = "calendar-cell " + weekClass(i);
td.className = td_class_value = "date-calendar-cell " + weekClass(i);
},

@@ -775,3 +920,3 @@ m: function mount(target, anchor) {

} else {
if_block = create_if_block_1(component, state);
if_block = create_if_block_1$1(component, state);
if_block.c();

@@ -794,6 +939,6 @@ if_block.m(td, null);

};
} // (28:10) {{#if cell}}
} // (21:10) {{#if cell}}
function create_if_block_1(component, state) {
function create_if_block_1$1(component, state) {
var row = state.row,

@@ -868,17 +1013,12 @@ each_value_1 = state.each_value_1,

function create_if_block(component, state) {
var p,
span,
text_value = format(state.locale.year, state.current.year),
text,
text_2,
span_1,
text_3_value = format(state.locale.months[state.current.month]),
text_3,
text_6,
table,
thead,
tr,
text_9,
tbody;
function create_if_block$1(component, state) {
var text, table, thead, tr, text_3, tbody;
var calendarheader = new CalendarHeader({
root: component.root,
data: {
locale: state.locale,
year: state.current.year,
month: state.current.month
}
});
var each_value = state.locale.weekDays;

@@ -912,9 +1052,5 @@ var each_blocks = [];

c: function create() {
p = createElement("p");
span = createElement("span");
text = createText(text_value);
text_2 = createText("\n ");
span_1 = createElement("span");
text_3 = createText(text_3_value);
text_6 = createText("\n\n ");
calendarheader._fragment.c();
text = createText("\n\n ");
table = createElement("table");

@@ -928,3 +1064,3 @@ thead = createElement("thead");

text_9 = createText("\n\n ");
text_3 = createText("\n\n ");
tbody = createElement("tbody");

@@ -939,16 +1075,9 @@

h: function hydrate() {
span.className = "calendar-year";
span_1.className = "calendar-month";
p.className = "calendar-header";
addListener(tbody, "mouseleave", mouseleave_handler);
table.className = "calendar-table";
table.className = "date-calendar-table";
},
m: function mount(target, anchor) {
insertNode(p, target, anchor);
appendNode(span, p);
appendNode(text, span);
appendNode(text_2, p);
appendNode(span_1, p);
appendNode(text_3, span_1);
insertNode(text_6, target, anchor);
calendarheader._mount(target, anchor);
insertNode(text, target, anchor);
insertNode(table, target, anchor);

@@ -962,3 +1091,3 @@ appendNode(thead, table);

appendNode(text_9, table);
appendNode(text_3, table);
appendNode(tbody, table);

@@ -971,9 +1100,8 @@

p: function update(changed, state) {
if ((changed.locale || changed.current) && text_value !== (text_value = format(state.locale.year, state.current.year))) {
text.data = text_value;
}
var calendarheader_changes = {};
if (changed.locale) calendarheader_changes.locale = state.locale;
if (changed.current) calendarheader_changes.year = state.current.year;
if (changed.current) calendarheader_changes.month = state.current.month;
if ((changed.locale || changed.current) && text_3_value !== (text_3_value = format(state.locale.months[state.current.month]))) {
text_3.data = text_3_value;
}
calendarheader._set(calendarheader_changes);

@@ -1035,4 +1163,5 @@ var each_value = state.locale.weekDays;

u: function unmount() {
detachNode(p);
detachNode(text_6);
calendarheader._unmount();
detachNode(text);
detachNode(table);

@@ -1049,2 +1178,3 @@

d: function destroy$$1() {
calendarheader.destroy(false);
destroyEach(each_blocks);

@@ -1073,3 +1203,3 @@ destroyEach(each_1_blocks);

this._fragment = create_main_fragment$1(this, this._state);
this._fragment = create_main_fragment$2(this, this._state);

@@ -1141,3 +1271,3 @@ this.root._oncreate.push(_oncreate);

function create_main_fragment$2(component, state) {
function create_main_fragment$3(component, state) {
var datecalendar = new DateCalendar({

@@ -1193,3 +1323,3 @@ root: component.root,

this._fragment = create_main_fragment$2(this, this._state);
this._fragment = create_main_fragment$3(this, this._state);

@@ -1212,2 +1342,418 @@ if (options.target) {

/* src/MonthCalendar.html generated by Svelte v1.58.0 */
function isSelected$1(month, selected) {
return arrayfy(selected).reduce(function (acc, s) {
return acc || equalsMonth(month, s.getFullYear(), s.getMonth());
}, false);
}
function calendar$1(currentYear) {
return getMonthCalendar(currentYear);
}
function data$2() {
var today = new Date();
return {
currentYear: today.getFullYear(),
isHighlighted: no
};
}
var methods$2 = {
onClickCell: function onClickCell(month) {
if (!month) return;
this.fire('select', month);
},
onHoverCell: function onHoverCell(month) {
this.fire('hover', month);
},
onHoverOut: function onHoverOut() {
this.fire('hover', null);
}
};
function oncreate$1() {
var _get = this.get(),
locale = _get.locale;
if (!locale) {
this.set({
locale: this.constructor.locale
});
}
}
var setup$2 = setupCalendar;
function create_main_fragment$4(component, state) {
var div;
var if_block = state.locale && create_if_block$2(component, state);
return {
c: function create() {
div = createElement("div");
if (if_block) if_block.c();
this.h();
},
h: function hydrate() {
div.className = "month-calendar svelte-66r1f2";
},
m: function mount(target, anchor) {
insertNode(div, target, anchor);
if (if_block) if_block.m(div, null);
},
p: function update(changed, state) {
if (state.locale) {
if (if_block) {
if_block.p(changed, state);
} else {
if_block = create_if_block$2(component, state);
if_block.c();
if_block.m(div, null);
}
} else if (if_block) {
if_block.u();
if_block.d();
if_block = null;
}
},
u: function unmount() {
detachNode(div);
if (if_block) if_block.u();
},
d: function destroy$$1() {
if (if_block) if_block.d();
}
};
} // (6:4) {{#each calendar as month }}
function create_each_block$1(component, state) {
var month_1 = state.month,
each_value = state.each_value,
month_index = state.month_index;
var li,
text,
text_1_value = format(state.locale.months[month_1.getMonth()]),
text_1,
text_2;
var cellbutton = new CellButton({
root: component.root,
slots: {
default: createFragment()
},
data: {
selected: isSelected$1(month_1, state.selected),
highlighted: state.isHighlighted(month_1, state.selected)
}
});
cellbutton.on("mouseenter", function (event) {
component.onHoverCell(month_1);
});
cellbutton.on("click", function (event) {
component.onClickCell(month_1);
});
return {
c: function create() {
li = createElement("li");
text = createText("\n ");
text_1 = createText(text_1_value);
text_2 = createText("\n ");
cellbutton._fragment.c();
this.h();
},
h: function hydrate() {
li.className = "month-calendar-item";
},
m: function mount(target, anchor) {
insertNode(li, target, anchor);
appendNode(text, cellbutton._slotted.default);
appendNode(text_1, cellbutton._slotted.default);
appendNode(text_2, cellbutton._slotted.default);
cellbutton._mount(li, null);
},
p: function update(changed, state) {
month_1 = state.month;
each_value = state.each_value;
month_index = state.month_index;
if ((changed.locale || changed.calendar) && text_1_value !== (text_1_value = format(state.locale.months[month_1.getMonth()]))) {
text_1.data = text_1_value;
}
var cellbutton_changes = {};
if (changed.calendar || changed.selected) cellbutton_changes.selected = isSelected$1(month_1, state.selected);
if (changed.isHighlighted || changed.calendar || changed.selected) cellbutton_changes.highlighted = state.isHighlighted(month_1, state.selected);
cellbutton._set(cellbutton_changes);
},
u: function unmount() {
detachNode(li);
},
d: function destroy$$1() {
cellbutton.destroy(false);
}
};
} // (2:2) {{#if locale }}
function create_if_block$2(component, state) {
var text, ul;
var calendarheader = new CalendarHeader({
root: component.root,
data: {
locale: state.locale,
year: state.currentYear
}
});
var each_value = state.calendar;
var each_blocks = [];
for (var i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$1(component, assign({}, state, {
each_value: each_value,
month: each_value[i],
month_index: i
}));
}
function mouseleave_handler(event) {
component.onHoverOut();
}
return {
c: function create() {
calendarheader._fragment.c();
text = createText("\n\n ");
ul = createElement("ul");
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
this.h();
},
h: function hydrate() {
ul.className = "month-calendar-list";
addListener(ul, "mouseleave", mouseleave_handler);
},
m: function mount(target, anchor) {
calendarheader._mount(target, anchor);
insertNode(text, target, anchor);
insertNode(ul, target, anchor);
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(ul, null);
}
},
p: function update(changed, state) {
var calendarheader_changes = {};
if (changed.locale) calendarheader_changes.locale = state.locale;
if (changed.currentYear) calendarheader_changes.year = state.currentYear;
calendarheader._set(calendarheader_changes);
var each_value = state.calendar;
if (changed.calendar || changed.selected || changed.isHighlighted || changed.locale) {
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign({}, state, {
each_value: each_value,
month: each_value[i],
month_index: i
});
if (each_blocks[i]) {
each_blocks[i].p(changed, each_context);
} else {
each_blocks[i] = create_each_block$1(component, each_context);
each_blocks[i].c();
each_blocks[i].m(ul, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].u();
each_blocks[i].d();
}
each_blocks.length = each_value.length;
}
},
u: function unmount() {
calendarheader._unmount();
detachNode(text);
detachNode(ul);
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].u();
}
},
d: function destroy$$1() {
calendarheader.destroy(false);
destroyEach(each_blocks);
removeListener(ul, "mouseleave", mouseleave_handler);
}
};
}
function MonthCalendar(options) {
init(this, options);
this._state = assign(data$2(), options.data);
this._recompute({
currentYear: 1
}, this._state);
var _oncreate = oncreate$1.bind(this);
if (!options.root) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment$4(this, this._state);
this.root._oncreate.push(_oncreate);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
this._lock = false;
}
}
assign(MonthCalendar.prototype, methods$2, proto);
MonthCalendar.prototype._recompute = function _recompute(changed, state) {
if (changed.currentYear) {
if (this._differs(state.calendar, state.calendar = calendar$1(state.currentYear))) changed.calendar = true;
}
};
setup$2(MonthCalendar);
function isHighlighted$1(hovered, isSecond) {
return function (target, selected) {
var _arrayfy = arrayfy(selected),
_arrayfy2 = _slicedToArray(_arrayfy, 2),
first = _arrayfy2[0],
second = _arrayfy2[1];
var list = [first, target, isSecond ? hovered : second].filter(function (x) {
return x;
}).sort(compareMonthAsc);
return list.length === 3 && list[1] === target;
};
}
function data$3() {
return {
second: false
};
}
var methods$3 = {
onSelect: function onSelect(date) {
var _get$$1 = this.get(),
isSecond = _get$$1.second,
_prevSelected = _get$$1.selected;
var prevSelected = arrayfy(_prevSelected);
var index = isSecond ? 1 : 0;
var selected = prevSelected.slice(0, index).concat(date).sort(compareMonthAsc);
this.set({
selected: selected,
second: !isSecond
});
this.fire('select', selected);
},
onHover: function onHover(date) {
this.set({
hovered: date
});
this.fire('hover', date);
}
};
var setup$3 = setupHigherCalendar(MonthCalendar);
function create_main_fragment$5(component, state) {
var monthcalendar = new MonthCalendar({
root: component.root,
data: {
currentYear: state.currentYear,
selected: state.selected,
locale: state.locale,
isHighlighted: isHighlighted$1(state.hovered, state.second)
}
});
monthcalendar.on("select", function (event) {
component.onSelect(event);
});
monthcalendar.on("hover", function (event) {
component.onHover(event);
});
return {
c: function create() {
monthcalendar._fragment.c();
},
m: function mount(target, anchor) {
monthcalendar._mount(target, anchor);
},
p: function update(changed, state) {
var monthcalendar_changes = {};
if (changed.currentYear) monthcalendar_changes.currentYear = state.currentYear;
if (changed.selected) monthcalendar_changes.selected = state.selected;
if (changed.locale) monthcalendar_changes.locale = state.locale;
if (changed.hovered || changed.second) monthcalendar_changes.isHighlighted = isHighlighted$1(state.hovered, state.second);
monthcalendar._set(monthcalendar_changes);
},
u: function unmount() {
monthcalendar._unmount();
},
d: function destroy$$1() {
monthcalendar.destroy(false);
}
};
}
function MonthRangeCalendar(options) {
init(this, options);
this._state = assign(data$3(), options.data);
if (!options.root) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment$5(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
this._lock = false;
}
}
assign(MonthRangeCalendar.prototype, methods$3, proto);
setup$3(MonthRangeCalendar);
exports.en = en;

@@ -1217,1 +1763,3 @@ exports.ja = ja;

exports.DateRangeCalendar = DateRangeCalendar;
exports.MonthCalendar = MonthCalendar;
exports.MonthRangeCalendar = MonthRangeCalendar;
/*!
* calendar-set v0.2.4
* calendar-set v0.3.0
* https://github.com/ktsn/calendar-set

@@ -331,2 +331,3 @@ *

var WEEK_DAYS_NUM = 7;
var MONTH_NUM = 12;
var SUNDAY = 0;

@@ -349,3 +350,3 @@ /**

}
function getMonthCalendar(year, month) {
function getDateCalendar(year, month) {
var target = new Date(year, month, 1);

@@ -367,7 +368,13 @@ var offsetOfFirstDate = SUNDAY - getWeekDay(target);

}
function getMonthCalendar(year) {
return range(MONTH_NUM).map(function (month) {
return new Date(year, month);
});
}
function equalsMonth(date, year, month) {
return getYear(date) === year && getMonth(date) === month;
}
function compareMonthAsc(a, b) {
return compareAscSeed(a, b, [getYear, getMonth]);
}
function equalsDate(a, b) {

@@ -377,21 +384,21 @@ return compareDateAsc(a, b) === 0;

function compareDateAsc(a, b) {
function loop(a, b, getters) {
if (getters.length === 0) {
return 0;
}
return compareAscSeed(a, b, [getYear, getMonth, getDate]);
}
var _getters = _toArray(getters),
getter = _getters[0],
tail = _getters.slice(1);
function compareAscSeed(a, b, getters) {
if (getters.length === 0) {
return 0;
}
var res = compareAsc(getter(a), getter(b));
var _getters = _toArray(getters),
getter = _getters[0],
tail = _getters.slice(1);
if (res === 0) {
return loop(a, b, tail);
} else {
return res;
}
var res = compareAsc(getter(a), getter(b));
if (res === 0) {
return compareAscSeed(a, b, tail);
} else {
return res;
}
return loop(a, b, [getYear, getMonth, getDate]);
}

@@ -511,2 +518,140 @@

/* src/CalendarHeader.html generated by Svelte v1.58.0 */
function create_main_fragment$1(component, state) {
var p, text;
var if_block = state.year != null && create_if_block(component, state);
var if_block_1 = state.month != null && create_if_block_1(component, state);
return {
c: function create() {
p = createElement("p");
if (if_block) if_block.c();
text = createText(" ");
if (if_block_1) if_block_1.c();
this.h();
},
h: function hydrate() {
p.className = "calendar-header svelte-itebfq";
},
m: function mount(target, anchor) {
insertNode(p, target, anchor);
if (if_block) if_block.m(p, null);
appendNode(text, p);
if (if_block_1) if_block_1.m(p, null);
},
p: function update(changed, state) {
if (state.year != null) {
if (if_block) {
if_block.p(changed, state);
} else {
if_block = create_if_block(component, state);
if_block.c();
if_block.m(p, text);
}
} else if (if_block) {
if_block.u();
if_block.d();
if_block = null;
}
if (state.month != null) {
if (if_block_1) {
if_block_1.p(changed, state);
} else {
if_block_1 = create_if_block_1(component, state);
if_block_1.c();
if_block_1.m(p, null);
}
} else if (if_block_1) {
if_block_1.u();
if_block_1.d();
if_block_1 = null;
}
},
u: function unmount() {
detachNode(p);
if (if_block) if_block.u();
if (if_block_1) if_block_1.u();
},
d: function destroy$$1() {
if (if_block) if_block.d();
if (if_block_1) if_block_1.d();
}
};
} // (2:2) {{#if year != null }}
function create_if_block(component, state) {
var span,
text_value = format(state.locale.year, state.year),
text;
return {
c: function create() {
span = createElement("span");
text = createText(text_value);
this.h();
},
h: function hydrate() {
span.className = "calendar-year";
},
m: function mount(target, anchor) {
insertNode(span, target, anchor);
appendNode(text, span);
},
p: function update(changed, state) {
if ((changed.locale || changed.year) && text_value !== (text_value = format(state.locale.year, state.year))) {
text.data = text_value;
}
},
u: function unmount() {
detachNode(span);
},
d: noop
};
} // (6:10) {{#if month != null }}
function create_if_block_1(component, state) {
var span,
text_value = format(state.locale.months[state.month]),
text;
return {
c: function create() {
span = createElement("span");
text = createText(text_value);
this.h();
},
h: function hydrate() {
span.className = "calendar-month";
},
m: function mount(target, anchor) {
insertNode(span, target, anchor);
appendNode(text, span);
},
p: function update(changed, state) {
if ((changed.locale || changed.month) && text_value !== (text_value = format(state.locale.months[state.month]))) {
text.data = text_value;
}
},
u: function unmount() {
detachNode(span);
},
d: noop
};
}
function CalendarHeader(options) {
init(this, options);
this._state = assign({}, options.data);
this._fragment = create_main_fragment$1(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
}
}
assign(CalendarHeader.prototype, proto);
/* src/DateCalendar.html generated by Svelte v1.58.0 */

@@ -533,3 +678,3 @@

function calendar(current) {
return getMonthCalendar(current.year, current.month);
return getDateCalendar(current.year, current.month);
}

@@ -571,5 +716,5 @@

function create_main_fragment$1(component, state) {
function create_main_fragment$2(component, state) {
var div;
var if_block = state.locale && create_if_block(component, state);
var if_block = state.locale && create_if_block$1(component, state);
return {

@@ -582,3 +727,3 @@ c: function create() {

h: function hydrate() {
div.className = "calendar svelte-1qlxfod";
div.className = "date-calendar svelte-ji3oj2";
},

@@ -594,3 +739,3 @@ m: function mount(target, anchor) {

} else {
if_block = create_if_block(component, state);
if_block = create_if_block$1(component, state);
if_block.c();

@@ -613,3 +758,3 @@ if_block.m(div, null);

};
} // (15:8) {{#each locale.weekDays as weekDay, i}}
} // (8:8) {{#each locale.weekDays as weekDay, i}}

@@ -633,3 +778,3 @@

th.scope = "col";
th.className = th_class_value = "calendar-cell heading " + weekClass(i);
th.className = th_class_value = "date-calendar-cell heading " + weekClass(i);
},

@@ -654,3 +799,3 @@ m: function mount(target, anchor) {

};
} // (24:6) {{#each calendar as row}}
} // (17:6) {{#each calendar as row}}

@@ -731,3 +876,3 @@

};
} // (26:8) {{#each row as cell, i}}
} // (19:8) {{#each row as cell, i}}

@@ -743,3 +888,3 @@

var td, td_class_value;
var if_block = cell && create_if_block_1(component, state);
var if_block = cell && create_if_block_1$1(component, state);
return {

@@ -752,3 +897,3 @@ c: function create() {

h: function hydrate() {
td.className = td_class_value = "calendar-cell " + weekClass(i);
td.className = td_class_value = "date-calendar-cell " + weekClass(i);
},

@@ -771,3 +916,3 @@ m: function mount(target, anchor) {

} else {
if_block = create_if_block_1(component, state);
if_block = create_if_block_1$1(component, state);
if_block.c();

@@ -790,6 +935,6 @@ if_block.m(td, null);

};
} // (28:10) {{#if cell}}
} // (21:10) {{#if cell}}
function create_if_block_1(component, state) {
function create_if_block_1$1(component, state) {
var row = state.row,

@@ -864,17 +1009,12 @@ each_value_1 = state.each_value_1,

function create_if_block(component, state) {
var p,
span,
text_value = format(state.locale.year, state.current.year),
text,
text_2,
span_1,
text_3_value = format(state.locale.months[state.current.month]),
text_3,
text_6,
table,
thead,
tr,
text_9,
tbody;
function create_if_block$1(component, state) {
var text, table, thead, tr, text_3, tbody;
var calendarheader = new CalendarHeader({
root: component.root,
data: {
locale: state.locale,
year: state.current.year,
month: state.current.month
}
});
var each_value = state.locale.weekDays;

@@ -908,9 +1048,5 @@ var each_blocks = [];

c: function create() {
p = createElement("p");
span = createElement("span");
text = createText(text_value);
text_2 = createText("\n ");
span_1 = createElement("span");
text_3 = createText(text_3_value);
text_6 = createText("\n\n ");
calendarheader._fragment.c();
text = createText("\n\n ");
table = createElement("table");

@@ -924,3 +1060,3 @@ thead = createElement("thead");

text_9 = createText("\n\n ");
text_3 = createText("\n\n ");
tbody = createElement("tbody");

@@ -935,16 +1071,9 @@

h: function hydrate() {
span.className = "calendar-year";
span_1.className = "calendar-month";
p.className = "calendar-header";
addListener(tbody, "mouseleave", mouseleave_handler);
table.className = "calendar-table";
table.className = "date-calendar-table";
},
m: function mount(target, anchor) {
insertNode(p, target, anchor);
appendNode(span, p);
appendNode(text, span);
appendNode(text_2, p);
appendNode(span_1, p);
appendNode(text_3, span_1);
insertNode(text_6, target, anchor);
calendarheader._mount(target, anchor);
insertNode(text, target, anchor);
insertNode(table, target, anchor);

@@ -958,3 +1087,3 @@ appendNode(thead, table);

appendNode(text_9, table);
appendNode(text_3, table);
appendNode(tbody, table);

@@ -967,9 +1096,8 @@

p: function update(changed, state) {
if ((changed.locale || changed.current) && text_value !== (text_value = format(state.locale.year, state.current.year))) {
text.data = text_value;
}
var calendarheader_changes = {};
if (changed.locale) calendarheader_changes.locale = state.locale;
if (changed.current) calendarheader_changes.year = state.current.year;
if (changed.current) calendarheader_changes.month = state.current.month;
if ((changed.locale || changed.current) && text_3_value !== (text_3_value = format(state.locale.months[state.current.month]))) {
text_3.data = text_3_value;
}
calendarheader._set(calendarheader_changes);

@@ -1031,4 +1159,5 @@ var each_value = state.locale.weekDays;

u: function unmount() {
detachNode(p);
detachNode(text_6);
calendarheader._unmount();
detachNode(text);
detachNode(table);

@@ -1045,2 +1174,3 @@

d: function destroy$$1() {
calendarheader.destroy(false);
destroyEach(each_blocks);

@@ -1069,3 +1199,3 @@ destroyEach(each_1_blocks);

this._fragment = create_main_fragment$1(this, this._state);
this._fragment = create_main_fragment$2(this, this._state);

@@ -1137,3 +1267,3 @@ this.root._oncreate.push(_oncreate);

function create_main_fragment$2(component, state) {
function create_main_fragment$3(component, state) {
var datecalendar = new DateCalendar({

@@ -1189,3 +1319,3 @@ root: component.root,

this._fragment = create_main_fragment$2(this, this._state);
this._fragment = create_main_fragment$3(this, this._state);

@@ -1208,2 +1338,418 @@ if (options.target) {

export { en, ja, DateCalendar, DateRangeCalendar };
/* src/MonthCalendar.html generated by Svelte v1.58.0 */
function isSelected$1(month, selected) {
return arrayfy(selected).reduce(function (acc, s) {
return acc || equalsMonth(month, s.getFullYear(), s.getMonth());
}, false);
}
function calendar$1(currentYear) {
return getMonthCalendar(currentYear);
}
function data$2() {
var today = new Date();
return {
currentYear: today.getFullYear(),
isHighlighted: no
};
}
var methods$2 = {
onClickCell: function onClickCell(month) {
if (!month) return;
this.fire('select', month);
},
onHoverCell: function onHoverCell(month) {
this.fire('hover', month);
},
onHoverOut: function onHoverOut() {
this.fire('hover', null);
}
};
function oncreate$1() {
var _get = this.get(),
locale = _get.locale;
if (!locale) {
this.set({
locale: this.constructor.locale
});
}
}
var setup$2 = setupCalendar;
function create_main_fragment$4(component, state) {
var div;
var if_block = state.locale && create_if_block$2(component, state);
return {
c: function create() {
div = createElement("div");
if (if_block) if_block.c();
this.h();
},
h: function hydrate() {
div.className = "month-calendar svelte-66r1f2";
},
m: function mount(target, anchor) {
insertNode(div, target, anchor);
if (if_block) if_block.m(div, null);
},
p: function update(changed, state) {
if (state.locale) {
if (if_block) {
if_block.p(changed, state);
} else {
if_block = create_if_block$2(component, state);
if_block.c();
if_block.m(div, null);
}
} else if (if_block) {
if_block.u();
if_block.d();
if_block = null;
}
},
u: function unmount() {
detachNode(div);
if (if_block) if_block.u();
},
d: function destroy$$1() {
if (if_block) if_block.d();
}
};
} // (6:4) {{#each calendar as month }}
function create_each_block$1(component, state) {
var month_1 = state.month,
each_value = state.each_value,
month_index = state.month_index;
var li,
text,
text_1_value = format(state.locale.months[month_1.getMonth()]),
text_1,
text_2;
var cellbutton = new CellButton({
root: component.root,
slots: {
default: createFragment()
},
data: {
selected: isSelected$1(month_1, state.selected),
highlighted: state.isHighlighted(month_1, state.selected)
}
});
cellbutton.on("mouseenter", function (event) {
component.onHoverCell(month_1);
});
cellbutton.on("click", function (event) {
component.onClickCell(month_1);
});
return {
c: function create() {
li = createElement("li");
text = createText("\n ");
text_1 = createText(text_1_value);
text_2 = createText("\n ");
cellbutton._fragment.c();
this.h();
},
h: function hydrate() {
li.className = "month-calendar-item";
},
m: function mount(target, anchor) {
insertNode(li, target, anchor);
appendNode(text, cellbutton._slotted.default);
appendNode(text_1, cellbutton._slotted.default);
appendNode(text_2, cellbutton._slotted.default);
cellbutton._mount(li, null);
},
p: function update(changed, state) {
month_1 = state.month;
each_value = state.each_value;
month_index = state.month_index;
if ((changed.locale || changed.calendar) && text_1_value !== (text_1_value = format(state.locale.months[month_1.getMonth()]))) {
text_1.data = text_1_value;
}
var cellbutton_changes = {};
if (changed.calendar || changed.selected) cellbutton_changes.selected = isSelected$1(month_1, state.selected);
if (changed.isHighlighted || changed.calendar || changed.selected) cellbutton_changes.highlighted = state.isHighlighted(month_1, state.selected);
cellbutton._set(cellbutton_changes);
},
u: function unmount() {
detachNode(li);
},
d: function destroy$$1() {
cellbutton.destroy(false);
}
};
} // (2:2) {{#if locale }}
function create_if_block$2(component, state) {
var text, ul;
var calendarheader = new CalendarHeader({
root: component.root,
data: {
locale: state.locale,
year: state.currentYear
}
});
var each_value = state.calendar;
var each_blocks = [];
for (var i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$1(component, assign({}, state, {
each_value: each_value,
month: each_value[i],
month_index: i
}));
}
function mouseleave_handler(event) {
component.onHoverOut();
}
return {
c: function create() {
calendarheader._fragment.c();
text = createText("\n\n ");
ul = createElement("ul");
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
this.h();
},
h: function hydrate() {
ul.className = "month-calendar-list";
addListener(ul, "mouseleave", mouseleave_handler);
},
m: function mount(target, anchor) {
calendarheader._mount(target, anchor);
insertNode(text, target, anchor);
insertNode(ul, target, anchor);
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(ul, null);
}
},
p: function update(changed, state) {
var calendarheader_changes = {};
if (changed.locale) calendarheader_changes.locale = state.locale;
if (changed.currentYear) calendarheader_changes.year = state.currentYear;
calendarheader._set(calendarheader_changes);
var each_value = state.calendar;
if (changed.calendar || changed.selected || changed.isHighlighted || changed.locale) {
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign({}, state, {
each_value: each_value,
month: each_value[i],
month_index: i
});
if (each_blocks[i]) {
each_blocks[i].p(changed, each_context);
} else {
each_blocks[i] = create_each_block$1(component, each_context);
each_blocks[i].c();
each_blocks[i].m(ul, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].u();
each_blocks[i].d();
}
each_blocks.length = each_value.length;
}
},
u: function unmount() {
calendarheader._unmount();
detachNode(text);
detachNode(ul);
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].u();
}
},
d: function destroy$$1() {
calendarheader.destroy(false);
destroyEach(each_blocks);
removeListener(ul, "mouseleave", mouseleave_handler);
}
};
}
function MonthCalendar(options) {
init(this, options);
this._state = assign(data$2(), options.data);
this._recompute({
currentYear: 1
}, this._state);
var _oncreate = oncreate$1.bind(this);
if (!options.root) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment$4(this, this._state);
this.root._oncreate.push(_oncreate);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
this._lock = false;
}
}
assign(MonthCalendar.prototype, methods$2, proto);
MonthCalendar.prototype._recompute = function _recompute(changed, state) {
if (changed.currentYear) {
if (this._differs(state.calendar, state.calendar = calendar$1(state.currentYear))) changed.calendar = true;
}
};
setup$2(MonthCalendar);
function isHighlighted$1(hovered, isSecond) {
return function (target, selected) {
var _arrayfy = arrayfy(selected),
_arrayfy2 = _slicedToArray(_arrayfy, 2),
first = _arrayfy2[0],
second = _arrayfy2[1];
var list = [first, target, isSecond ? hovered : second].filter(function (x) {
return x;
}).sort(compareMonthAsc);
return list.length === 3 && list[1] === target;
};
}
function data$3() {
return {
second: false
};
}
var methods$3 = {
onSelect: function onSelect(date) {
var _get$$1 = this.get(),
isSecond = _get$$1.second,
_prevSelected = _get$$1.selected;
var prevSelected = arrayfy(_prevSelected);
var index = isSecond ? 1 : 0;
var selected = prevSelected.slice(0, index).concat(date).sort(compareMonthAsc);
this.set({
selected: selected,
second: !isSecond
});
this.fire('select', selected);
},
onHover: function onHover(date) {
this.set({
hovered: date
});
this.fire('hover', date);
}
};
var setup$3 = setupHigherCalendar(MonthCalendar);
function create_main_fragment$5(component, state) {
var monthcalendar = new MonthCalendar({
root: component.root,
data: {
currentYear: state.currentYear,
selected: state.selected,
locale: state.locale,
isHighlighted: isHighlighted$1(state.hovered, state.second)
}
});
monthcalendar.on("select", function (event) {
component.onSelect(event);
});
monthcalendar.on("hover", function (event) {
component.onHover(event);
});
return {
c: function create() {
monthcalendar._fragment.c();
},
m: function mount(target, anchor) {
monthcalendar._mount(target, anchor);
},
p: function update(changed, state) {
var monthcalendar_changes = {};
if (changed.currentYear) monthcalendar_changes.currentYear = state.currentYear;
if (changed.selected) monthcalendar_changes.selected = state.selected;
if (changed.locale) monthcalendar_changes.locale = state.locale;
if (changed.hovered || changed.second) monthcalendar_changes.isHighlighted = isHighlighted$1(state.hovered, state.second);
monthcalendar._set(monthcalendar_changes);
},
u: function unmount() {
monthcalendar._unmount();
},
d: function destroy$$1() {
monthcalendar.destroy(false);
}
};
}
function MonthRangeCalendar(options) {
init(this, options);
this._state = assign(data$3(), options.data);
if (!options.root) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment$5(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
this._lock = false;
}
}
assign(MonthRangeCalendar.prototype, methods$3, proto);
setup$3(MonthRangeCalendar);
export { en, ja, DateCalendar, DateRangeCalendar, MonthCalendar, MonthRangeCalendar };
/*!
* calendar-set v0.2.4
* calendar-set v0.3.0
* https://github.com/ktsn/calendar-set

@@ -337,2 +337,3 @@ *

var WEEK_DAYS_NUM = 7;
var MONTH_NUM = 12;
var SUNDAY = 0;

@@ -355,3 +356,3 @@ /**

}
function getMonthCalendar(year, month) {
function getDateCalendar(year, month) {
var target = new Date(year, month, 1);

@@ -373,7 +374,13 @@ var offsetOfFirstDate = SUNDAY - getWeekDay(target);

}
function getMonthCalendar(year) {
return range(MONTH_NUM).map(function (month) {
return new Date(year, month);
});
}
function equalsMonth(date, year, month) {
return getYear(date) === year && getMonth(date) === month;
}
function compareMonthAsc(a, b) {
return compareAscSeed(a, b, [getYear, getMonth]);
}
function equalsDate(a, b) {

@@ -383,21 +390,21 @@ return compareDateAsc(a, b) === 0;

function compareDateAsc(a, b) {
function loop(a, b, getters) {
if (getters.length === 0) {
return 0;
}
return compareAscSeed(a, b, [getYear, getMonth, getDate]);
}
var _getters = _toArray(getters),
getter = _getters[0],
tail = _getters.slice(1);
function compareAscSeed(a, b, getters) {
if (getters.length === 0) {
return 0;
}
var res = compareAsc(getter(a), getter(b));
var _getters = _toArray(getters),
getter = _getters[0],
tail = _getters.slice(1);
if (res === 0) {
return loop(a, b, tail);
} else {
return res;
}
var res = compareAsc(getter(a), getter(b));
if (res === 0) {
return compareAscSeed(a, b, tail);
} else {
return res;
}
return loop(a, b, [getYear, getMonth, getDate]);
}

@@ -517,2 +524,140 @@

/* src/CalendarHeader.html generated by Svelte v1.58.0 */
function create_main_fragment$1(component, state) {
var p, text;
var if_block = state.year != null && create_if_block(component, state);
var if_block_1 = state.month != null && create_if_block_1(component, state);
return {
c: function create() {
p = createElement("p");
if (if_block) if_block.c();
text = createText(" ");
if (if_block_1) if_block_1.c();
this.h();
},
h: function hydrate() {
p.className = "calendar-header svelte-itebfq";
},
m: function mount(target, anchor) {
insertNode(p, target, anchor);
if (if_block) if_block.m(p, null);
appendNode(text, p);
if (if_block_1) if_block_1.m(p, null);
},
p: function update(changed, state) {
if (state.year != null) {
if (if_block) {
if_block.p(changed, state);
} else {
if_block = create_if_block(component, state);
if_block.c();
if_block.m(p, text);
}
} else if (if_block) {
if_block.u();
if_block.d();
if_block = null;
}
if (state.month != null) {
if (if_block_1) {
if_block_1.p(changed, state);
} else {
if_block_1 = create_if_block_1(component, state);
if_block_1.c();
if_block_1.m(p, null);
}
} else if (if_block_1) {
if_block_1.u();
if_block_1.d();
if_block_1 = null;
}
},
u: function unmount() {
detachNode(p);
if (if_block) if_block.u();
if (if_block_1) if_block_1.u();
},
d: function destroy$$1() {
if (if_block) if_block.d();
if (if_block_1) if_block_1.d();
}
};
} // (2:2) {{#if year != null }}
function create_if_block(component, state) {
var span,
text_value = format(state.locale.year, state.year),
text;
return {
c: function create() {
span = createElement("span");
text = createText(text_value);
this.h();
},
h: function hydrate() {
span.className = "calendar-year";
},
m: function mount(target, anchor) {
insertNode(span, target, anchor);
appendNode(text, span);
},
p: function update(changed, state) {
if ((changed.locale || changed.year) && text_value !== (text_value = format(state.locale.year, state.year))) {
text.data = text_value;
}
},
u: function unmount() {
detachNode(span);
},
d: noop
};
} // (6:10) {{#if month != null }}
function create_if_block_1(component, state) {
var span,
text_value = format(state.locale.months[state.month]),
text;
return {
c: function create() {
span = createElement("span");
text = createText(text_value);
this.h();
},
h: function hydrate() {
span.className = "calendar-month";
},
m: function mount(target, anchor) {
insertNode(span, target, anchor);
appendNode(text, span);
},
p: function update(changed, state) {
if ((changed.locale || changed.month) && text_value !== (text_value = format(state.locale.months[state.month]))) {
text.data = text_value;
}
},
u: function unmount() {
detachNode(span);
},
d: noop
};
}
function CalendarHeader(options) {
init(this, options);
this._state = assign({}, options.data);
this._fragment = create_main_fragment$1(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
}
}
assign(CalendarHeader.prototype, proto);
/* src/DateCalendar.html generated by Svelte v1.58.0 */

@@ -539,3 +684,3 @@

function calendar(current) {
return getMonthCalendar(current.year, current.month);
return getDateCalendar(current.year, current.month);
}

@@ -577,5 +722,5 @@

function create_main_fragment$1(component, state) {
function create_main_fragment$2(component, state) {
var div;
var if_block = state.locale && create_if_block(component, state);
var if_block = state.locale && create_if_block$1(component, state);
return {

@@ -588,3 +733,3 @@ c: function create() {

h: function hydrate() {
div.className = "calendar svelte-1qlxfod";
div.className = "date-calendar svelte-ji3oj2";
},

@@ -600,3 +745,3 @@ m: function mount(target, anchor) {

} else {
if_block = create_if_block(component, state);
if_block = create_if_block$1(component, state);
if_block.c();

@@ -619,3 +764,3 @@ if_block.m(div, null);

};
} // (15:8) {{#each locale.weekDays as weekDay, i}}
} // (8:8) {{#each locale.weekDays as weekDay, i}}

@@ -639,3 +784,3 @@

th.scope = "col";
th.className = th_class_value = "calendar-cell heading " + weekClass(i);
th.className = th_class_value = "date-calendar-cell heading " + weekClass(i);
},

@@ -660,3 +805,3 @@ m: function mount(target, anchor) {

};
} // (24:6) {{#each calendar as row}}
} // (17:6) {{#each calendar as row}}

@@ -737,3 +882,3 @@

};
} // (26:8) {{#each row as cell, i}}
} // (19:8) {{#each row as cell, i}}

@@ -749,3 +894,3 @@

var td, td_class_value;
var if_block = cell && create_if_block_1(component, state);
var if_block = cell && create_if_block_1$1(component, state);
return {

@@ -758,3 +903,3 @@ c: function create() {

h: function hydrate() {
td.className = td_class_value = "calendar-cell " + weekClass(i);
td.className = td_class_value = "date-calendar-cell " + weekClass(i);
},

@@ -777,3 +922,3 @@ m: function mount(target, anchor) {

} else {
if_block = create_if_block_1(component, state);
if_block = create_if_block_1$1(component, state);
if_block.c();

@@ -796,6 +941,6 @@ if_block.m(td, null);

};
} // (28:10) {{#if cell}}
} // (21:10) {{#if cell}}
function create_if_block_1(component, state) {
function create_if_block_1$1(component, state) {
var row = state.row,

@@ -870,17 +1015,12 @@ each_value_1 = state.each_value_1,

function create_if_block(component, state) {
var p,
span,
text_value = format(state.locale.year, state.current.year),
text,
text_2,
span_1,
text_3_value = format(state.locale.months[state.current.month]),
text_3,
text_6,
table,
thead,
tr,
text_9,
tbody;
function create_if_block$1(component, state) {
var text, table, thead, tr, text_3, tbody;
var calendarheader = new CalendarHeader({
root: component.root,
data: {
locale: state.locale,
year: state.current.year,
month: state.current.month
}
});
var each_value = state.locale.weekDays;

@@ -914,9 +1054,5 @@ var each_blocks = [];

c: function create() {
p = createElement("p");
span = createElement("span");
text = createText(text_value);
text_2 = createText("\n ");
span_1 = createElement("span");
text_3 = createText(text_3_value);
text_6 = createText("\n\n ");
calendarheader._fragment.c();
text = createText("\n\n ");
table = createElement("table");

@@ -930,3 +1066,3 @@ thead = createElement("thead");

text_9 = createText("\n\n ");
text_3 = createText("\n\n ");
tbody = createElement("tbody");

@@ -941,16 +1077,9 @@

h: function hydrate() {
span.className = "calendar-year";
span_1.className = "calendar-month";
p.className = "calendar-header";
addListener(tbody, "mouseleave", mouseleave_handler);
table.className = "calendar-table";
table.className = "date-calendar-table";
},
m: function mount(target, anchor) {
insertNode(p, target, anchor);
appendNode(span, p);
appendNode(text, span);
appendNode(text_2, p);
appendNode(span_1, p);
appendNode(text_3, span_1);
insertNode(text_6, target, anchor);
calendarheader._mount(target, anchor);
insertNode(text, target, anchor);
insertNode(table, target, anchor);

@@ -964,3 +1093,3 @@ appendNode(thead, table);

appendNode(text_9, table);
appendNode(text_3, table);
appendNode(tbody, table);

@@ -973,9 +1102,8 @@

p: function update(changed, state) {
if ((changed.locale || changed.current) && text_value !== (text_value = format(state.locale.year, state.current.year))) {
text.data = text_value;
}
var calendarheader_changes = {};
if (changed.locale) calendarheader_changes.locale = state.locale;
if (changed.current) calendarheader_changes.year = state.current.year;
if (changed.current) calendarheader_changes.month = state.current.month;
if ((changed.locale || changed.current) && text_3_value !== (text_3_value = format(state.locale.months[state.current.month]))) {
text_3.data = text_3_value;
}
calendarheader._set(calendarheader_changes);

@@ -1037,4 +1165,5 @@ var each_value = state.locale.weekDays;

u: function unmount() {
detachNode(p);
detachNode(text_6);
calendarheader._unmount();
detachNode(text);
detachNode(table);

@@ -1051,2 +1180,3 @@

d: function destroy$$1() {
calendarheader.destroy(false);
destroyEach(each_blocks);

@@ -1075,3 +1205,3 @@ destroyEach(each_1_blocks);

this._fragment = create_main_fragment$1(this, this._state);
this._fragment = create_main_fragment$2(this, this._state);

@@ -1143,3 +1273,3 @@ this.root._oncreate.push(_oncreate);

function create_main_fragment$2(component, state) {
function create_main_fragment$3(component, state) {
var datecalendar = new DateCalendar({

@@ -1195,3 +1325,3 @@ root: component.root,

this._fragment = create_main_fragment$2(this, this._state);
this._fragment = create_main_fragment$3(this, this._state);

@@ -1214,2 +1344,418 @@ if (options.target) {

/* src/MonthCalendar.html generated by Svelte v1.58.0 */
function isSelected$1(month, selected) {
return arrayfy(selected).reduce(function (acc, s) {
return acc || equalsMonth(month, s.getFullYear(), s.getMonth());
}, false);
}
function calendar$1(currentYear) {
return getMonthCalendar(currentYear);
}
function data$2() {
var today = new Date();
return {
currentYear: today.getFullYear(),
isHighlighted: no
};
}
var methods$2 = {
onClickCell: function onClickCell(month) {
if (!month) return;
this.fire('select', month);
},
onHoverCell: function onHoverCell(month) {
this.fire('hover', month);
},
onHoverOut: function onHoverOut() {
this.fire('hover', null);
}
};
function oncreate$1() {
var _get = this.get(),
locale = _get.locale;
if (!locale) {
this.set({
locale: this.constructor.locale
});
}
}
var setup$2 = setupCalendar;
function create_main_fragment$4(component, state) {
var div;
var if_block = state.locale && create_if_block$2(component, state);
return {
c: function create() {
div = createElement("div");
if (if_block) if_block.c();
this.h();
},
h: function hydrate() {
div.className = "month-calendar svelte-66r1f2";
},
m: function mount(target, anchor) {
insertNode(div, target, anchor);
if (if_block) if_block.m(div, null);
},
p: function update(changed, state) {
if (state.locale) {
if (if_block) {
if_block.p(changed, state);
} else {
if_block = create_if_block$2(component, state);
if_block.c();
if_block.m(div, null);
}
} else if (if_block) {
if_block.u();
if_block.d();
if_block = null;
}
},
u: function unmount() {
detachNode(div);
if (if_block) if_block.u();
},
d: function destroy$$1() {
if (if_block) if_block.d();
}
};
} // (6:4) {{#each calendar as month }}
function create_each_block$1(component, state) {
var month_1 = state.month,
each_value = state.each_value,
month_index = state.month_index;
var li,
text,
text_1_value = format(state.locale.months[month_1.getMonth()]),
text_1,
text_2;
var cellbutton = new CellButton({
root: component.root,
slots: {
default: createFragment()
},
data: {
selected: isSelected$1(month_1, state.selected),
highlighted: state.isHighlighted(month_1, state.selected)
}
});
cellbutton.on("mouseenter", function (event) {
component.onHoverCell(month_1);
});
cellbutton.on("click", function (event) {
component.onClickCell(month_1);
});
return {
c: function create() {
li = createElement("li");
text = createText("\n ");
text_1 = createText(text_1_value);
text_2 = createText("\n ");
cellbutton._fragment.c();
this.h();
},
h: function hydrate() {
li.className = "month-calendar-item";
},
m: function mount(target, anchor) {
insertNode(li, target, anchor);
appendNode(text, cellbutton._slotted.default);
appendNode(text_1, cellbutton._slotted.default);
appendNode(text_2, cellbutton._slotted.default);
cellbutton._mount(li, null);
},
p: function update(changed, state) {
month_1 = state.month;
each_value = state.each_value;
month_index = state.month_index;
if ((changed.locale || changed.calendar) && text_1_value !== (text_1_value = format(state.locale.months[month_1.getMonth()]))) {
text_1.data = text_1_value;
}
var cellbutton_changes = {};
if (changed.calendar || changed.selected) cellbutton_changes.selected = isSelected$1(month_1, state.selected);
if (changed.isHighlighted || changed.calendar || changed.selected) cellbutton_changes.highlighted = state.isHighlighted(month_1, state.selected);
cellbutton._set(cellbutton_changes);
},
u: function unmount() {
detachNode(li);
},
d: function destroy$$1() {
cellbutton.destroy(false);
}
};
} // (2:2) {{#if locale }}
function create_if_block$2(component, state) {
var text, ul;
var calendarheader = new CalendarHeader({
root: component.root,
data: {
locale: state.locale,
year: state.currentYear
}
});
var each_value = state.calendar;
var each_blocks = [];
for (var i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block$1(component, assign({}, state, {
each_value: each_value,
month: each_value[i],
month_index: i
}));
}
function mouseleave_handler(event) {
component.onHoverOut();
}
return {
c: function create() {
calendarheader._fragment.c();
text = createText("\n\n ");
ul = createElement("ul");
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
this.h();
},
h: function hydrate() {
ul.className = "month-calendar-list";
addListener(ul, "mouseleave", mouseleave_handler);
},
m: function mount(target, anchor) {
calendarheader._mount(target, anchor);
insertNode(text, target, anchor);
insertNode(ul, target, anchor);
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(ul, null);
}
},
p: function update(changed, state) {
var calendarheader_changes = {};
if (changed.locale) calendarheader_changes.locale = state.locale;
if (changed.currentYear) calendarheader_changes.year = state.currentYear;
calendarheader._set(calendarheader_changes);
var each_value = state.calendar;
if (changed.calendar || changed.selected || changed.isHighlighted || changed.locale) {
for (var i = 0; i < each_value.length; i += 1) {
var each_context = assign({}, state, {
each_value: each_value,
month: each_value[i],
month_index: i
});
if (each_blocks[i]) {
each_blocks[i].p(changed, each_context);
} else {
each_blocks[i] = create_each_block$1(component, each_context);
each_blocks[i].c();
each_blocks[i].m(ul, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].u();
each_blocks[i].d();
}
each_blocks.length = each_value.length;
}
},
u: function unmount() {
calendarheader._unmount();
detachNode(text);
detachNode(ul);
for (var i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].u();
}
},
d: function destroy$$1() {
calendarheader.destroy(false);
destroyEach(each_blocks);
removeListener(ul, "mouseleave", mouseleave_handler);
}
};
}
function MonthCalendar(options) {
init(this, options);
this._state = assign(data$2(), options.data);
this._recompute({
currentYear: 1
}, this._state);
var _oncreate = oncreate$1.bind(this);
if (!options.root) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment$4(this, this._state);
this.root._oncreate.push(_oncreate);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
this._lock = false;
}
}
assign(MonthCalendar.prototype, methods$2, proto);
MonthCalendar.prototype._recompute = function _recompute(changed, state) {
if (changed.currentYear) {
if (this._differs(state.calendar, state.calendar = calendar$1(state.currentYear))) changed.calendar = true;
}
};
setup$2(MonthCalendar);
function isHighlighted$1(hovered, isSecond) {
return function (target, selected) {
var _arrayfy = arrayfy(selected),
_arrayfy2 = _slicedToArray(_arrayfy, 2),
first = _arrayfy2[0],
second = _arrayfy2[1];
var list = [first, target, isSecond ? hovered : second].filter(function (x) {
return x;
}).sort(compareMonthAsc);
return list.length === 3 && list[1] === target;
};
}
function data$3() {
return {
second: false
};
}
var methods$3 = {
onSelect: function onSelect(date) {
var _get$$1 = this.get(),
isSecond = _get$$1.second,
_prevSelected = _get$$1.selected;
var prevSelected = arrayfy(_prevSelected);
var index = isSecond ? 1 : 0;
var selected = prevSelected.slice(0, index).concat(date).sort(compareMonthAsc);
this.set({
selected: selected,
second: !isSecond
});
this.fire('select', selected);
},
onHover: function onHover(date) {
this.set({
hovered: date
});
this.fire('hover', date);
}
};
var setup$3 = setupHigherCalendar(MonthCalendar);
function create_main_fragment$5(component, state) {
var monthcalendar = new MonthCalendar({
root: component.root,
data: {
currentYear: state.currentYear,
selected: state.selected,
locale: state.locale,
isHighlighted: isHighlighted$1(state.hovered, state.second)
}
});
monthcalendar.on("select", function (event) {
component.onSelect(event);
});
monthcalendar.on("hover", function (event) {
component.onHover(event);
});
return {
c: function create() {
monthcalendar._fragment.c();
},
m: function mount(target, anchor) {
monthcalendar._mount(target, anchor);
},
p: function update(changed, state) {
var monthcalendar_changes = {};
if (changed.currentYear) monthcalendar_changes.currentYear = state.currentYear;
if (changed.selected) monthcalendar_changes.selected = state.selected;
if (changed.locale) monthcalendar_changes.locale = state.locale;
if (changed.hovered || changed.second) monthcalendar_changes.isHighlighted = isHighlighted$1(state.hovered, state.second);
monthcalendar._set(monthcalendar_changes);
},
u: function unmount() {
monthcalendar._unmount();
},
d: function destroy$$1() {
monthcalendar.destroy(false);
}
};
}
function MonthRangeCalendar(options) {
init(this, options);
this._state = assign(data$3(), options.data);
if (!options.root) {
this._oncreate = [];
this._beforecreate = [];
this._aftercreate = [];
}
this._fragment = create_main_fragment$5(this, this._state);
if (options.target) {
this._fragment.c();
this._mount(options.target, options.anchor);
this._lock = true;
callAll(this._beforecreate);
callAll(this._oncreate);
callAll(this._aftercreate);
this._lock = false;
}
}
assign(MonthRangeCalendar.prototype, methods$3, proto);
setup$3(MonthRangeCalendar);
exports.en = en;

@@ -1219,2 +1765,4 @@ exports.ja = ja;

exports.DateRangeCalendar = DateRangeCalendar;
exports.MonthCalendar = MonthCalendar;
exports.MonthRangeCalendar = MonthRangeCalendar;

@@ -1221,0 +1769,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

4

dist/calendar-set.min.js
/*!
* calendar-set v0.2.4
* calendar-set v0.3.0
* 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 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.type="button",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})});
!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 c(t){t.parentNode.removeChild(t)}function i(t){for(var e=0;e<t.length;e+=1)t[e]&&t[e].d()}function a(){return document.createDocumentFragment()}function l(t){return document.createElement(t)}function u(t){return document.createTextNode(t)}function s(t,e,n){t.addEventListener(e,n,!1)}function h(t,e,n){t.removeEventListener(e,n,!1)}function f(){return Object.create(null)}function d(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 _(t,e,n,r,o){for(var c in e)if(n[c]){var i=r[c],a=o[c],l=e[c];if(l)for(var u=0;u<l.length;u+=1){var s=l[u];s.__calling||(s.__calling=!0,s.call(t,i,a),s.__calling=!1)}}}function g(t,e){t._observers={pre:f(),post:f()},t._handlers=f(),t._bind=e._bind,t.options=e,t.root=e.root||t,t.store=t.root.store||e.store}function m(t){for(;t&&t.length;)t.shift()()}var v={destroy:d,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,m(this.root._beforecreate),m(this.root._oncreate),m(this.root._aftercreate),this.root._lock=!1)},teardown:d,_recompute:e,_set:function(t){var e=this._state,r={},o=!1;for(var c in t)this._differs(t[c],e[c])&&(r[c]=o=!0);o&&(this._state=n({},e,t),this._recompute(r,this._state),this._bind&&this._bind(r,this._state),this._fragment&&(_(this,this._observers.pre,r,this._state,e),this._fragment.p(r,this._state),_(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 p(){return!1}function y(t){return Array.apply(null,Array(t)).map(function(t,e){return e})}function w(t){return null==t?[]:Array.isArray(t)?t:[t]}function b(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 k(t,e){return C(t)||function(t,e){var n=[],r=!0,o=!1,c=void 0;try{for(var i,a=t[Symbol.iterator]();!(r=(i=a.next()).done)&&(n.push(i.value),!e||n.length!==e);r=!0);}catch(t){o=!0,c=t}finally{try{r||null==a.return||a.return()}finally{if(o)throw c}}return n}(t,e)||D()}function H(t){return C(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||D()}function C(t){if(Array.isArray(t))return t}function D(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var x=7,N=12,Y=0;function j(t){t.setLocale=function(e){t.locale=e}}function A(t){return function(e){e.setLocale=function(e){t.setLocale(e)}}}function M(t,e,n){return L(t)===e&&E(t)===n}function O(t,e){return F(t,e,[L,E])}function S(t,e){return F(t,e,[L,E,T])}function F(t,e,n){if(0===n.length)return 0;var r=H(n),o=r[0],c=r.slice(1),i=function(t,e){return t<e?-1:t>e?1:0}(o(t),o(e));return 0===i?F(t,e,c):i}function L(t){return t.getFullYear()}function E(t){return t.getMonth()}function T(t){return t.getDate()}function J(t,e){var n=[];return t&&n.push("selected"),e&&n.push("highlighted"),n.join(" ")}function W(t){g(this,t),this._state=n({},t.data),this._slotted=t.slots||{},this.slots={},this._fragment=function(t,e){var n,i,a=t._slotted.default;function u(e){t.fire("click",e)}function f(e){t.fire("mouseenter",e)}return{c:function(){n=l("button"),this.h()},h:function(){n.type="button",n.className=i="calendar-cell-button "+J(e.selected,e.highlighted)+" svelte-acia7y",s(n,"click",u),s(n,"mouseenter",f)},m:function(t,e){o(n,t,e),a&&r(a,n)},p:function(t,e){(t.selected||t.highlighted)&&i!==(i="calendar-cell-button "+J(e.selected,e.highlighted)+" svelte-acia7y")&&(n.className=i)},u:function(){c(n),a&&function(t,e){for(;t.firstChild;)e.appendChild(t.firstChild)}(n,a)},d:function(){h(n,"click",u),h(n,"mouseenter",f)}}}(this,this._state),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor))}function R(t,n){var i,a,s=b(n.locale.year,n.year);return{c:function(){i=l("span"),a=u(s),this.h()},h:function(){i.className="calendar-year"},m:function(t,e){o(i,t,e),r(a,i)},p:function(t,e){(t.locale||t.year)&&s!==(s=b(e.locale.year,e.year))&&(a.data=s)},u:function(){c(i)},d:e}}function q(t,n){var i,a,s=b(n.locale.months[n.month]);return{c:function(){i=l("span"),a=u(s),this.h()},h:function(){i.className="calendar-month"},m:function(t,e){o(i,t,e),r(a,i)},p:function(t,e){(t.locale||t.month)&&s!==(s=b(e.locale.months[e.month]))&&(a.data=s)},u:function(){c(i)},d:e}}function B(t){var e,i,a,s,h;g(this,t),this._state=n({},t.data),this._fragment=(e=this._state,s=null!=e.year&&R(0,e),h=null!=e.month&&q(0,e),{c:function(){i=l("p"),s&&s.c(),a=u(" "),h&&h.c(),this.h()},h:function(){i.className="calendar-header svelte-itebfq"},m:function(t,e){o(i,t,e),s&&s.m(i,null),r(a,i),h&&h.m(i,null)},p:function(t,e){null!=e.year?s?s.p(t,e):((s=R(0,e)).c(),s.m(i,a)):s&&(s.u(),s.d(),s=null),null!=e.month?h?h.p(t,e):((h=q(0,e)).c(),h.m(i,null)):h&&(h.u(),h.d(),h=null)},u:function(){c(i),s&&s.u(),h&&h.u()},d:function(){s&&s.d(),h&&h.d()}}),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor))}function I(t,e){return w(e).reduce(function(e,n){return e||0===S(t,n)},!1)}function P(t){return 0===t?"sunday":6===t?"saturday":""}function z(t){return e=t.year,n=t.month,r=new Date(e,n,1),o=Y-r.getDay(),function(t,e){for(var n,r=[],o=0;e(n,o);)n=t(n,o),r.push(n),o++;return r}(function(t,r){var c=x*r;return y(x).map(function(t){var r=new Date(e,n,o+c+t+1);return M(r,e,n)?r:void 0})},function(t){if(!t)return!0;var r=t[x-1];return!!r&&M(new Date(L(r),E(r),T(r)+1),e,n)});var e,n,r,o}n(W.prototype,v),n(B.prototype,v);var G=j;function K(t,n){var i,a,s=n.weekDay,h=(n.each_value,n.i),f=b(s);return{c:function(){i=l("th"),a=u(f),this.h()},h:function(){i.scope="col",i.className="date-calendar-cell heading "+P(h)},m:function(t,e){o(i,t,e),r(a,i)},p:function(t,e){s=e.weekDay,e.each_value,h=e.i,t.locale&&f!==(f=b(s))&&(a.data=f)},u:function(){c(i)},d:e}}function Q(t,e){for(var r,a=e.row,u=(e.each_value_1,e.row_index,a),s=[],h=0;h<u.length;h+=1)s[h]=U(t,n({},e,{each_value_2:u,cell:u[h],i:h}));return{c:function(){r=l("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){a=o.row,o.each_value_1,o.row_index;var c=a;if(e.calendar||e.selected||e.isHighlighted){for(var i=0;i<c.length;i+=1){var l=n({},o,{each_value_2:c,cell:c[i],i:i});s[i]?s[i].p(e,l):(s[i]=U(t,l),s[i].c(),s[i].m(r,null))}for(;i<s.length;i+=1)s[i].u(),s[i].d();s.length=c.length}},u:function(){c(r);for(var t=0;t<s.length;t+=1)s[t].u()},d:function(){i(s)}}}function U(t,e){e.row,e.each_value_1,e.row_index;var n,r=e.cell,i=(e.each_value_2,e.i),a=r&&V(t,e);return{c:function(){n=l("td"),a&&a.c(),this.h()},h:function(){n.className="date-calendar-cell "+P(i)},m:function(t,e){o(n,t,e),a&&a.m(n,null)},p:function(e,o){o.row,o.each_value_1,o.row_index,r=o.cell,o.each_value_2,i=o.i,r?a?a.p(e,o):((a=V(t,o)).c(),a.m(n,null)):a&&(a.u(),a.d(),a=null)},u:function(){c(n),a&&a.u()},d:function(){a&&a.d()}}}function V(t,e){e.row,e.each_value_1,e.row_index;var n,o,c,i=e.cell,l=(e.each_value_2,e.i,i.getDate()),s=new W({root:t.root,slots:{default:a()},data:{selected:I(i,e.selected),highlighted:e.isHighlighted(i,e.selected)}});return s.on("click",function(e){t.onClickCell(i)}),s.on("mouseenter",function(e){t.onHoverCell(i)}),{c:function(){n=u("\n "),o=u(l),c=u("\n "),s._fragment.c()},m:function(t,e){r(n,s._slotted.default),r(o,s._slotted.default),r(c,s._slotted.default),s._mount(t,e)},p:function(t,e){e.row,e.each_value_1,e.row_index,i=e.cell,e.each_value_2,e.i,t.calendar&&l!==(l=i.getDate())&&(o.data=l);var n={};(t.calendar||t.selected)&&(n.selected=I(i,e.selected)),(t.isHighlighted||t.calendar||t.selected)&&(n.highlighted=e.isHighlighted(i,e.selected)),s._set(n)},u:function(){s._unmount()},d:function(){s.destroy(!1)}}}function X(t,e){for(var a,f,d,_,g,m,v=new B({root:t.root,data:{locale:e.locale,year:e.current.year,month:e.current.month}}),p=e.locale.weekDays,y=[],w=0;w<p.length;w+=1)y[w]=K(0,n({},e,{each_value:p,weekDay:p[w],i:w}));var b=e.calendar,k=[];for(w=0;w<b.length;w+=1)k[w]=Q(t,n({},e,{each_value_1:b,row:b[w],row_index:w}));function H(e){t.onHoverOut()}return{c:function(){v._fragment.c(),a=u("\n\n "),f=l("table"),d=l("thead"),_=l("tr");for(var t=0;t<y.length;t+=1)y[t].c();g=u("\n\n "),m=l("tbody");for(t=0;t<k.length;t+=1)k[t].c();this.h()},h:function(){s(m,"mouseleave",H),f.className="date-calendar-table"},m:function(t,e){v._mount(t,e),o(a,t,e),o(f,t,e),r(d,f),r(_,d);for(var n=0;n<y.length;n+=1)y[n].m(_,null);r(g,f),r(m,f);for(n=0;n<k.length;n+=1)k[n].m(m,null)},p:function(e,r){var o={};e.locale&&(o.locale=r.locale),e.current&&(o.year=r.current.year),e.current&&(o.month=r.current.month),v._set(o);var c=r.locale.weekDays;if(e.locale){for(var i=0;i<c.length;i+=1){var a=n({},r,{each_value:c,weekDay:c[i],i:i});y[i]?y[i].p(e,a):(y[i]=K(0,a),y[i].c(),y[i].m(_,null))}for(;i<y.length;i+=1)y[i].u(),y[i].d();y.length=c.length}var l=r.calendar;if(e.calendar||e.selected||e.isHighlighted){for(i=0;i<l.length;i+=1){var u=n({},r,{each_value_1:l,row:l[i],row_index:i});k[i]?k[i].p(e,u):(k[i]=Q(t,u),k[i].c(),k[i].m(m,null))}for(;i<k.length;i+=1)k[i].u(),k[i].d();k.length=l.length}},u:function(){v._unmount(),c(a),c(f);for(var t=0;t<y.length;t+=1)y[t].u();for(t=0;t<k.length;t+=1)k[t].u()},d:function(){v.destroy(!1),i(y),i(k),h(m,"mouseleave",H)}}}function Z(t){var e;g(this,t),this._state=n({current:{year:(e=new Date).getFullYear(),month:e.getMonth()},isHighlighted:p},t.data),this._recompute({current:1},this._state);var r,i,a,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,i=this._state,u=i.locale&&X(r,i),{c:function(){a=l("div"),u&&u.c(),this.h()},h:function(){a.className="date-calendar svelte-ji3oj2"},m:function(t,e){o(a,t,e),u&&u.m(a,null)},p:function(t,e){e.locale?u?u.p(t,e):((u=X(r,e)).c(),u.m(a,null)):u&&(u.u(),u.d(),u=null)},u:function(){c(a),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,m(this._beforecreate),m(this._oncreate),m(this._aftercreate),this._lock=!1)}function $(t,e){return function(n,r){var o=k(w(r),2),c=o[0],i=o[1],a=[c,n,e?t:i].filter(function(t){return t}).sort(S);return 3===a.length&&a[1]===n}}n(Z.prototype,{onClickCell:function(t){t&&this.fire("select",t)},onHoverCell:function(t){this.fire("hover",t)},onHoverOut:function(){this.fire("hover",null)}},v),Z.prototype._recompute=function(t,e){t.current&&this._differs(e.calendar,e.calendar=z(e.current))&&(t.calendar=!0)},G(Z);var tt={onSelect:function(t){var e=this.get("second"),n=e?1:0,r=w(this.get("selected")).slice(0,n).concat(t).sort(S);this.set({selected:r,second:!e}),this.fire("select",r)},onHover:function(t){this.set({hovered:t}),this.fire("hover",t)}},et=A(Z);function nt(t){var e,r,o;g(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 Z({root:e.root,data:{current:r.current,selected:r.selected,locale:r.locale,isHighlighted:$(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=$(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,m(this._beforecreate),m(this._oncreate),m(this._aftercreate),this._lock=!1)}function rt(t,e){return w(e).reduce(function(e,n){return e||M(t,n.getFullYear(),n.getMonth())},!1)}function ot(t){return e=t,y(N).map(function(t){return new Date(e,t)});var e}n(nt.prototype,tt,v),et(nt);var ct=j;function it(t,e){var n,i,s,h,f=e.month,d=(e.each_value,e.month_index,b(e.locale.months[f.getMonth()])),_=new W({root:t.root,slots:{default:a()},data:{selected:rt(f,e.selected),highlighted:e.isHighlighted(f,e.selected)}});return _.on("mouseenter",function(e){t.onHoverCell(f)}),_.on("click",function(e){t.onClickCell(f)}),{c:function(){n=l("li"),i=u("\n "),s=u(d),h=u("\n "),_._fragment.c(),this.h()},h:function(){n.className="month-calendar-item"},m:function(t,e){o(n,t,e),r(i,_._slotted.default),r(s,_._slotted.default),r(h,_._slotted.default),_._mount(n,null)},p:function(t,e){f=e.month,e.each_value,e.month_index,(t.locale||t.calendar)&&d!==(d=b(e.locale.months[f.getMonth()]))&&(s.data=d);var n={};(t.calendar||t.selected)&&(n.selected=rt(f,e.selected)),(t.isHighlighted||t.calendar||t.selected)&&(n.highlighted=e.isHighlighted(f,e.selected)),_._set(n)},u:function(){c(n)},d:function(){_.destroy(!1)}}}function at(t,e){for(var r,a,f=new B({root:t.root,data:{locale:e.locale,year:e.currentYear}}),d=e.calendar,_=[],g=0;g<d.length;g+=1)_[g]=it(t,n({},e,{each_value:d,month:d[g],month_index:g}));function m(e){t.onHoverOut()}return{c:function(){f._fragment.c(),r=u("\n\n "),a=l("ul");for(var t=0;t<_.length;t+=1)_[t].c();this.h()},h:function(){a.className="month-calendar-list",s(a,"mouseleave",m)},m:function(t,e){f._mount(t,e),o(r,t,e),o(a,t,e);for(var n=0;n<_.length;n+=1)_[n].m(a,null)},p:function(e,r){var o={};e.locale&&(o.locale=r.locale),e.currentYear&&(o.year=r.currentYear),f._set(o);var c=r.calendar;if(e.calendar||e.selected||e.isHighlighted||e.locale){for(var i=0;i<c.length;i+=1){var l=n({},r,{each_value:c,month:c[i],month_index:i});_[i]?_[i].p(e,l):(_[i]=it(t,l),_[i].c(),_[i].m(a,null))}for(;i<_.length;i+=1)_[i].u(),_[i].d();_.length=c.length}},u:function(){f._unmount(),c(r),c(a);for(var t=0;t<_.length;t+=1)_[t].u()},d:function(){f.destroy(!1),i(_),h(a,"mouseleave",m)}}}function lt(t){g(this,t),this._state=n({currentYear:(new Date).getFullYear(),isHighlighted:p},t.data),this._recompute({currentYear:1},this._state);var e,r,i,a,u=function(){this.get().locale||this.set({locale:this.constructor.locale})}.bind(this);t.root||(this._oncreate=[],this._beforecreate=[],this._aftercreate=[]),this._fragment=(e=this,r=this._state,a=r.locale&&at(e,r),{c:function(){i=l("div"),a&&a.c(),this.h()},h:function(){i.className="month-calendar svelte-66r1f2"},m:function(t,e){o(i,t,e),a&&a.m(i,null)},p:function(t,n){n.locale?a?a.p(t,n):((a=at(e,n)).c(),a.m(i,null)):a&&(a.u(),a.d(),a=null)},u:function(){c(i),a&&a.u()},d:function(){a&&a.d()}}),this.root._oncreate.push(u),t.target&&(this._fragment.c(),this._mount(t.target,t.anchor),this._lock=!0,m(this._beforecreate),m(this._oncreate),m(this._aftercreate),this._lock=!1)}function ut(t,e){return function(n,r){var o=k(w(r),2),c=o[0],i=o[1],a=[c,n,e?t:i].filter(function(t){return t}).sort(O);return 3===a.length&&a[1]===n}}n(lt.prototype,{onClickCell:function(t){t&&this.fire("select",t)},onHoverCell:function(t){this.fire("hover",t)},onHoverOut:function(){this.fire("hover",null)}},v),lt.prototype._recompute=function(t,e){t.currentYear&&this._differs(e.calendar,e.calendar=ot(e.currentYear))&&(t.calendar=!0)},ct(lt);var st={onSelect:function(t){var e=this.get(),n=e.second,r=w(e.selected),o=n?1:0,c=r.slice(0,o).concat(t).sort(O);this.set({selected:c,second:!n}),this.fire("select",c)},onHover:function(t){this.set({hovered:t}),this.fire("hover",t)}},ht=A(lt);function ft(t){var e,r,o;g(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 lt({root:e.root,data:{currentYear:r.currentYear,selected:r.selected,locale:r.locale,isHighlighted:ut(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.currentYear&&(n.currentYear=e.currentYear),t.selected&&(n.selected=e.selected),t.locale&&(n.locale=e.locale),(t.hovered||t.second)&&(n.isHighlighted=ut(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,m(this._beforecreate),m(this._oncreate),m(this._aftercreate),this._lock=!1)}n(ft.prototype,st,v),ht(ft),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=Z,t.DateRangeCalendar=nt,t.MonthCalendar=lt,t.MonthRangeCalendar=ft,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=calendar-set.min.js.map
{
"name": "calendar-set",
"version": "0.2.4",
"version": "0.3.0",
"description": "Framework agnostic calendar components",

@@ -5,0 +5,0 @@ "keywords": [

@@ -67,3 +67,3 @@ # calendar-set

Similar to DateCalendar but can be selected range of two date.
Similar to DateCalendar but can be selected range of two dates.

@@ -90,2 +90,41 @@ #### Data

### MonthCalendar
#### Data
```ts
{
currentYear: number
selected: Date | Date[] | undefined
isHighlighted: (target: Date, selected: Date | Date[] | undefined) => boolean
locale: Locale
}
```
#### Events
* `fire('select', selectedMonth)`
* `fire('hover', hoveredMonth)`
### MonthRangeCalendar
Similar to MonthCalendar but can be selected range of two months.
#### Data
```ts
{
currentYear: number
selected: Date | Date[] | undefined
hovered: Date | undefined
second: boolean // `true` if it is going to select the second month
locale: Locale
}
```
#### Events
* `fire('select', selectedMonth)`: `selectedMonth` is an array and always sorted with ASC order by month.
* `fire('hover', hoveredMonth)`
## Styles

@@ -92,0 +131,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