flatpickr-ce 0.0.0-stage → 4.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +107 -2
  3. package/dist/esm/index.js +2043 -0
  4. package/dist/esm/l10n/ar-dz.js +48 -0
  5. package/dist/esm/l10n/ar.js +49 -0
  6. package/dist/esm/l10n/at.js +57 -0
  7. package/dist/esm/l10n/az.js +61 -0
  8. package/dist/esm/l10n/be.js +62 -0
  9. package/dist/esm/l10n/bg.js +53 -0
  10. package/dist/esm/l10n/bn.js +51 -0
  11. package/dist/esm/l10n/bs.js +53 -0
  12. package/dist/esm/l10n/cat.js +71 -0
  13. package/dist/esm/l10n/ckb.js +63 -0
  14. package/dist/esm/l10n/cs.js +62 -0
  15. package/dist/esm/l10n/cy.js +79 -0
  16. package/dist/esm/l10n/da.js +58 -0
  17. package/dist/esm/l10n/de.js +57 -0
  18. package/dist/esm/l10n/default.js +72 -0
  19. package/dist/esm/l10n/eo.js +60 -0
  20. package/dist/esm/l10n/es.js +57 -0
  21. package/dist/esm/l10n/et.js +60 -0
  22. package/dist/esm/l10n/fa.js +55 -0
  23. package/dist/esm/l10n/fi.js +56 -0
  24. package/dist/esm/l10n/fo.js +61 -0
  25. package/dist/esm/l10n/fr.js +62 -0
  26. package/dist/esm/l10n/ga.js +53 -0
  27. package/dist/esm/l10n/gr.js +64 -0
  28. package/dist/esm/l10n/he.js +45 -0
  29. package/dist/esm/l10n/hi.js +51 -0
  30. package/dist/esm/l10n/hr.js +53 -0
  31. package/dist/esm/l10n/hu.js +60 -0
  32. package/dist/esm/l10n/hy.js +65 -0
  33. package/dist/esm/l10n/id.js +49 -0
  34. package/dist/esm/l10n/index.js +142 -0
  35. package/dist/esm/l10n/is.js +59 -0
  36. package/dist/esm/l10n/it.js +58 -0
  37. package/dist/esm/l10n/ja.js +58 -0
  38. package/dist/esm/l10n/ka.js +62 -0
  39. package/dist/esm/l10n/km.js +61 -0
  40. package/dist/esm/l10n/ko.js +56 -0
  41. package/dist/esm/l10n/kz.js +61 -0
  42. package/dist/esm/l10n/lt.js +60 -0
  43. package/dist/esm/l10n/lv.js +54 -0
  44. package/dist/esm/l10n/mk.js +55 -0
  45. package/dist/esm/l10n/mn.js +46 -0
  46. package/dist/esm/l10n/ms.js +47 -0
  47. package/dist/esm/l10n/my.js +56 -0
  48. package/dist/esm/l10n/nl.js +62 -0
  49. package/dist/esm/l10n/nn.js +60 -0
  50. package/dist/esm/l10n/no.js +60 -0
  51. package/dist/esm/l10n/pa.js +52 -0
  52. package/dist/esm/l10n/pl.js +60 -0
  53. package/dist/esm/l10n/pt.js +53 -0
  54. package/dist/esm/l10n/ro.js +56 -0
  55. package/dist/esm/l10n/ru.js +62 -0
  56. package/dist/esm/l10n/si.js +52 -0
  57. package/dist/esm/l10n/sk.js +57 -0
  58. package/dist/esm/l10n/sl.js +57 -0
  59. package/dist/esm/l10n/sq.js +59 -0
  60. package/dist/esm/l10n/sr-cyr.js +54 -0
  61. package/dist/esm/l10n/sr.js +55 -0
  62. package/dist/esm/l10n/sv.js +58 -0
  63. package/dist/esm/l10n/th.js +59 -0
  64. package/dist/esm/l10n/tr.js +61 -0
  65. package/dist/esm/l10n/uk.js +53 -0
  66. package/dist/esm/l10n/uz.js +62 -0
  67. package/dist/esm/l10n/uz_latn.js +62 -0
  68. package/dist/esm/l10n/vn.js +53 -0
  69. package/dist/esm/l10n/zh.js +55 -0
  70. package/dist/esm/l10n/zh_tw.js +55 -0
  71. package/dist/esm/plugins/confirmDate/confirmDate.js +68 -0
  72. package/dist/esm/plugins/labelPlugin/labelPlugin.js +22 -0
  73. package/dist/esm/plugins/minMaxTimePlugin.js +77 -0
  74. package/dist/esm/plugins/momentPlugin.js +47 -0
  75. package/dist/esm/plugins/monthSelect/index.js +259 -0
  76. package/dist/esm/plugins/rangePlugin.js +154 -0
  77. package/dist/esm/plugins/scrollPlugin.js +72 -0
  78. package/dist/esm/plugins/weekSelect/weekSelect.js +78 -0
  79. package/dist/esm/types/globals.js +1 -0
  80. package/dist/esm/types/instance.js +1 -0
  81. package/dist/esm/types/locale.js +1 -0
  82. package/dist/esm/types/options.js +83 -0
  83. package/dist/esm/utils/dates.js +143 -0
  84. package/dist/esm/utils/dom.js +58 -0
  85. package/dist/esm/utils/formatting.js +134 -0
  86. package/dist/esm/utils/index.js +17 -0
  87. package/dist/esm/utils/polyfills.js +22 -0
  88. package/dist/flatpickr.css +795 -0
  89. package/dist/flatpickr.js +2724 -0
  90. package/dist/flatpickr.min.css +13 -0
  91. package/dist/flatpickr.min.js +2 -0
  92. package/dist/ie.css +13 -0
  93. package/dist/l10n/ar-dz.d.ts +72 -0
  94. package/dist/l10n/ar-dz.js +61 -0
  95. package/dist/l10n/ar.d.ts +72 -0
  96. package/dist/l10n/ar.js +62 -0
  97. package/dist/l10n/at.d.ts +72 -0
  98. package/dist/l10n/at.js +70 -0
  99. package/dist/l10n/az.d.ts +72 -0
  100. package/dist/l10n/az.js +74 -0
  101. package/dist/l10n/be.d.ts +72 -0
  102. package/dist/l10n/be.js +75 -0
  103. package/dist/l10n/bg.d.ts +72 -0
  104. package/dist/l10n/bg.js +66 -0
  105. package/dist/l10n/bn.d.ts +72 -0
  106. package/dist/l10n/bn.js +64 -0
  107. package/dist/l10n/bs.d.ts +72 -0
  108. package/dist/l10n/bs.js +66 -0
  109. package/dist/l10n/cat.d.ts +72 -0
  110. package/dist/l10n/cat.js +84 -0
  111. package/dist/l10n/ckb.d.ts +72 -0
  112. package/dist/l10n/ckb.js +76 -0
  113. package/dist/l10n/cs.d.ts +72 -0
  114. package/dist/l10n/cs.js +75 -0
  115. package/dist/l10n/cy.d.ts +72 -0
  116. package/dist/l10n/cy.js +93 -0
  117. package/dist/l10n/da.d.ts +72 -0
  118. package/dist/l10n/da.js +71 -0
  119. package/dist/l10n/de.d.ts +72 -0
  120. package/dist/l10n/de.js +70 -0
  121. package/dist/l10n/default.d.ts +3 -0
  122. package/dist/l10n/default.js +84 -0
  123. package/dist/l10n/eo.d.ts +72 -0
  124. package/dist/l10n/eo.js +73 -0
  125. package/dist/l10n/es.d.ts +72 -0
  126. package/dist/l10n/es.js +70 -0
  127. package/dist/l10n/et.d.ts +72 -0
  128. package/dist/l10n/et.js +73 -0
  129. package/dist/l10n/fa.d.ts +72 -0
  130. package/dist/l10n/fa.js +68 -0
  131. package/dist/l10n/fi.d.ts +72 -0
  132. package/dist/l10n/fi.js +69 -0
  133. package/dist/l10n/fo.d.ts +72 -0
  134. package/dist/l10n/fo.js +74 -0
  135. package/dist/l10n/fr.d.ts +72 -0
  136. package/dist/l10n/fr.js +75 -0
  137. package/dist/l10n/ga.d.ts +72 -0
  138. package/dist/l10n/ga.js +66 -0
  139. package/dist/l10n/gr.d.ts +72 -0
  140. package/dist/l10n/gr.js +77 -0
  141. package/dist/l10n/he.d.ts +72 -0
  142. package/dist/l10n/he.js +58 -0
  143. package/dist/l10n/hi.d.ts +72 -0
  144. package/dist/l10n/hi.js +64 -0
  145. package/dist/l10n/hr.d.ts +72 -0
  146. package/dist/l10n/hr.js +66 -0
  147. package/dist/l10n/hu.d.ts +72 -0
  148. package/dist/l10n/hu.js +73 -0
  149. package/dist/l10n/hy.d.ts +72 -0
  150. package/dist/l10n/hy.js +78 -0
  151. package/dist/l10n/id.d.ts +72 -0
  152. package/dist/l10n/id.js +62 -0
  153. package/dist/l10n/index.d.ts +3 -0
  154. package/dist/l10n/index.js +3810 -0
  155. package/dist/l10n/is.d.ts +72 -0
  156. package/dist/l10n/is.js +72 -0
  157. package/dist/l10n/it.d.ts +72 -0
  158. package/dist/l10n/it.js +71 -0
  159. package/dist/l10n/ja.d.ts +72 -0
  160. package/dist/l10n/ja.js +71 -0
  161. package/dist/l10n/ka.d.ts +72 -0
  162. package/dist/l10n/ka.js +75 -0
  163. package/dist/l10n/km.d.ts +72 -0
  164. package/dist/l10n/km.js +74 -0
  165. package/dist/l10n/ko.d.ts +72 -0
  166. package/dist/l10n/ko.js +69 -0
  167. package/dist/l10n/kz.d.ts +72 -0
  168. package/dist/l10n/kz.js +74 -0
  169. package/dist/l10n/lt.d.ts +72 -0
  170. package/dist/l10n/lt.js +73 -0
  171. package/dist/l10n/lv.d.ts +72 -0
  172. package/dist/l10n/lv.js +67 -0
  173. package/dist/l10n/mk.d.ts +72 -0
  174. package/dist/l10n/mk.js +68 -0
  175. package/dist/l10n/mn.d.ts +72 -0
  176. package/dist/l10n/mn.js +59 -0
  177. package/dist/l10n/ms.d.ts +72 -0
  178. package/dist/l10n/ms.js +60 -0
  179. package/dist/l10n/my.d.ts +72 -0
  180. package/dist/l10n/my.js +69 -0
  181. package/dist/l10n/nl.d.ts +72 -0
  182. package/dist/l10n/nl.js +75 -0
  183. package/dist/l10n/nn.d.ts +72 -0
  184. package/dist/l10n/nn.js +73 -0
  185. package/dist/l10n/no.d.ts +72 -0
  186. package/dist/l10n/no.js +73 -0
  187. package/dist/l10n/pa.d.ts +72 -0
  188. package/dist/l10n/pa.js +65 -0
  189. package/dist/l10n/pl.d.ts +72 -0
  190. package/dist/l10n/pl.js +73 -0
  191. package/dist/l10n/pt.d.ts +72 -0
  192. package/dist/l10n/pt.js +66 -0
  193. package/dist/l10n/ro.d.ts +72 -0
  194. package/dist/l10n/ro.js +69 -0
  195. package/dist/l10n/ru.d.ts +72 -0
  196. package/dist/l10n/ru.js +75 -0
  197. package/dist/l10n/si.d.ts +72 -0
  198. package/dist/l10n/si.js +65 -0
  199. package/dist/l10n/sk.d.ts +72 -0
  200. package/dist/l10n/sk.js +70 -0
  201. package/dist/l10n/sl.d.ts +72 -0
  202. package/dist/l10n/sl.js +70 -0
  203. package/dist/l10n/sq.d.ts +72 -0
  204. package/dist/l10n/sq.js +72 -0
  205. package/dist/l10n/sr-cyr.d.ts +72 -0
  206. package/dist/l10n/sr-cyr.js +67 -0
  207. package/dist/l10n/sr.d.ts +72 -0
  208. package/dist/l10n/sr.js +68 -0
  209. package/dist/l10n/sv.d.ts +72 -0
  210. package/dist/l10n/sv.js +71 -0
  211. package/dist/l10n/th.d.ts +72 -0
  212. package/dist/l10n/th.js +72 -0
  213. package/dist/l10n/tr.d.ts +72 -0
  214. package/dist/l10n/tr.js +74 -0
  215. package/dist/l10n/uk.d.ts +72 -0
  216. package/dist/l10n/uk.js +66 -0
  217. package/dist/l10n/uz.d.ts +72 -0
  218. package/dist/l10n/uz.js +75 -0
  219. package/dist/l10n/uz_latn.d.ts +72 -0
  220. package/dist/l10n/uz_latn.js +75 -0
  221. package/dist/l10n/vn.d.ts +72 -0
  222. package/dist/l10n/vn.js +66 -0
  223. package/dist/l10n/zh.d.ts +72 -0
  224. package/dist/l10n/zh.js +68 -0
  225. package/dist/l10n/zh_tw.d.ts +72 -0
  226. package/dist/l10n/zh_tw.js +68 -0
  227. package/dist/plugins/confirmDate/confirmDate.css +24 -0
  228. package/dist/plugins/confirmDate/confirmDate.d.ts +9 -0
  229. package/dist/plugins/confirmDate/confirmDate.js +104 -0
  230. package/dist/plugins/labelPlugin/labelPlugin.d.ts +3 -0
  231. package/dist/plugins/labelPlugin/labelPlugin.js +31 -0
  232. package/dist/plugins/minMaxTimePlugin.d.ts +17 -0
  233. package/dist/plugins/minMaxTimePlugin.js +349 -0
  234. package/dist/plugins/momentPlugin.d.ts +6 -0
  235. package/dist/plugins/momentPlugin.js +69 -0
  236. package/dist/plugins/monthSelect/index.d.ts +17 -0
  237. package/dist/plugins/monthSelect/index.js +301 -0
  238. package/dist/plugins/monthSelect/style.css +117 -0
  239. package/dist/plugins/rangePlugin.d.ts +12 -0
  240. package/dist/plugins/rangePlugin.js +179 -0
  241. package/dist/plugins/scrollPlugin.d.ts +3 -0
  242. package/dist/plugins/scrollPlugin.js +93 -0
  243. package/dist/plugins/weekSelect/weekSelect.d.ts +7 -0
  244. package/dist/plugins/weekSelect/weekSelect.js +99 -0
  245. package/dist/themes/airbnb.css +883 -0
  246. package/dist/themes/confetti.css +806 -0
  247. package/dist/themes/dark.css +795 -0
  248. package/dist/themes/light.css +809 -0
  249. package/dist/themes/material_blue.css +806 -0
  250. package/dist/themes/material_green.css +806 -0
  251. package/dist/themes/material_orange.css +806 -0
  252. package/dist/themes/material_red.css +806 -0
  253. package/dist/types/globals.d.ts +20 -0
  254. package/dist/types/instance.d.ts +118 -0
  255. package/dist/types/locale.d.ts +112 -0
  256. package/dist/types/options.d.ts +148 -0
  257. package/dist/typings.d.ts +40 -0
  258. package/dist/utils/dates.d.ts +25 -0
  259. package/dist/utils/dom.d.ts +7 -0
  260. package/dist/utils/formatting.d.ts +13 -0
  261. package/dist/utils/index.d.ts +8 -0
  262. package/package.json +81 -4
  263. package/src/style/_vars.styl +34 -0
  264. package/src/style/flatpickr.styl +703 -0
  265. package/src/style/ie.styl +14 -0
  266. package/src/style/themes/airbnb.styl +87 -0
  267. package/src/style/themes/confetti.styl +18 -0
  268. package/src/style/themes/dark.styl +18 -0
  269. package/src/style/themes/light.styl +22 -0
  270. package/src/style/themes/material_blue.styl +18 -0
  271. package/src/style/themes/material_green.styl +18 -0
  272. package/src/style/themes/material_orange.styl +18 -0
  273. package/src/style/themes/material_red.styl +18 -0
