@lemonadejs/calendar 3.3.0 → 3.3.2

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 CHANGED
@@ -533,7 +533,7 @@ if (! Modal && typeof (require) === 'function') {
533
533
  const renderValue = function() {
534
534
  let value = null;
535
535
  if (self.range) {
536
- if (self.rangeValues) {
536
+ if (Array.isArray(self.rangeValues)) {
537
537
  if (self.numeric) {
538
538
  value = self.rangeValues;
539
539
  } else {
@@ -553,6 +553,24 @@ if (! Modal && typeof (require) === 'function') {
553
553
  }
554
554
 
555
555
  const updateValue = function(v) {
556
+ if (self.range) {
557
+ if (v) {
558
+ if (! Array.isArray(v)) {
559
+ v = v.split(',');
560
+ }
561
+ self.rangeValues = v;
562
+
563
+ if (v[0] && typeof(v[0]) === 'string' && v[0].indexOf('-')) {
564
+ self.rangeValues[0] = dateToNum(v[0]);
565
+ }
566
+ if (v[1] && typeof(v[1]) === 'string' && v[1].indexOf('-')) {
567
+ self.rangeValues[1] = dateToNum(v[1]);
568
+ }
569
+
570
+ v = v[0];
571
+ }
572
+ }
573
+
556
574
  let d;
557
575
  if (v) {
558
576
  v = isNumber(v) ? numToDate(v, true) : v;
@@ -593,23 +611,30 @@ if (! Modal && typeof (require) === 'function') {
593
611
  self.select = function(e, item) {
594
612
  // Update cursor generic
595
613
  let value = setCursor(item);
596
- // Update range
597
- setRange(item);
598
614
  // Based where was the click
599
615
  if (self.view !== 'days') {
600
616
  // Update the internal date
601
617
  setDate(value);
602
- // Change back to right view
618
+ // Back to the days
603
619
  self.view = 'days';
604
620
  }
605
621
  }
606
622
 
623
+ self.selectRange = function(e, item) {
624
+ if (self.view === 'days' && self.range === true) {
625
+ // Update cursor generic
626
+ setCursor(item);
627
+ // Update range
628
+ setRange(item);
629
+ }
630
+ }
631
+
607
632
  /**
608
633
  * Next handler
609
634
  * @param {object?} e mouse event
610
635
  */
611
636
  self.next = function(e) {
612
- if (! e || e.type === 'mousedown') {
637
+ if (! e || e.type === 'click') {
613
638
  // Icon click
614
639
  move(1);
615
640
  } else {
@@ -623,7 +648,7 @@ if (! Modal && typeof (require) === 'function') {
623
648
  * @param {object?} e mouse event
624
649
  */
625
650
  self.prev = function(e) {
626
- if (! e || e.type === 'mousedown') {
651
+ if (! e || e.type === 'click') {
627
652
  // Icon click
628
653
  move(-1);
629
654
  } else {
@@ -643,6 +668,12 @@ if (! Modal && typeof (require) === 'function') {
643
668
  if (! (self.input && e.target.getAttribute('readonly') === null)) {
644
669
  self.content.focus();
645
670
  }
671
+
672
+ // Update the internal date values
673
+ updateValue(self.value);
674
+ // Populate components
675
+ self.hours = views.hours();
676
+ self.minutes = views.minutes();
646
677
  }
647
678
  }
648
679
 
@@ -653,6 +684,8 @@ if (! Modal && typeof (require) === 'function') {
653
684
  if (self.modal && self.modal.closed === false) {
654
685
  // Close modal
655
686
  self.modal.closed = true;
687
+ // Cancel range events
688
+ destroyRange();
656
689
  }
657
690
  }
658
691
 
@@ -767,6 +800,7 @@ if (! Modal && typeof (require) === 'function') {
767
800
  // Current view
768
801
  let view = self.view;
769
802
  // Select
803
+ self.selectRange(e, self.options[self.cursor.index]);
770
804
  self.select(e, self.options[self.cursor.index]);
771
805
  // If is range do something different
772
806
  if (view === 'days' && ! self.range) {
@@ -812,20 +846,20 @@ if (! Modal && typeof (require) === 'function') {
812
846
  }
813
847
 
814
848
  return `<div class="lm-calendar" :value="self.value">
815
- <div class="lm-calendar-options">
849
+ <div class="lm-calendar-options">
816
850
  <button onclick="self.reset">Reset</button>
817
851
  <button onclick="self.update">Done</button>
818
852
  </div>
819
853
  <div class="lm-calendar-container" data-view="{{self.view}}">
820
854
  <div class="lm-calendar-header">
821
855
  <div>
822
- <div class="lm-calendar-labels"><button onmousedown="self.setView" data-view="months">{{self.month}}</button> <button onmousedown="self.setView" data-view="years">{{self.year}}</button></div>
823
- <div class="lm-calendar-navigation"><button type="button" class="material-icons lm-ripple" onmousedown="self.prev" tabindex="0">arrow_drop_up</button> <button type="button" class="material-icons lm-ripple" onmousedown="self.next" tabindex="0">arrow_drop_down</button></div>
856
+ <div class="lm-calendar-labels"><button onclick="self.setView" data-view="months">{{self.month}}</button> <button onclick="self.setView" data-view="years">{{self.year}}</button></div>
857
+ <div class="lm-calendar-navigation"><button type="button" class="material-icons lm-ripple" onclick="self.prev" tabindex="0">arrow_drop_up</button> <button type="button" class="material-icons lm-ripple" onclick="self.next" tabindex="0">arrow_drop_down</button></div>
824
858
  </div>
825
859
  <div class="lm-calendar-weekdays" :loop="self.weekdays"><div>{{self.title}}</div></div>
826
860
  </div>
827
861
  <div class="lm-calendar-content" :loop="self.options" tabindex="0" :ref="self.content">
828
- <div data-start="{{self.start}}" data-end="{{self.end}}" data-range="{{self.range}}" data-event="{{self.data}}" data-grey="{{self.grey}}" data-bold="{{self.bold}}" data-selected="{{self.selected}}" onmousedown="self.parent.select">{{self.title}}</div>
862
+ <div data-start="{{self.start}}" data-end="{{self.end}}" data-range="{{self.range}}" data-event="{{self.data}}" data-grey="{{self.grey}}" data-bold="{{self.bold}}" data-selected="{{self.selected}}" onclick="self.parent.select" onmousedown="self.parent.selectRange">{{self.title}}</div>
829
863
  </div>
830
864
  <div class="lm-calendar-footer">
831
865
  <div><select :loop="self.hours"><option value="{{self.value}}">{{self.title}}</option></select>:<select :loop="self.minutes"><option value="{{self.value}}">{{self.title}}</option></select></div>
package/dist/style.css CHANGED
@@ -5,6 +5,7 @@
5
5
  -webkit-touch-callout: none;
6
6
  -webkit-user-select: none;
7
7
  -ms-user-select: none;
8
+ position: relative;
8
9
  }
9
10
 
10
11
  .lm-calendar .lm-modal {
@@ -19,7 +20,7 @@
19
20
  .lm-modal > div > .lm-calendar-options {
20
21
  display: flex;
21
22
  justify-content: space-between;
22
- border-bottom: 1px solid #ddd;
23
+ border-bottom: 1px solid var(--lm-border-color, #ccc);
23
24
  }
24
25
 
25
26
  .lm-modal > div > .lm-calendar-options button {
@@ -55,7 +56,7 @@
55
56
  font-size: 1.3em;
56
57
  border: 0;
57
58
  padding: 4px;
58
- background-color: #fff;
59
+ background-color: transparent;
59
60
  }
60
61
 
61
62
  .lm-calendar-navigation button {
@@ -66,7 +67,8 @@
66
67
  }
67
68
 
68
69
  .lm-calendar-navigation i:hover {
69
- background-color: #eee;
70
+ background-color: var(--lm-background-color-hover, #ebebeb);
71
+ color: #000;
70
72
  }
71
73
 
72
74
  .lm-calendar-weekdays {
@@ -115,6 +117,7 @@
115
117
  .lm-calendar-container[data-view="months"] .lm-calendar-content {
116
118
  grid-template-columns: repeat(4, 1fr);
117
119
  }
120
+
118
121
  .lm-calendar-container[data-view="years"] .lm-calendar-content {
119
122
  grid-template-columns: repeat(4, 1fr);
120
123
  }
@@ -140,6 +143,7 @@
140
143
  .lm-calendar-content > div[data-selected="true"] {
141
144
  font-weight: bold;
142
145
  background-color: #eee;
146
+ color: #000;
143
147
  }
144
148
 
145
149
  .lm-calendar-content:focus > div[data-selected="true"] {
@@ -149,6 +153,7 @@
149
153
 
150
154
  .lm-calendar-content > div:hover {
151
155
  background-color: #eee;
156
+ color: #000;
152
157
  }
153
158
 
154
159
  .lm-calendar-content > div[data-range="true"] {
@@ -157,7 +162,7 @@
157
162
 
158
163
  .lm-calendar-content > div[data-start="true"],
159
164
  .lm-calendar-content > div[data-end="true"] {
160
- background-color: #78D350;
165
+ background-color: var(--lm-main-color, #2196f3);
161
166
  color: initial;
162
167
  }
163
168
 
@@ -168,7 +173,7 @@
168
173
  right: 0;
169
174
  top: 8px;
170
175
  bottom: 8px;
171
- background-color: #78D35050;
176
+ background-color: var(--lm-main-color-alpha, #2196f3);
172
177
  }
173
178
 
174
179
  .lm-calendar-content > div[data-start="true"]::before {
@@ -188,7 +193,7 @@
188
193
  margin: 0 10px 0 10px;
189
194
  padding: 8px 0 8px 0;
190
195
  line-height: 34px;
191
- border-top: 1px solid #eee;
196
+ border-top: 1px solid var(--lm-border-color, #ccc);
192
197
  }
193
198
 
194
199
  .lm-calendar-footer select {
@@ -226,23 +231,15 @@
226
231
  }
227
232
 
228
233
  .lm-ripple:hover {
229
- background: #E0E0E0 radial-gradient(circle, transparent 1%, #E0E0E0 1%) center/15000%;
234
+ background: var(--lm-background-color-hover, #ebebeb) radial-gradient(circle, transparent 1%, var(--lm-background-color-hover, #ebebeb) 1%) center/15000%;
230
235
  }
231
236
 
232
237
  .lm-ripple:active {
233
- background-color: #E0E0E0;
238
+ background-color: var(--lm-background-color-active, #e8e8e8);
234
239
  background-size: 100%;
235
240
  transition: background 0s;
236
241
  }
237
242
 
238
- .lm-dark-mode .lm-ripple:hover {
239
- background-color: #888;
240
- }
241
-
242
- .lm-dark-mode .lm-ripple:active {
243
- background-color: #888;
244
- }
245
-
246
243
  .lm-dark-mode .lm-calendar-weekdays {
247
244
  color: #aaa;
248
245
  }
@@ -251,21 +248,12 @@
251
248
  background-color: initial;
252
249
  }
253
250
 
254
- .lm-dark-mode .lm-calendar-content > div[data-selected="true"] {
255
- background-color: #444;
256
- }
257
-
258
251
  .lm-dark-mode .lm-calendar-content:focus > div[data-selected="true"] {
259
252
  outline-color: white;
260
253
  }
261
254
 
262
255
  .lm-dark-mode .lm-calendar-content > div[data-grey="true"] {
263
- color: #777;
264
- }
265
-
266
- .lm-dark-mode .lm-calendar-content > div:hover {
267
- color: white;
268
- background-color: #333;
256
+ color: var(--lm-font-grayout, #777);
269
257
  }
270
258
 
271
259
  .lm-dark-mode .lm-calendar-footer select:focus {
package/package.json CHANGED
@@ -14,10 +14,10 @@
14
14
  "javascript plugins"
15
15
  ],
16
16
  "dependencies": {
17
- "lemonadejs": "^4.2.1",
18
- "@lemonadejs/modal": "^2.8.0"
17
+ "lemonadejs": "^4.2.2",
18
+ "@lemonadejs/modal": "^2.8.1"
19
19
  },
20
20
  "main": "dist/index.js",
21
21
  "types": "dist/index.d.ts",
22
- "version": "3.3.0"
22
+ "version": "3.3.2"
23
23
  }