@lemonadejs/calendar 3.5.0 → 5.0.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/dist/index.js +123 -119
- package/dist/style.css +11 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -13,136 +13,136 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
13
13
|
var Modal = require('@lemonadejs/modal');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
; (function (global, factory) {
|
|
17
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
18
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
19
|
+
global.Calendar = factory();
|
|
20
|
+
}(this, (function () {
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
const Helpers = (function() {
|
|
23
|
+
const component = {};
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const excelLeapYearBug = Date.UTC(1900, 1, 29);
|
|
25
|
-
const millisecondsPerDay = 86400000;
|
|
25
|
+
component.weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
26
|
+
component.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
value = '0' + value;
|
|
32
|
-
}
|
|
33
|
-
return value;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
component.isValidDate = function(d) {
|
|
37
|
-
return d instanceof Date && !isNaN(d.getTime());
|
|
38
|
-
}
|
|
28
|
+
// Excel like dates
|
|
29
|
+
const excelInitialTime = Date.UTC(1900, 0, 0);
|
|
30
|
+
const excelLeapYearBug = Date.UTC(1900, 1, 29);
|
|
31
|
+
const millisecondsPerDay = 86400000;
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
let i = null;
|
|
46
|
-
let s = null;
|
|
47
|
-
|
|
48
|
-
if (Array.isArray(date)) {
|
|
49
|
-
y = date[0];
|
|
50
|
-
m = date[1];
|
|
51
|
-
d = date[2];
|
|
52
|
-
h = date[3];
|
|
53
|
-
i = date[4];
|
|
54
|
-
s = date[5];
|
|
55
|
-
} else {
|
|
56
|
-
if (! date) {
|
|
57
|
-
date = new Date();
|
|
33
|
+
// Transform in two digits
|
|
34
|
+
component.Two = function(value) {
|
|
35
|
+
value = '' + value;
|
|
36
|
+
if (value.length === 1) {
|
|
37
|
+
value = '0' + value;
|
|
58
38
|
}
|
|
59
|
-
|
|
60
|
-
m = date.getMonth() + 1;
|
|
61
|
-
d = date.getDate();
|
|
62
|
-
h = date.getHours();
|
|
63
|
-
i = date.getMinutes();
|
|
64
|
-
s = date.getSeconds();
|
|
39
|
+
return value;
|
|
65
40
|
}
|
|
66
41
|
|
|
67
|
-
|
|
68
|
-
return
|
|
69
|
-
} else {
|
|
70
|
-
return component.Two(y) + '-' + component.Two(m) + '-' + component.Two(d) + ' ' + component.Two(h) + ':' + component.Two(i) + ':' + component.Two(s);
|
|
42
|
+
component.isValidDate = function(d) {
|
|
43
|
+
return d instanceof Date && !isNaN(d.getTime());
|
|
71
44
|
}
|
|
72
|
-
}
|
|
73
45
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
46
|
+
component.toString = function (date, dateOnly) {
|
|
47
|
+
let y = null;
|
|
48
|
+
let m = null;
|
|
49
|
+
let d = null;
|
|
50
|
+
let h = null;
|
|
51
|
+
let i = null;
|
|
52
|
+
let s = null;
|
|
77
53
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
54
|
+
if (Array.isArray(date)) {
|
|
55
|
+
y = date[0];
|
|
56
|
+
m = date[1];
|
|
57
|
+
d = date[2];
|
|
58
|
+
h = date[3];
|
|
59
|
+
i = date[4];
|
|
60
|
+
s = date[5];
|
|
61
|
+
} else {
|
|
62
|
+
if (! date) {
|
|
63
|
+
date = new Date();
|
|
64
|
+
}
|
|
65
|
+
y = date.getFullYear();
|
|
66
|
+
m = date.getMonth() + 1;
|
|
67
|
+
d = date.getDate();
|
|
68
|
+
h = date.getHours();
|
|
69
|
+
i = date.getMinutes();
|
|
70
|
+
s = date.getSeconds();
|
|
71
|
+
}
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
if (dateOnly === true) {
|
|
74
|
+
return component.Two(y) + '-' + component.Two(m) + '-' + component.Two(d);
|
|
75
|
+
} else {
|
|
76
|
+
return component.Two(y) + '-' + component.Two(m) + '-' + component.Two(d) + ' ' + component.Two(h) + ':' + component.Two(i) + ':' + component.Two(s);
|
|
77
|
+
}
|
|
89
78
|
}
|
|
90
|
-
return [y, m, d, h, i, 0];
|
|
91
|
-
}
|
|
92
79
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
80
|
+
component.toArray = function (value) {
|
|
81
|
+
let date = value.split(((value.indexOf('T') !== -1) ? 'T' : ' '));
|
|
82
|
+
let time = date[1];
|
|
96
83
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
84
|
+
date = date[0].split('-');
|
|
85
|
+
let y = parseInt(date[0]);
|
|
86
|
+
let m = parseInt(date[1]);
|
|
87
|
+
let d = parseInt(date[2]);
|
|
88
|
+
let h = 0;
|
|
89
|
+
let i = 0;
|
|
90
|
+
|
|
91
|
+
if (time) {
|
|
92
|
+
time = time.split(':');
|
|
93
|
+
h = parseInt(time[0]);
|
|
94
|
+
i = parseInt(time[1]);
|
|
95
|
+
}
|
|
96
|
+
return [y, m, d, h, i, 0];
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
|
|
99
|
+
component.arrayToStringDate = function(arr) {
|
|
100
|
+
return component.toString(arr, true);
|
|
104
101
|
}
|
|
105
|
-
jsDateInMilliseconds -= excelInitialTime;
|
|
106
102
|
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
component.dateToNum = function(jsDate) {
|
|
104
|
+
if (typeof(jsDate) === 'string') {
|
|
105
|
+
jsDate = new Date(jsDate + ' GMT+0');
|
|
106
|
+
}
|
|
107
|
+
let jsDateInMilliseconds = jsDate.getTime();
|
|
108
|
+
if (jsDateInMilliseconds >= excelLeapYearBug) {
|
|
109
|
+
jsDateInMilliseconds += millisecondsPerDay;
|
|
110
|
+
}
|
|
111
|
+
jsDateInMilliseconds -= excelInitialTime;
|
|
109
112
|
|
|
110
|
-
|
|
111
|
-
if (! excelSerialNumber) {
|
|
112
|
-
return '';
|
|
113
|
+
return jsDateInMilliseconds / millisecondsPerDay;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
component.numToDate = function(excelSerialNumber, asString){
|
|
117
|
+
if (! excelSerialNumber) {
|
|
118
|
+
return '';
|
|
119
|
+
}
|
|
119
120
|
|
|
120
|
-
|
|
121
|
+
let jsDateInMilliseconds = excelInitialTime + excelSerialNumber * millisecondsPerDay;
|
|
122
|
+
if (jsDateInMilliseconds >= excelLeapYearBug) {
|
|
123
|
+
jsDateInMilliseconds -= millisecondsPerDay;
|
|
124
|
+
}
|
|
121
125
|
|
|
122
|
-
|
|
123
|
-
d.getUTCFullYear(),
|
|
124
|
-
component.Two(d.getUTCMonth() + 1),
|
|
125
|
-
component.Two(d.getUTCDate()),
|
|
126
|
-
component.Two(d.getUTCHours()),
|
|
127
|
-
component.Two(d.getUTCMinutes()),
|
|
128
|
-
component.Two(d.getUTCSeconds()),
|
|
129
|
-
];
|
|
126
|
+
const d = new Date(jsDateInMilliseconds);
|
|
130
127
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
let arr = [
|
|
129
|
+
d.getUTCFullYear(),
|
|
130
|
+
component.Two(d.getUTCMonth() + 1),
|
|
131
|
+
component.Two(d.getUTCDate()),
|
|
132
|
+
component.Two(d.getUTCHours()),
|
|
133
|
+
component.Two(d.getUTCMinutes()),
|
|
134
|
+
component.Two(d.getUTCSeconds()),
|
|
135
|
+
];
|
|
137
136
|
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
if (asString) {
|
|
138
|
+
return component.arrayToStringDate(arr);
|
|
139
|
+
} else {
|
|
140
|
+
return arr;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
140
143
|
|
|
141
|
-
;
|
|
142
|
-
|
|
143
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
144
|
-
global.Calendar = factory();
|
|
145
|
-
}(this, (function () {
|
|
144
|
+
return component;
|
|
145
|
+
})();
|
|
146
146
|
|
|
147
147
|
const isNumber = function (num) {
|
|
148
148
|
if (typeof(num) === 'string') {
|
|
@@ -856,20 +856,23 @@ const Helpers = (function() {
|
|
|
856
856
|
// Create input controls
|
|
857
857
|
if (self.input) {
|
|
858
858
|
let input = getInput();
|
|
859
|
-
input.
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
859
|
+
if (input && input.tagName) {
|
|
860
|
+
input.classList.add('lm-input');
|
|
861
|
+
input.classList.add('lm-calendar-input');
|
|
862
|
+
input.addEventListener('focus', self.open);
|
|
863
|
+
input.addEventListener('click', self.open);
|
|
864
|
+
input.addEventListener('blur', blur);
|
|
865
|
+
|
|
866
|
+
if (self.onChange) {
|
|
867
|
+
input.addEventListener('change', self.onChange);
|
|
868
|
+
}
|
|
867
869
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
870
|
+
// Retrieve the value
|
|
871
|
+
if (self.value) {
|
|
872
|
+
input.value = self.value;
|
|
873
|
+
} else if (input.value && input.value !== self.value) {
|
|
874
|
+
self.value = input.value;
|
|
875
|
+
}
|
|
873
876
|
}
|
|
874
877
|
}
|
|
875
878
|
|
|
@@ -901,7 +904,8 @@ const Helpers = (function() {
|
|
|
901
904
|
prevent = true;
|
|
902
905
|
} else {
|
|
903
906
|
if (self.input) {
|
|
904
|
-
|
|
907
|
+
// TODO: mask
|
|
908
|
+
//jSuites.mask(e);
|
|
905
909
|
}
|
|
906
910
|
}
|
|
907
911
|
|
package/dist/style.css
CHANGED
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
position: relative;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
.lm-calendar button {
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
.lm-calendar .lm-modal {
|
|
12
16
|
min-width: initial;
|
|
13
17
|
min-height: initial;
|
|
@@ -60,8 +64,13 @@
|
|
|
60
64
|
font-weight: bold;
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
.lm-calendar-navigation {
|
|
68
|
+
display: grid;
|
|
69
|
+
grid-template-columns: repeat(2, 1fr);
|
|
70
|
+
gap: 6px;
|
|
71
|
+
}
|
|
72
|
+
|
|
63
73
|
.lm-calendar-navigation button {
|
|
64
|
-
cursor: pointer;
|
|
65
74
|
padding: 8px;
|
|
66
75
|
border: 0;
|
|
67
76
|
border-radius: 24px;
|
|
@@ -176,6 +185,7 @@
|
|
|
176
185
|
top: calc(25%);
|
|
177
186
|
height: 50%;
|
|
178
187
|
background-color: var(--lm-main-color-alpha, #2196f388);
|
|
188
|
+
z-index: -1;
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
.lm-calendar-content > div[data-start="true"]::before {
|
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"javascript plugins"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"lemonadejs": "^
|
|
18
|
-
"@lemonadejs/modal": "^
|
|
17
|
+
"lemonadejs": "^5.0.3",
|
|
18
|
+
"@lemonadejs/modal": "^5.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"version": "
|
|
22
|
+
"version": "5.0.0"
|
|
23
23
|
}
|