@@ -0,0 +1,72 @@
1
+ import { getEventTarget } from "../utils/dom";
2
+ if (typeof window.CustomEvent !== "function") {
3
+ var CustomEvent_1 = function (typeArg, eventInitDict) {
4
+ eventInitDict = eventInitDict || {
5
+ bubbles: false,
6
+ cancelable: false,
7
+ detail: undefined,
8
+ };
9
+ var evt = document.createEvent("CustomEvent");
10
+ evt.initCustomEvent(typeArg, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
11
+ return evt;
12
+ };
13
+ CustomEvent_1.prototype = window.Event.prototype;
14
+ window.CustomEvent = CustomEvent_1;
15
+ }
16
+ function delta(e) {
17
+ return Math.max(-1, Math.min(1, e.wheelDelta || -e.deltaY));
18
+ }
19
+ var scroll = function (e) {
20
+ e.preventDefault();
21
+ var ev = new CustomEvent("increment", {
22
+ bubbles: true,
23
+ });
24
+ ev.delta = delta(e);
25
+ getEventTarget(e).dispatchEvent(ev);
26
+ };
27
+ function scrollMonth(fp) {
28
+ return function (e) {
29
+ e.preventDefault();
30
+ var mDelta = delta(e);
31
+ fp.changeMonth(mDelta);
32
+ };
33
+ }
34
+ function scrollPlugin() {
35
+ return function (fp) {
36
+ var monthScroller = scrollMonth(fp);
37
+ return {
38
+ onReady: function () {
39
+ if (fp.timeContainer) {
40
+ fp.timeContainer.addEventListener("wheel", scroll);
41
+ }
42
+ if (fp.yearElements) {
43
+ fp.yearElements.forEach(function (yearElem) {
44
+ return yearElem.addEventListener("wheel", scroll);
45
+ });
46
+ }
47
+ if (fp.monthElements) {
48
+ fp.monthElements.forEach(function (monthElem) {
49
+ return monthElem.addEventListener("wheel", monthScroller);
50
+ });
51
+ }
52
+ fp.loadedPlugins.push("scroll");
53
+ },
54
+ onDestroy: function () {
55
+ if (fp.timeContainer) {
56
+ fp.timeContainer.removeEventListener("wheel", scroll);
57
+ }
58
+ if (fp.yearElements) {
59
+ fp.yearElements.forEach(function (yearElem) {
60
+ return yearElem.removeEventListener("wheel", scroll);
61
+ });
62
+ }
63
+ if (fp.monthElements) {
64
+ fp.monthElements.forEach(function (monthElem) {
65
+ return monthElem.removeEventListener("wheel", monthScroller);
66
+ });
67
+ }
68
+ },
69
+ };
70
+ };
71
+ }
72
+ export default scrollPlugin;
@@ -0,0 +1,78 @@
1
+ import { getEventTarget } from "../../utils/dom";
2
+ function weekSelectPlugin() {
3
+ return function (fp) {
4
+ function onDayHover(event) {
5
+ var day = getEventTarget(event);
6
+ if (!day.classList.contains("flatpickr-day"))
7
+ return;
8
+ var days = fp.days.childNodes;
9
+ var dayIndex = day.$i;
10
+ var dayIndSeven = dayIndex / 7;
11
+ var weekStartDay = days[7 * Math.floor(dayIndSeven)]
12
+ .dateObj;
13
+ var weekEndDay = days[7 * Math.ceil(dayIndSeven + 0.01) - 1].dateObj;
14
+ for (var i = days.length; i--;) {
15
+ var day_1 = days[i];
16
+ var date = day_1.dateObj;
17
+ if (date > weekEndDay || date < weekStartDay)
18
+ day_1.classList.remove("inRange");
19
+ else
20
+ day_1.classList.add("inRange");
21
+ }
22
+ }
23
+ function highlightWeek() {
24
+ var selDate = fp.latestSelectedDateObj;
25
+ if (selDate !== undefined &&
26
+ selDate.getMonth() === fp.currentMonth &&
27
+ selDate.getFullYear() === fp.currentYear) {
28
+ fp.weekStartDay = fp.days.childNodes[7 * Math.floor(fp.selectedDateElem.$i / 7)].dateObj;
29
+ fp.weekEndDay = fp.days.childNodes[7 * Math.ceil(fp.selectedDateElem.$i / 7 + 0.01) - 1].dateObj;
30
+ }
31
+ var days = fp.days.childNodes;
32
+ for (var i = days.length; i--;) {
33
+ var date = days[i].dateObj;
34
+ if (date >= fp.weekStartDay && date <= fp.weekEndDay)
35
+ days[i].classList.add("week", "selected");
36
+ }
37
+ }
38
+ function clearHover() {
39
+ var days = fp.days.childNodes;
40
+ for (var i = days.length; i--;)
41
+ days[i].classList.remove("inRange");
42
+ }
43
+ function onReady() {
44
+ if (fp.daysContainer !== undefined)
45
+ fp.daysContainer.addEventListener("mouseover", onDayHover);
46
+ }
47
+ function onDestroy() {
48
+ if (fp.daysContainer !== undefined)
49
+ fp.daysContainer.removeEventListener("mouseover", onDayHover);
50
+ }
51
+ return {
52
+ onValueUpdate: highlightWeek,
53
+ onMonthChange: highlightWeek,
54
+ onYearChange: highlightWeek,
55
+ onOpen: highlightWeek,
56
+ onClose: clearHover,
57
+ onParseConfig: function () {
58
+ fp.config.mode = "single";
59
+ fp.config.enableTime = false;
60
+ fp.config.dateFormat = fp.config.dateFormat
61
+ ? fp.config.dateFormat
62
+ : "\\W\\e\\e\\k #W, Y";
63
+ fp.config.altFormat = fp.config.altFormat
64
+ ? fp.config.altFormat
65
+ : "\\W\\e\\e\\k #W, Y";
66
+ },
67
+ onReady: [
68
+ onReady,
69
+ highlightWeek,
70
+ function () {
71
+ fp.loadedPlugins.push("weekSelect");
72
+ },
73
+ ],
74
+ onDestroy: onDestroy,
75
+ };
76
+ };
77
+ }
78
+ export default weekSelectPlugin;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,83 @@
1
+ export var HOOKS = [
2
+ "onChange",
3
+ "onClose",
4
+ "onDayCreate",
5
+ "onDestroy",
6
+ "onKeyDown",
7
+ "onMonthChange",
8
+ "onOpen",
9
+ "onParseConfig",
10
+ "onReady",
11
+ "onValueUpdate",
12
+ "onYearChange",
13
+ "onPreCalendarPosition",
14
+ ];
15
+ export var defaults = {
16
+ _disable: [],
17
+ allowInput: false,
18
+ allowInvalidPreload: false,
19
+ altFormat: "F j, Y",
20
+ altInput: false,
21
+ altInputClass: "form-control input",
22
+ animate: typeof window === "object" &&
23
+ window.navigator.userAgent.indexOf("MSIE") === -1,
24
+ ariaDateFormat: "F j, Y",
25
+ autoFillDefaultTime: true,
26
+ clickOpens: true,
27
+ closeOnSelect: true,
28
+ conjunction: ", ",
29
+ dateFormat: "Y-m-d",
30
+ defaultHour: 12,
31
+ defaultMinute: 0,
32
+ defaultSeconds: 0,
33
+ disable: [],
34
+ disableMobile: false,
35
+ enableSeconds: false,
36
+ enableTime: false,
37
+ errorHandler: function (err) {
38
+ return typeof console !== "undefined" && console.warn(err);
39
+ },
40
+ getWeek: function (givenDate) {
41
+ var date = new Date(givenDate.getTime());
42
+ date.setHours(0, 0, 0, 0);
43
+ date.setDate(date.getDate() + 3 - ((date.getDay() + 6) % 7));
44
+ var week1 = new Date(date.getFullYear(), 0, 4);
45
+ return (1 +
46
+ Math.round(((date.getTime() - week1.getTime()) / 86400000 -
47
+ 3 +
48
+ ((week1.getDay() + 6) % 7)) /
49
+ 7));
50
+ },
51
+ hourIncrement: 1,
52
+ ignoredFocusElements: [],
53
+ inline: false,
54
+ locale: "default",
55
+ minuteIncrement: 5,
56
+ mode: "single",
57
+ monthSelectorType: "dropdown",
58
+ nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
59
+ noCalendar: false,
60
+ now: new Date(),
61
+ onChange: [],
62
+ onClose: [],
63
+ onDayCreate: [],
64
+ onDestroy: [],
65
+ onKeyDown: [],
66
+ onMonthChange: [],
67
+ onOpen: [],
68
+ onParseConfig: [],
69
+ onReady: [],
70
+ onValueUpdate: [],
71
+ onYearChange: [],
72
+ onPreCalendarPosition: [],
73
+ plugins: [],
74
+ position: "auto",
75
+ positionElement: undefined,
76
+ prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
77
+ shorthandCurrentMonth: false,
78
+ showMonths: 1,
79
+ static: false,
80
+ time_24hr: false,
81
+ weekNumbers: false,
82
+ wrap: false,
83
+ };
@@ -0,0 +1,143 @@
1
+ import { tokenRegex, revFormat, formats, } from "./formatting";
2
+ import { defaults } from "../types/options";
3
+ import { english } from "../l10n/default";
4
+ export var createDateFormatter = function (_a) {
5
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c, _d = _a.isMobile, isMobile = _d === void 0 ? false : _d;
6
+ return function (dateObj, frmt, overrideLocale) {
7
+ var locale = overrideLocale || l10n;
8
+ if (config.formatDate !== undefined && !isMobile) {
9
+ return config.formatDate(dateObj, frmt, locale);
10
+ }
11
+ return frmt
12
+ .split("")
13
+ .map(function (c, i, arr) {
14
+ return formats[c] && arr[i - 1] !== "\\"
15
+ ? formats[c](dateObj, locale, config)
16
+ : c !== "\\"
17
+ ? c
18
+ : "";
19
+ })
20
+ .join("");
21
+ };
22
+ };
23
+ export var createDateParser = function (_a) {
24
+ var _b = _a.config, config = _b === void 0 ? defaults : _b, _c = _a.l10n, l10n = _c === void 0 ? english : _c;
25
+ return function (date, givenFormat, timeless, customLocale) {
26
+ if (date !== 0 && !date)
27
+ return undefined;
28
+ var locale = customLocale || l10n;
29
+ var parsedDate;
30
+ var dateOrig = date;
31
+ if (date instanceof Date)
32
+ parsedDate = new Date(date.getTime());
33
+ else if (typeof date !== "string" &&
34
+ date.toFixed !== undefined)
35
+ parsedDate = new Date(date);
36
+ else if (typeof date === "string") {
37
+ var format = givenFormat || (config || defaults).dateFormat;
38
+ var datestr = String(date).trim();
39
+ if (datestr === "today") {
40
+ parsedDate = new Date();
41
+ timeless = true;
42
+ }
43
+ else if (config && config.parseDate) {
44
+ parsedDate = config.parseDate(date, format);
45
+ }
46
+ else if (/Z$/.test(datestr) ||
47
+ /GMT$/.test(datestr)) {
48
+ parsedDate = new Date(date);
49
+ }
50
+ else {
51
+ var matched = void 0, ops = [];
52
+ for (var i = 0, matchIndex = 0, regexStr = ""; i < format.length; i++) {
53
+ var token = format[i];
54
+ var isBackSlash = token === "\\";
55
+ var escaped = format[i - 1] === "\\" || isBackSlash;
56
+ if (tokenRegex[token] && !escaped) {
57
+ regexStr += tokenRegex[token];
58
+ var match = new RegExp(regexStr).exec(date);
59
+ if (match && (matched = true)) {
60
+ ops[token !== "Y" ? "push" : "unshift"]({
61
+ fn: revFormat[token],
62
+ val: match[++matchIndex],
63
+ });
64
+ }
65
+ }
66
+ else if (!isBackSlash)
67
+ regexStr += ".";
68
+ }
69
+ parsedDate =
70
+ !config || !config.noCalendar
71
+ ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0)
72
+ : new Date(new Date().setHours(0, 0, 0, 0));
73
+ ops.forEach(function (_a) {
74
+ var fn = _a.fn, val = _a.val;
75
+ return (parsedDate = fn(parsedDate, val, locale) || parsedDate);
76
+ });
77
+ parsedDate = matched ? parsedDate : undefined;
78
+ }
79
+ }
80
+ if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
81
+ config.errorHandler(new Error("Invalid date provided: " + dateOrig));
82
+ return undefined;
83
+ }
84
+ if (timeless === true)
85
+ parsedDate.setHours(0, 0, 0, 0);
86
+ return parsedDate;
87
+ };
88
+ };
89
+ export function compareDates(date1, date2, timeless) {
90
+ if (timeless === void 0) { timeless = true; }
91
+ if (timeless !== false) {
92
+ return (new Date(date1.getTime()).setHours(0, 0, 0, 0) -
93
+ new Date(date2.getTime()).setHours(0, 0, 0, 0));
94
+ }
95
+ return date1.getTime() - date2.getTime();
96
+ }
97
+ export function compareTimes(date1, date2) {
98
+ return (3600 * (date1.getHours() - date2.getHours()) +
99
+ 60 * (date1.getMinutes() - date2.getMinutes()) +
100
+ date1.getSeconds() -
101
+ date2.getSeconds());
102
+ }
103
+ export var isBetween = function (ts, ts1, ts2) {
104
+ return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
105
+ };
106
+ export var calculateSecondsSinceMidnight = function (hours, minutes, seconds) {
107
+ return hours * 3600 + minutes * 60 + seconds;
108
+ };
109
+ export var parseSeconds = function (secondsSinceMidnight) {
110
+ var hours = Math.floor(secondsSinceMidnight / 3600), minutes = (secondsSinceMidnight - hours * 3600) / 60;
111
+ return [hours, minutes, secondsSinceMidnight - hours * 3600 - minutes * 60];
112
+ };
113
+ export var duration = {
114
+ DAY: 86400000,
115
+ };
116
+ export function getDefaultHours(config) {
117
+ var hours = config.defaultHour;
118
+ var minutes = config.defaultMinute;
119
+ var seconds = config.defaultSeconds;
120
+ if (config.minDate !== undefined) {
121
+ var minHour = config.minDate.getHours();
122
+ var minMinutes = config.minDate.getMinutes();
123
+ var minSeconds = config.minDate.getSeconds();
124
+ if (hours < minHour) {
125
+ hours = minHour;
126
+ }
127
+ if (hours === minHour && minutes < minMinutes) {
128
+ minutes = minMinutes;
129
+ }
130
+ if (hours === minHour && minutes === minMinutes && seconds < minSeconds)
131
+ seconds = config.minDate.getSeconds();
132
+ }
133
+ if (config.maxDate !== undefined) {
134
+ var maxHr = config.maxDate.getHours();
135
+ var maxMinutes = config.maxDate.getMinutes();
136
+ hours = Math.min(hours, maxHr);
137
+ if (hours === maxHr)
138
+ minutes = Math.min(maxMinutes, minutes);
139
+ if (hours === maxHr && minutes === maxMinutes)
140
+ seconds = config.maxDate.getSeconds();
141
+ }
142
+ return { hours: hours, minutes: minutes, seconds: seconds };
143
+ }
@@ -0,0 +1,58 @@
1
+ export function toggleClass(elem, className, bool) {
2
+ if (bool === true)
3
+ return elem.classList.add(className);
4
+ elem.classList.remove(className);
5
+ }
6
+ export function createElement(tag, className, content) {
7
+ var e = window.document.createElement(tag);
8
+ className = className || "";
9
+ content = content || "";
10
+ e.className = className;
11
+ if (content !== undefined)
12
+ e.textContent = content;
13
+ return e;
14
+ }
15
+ export function clearNode(node) {
16
+ while (node.firstChild)
17
+ node.removeChild(node.firstChild);
18
+ }
19
+ export function findParent(node, condition) {
20
+ if (condition(node))
21
+ return node;
22
+ else if (node.parentNode)
23
+ return findParent(node.parentNode, condition);
24
+ return undefined;
25
+ }
26
+ export function createNumberInput(inputClassName, opts) {
27
+ var wrapper = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
28
+ if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
29
+ numInput.type = "number";
30
+ }
31
+ else {
32
+ numInput.type = "text";
33
+ numInput.pattern = "\\d*";
34
+ }
35
+ if (opts !== undefined)
36
+ for (var key in opts)
37
+ numInput.setAttribute(key, opts[key]);
38
+ wrapper.appendChild(numInput);
39
+ wrapper.appendChild(arrowUp);
40
+ wrapper.appendChild(arrowDown);
41
+ return wrapper;
42
+ }
43
+ export function getEventTarget(event) {
44
+ try {
45
+ if (typeof event.composedPath === "function") {
46
+ var path = event.composedPath();
47
+ return path[0];
48
+ }
49
+ return event.target;
50
+ }
51
+ catch (error) {
52
+ return event.target;
53
+ }
54
+ }
55
+ export function isNode(value) {
56
+ var _a;
57
+ return typeof ((_a = value) === null || _a === void 0 ? void 0 : _a.nodeType) === "number";
58
+ }
@@ -0,0 +1,134 @@
1
+ import { int, pad } from "../utils";
2
+ var doNothing = function () { return undefined; };
3
+ export var monthToStr = function (monthNumber, shorthand, locale) { return locale.months[shorthand ? "shorthand" : "longhand"][monthNumber]; };
4
+ export var revFormat = {
5
+ D: doNothing,
6
+ F: function (dateObj, monthName, locale) {
7
+ dateObj.setMonth(locale.months.longhand.indexOf(monthName));
8
+ },
9
+ G: function (dateObj, hour) {
10
+ dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
11
+ },
12
+ H: function (dateObj, hour) {
13
+ dateObj.setHours(parseFloat(hour));
14
+ },
15
+ J: function (dateObj, day) {
16
+ dateObj.setDate(parseFloat(day));
17
+ },
18
+ K: function (dateObj, amPM, locale) {
19
+ dateObj.setHours((dateObj.getHours() % 12) +
20
+ 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
21
+ },
22
+ M: function (dateObj, shortMonth, locale) {
23
+ dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
24
+ },
25
+ S: function (dateObj, seconds) {
26
+ dateObj.setSeconds(parseFloat(seconds));
27
+ },
28
+ U: function (_, unixSeconds) { return new Date(parseFloat(unixSeconds) * 1000); },
29
+ W: function (dateObj, weekNum, locale) {
30
+ var weekNumber = parseInt(weekNum);
31
+ var date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
32
+ date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
33
+ return date;
34
+ },
35
+ Y: function (dateObj, year) {
36
+ dateObj.setFullYear(parseFloat(year));
37
+ },
38
+ Z: function (_, ISODate) { return new Date(ISODate); },
39
+ d: function (dateObj, day) {
40
+ dateObj.setDate(parseFloat(day));
41
+ },
42
+ h: function (dateObj, hour) {
43
+ dateObj.setHours((dateObj.getHours() >= 12 ? 12 : 0) + parseFloat(hour));
44
+ },
45
+ i: function (dateObj, minutes) {
46
+ dateObj.setMinutes(parseFloat(minutes));
47
+ },
48
+ j: function (dateObj, day) {
49
+ dateObj.setDate(parseFloat(day));
50
+ },
51
+ l: doNothing,
52
+ m: function (dateObj, month) {
53
+ dateObj.setMonth(parseFloat(month) - 1);
54
+ },
55
+ n: function (dateObj, month) {
56
+ dateObj.setMonth(parseFloat(month) - 1);
57
+ },
58
+ s: function (dateObj, seconds) {
59
+ dateObj.setSeconds(parseFloat(seconds));
60
+ },
61
+ u: function (_, unixMillSeconds) {
62
+ return new Date(parseFloat(unixMillSeconds));
63
+ },
64
+ w: doNothing,
65
+ y: function (dateObj, year) {
66
+ dateObj.setFullYear(2000 + parseFloat(year));
67
+ },
68
+ };
69
+ export var tokenRegex = {
70
+ D: "",
71
+ F: "",
72
+ G: "(\\d\\d|\\d)",
73
+ H: "(\\d\\d|\\d)",
74
+ J: "(\\d\\d|\\d)\\w+",
75
+ K: "",
76
+ M: "",
77
+ S: "(\\d\\d|\\d)",
78
+ U: "(.+)",
79
+ W: "(\\d\\d|\\d)",
80
+ Y: "(\\d{4})",
81
+ Z: "(.+)",
82
+ d: "(\\d\\d|\\d)",
83
+ h: "(\\d\\d|\\d)",
84
+ i: "(\\d\\d|\\d)",
85
+ j: "(\\d\\d|\\d)",
86
+ l: "",
87
+ m: "(\\d\\d|\\d)",
88
+ n: "(\\d\\d|\\d)",
89
+ s: "(\\d\\d|\\d)",
90
+ u: "(.+)",
91
+ w: "(\\d\\d|\\d)",
92
+ y: "(\\d{2})",
93
+ };
94
+ export var formats = {
95
+ Z: function (date) { return date.toISOString(); },
96
+ D: function (date, locale, options) {
97
+ return locale.weekdays.shorthand[formats.w(date, locale, options)];
98
+ },
99
+ F: function (date, locale, options) {
100
+ return monthToStr(formats.n(date, locale, options) - 1, false, locale);
101
+ },
102
+ G: function (date, locale, options) {
103
+ return pad(formats.h(date, locale, options));
104
+ },
105
+ H: function (date) { return pad(date.getHours()); },
106
+ J: function (date, locale) {
107
+ return locale.ordinal !== undefined
108
+ ? date.getDate() + locale.ordinal(date.getDate())
109
+ : date.getDate();
110
+ },
111
+ K: function (date, locale) { return locale.amPM[int(date.getHours() > 11)]; },
112
+ M: function (date, locale) {
113
+ return monthToStr(date.getMonth(), true, locale);
114
+ },
115
+ S: function (date) { return pad(date.getSeconds()); },
116
+ U: function (date) { return date.getTime() / 1000; },
117
+ W: function (date, _, options) {
118
+ return options.getWeek(date);
119
+ },
120
+ Y: function (date) { return pad(date.getFullYear(), 4); },
121
+ d: function (date) { return pad(date.getDate()); },
122
+ h: function (date) { return (date.getHours() % 12 ? date.getHours() % 12 : 12); },
123
+ i: function (date) { return pad(date.getMinutes()); },
124
+ j: function (date) { return date.getDate(); },
125
+ l: function (date, locale) {
126
+ return locale.weekdays.longhand[date.getDay()];
127
+ },
128
+ m: function (date) { return pad(date.getMonth() + 1); },
129
+ n: function (date) { return date.getMonth() + 1; },
130
+ s: function (date) { return date.getSeconds(); },
131
+ u: function (date) { return date.getTime(); },
132
+ w: function (date) { return date.getDay(); },
133
+ y: function (date) { return String(date.getFullYear()).substring(2); },
134
+ };
@@ -0,0 +1,17 @@
1
+ export var pad = function (number, length) {
2
+ if (length === void 0) { length = 2; }
3
+ return ("000" + number).slice(length * -1);
4
+ };
5
+ export var int = function (bool) { return (bool === true ? 1 : 0); };
6
+ export function debounce(fn, wait) {
7
+ var t;
8
+ return function () {
9
+ var _this = this;
10
+ var args = arguments;
11
+ clearTimeout(t);
12
+ t = setTimeout(function () { return fn.apply(_this, args); }, wait);
13
+ };
14
+ }
15
+ export var arrayify = function (obj) {
16
+ return obj instanceof Array ? obj : [obj];
17
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ if (typeof Object.assign !== "function") {
3
+ Object.assign = function (target) {
4
+ var args = [];
5
+ for (var _i = 1; _i < arguments.length; _i++) {
6
+ args[_i - 1] = arguments[_i];
7
+ }
8
+ if (!target) {
9
+ throw TypeError("Cannot convert undefined or null to object");
10
+ }
11
+ var _loop_1 = function (source) {
12
+ if (source) {
13
+ Object.keys(source).forEach(function (key) { return (target[key] = source[key]); });
14
+ }
15
+ };
16
+ for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
17
+ var source = args_1[_a];
18
+ _loop_1(source);
19
+ }
20
+ return target;
21
+ };
22
+ }