@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,45 @@
|
|
|
1
|
+
describe('inline mode', function () {
|
|
2
|
+
let element;
|
|
3
|
+
let dp;
|
|
4
|
+
let picker;
|
|
5
|
+
|
|
6
|
+
beforeEach(function () {
|
|
7
|
+
element = parseHTML('<div data-date="04/22/2020"></div>').firstChild;
|
|
8
|
+
testContainer.appendChild(element);
|
|
9
|
+
dp = new Datepicker(element, {container: 'body'});
|
|
10
|
+
picker = document.querySelector('.datepicker');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterEach(function () {
|
|
14
|
+
dp.destroy();
|
|
15
|
+
testContainer.removeChild(element);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('uses the bound element for the container regardless of the container option', function () {
|
|
19
|
+
expect(picker.parentElement, 'to be', element);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('does not add datepicker-input class to the bound element', function () {
|
|
23
|
+
expect(element.classList.contains('datepicker-input'), 'to be false');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('shows the picker on construction', function () {
|
|
27
|
+
expect(isVisible(picker), 'to be true');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('uses the data-date attribute for the initial date(s)', function () {
|
|
31
|
+
expect(dp.dates[0], 'to be', dateValue(2020, 3, 22));
|
|
32
|
+
expect(getViewSwitch(picker).textContent, 'to be', 'April 2020');
|
|
33
|
+
expect(picker.querySelector('.datepicker-cell.selected').textContent, 'to be', '22');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('hide() takes no effect', function () {
|
|
37
|
+
dp.hide();
|
|
38
|
+
expect(isVisible(picker), 'to be true');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('enterEditMode() takes no effect', function () {
|
|
42
|
+
dp.enterEditMode();
|
|
43
|
+
expect(dp.editMode, 'to be undefined');
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
describe('keyboard operation - arrow-down', function () {
|
|
2
|
+
const replaceInput = () => {
|
|
3
|
+
const newInput = document.createElement('input');
|
|
4
|
+
testContainer.replaceChild(newInput, input);
|
|
5
|
+
return newInput;
|
|
6
|
+
};
|
|
7
|
+
let input;
|
|
8
|
+
|
|
9
|
+
beforeEach(function () {
|
|
10
|
+
input = document.createElement('input');
|
|
11
|
+
testContainer.appendChild(input);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterEach(function () {
|
|
15
|
+
testContainer.removeChild(input);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('shows the picker if it is hidden', function () {
|
|
19
|
+
const {dp, picker} = createDP(input);
|
|
20
|
+
|
|
21
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
22
|
+
expect(isVisible(picker), 'to be true');
|
|
23
|
+
|
|
24
|
+
dp.destroy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('moves the view date/month/year/decade to 1 step down side', function () {
|
|
28
|
+
const clock = sinon.useFakeTimers({now: new Date(2044, 5, 15)});
|
|
29
|
+
const {dp, picker} = createDP(input);
|
|
30
|
+
const viewSwitch = getViewSwitch(picker);
|
|
31
|
+
input.focus();
|
|
32
|
+
|
|
33
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
34
|
+
expect(viewSwitch.textContent, 'to be', 'June 2044');
|
|
35
|
+
|
|
36
|
+
let cells = getCells(picker);
|
|
37
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[24]]);
|
|
38
|
+
expect(cells[24].textContent, 'to be', '22');
|
|
39
|
+
|
|
40
|
+
viewSwitch.click();
|
|
41
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
42
|
+
expect(viewSwitch.textContent, 'to be', '2044');
|
|
43
|
+
|
|
44
|
+
cells = getCells(picker);
|
|
45
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[9]]);
|
|
46
|
+
|
|
47
|
+
viewSwitch.click();
|
|
48
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
49
|
+
expect(viewSwitch.textContent, 'to be', '2040-2049');
|
|
50
|
+
|
|
51
|
+
cells = getCells(picker);
|
|
52
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[9]]);
|
|
53
|
+
expect(cells[9].textContent, 'to be', '2048');
|
|
54
|
+
|
|
55
|
+
viewSwitch.click();
|
|
56
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
57
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
58
|
+
|
|
59
|
+
cells = getCells(picker);
|
|
60
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[9]]);
|
|
61
|
+
expect(cells[9].textContent, 'to be', '2080');
|
|
62
|
+
|
|
63
|
+
dp.destroy();
|
|
64
|
+
clock.restore();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('also changes month of the days view if the current view date >= last 7 days of month', function () {
|
|
68
|
+
let clock = sinon.useFakeTimers({now: new Date(2020, 1, 23)});
|
|
69
|
+
let {dp, picker} = createDP(input);
|
|
70
|
+
let viewSwitch = getViewSwitch(picker);
|
|
71
|
+
input.focus();
|
|
72
|
+
|
|
73
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
74
|
+
expect(viewSwitch.textContent, 'to be', 'March 2020');
|
|
75
|
+
|
|
76
|
+
let cells = getCells(picker);
|
|
77
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[0]]);
|
|
78
|
+
expect(cells[0].textContent, 'to be', '1');
|
|
79
|
+
|
|
80
|
+
dp.destroy();
|
|
81
|
+
clock.restore();
|
|
82
|
+
input = replaceInput();
|
|
83
|
+
|
|
84
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 1, 26)});
|
|
85
|
+
({dp, picker} = createDP(input));
|
|
86
|
+
viewSwitch = getViewSwitch(picker);
|
|
87
|
+
input.focus();
|
|
88
|
+
|
|
89
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
90
|
+
expect(viewSwitch.textContent, 'to be', 'March 2020');
|
|
91
|
+
|
|
92
|
+
cells = getCells(picker);
|
|
93
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
94
|
+
expect(cells[3].textContent, 'to be', '4');
|
|
95
|
+
|
|
96
|
+
dp.destroy();
|
|
97
|
+
clock.restore();
|
|
98
|
+
input = replaceInput();
|
|
99
|
+
|
|
100
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 1, 29)});
|
|
101
|
+
({dp, picker} = createDP(input));
|
|
102
|
+
viewSwitch = getViewSwitch(picker);
|
|
103
|
+
input.focus();
|
|
104
|
+
|
|
105
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
106
|
+
expect(viewSwitch.textContent, 'to be', 'March 2020');
|
|
107
|
+
|
|
108
|
+
cells = getCells(picker);
|
|
109
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[6]]);
|
|
110
|
+
expect(cells[6].textContent, 'to be', '7');
|
|
111
|
+
|
|
112
|
+
dp.destroy();
|
|
113
|
+
clock.restore();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('also changes year of the months view if the current view month is Sep/Oct/Npv/Dec', function () {
|
|
117
|
+
let clock = sinon.useFakeTimers({now: new Date(2020, 8, 1)});
|
|
118
|
+
let {dp, picker} = createDP(input);
|
|
119
|
+
let viewSwitch = getViewSwitch(picker);
|
|
120
|
+
input.focus();
|
|
121
|
+
viewSwitch.click();
|
|
122
|
+
|
|
123
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
124
|
+
expect(viewSwitch.textContent, 'to be', '2021');
|
|
125
|
+
|
|
126
|
+
let cells = getCells(picker);
|
|
127
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[0]]);
|
|
128
|
+
|
|
129
|
+
dp.destroy();
|
|
130
|
+
clock.restore();
|
|
131
|
+
input = replaceInput();
|
|
132
|
+
|
|
133
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 9, 1)});
|
|
134
|
+
({dp, picker} = createDP(input));
|
|
135
|
+
viewSwitch = getViewSwitch(picker);
|
|
136
|
+
input.focus();
|
|
137
|
+
viewSwitch.click();
|
|
138
|
+
|
|
139
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
140
|
+
expect(viewSwitch.textContent, 'to be', '2021');
|
|
141
|
+
|
|
142
|
+
cells = getCells(picker);
|
|
143
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
144
|
+
|
|
145
|
+
dp.destroy();
|
|
146
|
+
clock.restore();
|
|
147
|
+
input = replaceInput();
|
|
148
|
+
|
|
149
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 10, 1)});
|
|
150
|
+
({dp, picker} = createDP(input));
|
|
151
|
+
viewSwitch = getViewSwitch(picker);
|
|
152
|
+
input.focus();
|
|
153
|
+
viewSwitch.click();
|
|
154
|
+
|
|
155
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
156
|
+
expect(viewSwitch.textContent, 'to be', '2021');
|
|
157
|
+
|
|
158
|
+
cells = getCells(picker);
|
|
159
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
160
|
+
|
|
161
|
+
dp.destroy();
|
|
162
|
+
clock.restore();
|
|
163
|
+
input = replaceInput();
|
|
164
|
+
|
|
165
|
+
clock = sinon.useFakeTimers({now: new Date(2020, 11, 1)});
|
|
166
|
+
({dp, picker} = createDP(input));
|
|
167
|
+
viewSwitch = getViewSwitch(picker);
|
|
168
|
+
input.focus();
|
|
169
|
+
viewSwitch.click();
|
|
170
|
+
|
|
171
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
172
|
+
expect(viewSwitch.textContent, 'to be', '2021');
|
|
173
|
+
|
|
174
|
+
cells = getCells(picker);
|
|
175
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
176
|
+
|
|
177
|
+
dp.destroy();
|
|
178
|
+
clock.restore();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('also changes decade of the years view if the current view year is the first 4 of the decade', function () {
|
|
182
|
+
let clock = sinon.useFakeTimers({now: new Date(2016, 1, 1)});
|
|
183
|
+
let {dp, picker} = createDP(input);
|
|
184
|
+
let viewSwitch = getViewSwitch(picker);
|
|
185
|
+
input.focus();
|
|
186
|
+
viewSwitch.click();
|
|
187
|
+
viewSwitch.click();
|
|
188
|
+
|
|
189
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
190
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
191
|
+
|
|
192
|
+
let cells = getCells(picker);
|
|
193
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
194
|
+
expect(cells[1].textContent, 'to be', '2020');
|
|
195
|
+
|
|
196
|
+
dp.destroy();
|
|
197
|
+
clock.restore();
|
|
198
|
+
input = replaceInput();
|
|
199
|
+
|
|
200
|
+
clock = sinon.useFakeTimers({now: new Date(2018, 1, 1)});
|
|
201
|
+
({dp, picker} = createDP(input));
|
|
202
|
+
viewSwitch = getViewSwitch(picker);
|
|
203
|
+
input.focus();
|
|
204
|
+
viewSwitch.click();
|
|
205
|
+
viewSwitch.click();
|
|
206
|
+
|
|
207
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
208
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
209
|
+
|
|
210
|
+
cells = getCells(picker);
|
|
211
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
212
|
+
expect(cells[3].textContent, 'to be', '2022');
|
|
213
|
+
|
|
214
|
+
dp.destroy();
|
|
215
|
+
clock.restore();
|
|
216
|
+
input = replaceInput();
|
|
217
|
+
|
|
218
|
+
clock = sinon.useFakeTimers({now: new Date(2019, 1, 1)});
|
|
219
|
+
({dp, picker} = createDP(input));
|
|
220
|
+
viewSwitch = getViewSwitch(picker);
|
|
221
|
+
input.focus();
|
|
222
|
+
viewSwitch.click();
|
|
223
|
+
viewSwitch.click();
|
|
224
|
+
|
|
225
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
226
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
227
|
+
|
|
228
|
+
cells = getCells(picker);
|
|
229
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[4]]);
|
|
230
|
+
expect(cells[4].textContent, 'to be', '2023');
|
|
231
|
+
|
|
232
|
+
dp.destroy();
|
|
233
|
+
clock.restore();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('also changes century of the decades view if the current view decade is the first 4 of the century', function () {
|
|
237
|
+
let clock = sinon.useFakeTimers({now: new Date(1960, 1, 1)});
|
|
238
|
+
let {dp, picker} = createDP(input);
|
|
239
|
+
let viewSwitch = getViewSwitch(picker);
|
|
240
|
+
input.focus();
|
|
241
|
+
viewSwitch.click();
|
|
242
|
+
viewSwitch.click();
|
|
243
|
+
viewSwitch.click();
|
|
244
|
+
|
|
245
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
246
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
247
|
+
|
|
248
|
+
let cells = getCells(picker);
|
|
249
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
250
|
+
expect(cells[1].textContent, 'to be', '2000');
|
|
251
|
+
|
|
252
|
+
dp.destroy();
|
|
253
|
+
clock.restore();
|
|
254
|
+
input = replaceInput();
|
|
255
|
+
|
|
256
|
+
clock = sinon.useFakeTimers({now: new Date(1980, 1, 1)});
|
|
257
|
+
({dp, picker} = createDP(input));
|
|
258
|
+
viewSwitch = getViewSwitch(picker);
|
|
259
|
+
input.focus();
|
|
260
|
+
viewSwitch.click();
|
|
261
|
+
viewSwitch.click();
|
|
262
|
+
viewSwitch.click();
|
|
263
|
+
|
|
264
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
265
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
266
|
+
|
|
267
|
+
cells = getCells(picker);
|
|
268
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[3]]);
|
|
269
|
+
expect(cells[3].textContent, 'to be', '2020');
|
|
270
|
+
|
|
271
|
+
dp.destroy();
|
|
272
|
+
clock.restore();
|
|
273
|
+
input = replaceInput();
|
|
274
|
+
|
|
275
|
+
clock = sinon.useFakeTimers({now: new Date(1990, 1, 1)});
|
|
276
|
+
({dp, picker} = createDP(input));
|
|
277
|
+
viewSwitch = getViewSwitch(picker);
|
|
278
|
+
input.focus();
|
|
279
|
+
viewSwitch.click();
|
|
280
|
+
viewSwitch.click();
|
|
281
|
+
viewSwitch.click();
|
|
282
|
+
|
|
283
|
+
simulant.fire(input, 'keydown', {key: 'ArrowDown'});
|
|
284
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
285
|
+
|
|
286
|
+
cells = getCells(picker);
|
|
287
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[4]]);
|
|
288
|
+
expect(cells[4].textContent, 'to be', '2030');
|
|
289
|
+
|
|
290
|
+
dp.destroy();
|
|
291
|
+
clock.restore();
|
|
292
|
+
});
|
|
293
|
+
});
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
describe('keyboard operation - arrow-left', function () {
|
|
2
|
+
let input;
|
|
3
|
+
|
|
4
|
+
beforeEach(function () {
|
|
5
|
+
input = document.createElement('input');
|
|
6
|
+
testContainer.appendChild(input);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
afterEach(function () {
|
|
10
|
+
testContainer.removeChild(input);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('moves the view date/month/year/decade to 1 step left side', function () {
|
|
14
|
+
const clock = sinon.useFakeTimers({now: new Date(2024, 5, 12)});
|
|
15
|
+
const {dp, picker} = createDP(input);
|
|
16
|
+
const viewSwitch = getViewSwitch(picker);
|
|
17
|
+
input.focus();
|
|
18
|
+
|
|
19
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
20
|
+
expect(viewSwitch.textContent, 'to be', 'June 2024');
|
|
21
|
+
|
|
22
|
+
let cells = getCells(picker);
|
|
23
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[16]]);
|
|
24
|
+
expect(cells[16].textContent, 'to be', '11');
|
|
25
|
+
|
|
26
|
+
viewSwitch.click();
|
|
27
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
28
|
+
expect(viewSwitch.textContent, 'to be', '2024');
|
|
29
|
+
|
|
30
|
+
cells = getCells(picker);
|
|
31
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[4]]);
|
|
32
|
+
|
|
33
|
+
viewSwitch.click();
|
|
34
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
35
|
+
expect(viewSwitch.textContent, 'to be', '2020-2029');
|
|
36
|
+
|
|
37
|
+
cells = getCells(picker);
|
|
38
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[4]]);
|
|
39
|
+
expect(cells[4].textContent, 'to be', '2023');
|
|
40
|
+
|
|
41
|
+
viewSwitch.click();
|
|
42
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
43
|
+
expect(viewSwitch.textContent, 'to be', '2000-2090');
|
|
44
|
+
|
|
45
|
+
cells = getCells(picker);
|
|
46
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
47
|
+
expect(cells[2].textContent, 'to be', '2010');
|
|
48
|
+
|
|
49
|
+
clock.restore();
|
|
50
|
+
dp.destroy();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('also changes month of the days view if the current view date is the 1st', function () {
|
|
54
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 2, 1)});
|
|
55
|
+
const {dp, picker} = createDP(input);
|
|
56
|
+
const viewSwitch = getViewSwitch(picker);
|
|
57
|
+
input.focus();
|
|
58
|
+
|
|
59
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
60
|
+
expect(viewSwitch.textContent, 'to be', 'February 2020');
|
|
61
|
+
|
|
62
|
+
let cells = getCells(picker);
|
|
63
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[34]]);
|
|
64
|
+
expect(cells[34].textContent, 'to be', '29');
|
|
65
|
+
|
|
66
|
+
dp.destroy();
|
|
67
|
+
clock.restore();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('also changes year of the months view if the current view month is January', function () {
|
|
71
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 0, 1)});
|
|
72
|
+
const {dp, picker} = createDP(input);
|
|
73
|
+
const viewSwitch = getViewSwitch(picker);
|
|
74
|
+
input.focus();
|
|
75
|
+
viewSwitch.click();
|
|
76
|
+
|
|
77
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
78
|
+
expect(viewSwitch.textContent, 'to be', '2019');
|
|
79
|
+
|
|
80
|
+
let cells = getCells(picker);
|
|
81
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[11]]);
|
|
82
|
+
|
|
83
|
+
dp.destroy();
|
|
84
|
+
clock.restore();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('also changes decade of the years view if the current view year is the start of the decade', function () {
|
|
88
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 1, 1)});
|
|
89
|
+
const {dp, picker} = createDP(input);
|
|
90
|
+
const viewSwitch = getViewSwitch(picker);
|
|
91
|
+
input.focus();
|
|
92
|
+
viewSwitch.click();
|
|
93
|
+
viewSwitch.click();
|
|
94
|
+
|
|
95
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
96
|
+
expect(viewSwitch.textContent, 'to be', '2010-2019');
|
|
97
|
+
|
|
98
|
+
let cells = getCells(picker);
|
|
99
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
100
|
+
expect(cells[10].textContent, 'to be', '2019');
|
|
101
|
+
|
|
102
|
+
dp.destroy();
|
|
103
|
+
clock.restore();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('also changes century of the decades view if the current view decade is the start of the century', function () {
|
|
107
|
+
const clock = sinon.useFakeTimers({now: new Date(2000, 1, 1)});
|
|
108
|
+
const {dp, picker} = createDP(input);
|
|
109
|
+
const viewSwitch = getViewSwitch(picker);
|
|
110
|
+
input.focus();
|
|
111
|
+
viewSwitch.click();
|
|
112
|
+
viewSwitch.click();
|
|
113
|
+
viewSwitch.click();
|
|
114
|
+
|
|
115
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
116
|
+
expect(viewSwitch.textContent, 'to be', '1900-1990');
|
|
117
|
+
|
|
118
|
+
let cells = getCells(picker);
|
|
119
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
120
|
+
expect(cells[10].textContent, 'to be', '1990');
|
|
121
|
+
|
|
122
|
+
dp.destroy();
|
|
123
|
+
clock.restore();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('does nothing if the view date is 0000-01-01', function () {
|
|
127
|
+
input.value = '01/01/0000';
|
|
128
|
+
|
|
129
|
+
const {dp, picker} = createDP(input);
|
|
130
|
+
const viewSwitch = getViewSwitch(picker);
|
|
131
|
+
input.focus();
|
|
132
|
+
|
|
133
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
134
|
+
expect(viewSwitch.textContent, 'to be', 'January 0');
|
|
135
|
+
|
|
136
|
+
let cells = getCells(picker);
|
|
137
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[6]]);
|
|
138
|
+
expect(cells[6].textContent, 'to be', '1');
|
|
139
|
+
|
|
140
|
+
viewSwitch.click();
|
|
141
|
+
|
|
142
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
143
|
+
expect(viewSwitch.textContent, 'to be', '0');
|
|
144
|
+
cells = getCells(picker);
|
|
145
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[0]]);
|
|
146
|
+
|
|
147
|
+
viewSwitch.click();
|
|
148
|
+
|
|
149
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
150
|
+
expect(viewSwitch.textContent, 'to be', '0-9');
|
|
151
|
+
cells = getCells(picker);
|
|
152
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
153
|
+
expect(cells[1].textContent, 'to be', '0');
|
|
154
|
+
|
|
155
|
+
viewSwitch.click();
|
|
156
|
+
|
|
157
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft'});
|
|
158
|
+
expect(viewSwitch.textContent, 'to be', '0-90');
|
|
159
|
+
cells = getCells(picker);
|
|
160
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
161
|
+
expect(cells[1].textContent, 'to be', '0');
|
|
162
|
+
|
|
163
|
+
dp.destroy();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('with control', function () {
|
|
167
|
+
it('functions as the shortcut key of the prev button', function () {
|
|
168
|
+
const clock = sinon.useFakeTimers({now: new Date(2020, 3, 22)});
|
|
169
|
+
const {dp, picker} = createDP(input);
|
|
170
|
+
const viewSwitch = getViewSwitch(picker);
|
|
171
|
+
input.focus();
|
|
172
|
+
|
|
173
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', ctrlKey: true});
|
|
174
|
+
expect(viewSwitch.textContent, 'to be', 'March 2020');
|
|
175
|
+
|
|
176
|
+
// view date is changed to the same day of the previous month
|
|
177
|
+
let cells = getCells(picker);
|
|
178
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[21]]);
|
|
179
|
+
expect(cells[21].textContent, 'to be', '22');
|
|
180
|
+
|
|
181
|
+
viewSwitch.click();
|
|
182
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', ctrlKey: true});
|
|
183
|
+
expect(viewSwitch.textContent, 'to be', '2019');
|
|
184
|
+
|
|
185
|
+
// view date is changed to the same month of the previous year
|
|
186
|
+
cells = getCells(picker);
|
|
187
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
188
|
+
expect(filterCells(cells, '.selected'), 'to equal', []);
|
|
189
|
+
|
|
190
|
+
viewSwitch.click();
|
|
191
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', ctrlKey: true});
|
|
192
|
+
expect(viewSwitch.textContent, 'to be', '2000-2009');
|
|
193
|
+
|
|
194
|
+
cells = getCells(picker);
|
|
195
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
196
|
+
expect(cells[10].textContent, 'to be', '2009');
|
|
197
|
+
|
|
198
|
+
viewSwitch.click();
|
|
199
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', ctrlKey: true});
|
|
200
|
+
expect(viewSwitch.textContent, 'to be', '1900-1990');
|
|
201
|
+
|
|
202
|
+
cells = getCells(picker);
|
|
203
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
204
|
+
expect(cells[1].textContent, 'to be', '1900');
|
|
205
|
+
|
|
206
|
+
dp.destroy();
|
|
207
|
+
clock.reset();
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe('with meta', function () {
|
|
212
|
+
it('functions as a substitute for the "+ctrl" key combination', function () {
|
|
213
|
+
let clock = sinon.useFakeTimers({now: new Date(2020, 3, 22)});
|
|
214
|
+
let {dp, picker} = createDP(input);
|
|
215
|
+
let viewSwitch = getViewSwitch(picker);
|
|
216
|
+
input.focus();
|
|
217
|
+
|
|
218
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', metaKey: true});
|
|
219
|
+
expect(viewSwitch.textContent, 'to be', 'March 2020');
|
|
220
|
+
|
|
221
|
+
// view date is changed to the same day of the previous month
|
|
222
|
+
let cells = getCells(picker);
|
|
223
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[21]]);
|
|
224
|
+
expect(cells[21].textContent, 'to be', '22');
|
|
225
|
+
|
|
226
|
+
viewSwitch.click();
|
|
227
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', metaKey: true});
|
|
228
|
+
expect(viewSwitch.textContent, 'to be', '2019');
|
|
229
|
+
|
|
230
|
+
// view date is changed to the same month of the previous year
|
|
231
|
+
cells = getCells(picker);
|
|
232
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[2]]);
|
|
233
|
+
expect(filterCells(cells, '.selected'), 'to equal', []);
|
|
234
|
+
|
|
235
|
+
viewSwitch.click();
|
|
236
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', metaKey: true});
|
|
237
|
+
expect(viewSwitch.textContent, 'to be', '2000-2009');
|
|
238
|
+
|
|
239
|
+
cells = getCells(picker);
|
|
240
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[10]]);
|
|
241
|
+
expect(cells[10].textContent, 'to be', '2009');
|
|
242
|
+
|
|
243
|
+
viewSwitch.click();
|
|
244
|
+
simulant.fire(input, 'keydown', {key: 'ArrowLeft', metaKey: true});
|
|
245
|
+
expect(viewSwitch.textContent, 'to be', '1900-1990');
|
|
246
|
+
|
|
247
|
+
cells = getCells(picker);
|
|
248
|
+
expect(filterCells(cells, '.focused'), 'to equal', [cells[1]]);
|
|
249
|
+
expect(cells[1].textContent, 'to be', '1900');
|
|
250
|
+
|
|
251
|
+
dp.destroy();
|
|
252
|
+
clock.restore();
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
});
|