@ohos-ports/flowbite-datepicker 2.0.0-beta.0

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 (291) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +73 -0
  3. package/.stylelintrc +12 -0
  4. package/CHANGELOG.md +72 -0
  5. package/LICENSE +21 -0
  6. package/README.md +71 -0
  7. package/demo/index.html +582 -0
  8. package/demo/live-demo.js +471 -0
  9. package/dist/DateRangePicker.cjs.js +2996 -0
  10. package/dist/DateRangePicker.esm.js +2994 -0
  11. package/dist/DateRangePicker.umd.js +3002 -0
  12. package/dist/Datepicker.cjs.js +2778 -0
  13. package/dist/Datepicker.esm.js +2776 -0
  14. package/dist/Datepicker.umd.js +2784 -0
  15. package/dist/css/datepicker-bs4.css +276 -0
  16. package/dist/css/datepicker-bs4.min.css +1 -0
  17. package/dist/css/datepicker-bs5.css +276 -0
  18. package/dist/css/datepicker-bs5.min.css +1 -0
  19. package/dist/css/datepicker-bulma.css +258 -0
  20. package/dist/css/datepicker-bulma.min.css +1 -0
  21. package/dist/css/datepicker-foundation.css +262 -0
  22. package/dist/css/datepicker-foundation.min.css +1 -0
  23. package/dist/css/datepicker.css +306 -0
  24. package/dist/css/datepicker.min.css +1403 -0
  25. package/dist/js/datepicker-full.js +2777 -0
  26. package/dist/js/datepicker-full.min.js +1 -0
  27. package/dist/js/datepicker.js +2569 -0
  28. package/dist/js/datepicker.min.js +1 -0
  29. package/dist/js/locales/ar-tn.js +15 -0
  30. package/dist/js/locales/ar.js +15 -0
  31. package/dist/js/locales/az.js +14 -0
  32. package/dist/js/locales/bg.js +14 -0
  33. package/dist/js/locales/bm.js +18 -0
  34. package/dist/js/locales/bn.js +19 -0
  35. package/dist/js/locales/br.js +18 -0
  36. package/dist/js/locales/bs.js +15 -0
  37. package/dist/js/locales/ca.js +18 -0
  38. package/dist/js/locales/cs.js +19 -0
  39. package/dist/js/locales/cy.js +14 -0
  40. package/dist/js/locales/da.js +19 -0
  41. package/dist/js/locales/de.js +18 -0
  42. package/dist/js/locales/el.js +16 -0
  43. package/dist/js/locales/en-AU.js +18 -0
  44. package/dist/js/locales/en-CA.js +18 -0
  45. package/dist/js/locales/en-GB.js +18 -0
  46. package/dist/js/locales/en-IE.js +17 -0
  47. package/dist/js/locales/en-NZ.js +17 -0
  48. package/dist/js/locales/en-ZA.js +17 -0
  49. package/dist/js/locales/eo.js +17 -0
  50. package/dist/js/locales/es.js +18 -0
  51. package/dist/js/locales/et.js +18 -0
  52. package/dist/js/locales/eu.js +18 -0
  53. package/dist/js/locales/fa.js +17 -0
  54. package/dist/js/locales/fi.js +17 -0
  55. package/dist/js/locales/fo.js +15 -0
  56. package/dist/js/locales/fr-CH.js +21 -0
  57. package/dist/js/locales/fr.js +18 -0
  58. package/dist/js/locales/gl.js +16 -0
  59. package/dist/js/locales/he.js +15 -0
  60. package/dist/js/locales/hi.js +18 -0
  61. package/dist/js/locales/hr.js +13 -0
  62. package/dist/js/locales/hu.js +18 -0
  63. package/dist/js/locales/hy.js +18 -0
  64. package/dist/js/locales/id.js +15 -0
  65. package/dist/js/locales/is.js +14 -0
  66. package/dist/js/locales/it-CH.js +20 -0
  67. package/dist/js/locales/it.js +18 -0
  68. package/dist/js/locales/ja.js +17 -0
  69. package/dist/js/locales/ka.js +17 -0
  70. package/dist/js/locales/kk.js +15 -0
  71. package/dist/js/locales/km.js +15 -0
  72. package/dist/js/locales/ko.js +18 -0
  73. package/dist/js/locales/lt.js +19 -0
  74. package/dist/js/locales/lv.js +18 -0
  75. package/dist/js/locales/me.js +17 -0
  76. package/dist/js/locales/mk.js +15 -0
  77. package/dist/js/locales/mn.js +17 -0
  78. package/dist/js/locales/mr.js +18 -0
  79. package/dist/js/locales/ms.js +15 -0
  80. package/dist/js/locales/nl-BE.js +18 -0
  81. package/dist/js/locales/nl.js +18 -0
  82. package/dist/js/locales/no.js +18 -0
  83. package/dist/js/locales/oc.js +17 -0
  84. package/dist/js/locales/pl.js +17 -0
  85. package/dist/js/locales/pt-BR.js +17 -0
  86. package/dist/js/locales/pt.js +18 -0
  87. package/dist/js/locales/ro.js +17 -0
  88. package/dist/js/locales/ru.js +18 -0
  89. package/dist/js/locales/si.js +18 -0
  90. package/dist/js/locales/sk.js +18 -0
  91. package/dist/js/locales/sl.js +15 -0
  92. package/dist/js/locales/sq.js +18 -0
  93. package/dist/js/locales/sr-latn.js +16 -0
  94. package/dist/js/locales/sr.js +16 -0
  95. package/dist/js/locales/sv.js +17 -0
  96. package/dist/js/locales/sw.js +15 -0
  97. package/dist/js/locales/ta.js +18 -0
  98. package/dist/js/locales/tg.js +19 -0
  99. package/dist/js/locales/th.js +14 -0
  100. package/dist/js/locales/tk.js +18 -0
  101. package/dist/js/locales/tr.js +17 -0
  102. package/dist/js/locales/uk.js +17 -0
  103. package/dist/js/locales/uz-cyrl.js +18 -0
  104. package/dist/js/locales/uz-latn.js +18 -0
  105. package/dist/js/locales/vi.js +16 -0
  106. package/dist/js/locales/zh-CN.js +19 -0
  107. package/dist/js/locales/zh-TW.js +18 -0
  108. package/dist/locales/index.cjs.js +1028 -0
  109. package/dist/locales/index.esm.js +1028 -0
  110. package/dist/main.cjs.js +2999 -0
  111. package/dist/main.esm.js +2994 -0
  112. package/dist/main.umd.js +3005 -0
  113. package/docs/.nojekyll +0 -0
  114. package/docs/README.md +266 -0
  115. package/docs/_sidebar.md +6 -0
  116. package/docs/api.md +284 -0
  117. package/docs/date-string+format.md +90 -0
  118. package/docs/i18n.md +99 -0
  119. package/docs/images/datepicker-inline.jpg +0 -0
  120. package/docs/images/datepicker.jpg +0 -0
  121. package/docs/images/multidate.jpg +0 -0
  122. package/docs/images/picker-structure.jpg +0 -0
  123. package/docs/images/rangepicker.jpg +0 -0
  124. package/docs/images/view-days.jpg +0 -0
  125. package/docs/images/view-decades.jpg +0 -0
  126. package/docs/images/view-months.jpg +0 -0
  127. package/docs/images/view-years.jpg +0 -0
  128. package/docs/index.html +26 -0
  129. package/docs/options.md +354 -0
  130. package/docs/overview.md +174 -0
  131. package/extras/twoDigitToFullYear/test/twoDigitToFullYear.js +58 -0
  132. package/extras/twoDigitToFullYear/twoDigitToFullYear.js +26 -0
  133. package/js/DateRangePicker.js +210 -0
  134. package/js/Datepicker.js +487 -0
  135. package/js/datepicker-full.js +5 -0
  136. package/js/events/functions.js +48 -0
  137. package/js/events/inputFieldListeners.js +206 -0
  138. package/js/events/otherListeners.js +15 -0
  139. package/js/events/pickerListeners.js +70 -0
  140. package/js/i18n/base-locales.js +13 -0
  141. package/js/i18n/locales/ar-tn.js +15 -0
  142. package/js/i18n/locales/ar.js +15 -0
  143. package/js/i18n/locales/az.js +14 -0
  144. package/js/i18n/locales/bg.js +14 -0
  145. package/js/i18n/locales/bm.js +18 -0
  146. package/js/i18n/locales/bn.js +19 -0
  147. package/js/i18n/locales/br.js +18 -0
  148. package/js/i18n/locales/bs.js +15 -0
  149. package/js/i18n/locales/ca.js +18 -0
  150. package/js/i18n/locales/cs.js +19 -0
  151. package/js/i18n/locales/cy.js +14 -0
  152. package/js/i18n/locales/da.js +19 -0
  153. package/js/i18n/locales/de.js +18 -0
  154. package/js/i18n/locales/el.js +16 -0
  155. package/js/i18n/locales/en-AU.js +18 -0
  156. package/js/i18n/locales/en-CA.js +18 -0
  157. package/js/i18n/locales/en-GB.js +18 -0
  158. package/js/i18n/locales/en-IE.js +17 -0
  159. package/js/i18n/locales/en-NZ.js +17 -0
  160. package/js/i18n/locales/en-ZA.js +17 -0
  161. package/js/i18n/locales/eo.js +17 -0
  162. package/js/i18n/locales/es.js +18 -0
  163. package/js/i18n/locales/et.js +18 -0
  164. package/js/i18n/locales/eu.js +18 -0
  165. package/js/i18n/locales/fa.js +17 -0
  166. package/js/i18n/locales/fi.js +17 -0
  167. package/js/i18n/locales/fo.js +15 -0
  168. package/js/i18n/locales/fr-CH.js +21 -0
  169. package/js/i18n/locales/fr.js +18 -0
  170. package/js/i18n/locales/gl.js +16 -0
  171. package/js/i18n/locales/he.js +15 -0
  172. package/js/i18n/locales/hi.js +18 -0
  173. package/js/i18n/locales/hr.js +13 -0
  174. package/js/i18n/locales/hu.js +18 -0
  175. package/js/i18n/locales/hy.js +18 -0
  176. package/js/i18n/locales/id.js +15 -0
  177. package/js/i18n/locales/is.js +14 -0
  178. package/js/i18n/locales/it-CH.js +20 -0
  179. package/js/i18n/locales/it.js +18 -0
  180. package/js/i18n/locales/ja.js +17 -0
  181. package/js/i18n/locales/ka.js +17 -0
  182. package/js/i18n/locales/kk.js +15 -0
  183. package/js/i18n/locales/km.js +15 -0
  184. package/js/i18n/locales/ko.js +18 -0
  185. package/js/i18n/locales/lt.js +19 -0
  186. package/js/i18n/locales/lv.js +18 -0
  187. package/js/i18n/locales/me.js +17 -0
  188. package/js/i18n/locales/mk.js +15 -0
  189. package/js/i18n/locales/mn.js +17 -0
  190. package/js/i18n/locales/mr.js +18 -0
  191. package/js/i18n/locales/ms.js +15 -0
  192. package/js/i18n/locales/nl-BE.js +18 -0
  193. package/js/i18n/locales/nl.js +18 -0
  194. package/js/i18n/locales/no.js +18 -0
  195. package/js/i18n/locales/oc.js +17 -0
  196. package/js/i18n/locales/pl.js +17 -0
  197. package/js/i18n/locales/pt-BR.js +17 -0
  198. package/js/i18n/locales/pt.js +18 -0
  199. package/js/i18n/locales/ro.js +17 -0
  200. package/js/i18n/locales/ru.js +18 -0
  201. package/js/i18n/locales/si.js +18 -0
  202. package/js/i18n/locales/sk.js +18 -0
  203. package/js/i18n/locales/sl.js +15 -0
  204. package/js/i18n/locales/sq.js +18 -0
  205. package/js/i18n/locales/sr-latn.js +16 -0
  206. package/js/i18n/locales/sr.js +16 -0
  207. package/js/i18n/locales/sv.js +17 -0
  208. package/js/i18n/locales/sw.js +15 -0
  209. package/js/i18n/locales/ta.js +18 -0
  210. package/js/i18n/locales/tg.js +19 -0
  211. package/js/i18n/locales/th.js +14 -0
  212. package/js/i18n/locales/tk.js +18 -0
  213. package/js/i18n/locales/tr.js +17 -0
  214. package/js/i18n/locales/uk.js +17 -0
  215. package/js/i18n/locales/uz-cyrl.js +18 -0
  216. package/js/i18n/locales/uz-latn.js +18 -0
  217. package/js/i18n/locales/vi.js +16 -0
  218. package/js/i18n/locales/zh-CN.js +19 -0
  219. package/js/i18n/locales/zh-TW.js +18 -0
  220. package/js/lib/date-format.js +185 -0
  221. package/js/lib/date.js +82 -0
  222. package/js/lib/dom.js +55 -0
  223. package/js/lib/event.js +68 -0
  224. package/js/lib/utils.js +61 -0
  225. package/js/main.js +4 -0
  226. package/js/options/defaultOptions.js +38 -0
  227. package/js/options/processOptions.js +263 -0
  228. package/js/picker/Picker.js +334 -0
  229. package/js/picker/templates/calendarWeeksTemplate.js +8 -0
  230. package/js/picker/templates/daysTemplate.js +8 -0
  231. package/js/picker/templates/pickerTemplate.js +23 -0
  232. package/js/picker/views/DaysView.js +250 -0
  233. package/js/picker/views/MonthsView.js +198 -0
  234. package/js/picker/views/View.js +55 -0
  235. package/js/picker/views/YearsView.js +170 -0
  236. package/package.json +81 -0
  237. package/postcss.config.js +5 -0
  238. package/rollup.config.js +75 -0
  239. package/sass/_mixins.scss +12 -0
  240. package/sass/datepicker-bs4.scss +91 -0
  241. package/sass/datepicker-bs5.scss +91 -0
  242. package/sass/datepicker-bulma.scss +69 -0
  243. package/sass/datepicker-foundation.scss +66 -0
  244. package/sass/datepicker.scss +436 -0
  245. package/sass/index-bs4.scss +5 -0
  246. package/sass/index-bs5.scss +5 -0
  247. package/sass/index-bulma.scss +6 -0
  248. package/sass/index-foundation.scss +3 -0
  249. package/scripts/build-css.js +39 -0
  250. package/scripts/build-locales.js +57 -0
  251. package/scripts/convert-bsdp-locales.js +65 -0
  252. package/scripts/minify-css.js +31 -0
  253. package/scripts/minify-js.js +17 -0
  254. package/style.css +10 -0
  255. package/tailwind.config.js +16 -0
  256. package/tailwind.css +1389 -0
  257. package/test/DateRangePicker/DateRangePicker.js +547 -0
  258. package/test/DateRangePicker/api-methods.js +415 -0
  259. package/test/DateRangePicker/date-selection.js +472 -0
  260. package/test/DateRangePicker/options.js +308 -0
  261. package/test/Datepicker/Datepicker-object.js +236 -0
  262. package/test/Datepicker/api-methods.js +328 -0
  263. package/test/_utils/date.js +102 -0
  264. package/test/_utils/dom.js +70 -0
  265. package/test/events.js +785 -0
  266. package/test/inline-mode.js +45 -0
  267. package/test/keyboard-operation/arrow-down.js +293 -0
  268. package/test/keyboard-operation/arrow-left.js +255 -0
  269. package/test/keyboard-operation/arrow-right.js +215 -0
  270. package/test/keyboard-operation/arrow-up.js +461 -0
  271. package/test/keyboard-operation/edit-mode.js +458 -0
  272. package/test/keyboard-operation/keyboard-operation.js +146 -0
  273. package/test/mouse-operation.js +580 -0
  274. package/test/options/before-show.js +635 -0
  275. package/test/options/bulma-datepicker.sublime-workspace +1280 -0
  276. package/test/options/buttons.js +383 -0
  277. package/test/options/date-restrictions.js +802 -0
  278. package/test/options/format.js +281 -0
  279. package/test/options/multidate.js +380 -0
  280. package/test/options/options.js +727 -0
  281. package/test/options/orientation.js +410 -0
  282. package/test/options/pick-levle+view.js +357 -0
  283. package/test/test.html +94 -0
  284. package/test/unit/DateRangePicker.js +192 -0
  285. package/test/unit/Datepicker.js +307 -0
  286. package/test/unit/_setup.js +28 -0
  287. package/test/unit/lib/date-format.js +310 -0
  288. package/test/unit/lib/date.js +211 -0
  289. package/test/unit/lib/dom.js +142 -0
  290. package/test/unit/lib/event.js +207 -0
  291. package/test/unit/lib/utils.js +135 -0
