@lemonadejs/calendar 3.3.1 → 3.4.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.d.ts +7 -3
- package/dist/index.js +28 -14
- package/dist/style.css +10 -2
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -17,11 +17,15 @@ declare namespace Calendar {
|
|
|
17
17
|
/** Calendar value will be a excel-like number or a ISO string. Default false */
|
|
18
18
|
numeric?: boolean;
|
|
19
19
|
/** Bind the calendar to na HTML input element */
|
|
20
|
-
input?: HTMLElement;
|
|
20
|
+
input?: HTMLElement | object;
|
|
21
21
|
/** Onchange event */
|
|
22
|
-
onchange
|
|
22
|
+
onchange?: (self: object, value: string) => void;
|
|
23
23
|
/** On update event */
|
|
24
|
-
onupdate
|
|
24
|
+
onupdate?: (self: object, value: string) => void;
|
|
25
|
+
/** Footer **/
|
|
26
|
+
footer?: boolean;
|
|
27
|
+
/** Show hour and minute picker **/
|
|
28
|
+
time?: boolean;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
interface Instance {
|
package/dist/index.js
CHANGED
|
@@ -590,6 +590,14 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
590
590
|
setDate(d);
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
+
const getInput = function() {
|
|
594
|
+
let input = self.input;
|
|
595
|
+
if (input && input.current) {
|
|
596
|
+
input = input.current;
|
|
597
|
+
}
|
|
598
|
+
return input;
|
|
599
|
+
}
|
|
600
|
+
|
|
593
601
|
const applyValue = function(reset) {
|
|
594
602
|
if (reset) {
|
|
595
603
|
self.value = '';
|
|
@@ -599,7 +607,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
599
607
|
self.value = renderValue();
|
|
600
608
|
}
|
|
601
609
|
if (self.input) {
|
|
602
|
-
|
|
610
|
+
let input = getInput();
|
|
611
|
+
input.value = self.value;
|
|
603
612
|
}
|
|
604
613
|
}
|
|
605
614
|
|
|
@@ -662,10 +671,11 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
662
671
|
*/
|
|
663
672
|
self.open = function(e) {
|
|
664
673
|
if (self.modal && self.modal.closed) {
|
|
674
|
+
let input = getInput();
|
|
665
675
|
// Open modal
|
|
666
676
|
self.modal.closed = false;
|
|
667
677
|
// Set the focus on the content to use the keyboard
|
|
668
|
-
if (! (
|
|
678
|
+
if (! (input && e.target.getAttribute('readonly') === null)) {
|
|
669
679
|
self.content.focus();
|
|
670
680
|
}
|
|
671
681
|
|
|
@@ -726,7 +736,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
726
736
|
self.value = v;
|
|
727
737
|
// Update input
|
|
728
738
|
if (self.input) {
|
|
729
|
-
|
|
739
|
+
let input = getInput();
|
|
740
|
+
input.value = self.value;
|
|
730
741
|
}
|
|
731
742
|
}
|
|
732
743
|
|
|
@@ -771,16 +782,17 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
771
782
|
|
|
772
783
|
// Create input controls
|
|
773
784
|
if (self.input) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
785
|
+
let input = getInput();
|
|
786
|
+
input.classList.add('lm-calendar-input');
|
|
787
|
+
input.addEventListener('focus', self.open);
|
|
788
|
+
input.addEventListener('click', self.open);
|
|
789
|
+
input.addEventListener('blur', blur);
|
|
778
790
|
|
|
779
791
|
// Retrieve the value
|
|
780
792
|
if (self.value) {
|
|
781
|
-
|
|
782
|
-
} else if (
|
|
783
|
-
self.value =
|
|
793
|
+
input.value = self.value;
|
|
794
|
+
} else if (input.value) {
|
|
795
|
+
self.value = input.value;
|
|
784
796
|
}
|
|
785
797
|
}
|
|
786
798
|
|
|
@@ -825,6 +837,7 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
825
837
|
} else {
|
|
826
838
|
self.next();
|
|
827
839
|
}
|
|
840
|
+
e.preventDefault();
|
|
828
841
|
});
|
|
829
842
|
|
|
830
843
|
/**
|
|
@@ -839,7 +852,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
839
852
|
|
|
840
853
|
// Create event for focus out
|
|
841
854
|
self.el.addEventListener("focusout", (e) => {
|
|
842
|
-
|
|
855
|
+
let input = getInput();
|
|
856
|
+
if (e.relatedTarget !== input && ! self.el.contains(e.relatedTarget)) {
|
|
843
857
|
self.close();
|
|
844
858
|
}
|
|
845
859
|
});
|
|
@@ -861,9 +875,9 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
861
875
|
<div class="lm-calendar-content" :loop="self.options" tabindex="0" :ref="self.content">
|
|
862
876
|
<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>
|
|
863
877
|
</div>
|
|
864
|
-
<div class="lm-calendar-footer">
|
|
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>
|
|
866
|
-
<div><input type="button" value="Update" onclick="self.update" class="lm-ripple"></div>
|
|
878
|
+
<div class="lm-calendar-footer" data-visible="{{self.footer}}">
|
|
879
|
+
<div class="lm-calendar-time" data-visible="{{self.time}}"><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>
|
|
880
|
+
<div class="lm-calendar-update"><input type="button" value="Update" onclick="self.update" class="lm-ripple"></div>
|
|
867
881
|
</div>
|
|
868
882
|
</div>
|
|
869
883
|
</div>`
|
package/dist/style.css
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.lm-calendar-header .lm-calendar-labels > button {
|
|
56
|
-
font-size: 1.
|
|
56
|
+
font-size: 1.2em;
|
|
57
57
|
border: 0;
|
|
58
58
|
padding: 4px;
|
|
59
59
|
background-color: transparent;
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
right: 0;
|
|
174
174
|
top: 8px;
|
|
175
175
|
bottom: 8px;
|
|
176
|
-
background-color: var(--lm-main-color-alpha, #
|
|
176
|
+
background-color: var(--lm-main-color-alpha, #2196f388);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
.lm-calendar-content > div[data-start="true"]::before {
|
|
@@ -196,6 +196,10 @@
|
|
|
196
196
|
border-top: 1px solid var(--lm-border-color, #ccc);
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
.lm-calendar-footer[data-visible="false"] {
|
|
200
|
+
display: none;
|
|
201
|
+
}
|
|
202
|
+
|
|
199
203
|
.lm-calendar-footer select {
|
|
200
204
|
border: 0;
|
|
201
205
|
background-color: transparent;
|
|
@@ -225,6 +229,10 @@
|
|
|
225
229
|
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Zm280 240q-17 0-28.5-11.5T440-440q0-17 11.5-28.5T480-480q17 0 28.5 11.5T520-440q0 17-11.5 28.5T480-400Zm-160 0q-17 0-28.5-11.5T280-440q0-17 11.5-28.5T320-480q17 0 28.5 11.5T360-440q0 17-11.5 28.5T320-400Zm320 0q-17 0-28.5-11.5T600-440q0-17 11.5-28.5T640-480q17 0 28.5 11.5T680-440q0 17-11.5 28.5T640-400ZM480-240q-17 0-28.5-11.5T440-280q0-17 11.5-28.5T480-320q17 0 28.5 11.5T520-280q0 17-11.5 28.5T480-240Zm-160 0q-17 0-28.5-11.5T280-280q0-17 11.5-28.5T320-320q17 0 28.5 11.5T360-280q0 17-11.5 28.5T320-240Zm320 0q-17 0-28.5-11.5T600-280q0-17 11.5-28.5T640-320q17 0 28.5 11.5T680-280q0 17-11.5 28.5T640-240Z" fill="gray" /></svg>') top 50% right 1px no-repeat;
|
|
226
230
|
}
|
|
227
231
|
|
|
232
|
+
.lm-calendar-time[data-visible="false"] {
|
|
233
|
+
display: none;
|
|
234
|
+
}
|
|
235
|
+
|
|
228
236
|
.lm-ripple {
|
|
229
237
|
background-position: center;
|
|
230
238
|
transition: background 0.8s;
|
package/package.json
CHANGED