@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,135 @@
|
|
|
1
|
+
import '../_setup.js';
|
|
2
|
+
import {
|
|
3
|
+
lastItemOf,
|
|
4
|
+
pushUnique,
|
|
5
|
+
stringToArray,
|
|
6
|
+
isInRange,
|
|
7
|
+
limitToRange,
|
|
8
|
+
createTagRepeat,
|
|
9
|
+
optimizeTemplateHTML
|
|
10
|
+
} from '../../../js/lib/utils.js';
|
|
11
|
+
|
|
12
|
+
describe('lib/utils', function () {
|
|
13
|
+
describe('lastItemOf()', function () {
|
|
14
|
+
it('returns the last item of array', function () {
|
|
15
|
+
expect(lastItemOf([1, 2, 3]), 'to be', 3);
|
|
16
|
+
expect(lastItemOf(['foo']), 'to be', 'foo');
|
|
17
|
+
expect(lastItemOf([]), 'to be undefined');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('pushUnique()', function () {
|
|
22
|
+
it('add items to an array if the item is not in the array', function () {
|
|
23
|
+
let arr = ['foo', 'bar'];
|
|
24
|
+
pushUnique(arr, 'foo');
|
|
25
|
+
expect(arr, 'to equal', arr);
|
|
26
|
+
|
|
27
|
+
pushUnique(arr, 'baz');
|
|
28
|
+
expect(arr, 'to equal', ['foo', 'bar', 'baz']);
|
|
29
|
+
|
|
30
|
+
arr = ['foo', 'bar'];
|
|
31
|
+
pushUnique(arr, 'bar', 'baz', 'bam', 'baz');
|
|
32
|
+
expect(arr, 'to equal', ['foo', 'bar', 'baz', 'bam']);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('returns the given array', function () {
|
|
36
|
+
let arr = ['foo', 'bar'];
|
|
37
|
+
expect(pushUnique(arr, 'baz'), 'to be', arr);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('stringToArray()', function () {
|
|
42
|
+
it('converts a string to array by spliting it with given separator', function () {
|
|
43
|
+
expect(stringToArray('foo,bar,baz', ','), 'to equal', ['foo', 'bar', 'baz']);
|
|
44
|
+
expect(stringToArray('abc-def', '-'), 'to equal', ['abc', 'def']);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('return an empty array if string is empty', function () {
|
|
48
|
+
expect(stringToArray('', ','), 'to equal', []);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('isInRange()', function () {
|
|
53
|
+
it('returns whether a value is between given min & max values', function () {
|
|
54
|
+
expect(isInRange(0, 1, 3), 'to be false');
|
|
55
|
+
expect(isInRange(1, 1, 3), 'to be true');
|
|
56
|
+
expect(isInRange(2, 1, 3), 'to be true');
|
|
57
|
+
expect(isInRange(3, 1, 3), 'to be true');
|
|
58
|
+
expect(isInRange(4, 1, 3), 'to be false');
|
|
59
|
+
//
|
|
60
|
+
expect(isInRange('abb', 'abc', 'ccc'), 'to be false');
|
|
61
|
+
expect(isInRange('bbc', 'abc', 'ccc'), 'to be true');
|
|
62
|
+
expect(isInRange('ccb', 'abc', 'ccc'), 'to be true');
|
|
63
|
+
expect(isInRange('ccd', 'abc', 'ccc'), 'to be false');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('omits minimum check if min = undefined', function () {
|
|
67
|
+
expect(isInRange(0, undefined, 3), 'to be true');
|
|
68
|
+
expect(isInRange(4, undefined, 3), 'to be false');
|
|
69
|
+
expect(isInRange(-Infinity, undefined, 3), 'to be true');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('omits maximum check if max = undefined', function () {
|
|
73
|
+
expect(isInRange(0, 1, undefined), 'to be false');
|
|
74
|
+
expect(isInRange(4, 1, undefined), 'to be true');
|
|
75
|
+
expect(isInRange(Infinity, 1, undefined), 'to be true');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('limitToRange()', function () {
|
|
80
|
+
it('returns min value if it\'s specified and the value < min', function () {
|
|
81
|
+
expect(limitToRange(0, 1, undefined), 'to be', 1);
|
|
82
|
+
expect(limitToRange(0, 1, 3), 'to be', 1);
|
|
83
|
+
expect(limitToRange('abb', 'abc', 'ccc'), 'to be', 'abc');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('returns max value if it\'s specified and the value > max', function () {
|
|
87
|
+
expect(limitToRange(4, undefined, 3), 'to be', 3);
|
|
88
|
+
expect(limitToRange(4, 1, 3), 'to be', 3);
|
|
89
|
+
expect(limitToRange('ccd', 'abc', 'ccc'), 'to be', 'ccc');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('returns the given value if it is within the specified min/max', function () {
|
|
93
|
+
expect(limitToRange(1, undefined, undefined), 'to be', 1);
|
|
94
|
+
expect(limitToRange(1, undefined, 3), 'to be', 1);
|
|
95
|
+
expect(limitToRange(3, 1, undefined), 'to be', 3);
|
|
96
|
+
expect(limitToRange(1, 1, 3), 'to be', 1);
|
|
97
|
+
expect(limitToRange(3, 1, 3), 'to be', 3);
|
|
98
|
+
|
|
99
|
+
expect(limitToRange('abc', 'aaa', 'ccc'), 'to be', 'abc');
|
|
100
|
+
expect(limitToRange('aaa', 'aaa', 'ccc'), 'to be', 'aaa');
|
|
101
|
+
expect(limitToRange('ccc', 'aaa', 'ccc'), 'to be', 'ccc');
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('createTagRepeat()', function () {
|
|
106
|
+
it('returns HTML of a tag repeated specified times', function () {
|
|
107
|
+
expect(createTagRepeat('div', 3), 'to be', '<div></div><div></div><div></div>');
|
|
108
|
+
expect(createTagRepeat('span', 2), 'to be', '<span></span><span></span>');
|
|
109
|
+
|
|
110
|
+
// returns at least 1 tag
|
|
111
|
+
expect(createTagRepeat('p', 0), 'to be', '<p></p>');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('adds addributes if name:value pairs are given', function () {
|
|
115
|
+
expect(createTagRepeat('p', 2, {class: 'foo bar'}), 'to be', '<p class="foo bar"></p><p class="foo bar"></p>');
|
|
116
|
+
expect(createTagRepeat('p', 2, {'data-x': '0', 'data-y': '1'}), 'to be', '<p data-x="0" data-y="1"></p><p data-x="0" data-y="1"></p>');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('accepts function that takes current index as the argument for attribute value', function () {
|
|
120
|
+
expect(createTagRepeat('li', 3, {'data-cnt': ix => ix + 1}), 'to be', '<li data-cnt="1"></li><li data-cnt="2"></li><li data-cnt="3"></li>');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('optimizeTemplateHTML()', function () {
|
|
125
|
+
it('removes spacing before and after tags', function () {
|
|
126
|
+
let text = `<div id="test">
|
|
127
|
+
<div>
|
|
128
|
+
test 123
|
|
129
|
+
</div>
|
|
130
|
+
</div>`;
|
|
131
|
+
expect(optimizeTemplateHTML(text), 'to be', '<div id="test"><div>test 123</div></div>');
|
|
132
|
+
expect(optimizeTemplateHTML('foo'), 'to be', 'foo');
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|