@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.
- package/.eslintignore +2 -0
- package/.eslintrc.js +73 -0
- package/.stylelintrc +12 -0
- package/CHANGELOG.md +72 -0
- package/LICENSE +21 -0
- package/README.md +71 -0
- package/demo/index.html +582 -0
- package/demo/live-demo.js +471 -0
- package/dist/DateRangePicker.cjs.js +2996 -0
- package/dist/DateRangePicker.esm.js +2994 -0
- package/dist/DateRangePicker.umd.js +3002 -0
- package/dist/Datepicker.cjs.js +2778 -0
- package/dist/Datepicker.esm.js +2776 -0
- package/dist/Datepicker.umd.js +2784 -0
- package/dist/css/datepicker-bs4.css +276 -0
- package/dist/css/datepicker-bs4.min.css +1 -0
- package/dist/css/datepicker-bs5.css +276 -0
- package/dist/css/datepicker-bs5.min.css +1 -0
- package/dist/css/datepicker-bulma.css +258 -0
- package/dist/css/datepicker-bulma.min.css +1 -0
- package/dist/css/datepicker-foundation.css +262 -0
- package/dist/css/datepicker-foundation.min.css +1 -0
- package/dist/css/datepicker.css +306 -0
- package/dist/css/datepicker.min.css +1403 -0
- package/dist/js/datepicker-full.js +2777 -0
- package/dist/js/datepicker-full.min.js +1 -0
- package/dist/js/datepicker.js +2569 -0
- package/dist/js/datepicker.min.js +1 -0
- package/dist/js/locales/ar-tn.js +15 -0
- package/dist/js/locales/ar.js +15 -0
- package/dist/js/locales/az.js +14 -0
- package/dist/js/locales/bg.js +14 -0
- package/dist/js/locales/bm.js +18 -0
- package/dist/js/locales/bn.js +19 -0
- package/dist/js/locales/br.js +18 -0
- package/dist/js/locales/bs.js +15 -0
- package/dist/js/locales/ca.js +18 -0
- package/dist/js/locales/cs.js +19 -0
- package/dist/js/locales/cy.js +14 -0
- package/dist/js/locales/da.js +19 -0
- package/dist/js/locales/de.js +18 -0
- package/dist/js/locales/el.js +16 -0
- package/dist/js/locales/en-AU.js +18 -0
- package/dist/js/locales/en-CA.js +18 -0
- package/dist/js/locales/en-GB.js +18 -0
- package/dist/js/locales/en-IE.js +17 -0
- package/dist/js/locales/en-NZ.js +17 -0
- package/dist/js/locales/en-ZA.js +17 -0
- package/dist/js/locales/eo.js +17 -0
- package/dist/js/locales/es.js +18 -0
- package/dist/js/locales/et.js +18 -0
- package/dist/js/locales/eu.js +18 -0
- package/dist/js/locales/fa.js +17 -0
- package/dist/js/locales/fi.js +17 -0
- package/dist/js/locales/fo.js +15 -0
- package/dist/js/locales/fr-CH.js +21 -0
- package/dist/js/locales/fr.js +18 -0
- package/dist/js/locales/gl.js +16 -0
- package/dist/js/locales/he.js +15 -0
- package/dist/js/locales/hi.js +18 -0
- package/dist/js/locales/hr.js +13 -0
- package/dist/js/locales/hu.js +18 -0
- package/dist/js/locales/hy.js +18 -0
- package/dist/js/locales/id.js +15 -0
- package/dist/js/locales/is.js +14 -0
- package/dist/js/locales/it-CH.js +20 -0
- package/dist/js/locales/it.js +18 -0
- package/dist/js/locales/ja.js +17 -0
- package/dist/js/locales/ka.js +17 -0
- package/dist/js/locales/kk.js +15 -0
- package/dist/js/locales/km.js +15 -0
- package/dist/js/locales/ko.js +18 -0
- package/dist/js/locales/lt.js +19 -0
- package/dist/js/locales/lv.js +18 -0
- package/dist/js/locales/me.js +17 -0
- package/dist/js/locales/mk.js +15 -0
- package/dist/js/locales/mn.js +17 -0
- package/dist/js/locales/mr.js +18 -0
- package/dist/js/locales/ms.js +15 -0
- package/dist/js/locales/nl-BE.js +18 -0
- package/dist/js/locales/nl.js +18 -0
- package/dist/js/locales/no.js +18 -0
- package/dist/js/locales/oc.js +17 -0
- package/dist/js/locales/pl.js +17 -0
- package/dist/js/locales/pt-BR.js +17 -0
- package/dist/js/locales/pt.js +18 -0
- package/dist/js/locales/ro.js +17 -0
- package/dist/js/locales/ru.js +18 -0
- package/dist/js/locales/si.js +18 -0
- package/dist/js/locales/sk.js +18 -0
- package/dist/js/locales/sl.js +15 -0
- package/dist/js/locales/sq.js +18 -0
- package/dist/js/locales/sr-latn.js +16 -0
- package/dist/js/locales/sr.js +16 -0
- package/dist/js/locales/sv.js +17 -0
- package/dist/js/locales/sw.js +15 -0
- package/dist/js/locales/ta.js +18 -0
- package/dist/js/locales/tg.js +19 -0
- package/dist/js/locales/th.js +14 -0
- package/dist/js/locales/tk.js +18 -0
- package/dist/js/locales/tr.js +17 -0
- package/dist/js/locales/uk.js +17 -0
- package/dist/js/locales/uz-cyrl.js +18 -0
- package/dist/js/locales/uz-latn.js +18 -0
- package/dist/js/locales/vi.js +16 -0
- package/dist/js/locales/zh-CN.js +19 -0
- package/dist/js/locales/zh-TW.js +18 -0
- package/dist/locales/index.cjs.js +1028 -0
- package/dist/locales/index.esm.js +1028 -0
- package/dist/main.cjs.js +2999 -0
- package/dist/main.esm.js +2994 -0
- package/dist/main.umd.js +3005 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +266 -0
- package/docs/_sidebar.md +6 -0
- package/docs/api.md +284 -0
- package/docs/date-string+format.md +90 -0
- package/docs/i18n.md +99 -0
- package/docs/images/datepicker-inline.jpg +0 -0
- package/docs/images/datepicker.jpg +0 -0
- package/docs/images/multidate.jpg +0 -0
- package/docs/images/picker-structure.jpg +0 -0
- package/docs/images/rangepicker.jpg +0 -0
- package/docs/images/view-days.jpg +0 -0
- package/docs/images/view-decades.jpg +0 -0
- package/docs/images/view-months.jpg +0 -0
- package/docs/images/view-years.jpg +0 -0
- package/docs/index.html +26 -0
- package/docs/options.md +354 -0
- package/docs/overview.md +174 -0
- package/extras/twoDigitToFullYear/test/twoDigitToFullYear.js +58 -0
- package/extras/twoDigitToFullYear/twoDigitToFullYear.js +26 -0
- package/js/DateRangePicker.js +210 -0
- package/js/Datepicker.js +487 -0
- package/js/datepicker-full.js +5 -0
- package/js/events/functions.js +48 -0
- package/js/events/inputFieldListeners.js +206 -0
- package/js/events/otherListeners.js +15 -0
- package/js/events/pickerListeners.js +70 -0
- package/js/i18n/base-locales.js +13 -0
- package/js/i18n/locales/ar-tn.js +15 -0
- package/js/i18n/locales/ar.js +15 -0
- package/js/i18n/locales/az.js +14 -0
- package/js/i18n/locales/bg.js +14 -0
- package/js/i18n/locales/bm.js +18 -0
- package/js/i18n/locales/bn.js +19 -0
- package/js/i18n/locales/br.js +18 -0
- package/js/i18n/locales/bs.js +15 -0
- package/js/i18n/locales/ca.js +18 -0
- package/js/i18n/locales/cs.js +19 -0
- package/js/i18n/locales/cy.js +14 -0
- package/js/i18n/locales/da.js +19 -0
- package/js/i18n/locales/de.js +18 -0
- package/js/i18n/locales/el.js +16 -0
- package/js/i18n/locales/en-AU.js +18 -0
- package/js/i18n/locales/en-CA.js +18 -0
- package/js/i18n/locales/en-GB.js +18 -0
- package/js/i18n/locales/en-IE.js +17 -0
- package/js/i18n/locales/en-NZ.js +17 -0
- package/js/i18n/locales/en-ZA.js +17 -0
- package/js/i18n/locales/eo.js +17 -0
- package/js/i18n/locales/es.js +18 -0
- package/js/i18n/locales/et.js +18 -0
- package/js/i18n/locales/eu.js +18 -0
- package/js/i18n/locales/fa.js +17 -0
- package/js/i18n/locales/fi.js +17 -0
- package/js/i18n/locales/fo.js +15 -0
- package/js/i18n/locales/fr-CH.js +21 -0
- package/js/i18n/locales/fr.js +18 -0
- package/js/i18n/locales/gl.js +16 -0
- package/js/i18n/locales/he.js +15 -0
- package/js/i18n/locales/hi.js +18 -0
- package/js/i18n/locales/hr.js +13 -0
- package/js/i18n/locales/hu.js +18 -0
- package/js/i18n/locales/hy.js +18 -0
- package/js/i18n/locales/id.js +15 -0
- package/js/i18n/locales/is.js +14 -0
- package/js/i18n/locales/it-CH.js +20 -0
- package/js/i18n/locales/it.js +18 -0
- package/js/i18n/locales/ja.js +17 -0
- package/js/i18n/locales/ka.js +17 -0
- package/js/i18n/locales/kk.js +15 -0
- package/js/i18n/locales/km.js +15 -0
- package/js/i18n/locales/ko.js +18 -0
- package/js/i18n/locales/lt.js +19 -0
- package/js/i18n/locales/lv.js +18 -0
- package/js/i18n/locales/me.js +17 -0
- package/js/i18n/locales/mk.js +15 -0
- package/js/i18n/locales/mn.js +17 -0
- package/js/i18n/locales/mr.js +18 -0
- package/js/i18n/locales/ms.js +15 -0
- package/js/i18n/locales/nl-BE.js +18 -0
- package/js/i18n/locales/nl.js +18 -0
- package/js/i18n/locales/no.js +18 -0
- package/js/i18n/locales/oc.js +17 -0
- package/js/i18n/locales/pl.js +17 -0
- package/js/i18n/locales/pt-BR.js +17 -0
- package/js/i18n/locales/pt.js +18 -0
- package/js/i18n/locales/ro.js +17 -0
- package/js/i18n/locales/ru.js +18 -0
- package/js/i18n/locales/si.js +18 -0
- package/js/i18n/locales/sk.js +18 -0
- package/js/i18n/locales/sl.js +15 -0
- package/js/i18n/locales/sq.js +18 -0
- package/js/i18n/locales/sr-latn.js +16 -0
- package/js/i18n/locales/sr.js +16 -0
- package/js/i18n/locales/sv.js +17 -0
- package/js/i18n/locales/sw.js +15 -0
- package/js/i18n/locales/ta.js +18 -0
- package/js/i18n/locales/tg.js +19 -0
- package/js/i18n/locales/th.js +14 -0
- package/js/i18n/locales/tk.js +18 -0
- package/js/i18n/locales/tr.js +17 -0
- package/js/i18n/locales/uk.js +17 -0
- package/js/i18n/locales/uz-cyrl.js +18 -0
- package/js/i18n/locales/uz-latn.js +18 -0
- package/js/i18n/locales/vi.js +16 -0
- package/js/i18n/locales/zh-CN.js +19 -0
- package/js/i18n/locales/zh-TW.js +18 -0
- package/js/lib/date-format.js +185 -0
- package/js/lib/date.js +82 -0
- package/js/lib/dom.js +55 -0
- package/js/lib/event.js +68 -0
- package/js/lib/utils.js +61 -0
- package/js/main.js +4 -0
- package/js/options/defaultOptions.js +38 -0
- package/js/options/processOptions.js +263 -0
- package/js/picker/Picker.js +334 -0
- package/js/picker/templates/calendarWeeksTemplate.js +8 -0
- package/js/picker/templates/daysTemplate.js +8 -0
- package/js/picker/templates/pickerTemplate.js +23 -0
- package/js/picker/views/DaysView.js +250 -0
- package/js/picker/views/MonthsView.js +198 -0
- package/js/picker/views/View.js +55 -0
- package/js/picker/views/YearsView.js +170 -0
- package/package.json +81 -0
- package/postcss.config.js +5 -0
- package/rollup.config.js +75 -0
- package/sass/_mixins.scss +12 -0
- package/sass/datepicker-bs4.scss +91 -0
- package/sass/datepicker-bs5.scss +91 -0
- package/sass/datepicker-bulma.scss +69 -0
- package/sass/datepicker-foundation.scss +66 -0
- package/sass/datepicker.scss +436 -0
- package/sass/index-bs4.scss +5 -0
- package/sass/index-bs5.scss +5 -0
- package/sass/index-bulma.scss +6 -0
- package/sass/index-foundation.scss +3 -0
- package/scripts/build-css.js +39 -0
- package/scripts/build-locales.js +57 -0
- package/scripts/convert-bsdp-locales.js +65 -0
- package/scripts/minify-css.js +31 -0
- package/scripts/minify-js.js +17 -0
- package/style.css +10 -0
- package/tailwind.config.js +16 -0
- package/tailwind.css +1389 -0
- package/test/DateRangePicker/DateRangePicker.js +547 -0
- package/test/DateRangePicker/api-methods.js +415 -0
- package/test/DateRangePicker/date-selection.js +472 -0
- package/test/DateRangePicker/options.js +308 -0
- package/test/Datepicker/Datepicker-object.js +236 -0
- package/test/Datepicker/api-methods.js +328 -0
- package/test/_utils/date.js +102 -0
- package/test/_utils/dom.js +70 -0
- package/test/events.js +785 -0
- package/test/inline-mode.js +45 -0
- package/test/keyboard-operation/arrow-down.js +293 -0
- package/test/keyboard-operation/arrow-left.js +255 -0
- package/test/keyboard-operation/arrow-right.js +215 -0
- package/test/keyboard-operation/arrow-up.js +461 -0
- package/test/keyboard-operation/edit-mode.js +458 -0
- package/test/keyboard-operation/keyboard-operation.js +146 -0
- package/test/mouse-operation.js +580 -0
- package/test/options/before-show.js +635 -0
- package/test/options/bulma-datepicker.sublime-workspace +1280 -0
- package/test/options/buttons.js +383 -0
- package/test/options/date-restrictions.js +802 -0
- package/test/options/format.js +281 -0
- package/test/options/multidate.js +380 -0
- package/test/options/options.js +727 -0
- package/test/options/orientation.js +410 -0
- package/test/options/pick-levle+view.js +357 -0
- package/test/test.html +94 -0
- package/test/unit/DateRangePicker.js +192 -0
- package/test/unit/Datepicker.js +307 -0
- package/test/unit/_setup.js +28 -0
- package/test/unit/lib/date-format.js +310 -0
- package/test/unit/lib/date.js +211 -0
- package/test/unit/lib/dom.js +142 -0
- package/test/unit/lib/event.js +207 -0
- package/test/unit/lib/utils.js +135 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import {hasProperty, pushUnique} from '../lib/utils.js';
|
|
2
|
+
import {dateValue} from '../lib/date.js';
|
|
3
|
+
import {reFormatTokens, parseDate} from '../lib/date-format.js';
|
|
4
|
+
import {parseHTML} from '../lib/dom.js';
|
|
5
|
+
import defaultOptions from './defaultOptions.js';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
language: defaultLang,
|
|
9
|
+
format: defaultFormat,
|
|
10
|
+
weekStart: defaultWeekStart,
|
|
11
|
+
} = defaultOptions;
|
|
12
|
+
|
|
13
|
+
// Reducer function to filter out invalid day-of-week from the input
|
|
14
|
+
function sanitizeDOW(dow, day) {
|
|
15
|
+
return dow.length < 6 && day >= 0 && day < 7
|
|
16
|
+
? pushUnique(dow, day)
|
|
17
|
+
: dow;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function calcEndOfWeek(startOfWeek) {
|
|
21
|
+
return (startOfWeek + 6) % 7;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// validate input date. if invalid, fallback to the original value
|
|
25
|
+
function validateDate(value, format, locale, origValue) {
|
|
26
|
+
const date = parseDate(value, format, locale);
|
|
27
|
+
return date !== undefined ? date : origValue;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Validate viewId. if invalid, fallback to the original value
|
|
31
|
+
function validateViewId(value, origValue, max = 3) {
|
|
32
|
+
const viewId = parseInt(value, 10);
|
|
33
|
+
return viewId >= 0 && viewId <= max ? viewId : origValue;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Create Datepicker configuration to set
|
|
37
|
+
export default function processOptions(options, datepicker) {
|
|
38
|
+
const inOpts = Object.assign({}, options);
|
|
39
|
+
const config = {};
|
|
40
|
+
const locales = datepicker.constructor.locales;
|
|
41
|
+
let {
|
|
42
|
+
format,
|
|
43
|
+
language,
|
|
44
|
+
locale,
|
|
45
|
+
maxDate,
|
|
46
|
+
maxView,
|
|
47
|
+
minDate,
|
|
48
|
+
pickLevel,
|
|
49
|
+
startView,
|
|
50
|
+
weekStart,
|
|
51
|
+
} = datepicker.config || {};
|
|
52
|
+
|
|
53
|
+
if (inOpts.language) {
|
|
54
|
+
let lang;
|
|
55
|
+
if (inOpts.language !== language) {
|
|
56
|
+
if (locales[inOpts.language]) {
|
|
57
|
+
lang = inOpts.language;
|
|
58
|
+
} else {
|
|
59
|
+
// Check if langauge + region tag can fallback to the one without
|
|
60
|
+
// region (e.g. fr-CA → fr)
|
|
61
|
+
lang = inOpts.language.split('-')[0];
|
|
62
|
+
if (locales[lang] === undefined) {
|
|
63
|
+
lang = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
delete inOpts.language;
|
|
68
|
+
if (lang) {
|
|
69
|
+
language = config.language = lang;
|
|
70
|
+
|
|
71
|
+
// update locale as well when updating language
|
|
72
|
+
const origLocale = locale || locales[defaultLang];
|
|
73
|
+
// use default language's properties for the fallback
|
|
74
|
+
locale = Object.assign({
|
|
75
|
+
format: defaultFormat,
|
|
76
|
+
weekStart: defaultWeekStart
|
|
77
|
+
}, locales[defaultLang]);
|
|
78
|
+
if (language !== defaultLang) {
|
|
79
|
+
Object.assign(locale, locales[language]);
|
|
80
|
+
}
|
|
81
|
+
config.locale = locale;
|
|
82
|
+
// if format and/or weekStart are the same as old locale's defaults,
|
|
83
|
+
// update them to new locale's defaults
|
|
84
|
+
if (format === origLocale.format) {
|
|
85
|
+
format = config.format = locale.format;
|
|
86
|
+
}
|
|
87
|
+
if (weekStart === origLocale.weekStart) {
|
|
88
|
+
weekStart = config.weekStart = locale.weekStart;
|
|
89
|
+
config.weekEnd = calcEndOfWeek(locale.weekStart);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (inOpts.format) {
|
|
95
|
+
const hasToDisplay = typeof inOpts.format.toDisplay === 'function';
|
|
96
|
+
const hasToValue = typeof inOpts.format.toValue === 'function';
|
|
97
|
+
const validFormatString = reFormatTokens.test(inOpts.format);
|
|
98
|
+
if ((hasToDisplay && hasToValue) || validFormatString) {
|
|
99
|
+
format = config.format = inOpts.format;
|
|
100
|
+
}
|
|
101
|
+
delete inOpts.format;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//*** dates ***//
|
|
105
|
+
// while min and maxDate for "no limit" in the options are better to be null
|
|
106
|
+
// (especially when updating), the ones in the config have to be undefined
|
|
107
|
+
// because null is treated as 0 (= unix epoch) when comparing with time value
|
|
108
|
+
let minDt = minDate;
|
|
109
|
+
let maxDt = maxDate;
|
|
110
|
+
if (inOpts.minDate !== undefined) {
|
|
111
|
+
minDt = inOpts.minDate === null
|
|
112
|
+
? dateValue(0, 0, 1) // set 0000-01-01 to prevent negative values for year
|
|
113
|
+
: validateDate(inOpts.minDate, format, locale, minDt);
|
|
114
|
+
delete inOpts.minDate;
|
|
115
|
+
}
|
|
116
|
+
if (inOpts.maxDate !== undefined) {
|
|
117
|
+
maxDt = inOpts.maxDate === null
|
|
118
|
+
? undefined
|
|
119
|
+
: validateDate(inOpts.maxDate, format, locale, maxDt);
|
|
120
|
+
delete inOpts.maxDate;
|
|
121
|
+
}
|
|
122
|
+
if (maxDt < minDt) {
|
|
123
|
+
minDate = config.minDate = maxDt;
|
|
124
|
+
maxDate = config.maxDate = minDt;
|
|
125
|
+
} else {
|
|
126
|
+
if (minDate !== minDt) {
|
|
127
|
+
minDate = config.minDate = minDt;
|
|
128
|
+
}
|
|
129
|
+
if (maxDate !== maxDt) {
|
|
130
|
+
maxDate = config.maxDate = maxDt;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (inOpts.datesDisabled) {
|
|
135
|
+
config.datesDisabled = inOpts.datesDisabled.reduce((dates, dt) => {
|
|
136
|
+
const date = parseDate(dt, format, locale);
|
|
137
|
+
return date !== undefined ? pushUnique(dates, date) : dates;
|
|
138
|
+
}, []);
|
|
139
|
+
delete inOpts.datesDisabled;
|
|
140
|
+
}
|
|
141
|
+
if (inOpts.defaultViewDate !== undefined) {
|
|
142
|
+
const viewDate = parseDate(inOpts.defaultViewDate, format, locale);
|
|
143
|
+
if (viewDate !== undefined) {
|
|
144
|
+
config.defaultViewDate = viewDate;
|
|
145
|
+
}
|
|
146
|
+
delete inOpts.defaultViewDate;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
//*** days of week ***//
|
|
150
|
+
if (inOpts.weekStart !== undefined) {
|
|
151
|
+
const wkStart = Number(inOpts.weekStart) % 7;
|
|
152
|
+
if (!isNaN(wkStart)) {
|
|
153
|
+
weekStart = config.weekStart = wkStart;
|
|
154
|
+
config.weekEnd = calcEndOfWeek(wkStart);
|
|
155
|
+
}
|
|
156
|
+
delete inOpts.weekStart;
|
|
157
|
+
}
|
|
158
|
+
if (inOpts.daysOfWeekDisabled) {
|
|
159
|
+
config.daysOfWeekDisabled = inOpts.daysOfWeekDisabled.reduce(sanitizeDOW, []);
|
|
160
|
+
delete inOpts.daysOfWeekDisabled;
|
|
161
|
+
}
|
|
162
|
+
if (inOpts.daysOfWeekHighlighted) {
|
|
163
|
+
config.daysOfWeekHighlighted = inOpts.daysOfWeekHighlighted.reduce(sanitizeDOW, []);
|
|
164
|
+
delete inOpts.daysOfWeekHighlighted;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
//*** multi date ***//
|
|
168
|
+
if (inOpts.maxNumberOfDates !== undefined) {
|
|
169
|
+
const maxNumberOfDates = parseInt(inOpts.maxNumberOfDates, 10);
|
|
170
|
+
if (maxNumberOfDates >= 0) {
|
|
171
|
+
config.maxNumberOfDates = maxNumberOfDates;
|
|
172
|
+
config.multidate = maxNumberOfDates !== 1;
|
|
173
|
+
}
|
|
174
|
+
delete inOpts.maxNumberOfDates;
|
|
175
|
+
}
|
|
176
|
+
if (inOpts.dateDelimiter) {
|
|
177
|
+
config.dateDelimiter = String(inOpts.dateDelimiter);
|
|
178
|
+
delete inOpts.dateDelimiter;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//*** pick level & view ***//
|
|
182
|
+
let newPickLevel = pickLevel;
|
|
183
|
+
if (inOpts.pickLevel !== undefined) {
|
|
184
|
+
newPickLevel = validateViewId(inOpts.pickLevel, 2);
|
|
185
|
+
delete inOpts.pickLevel;
|
|
186
|
+
}
|
|
187
|
+
if (newPickLevel !== pickLevel) {
|
|
188
|
+
pickLevel = config.pickLevel = newPickLevel;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let newMaxView = maxView;
|
|
192
|
+
if (inOpts.maxView !== undefined) {
|
|
193
|
+
newMaxView = validateViewId(inOpts.maxView, maxView);
|
|
194
|
+
delete inOpts.maxView;
|
|
195
|
+
}
|
|
196
|
+
// ensure max view >= pick level
|
|
197
|
+
newMaxView = pickLevel > newMaxView ? pickLevel : newMaxView;
|
|
198
|
+
if (newMaxView !== maxView) {
|
|
199
|
+
maxView = config.maxView = newMaxView;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
let newStartView = startView;
|
|
203
|
+
if (inOpts.startView !== undefined) {
|
|
204
|
+
newStartView = validateViewId(inOpts.startView, newStartView);
|
|
205
|
+
delete inOpts.startView;
|
|
206
|
+
}
|
|
207
|
+
// ensure pick level <= start view <= max view
|
|
208
|
+
if (newStartView < pickLevel) {
|
|
209
|
+
newStartView = pickLevel;
|
|
210
|
+
} else if (newStartView > maxView) {
|
|
211
|
+
newStartView = maxView;
|
|
212
|
+
}
|
|
213
|
+
if (newStartView !== startView) {
|
|
214
|
+
config.startView = newStartView;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
//*** template ***//
|
|
218
|
+
if (inOpts.prevArrow) {
|
|
219
|
+
const prevArrow = parseHTML(inOpts.prevArrow);
|
|
220
|
+
if (prevArrow.childNodes.length > 0) {
|
|
221
|
+
config.prevArrow = prevArrow.childNodes;
|
|
222
|
+
}
|
|
223
|
+
delete inOpts.prevArrow;
|
|
224
|
+
}
|
|
225
|
+
if (inOpts.nextArrow) {
|
|
226
|
+
const nextArrow = parseHTML(inOpts.nextArrow);
|
|
227
|
+
if (nextArrow.childNodes.length > 0) {
|
|
228
|
+
config.nextArrow = nextArrow.childNodes;
|
|
229
|
+
}
|
|
230
|
+
delete inOpts.nextArrow;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
//*** misc ***//
|
|
234
|
+
if (inOpts.disableTouchKeyboard !== undefined) {
|
|
235
|
+
config.disableTouchKeyboard = 'ontouchstart' in document && !!inOpts.disableTouchKeyboard;
|
|
236
|
+
delete inOpts.disableTouchKeyboard;
|
|
237
|
+
}
|
|
238
|
+
if (inOpts.orientation) {
|
|
239
|
+
const orientation = inOpts.orientation.toLowerCase().split(/\s+/g);
|
|
240
|
+
config.orientation = {
|
|
241
|
+
x: orientation.find(x => (x === 'left' || x === 'right')) || 'auto',
|
|
242
|
+
y: orientation.find(y => (y === 'top' || y === 'bottom')) || 'auto',
|
|
243
|
+
};
|
|
244
|
+
delete inOpts.orientation;
|
|
245
|
+
}
|
|
246
|
+
if (inOpts.todayBtnMode !== undefined) {
|
|
247
|
+
switch(inOpts.todayBtnMode) {
|
|
248
|
+
case 0:
|
|
249
|
+
case 1:
|
|
250
|
+
config.todayBtnMode = inOpts.todayBtnMode;
|
|
251
|
+
}
|
|
252
|
+
delete inOpts.todayBtnMode;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
//*** copy the rest ***//
|
|
256
|
+
Object.keys(inOpts).forEach((key) => {
|
|
257
|
+
if (inOpts[key] !== undefined && hasProperty(defaultOptions, key)) {
|
|
258
|
+
config[key] = inOpts[key];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
return config;
|
|
263
|
+
}
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import {hasProperty, lastItemOf, isInRange, limitToRange} from '../lib/utils.js';
|
|
2
|
+
import {today} from '../lib/date.js';
|
|
3
|
+
import {parseHTML, showElement, hideElement, emptyChildNodes} from '../lib/dom.js';
|
|
4
|
+
import {registerListeners} from '../lib/event.js';
|
|
5
|
+
import pickerTemplate from './templates/pickerTemplate.js';
|
|
6
|
+
import DaysView from './views/DaysView.js';
|
|
7
|
+
import MonthsView from './views/MonthsView.js';
|
|
8
|
+
import YearsView from './views/YearsView.js';
|
|
9
|
+
import {triggerDatepickerEvent} from '../events/functions.js';
|
|
10
|
+
import {
|
|
11
|
+
onClickTodayBtn,
|
|
12
|
+
onClickClearBtn,
|
|
13
|
+
onClickViewSwitch,
|
|
14
|
+
onClickPrevBtn,
|
|
15
|
+
onClickNextBtn,
|
|
16
|
+
onClickView,
|
|
17
|
+
onClickPicker,
|
|
18
|
+
} from '../events/pickerListeners.js';
|
|
19
|
+
|
|
20
|
+
function processPickerOptions(picker, options) {
|
|
21
|
+
if (options.title !== undefined) {
|
|
22
|
+
if (options.title) {
|
|
23
|
+
picker.controls.title.textContent = options.title;
|
|
24
|
+
showElement(picker.controls.title);
|
|
25
|
+
} else {
|
|
26
|
+
picker.controls.title.textContent = '';
|
|
27
|
+
hideElement(picker.controls.title);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (options.prevArrow) {
|
|
31
|
+
const prevBtn = picker.controls.prevBtn;
|
|
32
|
+
emptyChildNodes(prevBtn);
|
|
33
|
+
options.prevArrow.forEach((node) => {
|
|
34
|
+
prevBtn.appendChild(node.cloneNode(true));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (options.nextArrow) {
|
|
38
|
+
const nextBtn = picker.controls.nextBtn;
|
|
39
|
+
emptyChildNodes(nextBtn);
|
|
40
|
+
options.nextArrow.forEach((node) => {
|
|
41
|
+
nextBtn.appendChild(node.cloneNode(true));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (options.locale) {
|
|
45
|
+
picker.controls.todayBtn.textContent = options.locale.today;
|
|
46
|
+
picker.controls.clearBtn.textContent = options.locale.clear;
|
|
47
|
+
}
|
|
48
|
+
if (options.todayBtn !== undefined) {
|
|
49
|
+
if (options.todayBtn) {
|
|
50
|
+
showElement(picker.controls.todayBtn);
|
|
51
|
+
} else {
|
|
52
|
+
hideElement(picker.controls.todayBtn);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (hasProperty(options, 'minDate') || hasProperty(options, 'maxDate')) {
|
|
56
|
+
const {minDate, maxDate} = picker.datepicker.config;
|
|
57
|
+
picker.controls.todayBtn.disabled = !isInRange(today(), minDate, maxDate);
|
|
58
|
+
}
|
|
59
|
+
if (options.clearBtn !== undefined) {
|
|
60
|
+
if (options.clearBtn) {
|
|
61
|
+
showElement(picker.controls.clearBtn);
|
|
62
|
+
} else {
|
|
63
|
+
hideElement(picker.controls.clearBtn);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Compute view date to reset, which will be...
|
|
69
|
+
// - the last item of the selected dates or defaultViewDate if no selection
|
|
70
|
+
// - limitted to minDate or maxDate if it exceeds the range
|
|
71
|
+
function computeResetViewDate(datepicker) {
|
|
72
|
+
const {dates, config} = datepicker;
|
|
73
|
+
const viewDate = dates.length > 0 ? lastItemOf(dates) : config.defaultViewDate;
|
|
74
|
+
return limitToRange(viewDate, config.minDate, config.maxDate);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Change current view's view date
|
|
78
|
+
function setViewDate(picker, newDate) {
|
|
79
|
+
const oldViewDate = new Date(picker.viewDate);
|
|
80
|
+
const newViewDate = new Date(newDate);
|
|
81
|
+
const {id, year, first, last} = picker.currentView;
|
|
82
|
+
const viewYear = newViewDate.getFullYear();
|
|
83
|
+
|
|
84
|
+
picker.viewDate = newDate;
|
|
85
|
+
if (viewYear !== oldViewDate.getFullYear()) {
|
|
86
|
+
triggerDatepickerEvent(picker.datepicker, 'changeYear');
|
|
87
|
+
}
|
|
88
|
+
if (newViewDate.getMonth() !== oldViewDate.getMonth()) {
|
|
89
|
+
triggerDatepickerEvent(picker.datepicker, 'changeMonth');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// return whether the new date is in different period on time from the one
|
|
93
|
+
// displayed in the current view
|
|
94
|
+
// when true, the view needs to be re-rendered on the next UI refresh.
|
|
95
|
+
switch (id) {
|
|
96
|
+
case 0:
|
|
97
|
+
return newDate < first || newDate > last;
|
|
98
|
+
case 1:
|
|
99
|
+
return viewYear !== year;
|
|
100
|
+
default:
|
|
101
|
+
return viewYear < first || viewYear > last;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getTextDirection(el) {
|
|
106
|
+
return window.getComputedStyle(el).direction;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Class representing the picker UI
|
|
110
|
+
export default class Picker {
|
|
111
|
+
constructor(datepicker) {
|
|
112
|
+
this.datepicker = datepicker;
|
|
113
|
+
|
|
114
|
+
const template = pickerTemplate.replace(/%buttonClass%/g, datepicker.config.buttonClass);
|
|
115
|
+
const element = this.element = parseHTML(template).firstChild;
|
|
116
|
+
const [header, main, footer] = element.firstChild.children;
|
|
117
|
+
const title = header.firstElementChild;
|
|
118
|
+
const [prevBtn, viewSwitch, nextBtn] = header.lastElementChild.children;
|
|
119
|
+
const [todayBtn, clearBtn] = footer.firstChild.children;
|
|
120
|
+
const controls = {
|
|
121
|
+
title,
|
|
122
|
+
prevBtn,
|
|
123
|
+
viewSwitch,
|
|
124
|
+
nextBtn,
|
|
125
|
+
todayBtn,
|
|
126
|
+
clearBtn,
|
|
127
|
+
};
|
|
128
|
+
this.main = main;
|
|
129
|
+
this.controls = controls;
|
|
130
|
+
|
|
131
|
+
const elementClass = datepicker.inline ? 'inline' : 'dropdown';
|
|
132
|
+
element.classList.add(`datepicker-${elementClass}`);
|
|
133
|
+
elementClass === 'dropdown' ? element.classList.add('dropdown', 'absolute', 'top-0', 'left-0', 'z-50', 'pt-2') : null;
|
|
134
|
+
|
|
135
|
+
processPickerOptions(this, datepicker.config);
|
|
136
|
+
this.viewDate = computeResetViewDate(datepicker);
|
|
137
|
+
|
|
138
|
+
// set up event listeners
|
|
139
|
+
registerListeners(datepicker, [
|
|
140
|
+
[element, 'click', onClickPicker.bind(null, datepicker), {capture: true}],
|
|
141
|
+
[main, 'click', onClickView.bind(null, datepicker)],
|
|
142
|
+
[controls.viewSwitch, 'click', onClickViewSwitch.bind(null, datepicker)],
|
|
143
|
+
[controls.prevBtn, 'click', onClickPrevBtn.bind(null, datepicker)],
|
|
144
|
+
[controls.nextBtn, 'click', onClickNextBtn.bind(null, datepicker)],
|
|
145
|
+
[controls.todayBtn, 'click', onClickTodayBtn.bind(null, datepicker)],
|
|
146
|
+
[controls.clearBtn, 'click', onClickClearBtn.bind(null, datepicker)],
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
// set up views
|
|
150
|
+
this.views = [
|
|
151
|
+
new DaysView(this),
|
|
152
|
+
new MonthsView(this),
|
|
153
|
+
new YearsView(this, {id: 2, name: 'years', cellClass: 'year', step: 1}),
|
|
154
|
+
new YearsView(this, {id: 3, name: 'decades', cellClass: 'decade', step: 10}),
|
|
155
|
+
];
|
|
156
|
+
this.currentView = this.views[datepicker.config.startView];
|
|
157
|
+
|
|
158
|
+
this.currentView.render();
|
|
159
|
+
this.main.appendChild(this.currentView.element);
|
|
160
|
+
datepicker.config.container.appendChild(this.element);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setOptions(options) {
|
|
164
|
+
processPickerOptions(this, options);
|
|
165
|
+
this.views.forEach((view) => {
|
|
166
|
+
view.init(options, false);
|
|
167
|
+
});
|
|
168
|
+
this.currentView.render();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
detach() {
|
|
172
|
+
this.datepicker.config.container.removeChild(this.element);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
show() {
|
|
176
|
+
if (this.active) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.element.classList.add('active', 'block');
|
|
180
|
+
this.element.classList.remove('hidden');
|
|
181
|
+
this.active = true;
|
|
182
|
+
|
|
183
|
+
const datepicker = this.datepicker;
|
|
184
|
+
if (!datepicker.inline) {
|
|
185
|
+
// ensure picker's direction matches input's
|
|
186
|
+
const inputDirection = getTextDirection(datepicker.inputField);
|
|
187
|
+
if (inputDirection !== getTextDirection(datepicker.config.container)) {
|
|
188
|
+
this.element.dir = inputDirection;
|
|
189
|
+
} else if (this.element.dir) {
|
|
190
|
+
this.element.removeAttribute('dir');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
this.place();
|
|
194
|
+
if (datepicker.config.disableTouchKeyboard) {
|
|
195
|
+
datepicker.inputField.blur();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
triggerDatepickerEvent(datepicker, 'show');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
hide() {
|
|
202
|
+
if (!this.active) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
this.datepicker.exitEditMode();
|
|
206
|
+
this.element.classList.remove('active', 'block');
|
|
207
|
+
this.element.classList.add('active', 'block', 'hidden');
|
|
208
|
+
this.active = false;
|
|
209
|
+
triggerDatepickerEvent(this.datepicker, 'hide');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
place() {
|
|
213
|
+
const {classList, style} = this.element;
|
|
214
|
+
const {config, inputField} = this.datepicker;
|
|
215
|
+
const container = config.container;
|
|
216
|
+
const {
|
|
217
|
+
width: calendarWidth,
|
|
218
|
+
height: calendarHeight,
|
|
219
|
+
} = this.element.getBoundingClientRect();
|
|
220
|
+
const {
|
|
221
|
+
left: containerLeft,
|
|
222
|
+
top: containerTop,
|
|
223
|
+
width: containerWidth,
|
|
224
|
+
} = container.getBoundingClientRect();
|
|
225
|
+
const {
|
|
226
|
+
left: inputLeft,
|
|
227
|
+
top: inputTop,
|
|
228
|
+
width: inputWidth,
|
|
229
|
+
height: inputHeight
|
|
230
|
+
} = inputField.getBoundingClientRect();
|
|
231
|
+
let {x: orientX, y: orientY} = config.orientation;
|
|
232
|
+
let scrollTop;
|
|
233
|
+
let left;
|
|
234
|
+
let top;
|
|
235
|
+
|
|
236
|
+
if (container === document.body) {
|
|
237
|
+
scrollTop = window.scrollY;
|
|
238
|
+
left = inputLeft + window.scrollX;
|
|
239
|
+
top = inputTop + scrollTop;
|
|
240
|
+
} else {
|
|
241
|
+
scrollTop = container.scrollTop;
|
|
242
|
+
left = inputLeft - containerLeft;
|
|
243
|
+
top = inputTop - containerTop + scrollTop;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (orientX === 'auto') {
|
|
247
|
+
if (left < 0) {
|
|
248
|
+
// align to the left and move into visible area if input's left edge < window's
|
|
249
|
+
orientX = 'left';
|
|
250
|
+
left = 10;
|
|
251
|
+
} else if (left + calendarWidth > containerWidth) {
|
|
252
|
+
// align to the right if canlendar's right edge > container's
|
|
253
|
+
orientX = 'right';
|
|
254
|
+
} else {
|
|
255
|
+
orientX = getTextDirection(inputField) === 'rtl' ? 'right' : 'left';
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (orientX === 'right') {
|
|
259
|
+
left -= calendarWidth - inputWidth;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (orientY === 'auto') {
|
|
263
|
+
orientY = top - calendarHeight < scrollTop ? 'bottom' : 'top';
|
|
264
|
+
}
|
|
265
|
+
if (orientY === 'top') {
|
|
266
|
+
top -= calendarHeight;
|
|
267
|
+
} else {
|
|
268
|
+
top += inputHeight;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
classList.remove(
|
|
272
|
+
'datepicker-orient-top',
|
|
273
|
+
'datepicker-orient-bottom',
|
|
274
|
+
'datepicker-orient-right',
|
|
275
|
+
'datepicker-orient-left'
|
|
276
|
+
);
|
|
277
|
+
classList.add(`datepicker-orient-${orientY}`, `datepicker-orient-${orientX}`);
|
|
278
|
+
|
|
279
|
+
style.top = top ? `${top}px` : top;
|
|
280
|
+
style.left = left ? `${left}px` : left;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
setViewSwitchLabel(labelText) {
|
|
284
|
+
this.controls.viewSwitch.textContent = labelText;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
setPrevBtnDisabled(disabled) {
|
|
288
|
+
this.controls.prevBtn.disabled = disabled;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
setNextBtnDisabled(disabled) {
|
|
292
|
+
this.controls.nextBtn.disabled = disabled;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
changeView(viewId) {
|
|
296
|
+
const oldView = this.currentView;
|
|
297
|
+
const newView = this.views[viewId];
|
|
298
|
+
if (newView.id !== oldView.id) {
|
|
299
|
+
this.currentView = newView;
|
|
300
|
+
this._renderMethod = 'render';
|
|
301
|
+
triggerDatepickerEvent(this.datepicker, 'changeView');
|
|
302
|
+
this.main.replaceChild(newView.element, oldView.element);
|
|
303
|
+
}
|
|
304
|
+
return this;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Change the focused date (view date)
|
|
308
|
+
changeFocus(newViewDate) {
|
|
309
|
+
this._renderMethod = setViewDate(this, newViewDate) ? 'render' : 'refreshFocus';
|
|
310
|
+
this.views.forEach((view) => {
|
|
311
|
+
view.updateFocus();
|
|
312
|
+
});
|
|
313
|
+
return this;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Apply the change of the selected dates
|
|
317
|
+
update() {
|
|
318
|
+
const newViewDate = computeResetViewDate(this.datepicker);
|
|
319
|
+
this._renderMethod = setViewDate(this, newViewDate) ? 'render' : 'refresh';
|
|
320
|
+
this.views.forEach((view) => {
|
|
321
|
+
view.updateFocus();
|
|
322
|
+
view.updateSelection();
|
|
323
|
+
});
|
|
324
|
+
return this;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// Refresh the picker UI
|
|
328
|
+
render(quickRender = true) {
|
|
329
|
+
const renderMethod = (quickRender && this._renderMethod) || 'render';
|
|
330
|
+
delete this._renderMethod;
|
|
331
|
+
|
|
332
|
+
this.currentView[renderMethod]();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import {createTagRepeat, optimizeTemplateHTML} from '../../lib/utils.js';
|
|
2
|
+
|
|
3
|
+
const calendarWeeksTemplate = optimizeTemplateHTML(`<div class="calendar-weeks">
|
|
4
|
+
<div class="days-of-week flex"><span class="dow h-6 leading-6 text-sm font-medium text-fg-disabled"></span></div>
|
|
5
|
+
<div class="weeks">${createTagRepeat('span', 6, {class: 'week block flex-1 leading-9 border-0 rounded-base cursor-default text-center text-body font-medium text-sm'})}</div>
|
|
6
|
+
</div>`);
|
|
7
|
+
|
|
8
|
+
export default calendarWeeksTemplate;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import {createTagRepeat, optimizeTemplateHTML} from '../../lib/utils.js';
|
|
2
|
+
|
|
3
|
+
const daysTemplate = optimizeTemplateHTML(`<div class="days">
|
|
4
|
+
<div class="days-of-week grid grid-cols-7 mb-1">${createTagRepeat('span', 7, {class: 'dow block flex-1 leading-9 border-0 rounded-base cursor-default text-center text-body font-medium text-sm'})}</div>
|
|
5
|
+
<div class="datepicker-grid w-64 grid grid-cols-7">${createTagRepeat('span', 42 , {class: 'block flex-1 leading-9 border-0 rounded-base cursor-default text-center text-body font-medium text-sm h-6 leading-6 text-sm font-medium text-fg-disabled'})}</div>
|
|
6
|
+
</div>`);
|
|
7
|
+
|
|
8
|
+
export default daysTemplate;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {optimizeTemplateHTML} from '../../lib/utils.js';
|
|
2
|
+
|
|
3
|
+
const pickerTemplate = optimizeTemplateHTML(`<div class="datepicker hidden">
|
|
4
|
+
<div class="datepicker-picker inline-block rounded-base bg-neutral-primary-medium border border-default-medium p-4">
|
|
5
|
+
<div class="datepicker-header">
|
|
6
|
+
<div class="datepicker-title bg-neutral-primary-medium text-heading px-2 py-3 text-center font-medium"></div>
|
|
7
|
+
<div class="datepicker-controls flex justify-between mb-2">
|
|
8
|
+
<button type="button" class="bg-neutral-primary-medium rounded-base text-body hover:bg-neutral-tertiary-medium hover:text-heading text-lg p-2.5 focus:outline-none focus:ring-2 focus:ring-neutral-tertiary prev-btn"></button>
|
|
9
|
+
<button type="button" class="text-sm rounded-base text-heading bg-neutral-primary-medium font-medium py-2.5 px-5 hover:bg-neutral-tertiary-medium focus:outline-none focus:ring-2 focus:ring-neutral-tertiary view-switch"></button>
|
|
10
|
+
<button type="button" class="bg-neutral-primary-medium rounded-base text-body hover:bg-neutral-tertiary-medium hover:text-heading text-lg p-2.5 focus:outline-none focus:ring-2 focus:ring-neutral-tertiary next-btn"></button>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="datepicker-main p-1"></div>
|
|
14
|
+
<div class="datepicker-footer">
|
|
15
|
+
<div class="datepicker-controls flex space-x-2 rtl:space-x-reverse mt-2">
|
|
16
|
+
<button type="button" class="%buttonClass% today-btn text-white bg-brand hover:bg-brand-strong focus:ring-4 focus:ring-brand-medium font-medium rounded-base text-sm px-5 py-2 text-center w-1/2"></button>
|
|
17
|
+
<button type="button" class="%buttonClass% clear-btn text-body bg-neutral-secondary-medium border border-default-medium hover:bg-neutral-tertiary-medium focus:ring-4 focus:ring-neutral-tertiary font-medium rounded-base text-sm px-5 py-2 text-center w-1/2"></button>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>`);
|
|
22
|
+
|
|
23
|
+
export default pickerTemplate;
|