package/docs/i18n.md ADDED
@@ -0,0 +1,99 @@
1
+ # Internationalization (i18n)
2
+
3
+ Internationalization of Datepicker is done by adding languages' locales (month and day names, button labels, date format and start of the week) to `Datepicker.locales`.
4
+ `en`:_English (US)_ is the pre-installed default language and also used as the fallback language.
5
+
6
+ > The package includes locale files taken from [bootstrap-datepicker](https://github.com/uxsolutions/bootstrap-datepicker).
7
+
8
+ ## Adding languages
9
+
10
+ Import the ones you need and merge them with `Datepicker.locales`.
11
+
12
+ ```javascript
13
+ import Datepicker from 'path/to/node_modules/vanillajs-datepicker/js/Datepicker.js';
14
+ import es from 'path/to/node_modules/vanillajs-datepicker/js/i18n/locales/es.js';
15
+ import fr from 'path/to/node_modules/vanillajs-datepicker/js/i18n/locales/fr.js';
16
+ import zhCN from 'path/to/node_modules/vanillajs-datepicker/js/i18n/locales/zh-CN.js';
17
+
18
+ Object.assign(Datepicker.locales, es, fr, zhCN);
19
+ ```
20
+
21
+ _Or if you use a bundler that supports [package entry points](https://nodejs.org/api/packages.html#packages_package_entry_points) (e.g. [Rollup](https://rollupjs.org/) with [node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve) plugin v8.4+, [webpack](https://webpack.js.org/) v5+)_
22
+
23
+ ```javascript
24
+ import Datepicker from 'vanillajs-datepicker/Datepicker';
25
+ import es from 'vanillajs-datepicker/locales/es';
26
+ import fr from 'vanillajs-datepicker/locales/fr';
27
+ import zhCN from 'vanillajs-datepicker/locales/zh-CN';
28
+
29
+ Object.assign(Datepicker.locales, es, fr, zhCN);
30
+ ```
31
+
32
+ ##### for browser
33
+
34
+ Load the locale files you need after Datepicker
35
+
36
+ ```html
37
+ <script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/js/datepicker-full.min.js"></script>
38
+ <script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/js/locales/es.js"></script>
39
+ <script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/js/locales/fr.js"></script>
40
+ <script src="https://cdn.jsdelivr.net/npm/vanillajs-datepicker@1.1.4/dist/js/locales/zh-CN.js"></script>
41
+ ```
42
+
43
+ ### Custom locale
44
+
45
+ If needed, you can create your custom locale file by modifying the following template.
46
+
47
+ ```javascript
48
+ /**
49
+ * English translation
50
+ */
51
+ export default {
52
+ en: {
53
+ days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
54
+ daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
55
+ daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
56
+ months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
57
+ monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
58
+ today: "Today",
59
+ clear: "Clear",
60
+ titleFormat: "MM y",
61
+ format: "mm/dd/yyyy",
62
+ weekStart: 0
63
+ }
64
+ };
65
+ ```
66
+ > You can omit properties that can fallback to `en`:_English (US)_.
67
+ >
68
+ > **for browser:**
69
+ > ```javascript
70
+ > /**
71
+ > * English translation
72
+ > */
73
+ > (function () {
74
+ > Datepicker.locales.en = {
75
+ > //... same properties as the above
76
+ > }
77
+ > })();
78
+ > ```
79
+
80
+
81
+ Locale must be named with language code. The code can be arbitrary, but should comply with [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag).
82
+
83
+
84
+ ## Text Direction
85
+
86
+ Text direction handling of Datepicker is mainly done by stylesheet and completely separated from its language configuration.
87
+
88
+ The picker element is styled to follow the container element's text direction. If the direction of the associated input field is different from it, date picker automatically detects the difference and sets the picker element's `dir` attribute so that the direction matches the input field's.
89
+
90
+ > **When customizing the prev/next button**
91
+ >
92
+ > The default of the prev/next button arrows are a pair of a parenthesis variant, which automatically flip according to text direction. If you customize the arrows with something other than parenthesis characters, you may need to add a style like below to your project's CSS in order for the arrows to flip automatically.
93
+ >
94
+ > ```css
95
+ > [dir="rtl"] .datepicker-controls .prev-btn,
96
+ > [dir="rtl"] .datepicker-controls .next-btn {
97
+ > transform: scaleX(-1);
98
+ > }
99
+ >```
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>vannilajs-datepicker - Vanilla JS datepicker for Bulma and other CSS frameworks</title>
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7
+ <meta name="description" content="A vanilla JavaScript remake of bootstrap-datepicker for Bulma and other CSS frameworks">
8
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9
+ <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
10
+ </head>
11
+ <body>
12
+ <div id="app"></div>
13
+ <script>
14
+ window.$docsify = {
15
+ name: 'vanillajs-datepicker',
16
+ repo: 'https://github.com/mymth/vanillajs-datepicker',
17
+ loadSidebar: true,
18
+ subMaxLevel: 4,
19
+ auto2top: true,
20
+ };
21
+ </script>
22
+ <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
23
+ <script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
24
+ <script src="//unpkg.com/prismjs/components/prism-scss.min.js"></script>
25
+ </body>
26
+ </html>
@@ -0,0 +1,354 @@
1
+ # Options
2
+
3
+ There are 2 kinds of config options: the Datepicker options and the DateRangePicker options. The former are for `DatePicker` object and the latter are for `DateRangePicker` object.
4
+
5
+ Datepicker options can be used with date range picker. And when doing so, you can pass them mixing with DateRangePicker options into one "options" object.
6
+
7
+ > Datepicker options passed to date range picker are applied to its start- and end-date pickers.
8
+
9
+ Aside from a couple of exceptions, config options can be updated dynamically using the `setOptions()` method.
10
+
11
+ ### Datepicker Options
12
+
13
+ #### autohide
14
+ - Type: `Boolean`
15
+ - Default: `false`
16
+
17
+ Whether to hide the date picker immediately after a date is selected.
18
+
19
+ > Not available on inline picker.
20
+
21
+ #### beforeShowDay
22
+ - Type: `Function`
23
+ - Default: `null`
24
+
25
+ Function to customize the day cells in the days view. The function is called when each day cell is rendered.
26
+
27
+ - **function**
28
+ - Arguments:
29
+ - `date`: {`Date`} - Date associated with the cell
30
+ - Return:
31
+ - {`Object`} - Things to customize. Available properties are:
32
+ - `enabled`: {`Boolean`} - whether the cell is selectable
33
+ - `classes`: {`String`} - space-separated additional CSS classes for the cell element
34
+ - `content`: {`String`} - HTML for the cell element's child nodes
35
+ - {`String`} - additional classes — same as returning `{ classes: additionalClasses }`
36
+ - {`Boolean`} - whether the cell is selectable — same as returning `{ enabled: isSelectable }`
37
+
38
+ ```javascript
39
+ function (date) {
40
+ let isSelectable, additionalClasses, htmlFragment;
41
+ //...your customization logic
42
+
43
+ return {
44
+ enabled: isSelectable,
45
+ classes: additionalClasses,
46
+ content: htmlFragment,
47
+ };
48
+ // Or
49
+ return additionalClasses;
50
+ // Or
51
+ return isSelectable;
52
+ }
53
+ ```
54
+
55
+ #### beforeShowDecade
56
+ - Type: `Function`
57
+ - Default: `null`
58
+
59
+ Function to customize the decade cells in the decades view. The function is called when each decade cell is rendered.
60
+ > See [`beforeShowDay`](#beforeShowDay) for the function details.
61
+
62
+ #### beforeShowMonth
63
+ - Type: `Function`
64
+ - Default: `null`
65
+
66
+ Function to customize the month cells in the months view. The function is called when each month cell is rendered.
67
+ > See [`beforeShowDay`](#beforeShowDay) for the function details.
68
+
69
+ #### beforeShowYear
70
+ - Type: `Function`
71
+ - Default: `null`
72
+
73
+ Function to customize the year cells in the years view. The function is called when each year cell is rendered.
74
+ > See [`beforeShowDay`](#beforeShowDay) for the function details.
75
+
76
+ #### buttonClass
77
+ - Type: `String`
78
+ - Default: `'button'`
79
+
80
+ CSS class for `<button>` elements. (view switch, prev/next buttons, clear and today buttons)
81
+
82
+ > For constructor only. Cannot be used with `setOptions()`.
83
+
84
+ #### calendarWeeks
85
+ - Type: `Boolean`
86
+ - Default: `false`
87
+
88
+ Whether to show the week number ([ISO week](https://en.wikipedia.org/wiki/ISO_week_date)) on week rows.
89
+
90
+ #### clearBtn
91
+ - Type: `Boolean`
92
+ - Default: `false`
93
+
94
+ Whether to show the clear button.
95
+
96
+ #### container
97
+ - Type: `String`
98
+ - Default: `body`
99
+
100
+ CSS selector for the element to append the date picker.
101
+
102
+ > For constructor only. Cannot be used with `setOptions()`.
103
+ > On inline picker, this option is ignored and overwritten to the associated element.
104
+
105
+ #### dateDelimiter
106
+ - Type: `String`
107
+ - Default: `','`
108
+
109
+ Delimiter string to separate the dates in a multi-date string.
110
+
111
+ > The delimiter must not be included in date format string.
112
+
113
+ #### datesDisabled
114
+ - Type: `Array`
115
+ - Default: `[]`
116
+
117
+ Dates to disable. Array of date strings, Date objects, time values or mix of those.
118
+
119
+ > Multi-date string cannot be used. Use multiple single-date strings instead.
120
+
121
+ #### daysOfWeekDisabled
122
+ - Type: `Number[]`
123
+ - Default: `[]`
124
+
125
+ Days of the week to disable. `0`:_Sunday_ – `6`:_Saturday_, up to 6 items.
126
+
127
+ #### daysOfWeekHighlighted
128
+ - Type: `Number[]`
129
+ - Default: `[]`
130
+
131
+ Days of the week to highlight. `0`:_Sunday_ – `6`:_Saturday_, up to 6 items.
132
+
133
+ #### defaultViewDate
134
+ - Type: `String`|`Date`|`Number`
135
+ - Default: current date
136
+
137
+ The date to be focused when the date picker opens with no selected date(s).
138
+
139
+ #### disableTouchKeyboard
140
+ - Type: `Boolean`
141
+ - Default: `false`
142
+
143
+ Whether to prevent on-screen keyboard on mobile devices from showing up when the associated input field receives focus.
144
+
145
+ > Not available on inline picker.
146
+
147
+ #### format
148
+ - Type: `String`|`Object`
149
+ - Default: `'mm/dd/yyyy'`
150
+
151
+ [Date format](date-string+format?id=date-format) string.
152
+
153
+ > The format string must not include the [dateDelimiter](options?id=datedelimiter) string.
154
+
155
+ Alternatively, object that contains custom parser and formatter functions can be used.
156
+
157
+ - **Parser**
158
+ - Property \(function\) name: `toValue`
159
+ - Arguments:
160
+ - `date`: {`String`|`Date`|`Number`} - date string, Date object or time value to parse
161
+ - `format`: {`Object`} - format object itself
162
+ - `locale`: {`Object`} - locale of the current language
163
+ - Return:
164
+ - {`Date`} - parsed date object
165
+ - **Formatter**
166
+ - Property \(function\) name: `toDisplay`
167
+ - Arguments::
168
+ - `date`: {`Date`} - date object to format
169
+ - `format`: {`Object`} - format object itself
170
+ - `locale`: {`Object`} - locale of the current language
171
+ - Return:
172
+ - {`String`} - formated date
173
+
174
+ ```javascript
175
+ {
176
+ format: {
177
+ toValue(date, format, locale) {
178
+ let dateObject;
179
+ //...your custom parse logic
180
+ return dateObject;
181
+ },
182
+ toDisplay(date, format, locale) {
183
+ let dateString;
184
+ //...your custom format logic
185
+ return dateString;
186
+ },
187
+ },
188
+ }
189
+ ```
190
+
191
+ #### language
192
+ - Type: `String`
193
+ - Default: `'en'`
194
+
195
+ The language code of the language used by the date picker.
196
+
197
+ > For languages other than `en` to work, their locales must be loaded into your project/program.
198
+ > See [i18n](i18n) for the details.
199
+
200
+ #### maxDate
201
+ - Type: `String`|`Date`|`Number`
202
+ - Default: `null`
203
+
204
+ Maximum limit to selectable date. No limit is applied if `null` is set.
205
+
206
+ #### maxNumberOfDates
207
+ - Type: `Number`
208
+ - Default: `1`
209
+
210
+ Maximum number of dates users can select. No limit is applied if `0` is set.
211
+
212
+ > Not available for date range picker.
213
+
214
+ #### maxView
215
+ - Type: Number
216
+ - Default: `3`
217
+
218
+ Maximum limit to the view that the date picker displays. `0`:_days_ – `3`:_decades_.
219
+
220
+ #### minDate
221
+ - Type: `String`|`Date`|`Number`
222
+ - Default: `null`
223
+
224
+ Minimum limit to selectable date. No limit is applied if `null` is set.
225
+
226
+ #### nextArrow
227
+ - Type: `String`
228
+ - Default: `'»'`
229
+
230
+ HTML (or plain text) for the button label of the "Next" button.
231
+
232
+ > See the note in [i18n ≻ Text Direction](i18n?id=text-direction) when using with RTL languages.
233
+
234
+ #### orientation
235
+ - Type: `String`
236
+ - Default: `'auto'`
237
+
238
+ Space-separated string for date picker's horizontal and vertical placement to the associated input field. `left`|`right`|`auto` for horizontal and `top`|`bottom`|`auto` for vertical.
239
+
240
+ > The order can be random.
241
+ > If one direction is omitted, it falls back to `auto`. (e.g. `'top'` == `'top auto'`)
242
+ > Not available on inline picker.
243
+
244
+ #### pickLevel
245
+ - Type: `Number`
246
+ - Default: `0`
247
+
248
+ The level that the date picker allows to pick. `0`:_date_,`1`: _month_ &nbsp;or `2`:_year_.
249
+
250
+ > When this option is `1`, the selected date becomes the 1st of the month or, if the date picker is the end-date picker of date range picker, the last day of the month.
251
+ > When this option is `2`, the selected date becomes January 1st of the year or, if the date picker is the end-date picker of date range picker, December 31st of the year.
252
+
253
+ #### prevArrow
254
+ - Type: `String`
255
+ - Default: `'«'`
256
+
257
+ HTML (or plain text) for the button label of the "Prev" button.
258
+
259
+ > See the note in [i18n ≻ Text Direction](i18n?id=text-direction) when using with RTL languages.
260
+
261
+ #### showDaysOfWeek
262
+ - Type: `Boolean`
263
+ - Default: `true`
264
+
265
+ Whether to show the day names of the week.
266
+
267
+ #### showOnClick
268
+ - Type: `Boolean`
269
+ - Default: `true`
270
+
271
+ Whether to show the date picker when the associated input filed is clicked.
272
+
273
+ > Not available on inline picker.
274
+
275
+ #### showOnFocus
276
+ - Type: `Boolean`
277
+ - Default: `true`
278
+
279
+ Whether to show the date picker automatically when the associated input filed receives focus.
280
+
281
+ > Not available on inline picker.
282
+
283
+ #### startView
284
+ - Type: `Number`
285
+ - Default: `0`
286
+
287
+ The view displayed when the date picker opens. `0`:_days_ – `3`:_decades_.
288
+
289
+ #### title
290
+ - Type: `String`
291
+ - Default: `''`
292
+
293
+ Title string shown in the date picker's title bar.
294
+
295
+ > The title bar is not displayed if the title is empty.
296
+
297
+ #### todayBtn
298
+ - Type: `Boolean`
299
+ - Default: `false`
300
+
301
+ Whether to show the today button.
302
+
303
+ #### todayBtnMode
304
+ - Type: `Number`
305
+ - Default: `0`
306
+
307
+ The mode how the today button behaves.
308
+
309
+ Mode | Name | Description
310
+ --|--|--
311
+ `0` | focus | Move the focused date to the current date without changing the selection
312
+ `1` | select | Select (or toggle the selection of) the current date
313
+
314
+ #### todayHighlight
315
+ - Type: `Boolean`
316
+ - Default: `false`
317
+
318
+ Whether to highlight the current date.
319
+
320
+ #### updateOnBlur
321
+ - Type: `Boolean`
322
+ - Default: `true`
323
+
324
+ Whether to update the selected date(s) with the input field's value when the input field is losing focus.
325
+
326
+ > When this option is `false`, if the user edits the date string in input field, it will be parsed and applied only when the user presses the <kbd>Enter</kbd> key. If the edit is left unparsed, it will be discarded when input field becomes unfocused (by <kbd>Tab</kbd> key press or click outside the picker element/input field).
327
+ >
328
+ > Not available on inline picker.
329
+
330
+ #### weekStart
331
+ - Type: `Number`
332
+ - Default: `0`
333
+
334
+ Start day of the week. `0`:_Sunday_ – `6`:_Saturday_.
335
+
336
+
337
+ ### DateRangePicker Options
338
+
339
+ #### allowOneSidedRange
340
+ - Type: `Boolean`
341
+ - Default: `false`
342
+
343
+ Whether to allow one side of the date-range to be blank.
344
+
345
+ > When this option is `false`, if the user selects a date on one side while the other side is blank, the date range picker complements the blank side with the same date as the selected side.
346
+ > Similarly, if the user clears one side of the date-range, the date range picker also clears the other side automatically.
347
+
348
+ #### inputs
349
+ - Type: `Element[]`
350
+ - Default: `input` elements inside the associated block element
351
+
352
+ Input fields to attach start- and end-date pickers. Must contain 2 items.
353
+
354
+ > For constructor only. Cannot be used with `setOptions()`.
@@ -0,0 +1,174 @@
1
+ # Overview
2
+
3
+ ## Types
4
+
5
+ ##### Date picker (regular/text-input picker)
6
+
7
+ When Datepicker object is attached to an `<input>` element, it's configured as a regular date picker.
8
+
9
+ ![](./images/datepicker.jpg)
10
+
11
+ ##### Inline picker
12
+
13
+ When Datepicker object is attached to a block element, it's configured as an inline picker.
14
+
15
+ ![](./images/datepicker-inline.jpg)
16
+
17
+ - The picker element is embedded to the block element. (always shown)
18
+ - Initial selection can be set in the `data-date` attribute
19
+ - Inline picker does not support operation by keyboard.
20
+
21
+ ##### Date range picker
22
+
23
+ Date range picker is essentially a wrapper/controller of 2 date pickers. It's the only type of DateRangePicker object.
24
+
25
+ ![](./images/rangepicker.jpg)
26
+
27
+ - Date range picker cannot be attached to elements that contain less than 2 `<input>` elements
28
+ - Regular date picker is attached to each of `<input>` elements
29
+
30
+
31
+ ## Picker Element
32
+
33
+ ![](./images/picker-structure.jpg)
34
+
35
+ 1. **Title bar**
36
+ 2. **View switch**:
37
+ Button to change the view from days to months, months to years and years to decades
38
+ The button label is used for the title of view contents.
39
+ 3. **Prev button**:
40
+ Button to change the contents of the current view to the previous month/year/decade/century
41
+ 4. **Next button**:
42
+ Button to change the contents of the current view to the next month/year/decade/century
43
+ 5. **View**:
44
+ Area to display a calendar (for days) or a grid of months, years, or decades
45
+ 6. **Cell**:
46
+ Block for each day, month, year or decade
47
+ It works as a select button in days view. In the other views, it works as a button to change the view to the period of time it represents. (months view → days view of the month, years → months of the year, decades → years of the decade)
48
+ 7. **Today button**:
49
+ Button to jump to the current date
50
+ It can be customized to select the current date.
51
+ 8. **Clear button**:
52
+ Button to clear the selection
53
+
54
+ ##### Days view
55
+
56
+ The view to select a date. The days are displayed in monthly calendar layout. Optionally, ISO week numbers can be shown in the view.
57
+
58
+ ![](./images/view-days.jpg)
59
+
60
+ ##### Months view
61
+
62
+ The view to select a month. The months are shown in short name.
63
+
64
+ ![](./images/view-months.jpg)
65
+
66
+ ##### Years view
67
+
68
+ The view to select a year.
69
+
70
+ ![](./images/view-years.jpg)
71
+
72
+ ##### Decades view
73
+
74
+ The view to select a decade.
75
+
76
+ ![](./images/view-decades.jpg)
77
+
78
+
79
+ ## Multidate Mode
80
+
81
+ When [`maxNumberOfDates`](options?id=maxnumberofdates) config option is set to other than `1`, date picker turns to the multdate mode.
82
+
83
+ In this mode, the day cells in the days view act as toggle switch of the date's select status. The order of selection is kept; newly selected date is appended to the existing selection and the oldest item in the selection drops if the number of selected dates exceeds the option's value.
84
+ In the input field, selected dates are joined with the delimiter string set in the [`dateDelimiter`](options?id=dateDelimiter) config option.
85
+
86
+ ![](./images/multidate.jpg)
87
+
88
+ Multidate mode is not applied to the pickers of date range picker.
89
+
90
+ ## Providing date
91
+
92
+ Datepicker accepts [date string](date-string+format), Date object or [time value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Time_value_or_timestamp_number) for the source of a date. All given dates are parsed/converted into the internal date value individually.
93
+
94
+ > The time value of local time `00:00:00.000` of the date is used for the internal date value.
95
+
96
+ The dates before _January 1st, 0000_ are not supported because the built-in parser cannot handle negative numbers. (`-` sign is one of the predefined separator characters)
97
+
98
+ To provide dates for config options or API method arguments, you can just follow the above general rules.
99
+
100
+ ##### Initial selection
101
+
102
+ To provide initial date selection to a date picker, you can set a date string to the `<input>` element's `value` attribute. This also works for date range picker's `<input>` elements.
103
+
104
+ For inline picker, you can set a date string to the `data-date` attribute of the element to attach the picker.
105
+
106
+ ##### Input field
107
+
108
+ You can update the selected date by editing the date string in the input field.
109
+
110
+ > Since the built-in parser is very tolerant of format errors, a small typing error can cause an unexpected (and sometimes unimaginable) date in the input field. _(See [How Built-in Parser parses](./date-string+format?id=how-built-in-parser-parses))_
111
+ > If you think this is not good, you might want to consider using the [`updateOnBlur`](./options?id=updateonblur):`false` config option in order to implicitly nudge users to look at their input.
112
+
113
+ ## Keyboard Operation
114
+
115
+ You can operate date picker using keyboard. Here are the available keyboard operations.
116
+
117
+ **When picker is hidden**
118
+
119
+ - <KBD>**↓**</KBD> (arrowDown)**,** <kbd>**Esc**</kbd> **:**
120
+ Show the picker
121
+ - <kbd>**Enter**</kbd> **:**
122
+ Update the picker with the input field's value
123
+
124
+ **When picker is shown**
125
+
126
+ - <kbd>**Esc**</kbd> **:**
127
+ Hide the picker
128
+ - <kbd>**←**</kbd> (arrowLeft)**,** <kbd>**→**</kbd> (arrowRight) **:**
129
+ Move focused date/month/year/decade 1 step horizontally
130
+ - <kbd>**↑**</kbd> (arrowUp)**,** <kbd>**↓**</kbd> (arrowDown) **:**
131
+ Move focused date/month/year/decade 1 step vertically
132
+ - <kbd>**Ctrl**</kbd> (or <kbd>Meta</kbd>) **+** <kbd>**←**</kbd> (arrowLeft) **:**
133
+ Move to previous month/year/decade/century _(Shortcut of the "Prev" button)_
134
+ - <kbd>**Ctrl**</kbd> (or <kbd>Meta</kbd>) **+** <kbd>**→**</kbd> (arrowRight) **:**
135
+ Move to next month/year/decade/century _(Shortcut of the "Next" button)_
136
+ - <kbd>**Ctrl**</kbd> (or <kbd>Meta</kbd>) **+** <kbd>**↑**</kbd> (arrowUp) **:**
137
+ Change the view upward _(Shortcut of the view switch)_
138
+ - <kbd>**Enter**</kbd> **:**
139
+ - *when days view is shown:*
140
+ Select the focused date
141
+ - *otherwise:*
142
+ Change the view downward for the focused decade/year/month
143
+ - <kbd>**Backspace**</kbd>**,** <kbd>**Delete**</kbd>**, any printable character,** <kbd>**Shift**</kbd> **+ either of arrow keys** ( <kbd>←</kbd>/<kbd>→</kbd>/<kbd>↑</kbd>/<kbd>↓</kbd> ) **:**
144
+ Enter [edit mode](overview?id=edit-mode)
145
+
146
+ **When in [edit mode](overview?id=edit-mode)**
147
+
148
+ - <kbd>**Esc**</kbd> **:**
149
+ Hide the picker exiting edit mode
150
+ - <kbd>**Enter**</kbd> **:**
151
+ Exit edit mode updating the picker with the change on the input field
152
+
153
+ > Note: Keyboard operation is not supported by inline picker.
154
+
155
+ ## Edit Mode
156
+
157
+ When the picker element is shown, date picker (in the primary state) captures key-press events and uses them to control the picker element. Therefore, users cannot edit the `<input>` element in this state.
158
+ To solve this, Datepicker has the edit mode.
159
+
160
+ Date picker automatically enters edit mode when:
161
+
162
+ - the `<input>` element is clicked
163
+ - <kbd>Backspace</kbd>, <kbd>Delete</kbd> or any of printable character key is pressed (without control/meta key).
164
+ - <kbd>Shift</kbd> + either of arrow keys ( <kbd>←</kbd>/<kbd>→</kbd>/<kbd>↑</kbd>/<kbd>↓</kbd> ) is pressed (without control/meta key).
165
+
166
+ and exits edit mode when:
167
+
168
+ - <kbd>Enter</kbd> key or <kbd>Esc</kbd> key is pressed
169
+ - the picker element becomes hidden
170
+
171
+ While date picker is in edit mode,
172
+
173
+ - highlight of the `<input>` element becomes more prominent
174
+ - keyboard operation of the picker element is temporarily disabled