@lemonadejs/calendar 3.3.2 → 3.4.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.d.ts +11 -5
- package/dist/index.js +76 -38
- package/dist/react.js +16 -11
- package/dist/style.css +10 -2
- package/dist/vue.js +13 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,11 +17,17 @@ 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;
|
|
21
|
-
/**
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
|
|
20
|
+
input?: HTMLElement | object | 'auto';
|
|
21
|
+
/** Footer **/
|
|
22
|
+
footer?: boolean;
|
|
23
|
+
/** Show hour and minute picker **/
|
|
24
|
+
time?: boolean;
|
|
25
|
+
/** LemonadeJS on change event */
|
|
26
|
+
onchange?: (self: object, value: string) => void;
|
|
27
|
+
/** LemonadeJS on update event */
|
|
28
|
+
onupdate?: (self: object, value: string) => void;
|
|
29
|
+
/** React dedicated onChange event */
|
|
30
|
+
onChange?: (e: Event) => void;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
interface Instance {
|
package/dist/index.js
CHANGED
|
@@ -558,7 +558,7 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
558
558
|
if (! Array.isArray(v)) {
|
|
559
559
|
v = v.split(',');
|
|
560
560
|
}
|
|
561
|
-
self.rangeValues = v;
|
|
561
|
+
self.rangeValues = [...v];
|
|
562
562
|
|
|
563
563
|
if (v[0] && typeof(v[0]) === 'string' && v[0].indexOf('-')) {
|
|
564
564
|
self.rangeValues[0] = dateToNum(v[0]);
|
|
@@ -590,17 +590,32 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
590
590
|
setDate(d);
|
|
591
591
|
}
|
|
592
592
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
593
|
+
let autoInput = null;
|
|
594
|
+
|
|
595
|
+
const getInput = function() {
|
|
596
|
+
let input = self.input;
|
|
597
|
+
if (input && input.current) {
|
|
598
|
+
input = input.current;
|
|
597
599
|
} else {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
600
|
+
if (input === 'auto') {
|
|
601
|
+
if (! autoInput) {
|
|
602
|
+
autoInput = document.createElement('input');
|
|
603
|
+
autoInput.type = 'text';
|
|
604
|
+
if (self.class) {
|
|
605
|
+
autoInput.class = self.class;
|
|
606
|
+
}
|
|
607
|
+
if (self.name) {
|
|
608
|
+
autoInput.name = self.name;
|
|
609
|
+
}
|
|
610
|
+
if (self.placeholder) {
|
|
611
|
+
autoInput.placeholder = self.placeholder;
|
|
612
|
+
}
|
|
613
|
+
self.el.parentNode.insertBefore(autoInput, self.el);
|
|
614
|
+
}
|
|
615
|
+
input = autoInput;
|
|
616
|
+
}
|
|
603
617
|
}
|
|
618
|
+
return input;
|
|
604
619
|
}
|
|
605
620
|
|
|
606
621
|
/**
|
|
@@ -662,18 +677,18 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
662
677
|
*/
|
|
663
678
|
self.open = function(e) {
|
|
664
679
|
if (self.modal && self.modal.closed) {
|
|
680
|
+
let input = getInput();
|
|
665
681
|
// Open modal
|
|
666
682
|
self.modal.closed = false;
|
|
667
683
|
// Set the focus on the content to use the keyboard
|
|
668
|
-
if (! (
|
|
684
|
+
if (! (input && e.target.getAttribute('readonly') === null)) {
|
|
669
685
|
self.content.focus();
|
|
670
686
|
}
|
|
671
|
-
|
|
672
|
-
// Update the internal date values
|
|
673
|
-
updateValue(self.value);
|
|
674
687
|
// Populate components
|
|
675
688
|
self.hours = views.hours();
|
|
676
689
|
self.minutes = views.minutes();
|
|
690
|
+
// Update the internal date values
|
|
691
|
+
updateValue(self.value);
|
|
677
692
|
}
|
|
678
693
|
}
|
|
679
694
|
|
|
@@ -690,12 +705,12 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
690
705
|
}
|
|
691
706
|
|
|
692
707
|
self.reset = function() {
|
|
693
|
-
|
|
708
|
+
self.setValue('');
|
|
694
709
|
self.close();
|
|
695
710
|
}
|
|
696
711
|
|
|
697
712
|
self.update = function() {
|
|
698
|
-
|
|
713
|
+
self.setValue(renderValue());
|
|
699
714
|
self.close();
|
|
700
715
|
}
|
|
701
716
|
|
|
@@ -718,15 +733,19 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
718
733
|
}
|
|
719
734
|
|
|
720
735
|
self.setValue = function(v) {
|
|
721
|
-
// Destroy range
|
|
722
|
-
destroyRange();
|
|
723
736
|
// Update the internal controllers
|
|
724
737
|
updateValue(v);
|
|
725
|
-
//
|
|
726
|
-
|
|
738
|
+
// Destroy range
|
|
739
|
+
destroyRange();
|
|
727
740
|
// Update input
|
|
728
741
|
if (self.input) {
|
|
729
|
-
|
|
742
|
+
let input = getInput();
|
|
743
|
+
input.value = v;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
if (v !== self.value) {
|
|
747
|
+
// Update value
|
|
748
|
+
self.value = v;
|
|
730
749
|
}
|
|
731
750
|
}
|
|
732
751
|
|
|
@@ -743,14 +762,20 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
743
762
|
if (typeof (self.onupdate) === 'function') {
|
|
744
763
|
self.onupdate(self, self.value);
|
|
745
764
|
}
|
|
765
|
+
if (typeof(self.onChange) === 'function') {
|
|
766
|
+
let input = getInput();
|
|
767
|
+
if (input) {
|
|
768
|
+
input.dispatchEvent(new Event('change', {bubbles: true, cancelable: true}));
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
self.setValue(self.value);
|
|
746
773
|
} else if (prop === 'options') {
|
|
747
774
|
self.content.focus();
|
|
748
775
|
}
|
|
749
776
|
}
|
|
750
777
|
|
|
751
778
|
self.onload = function() {
|
|
752
|
-
// Update the internal date values
|
|
753
|
-
updateValue(self.value);
|
|
754
779
|
// Populate components
|
|
755
780
|
self.hours = views.hours();
|
|
756
781
|
self.minutes = views.minutes();
|
|
@@ -771,19 +796,27 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
771
796
|
|
|
772
797
|
// Create input controls
|
|
773
798
|
if (self.input) {
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
799
|
+
let input = getInput();
|
|
800
|
+
input.classList.add('lm-calendar-input');
|
|
801
|
+
input.addEventListener('focus', self.open);
|
|
802
|
+
input.addEventListener('click', self.open);
|
|
803
|
+
input.addEventListener('blur', blur);
|
|
804
|
+
|
|
805
|
+
if (self.onChange) {
|
|
806
|
+
input.addEventListener('change', self.onChange);
|
|
807
|
+
}
|
|
778
808
|
|
|
779
809
|
// Retrieve the value
|
|
780
810
|
if (self.value) {
|
|
781
|
-
|
|
782
|
-
} else if (
|
|
783
|
-
self.value =
|
|
811
|
+
input.value = self.value;
|
|
812
|
+
} else if (input.value && input.value !== self.value) {
|
|
813
|
+
self.value = input.value;
|
|
784
814
|
}
|
|
785
815
|
}
|
|
786
816
|
|
|
817
|
+
// Update the internal date values
|
|
818
|
+
updateValue(self.value);
|
|
819
|
+
|
|
787
820
|
/**
|
|
788
821
|
* Handler keyboard
|
|
789
822
|
* @param {object} e - event
|
|
@@ -825,6 +858,7 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
825
858
|
} else {
|
|
826
859
|
self.next();
|
|
827
860
|
}
|
|
861
|
+
e.preventDefault();
|
|
828
862
|
});
|
|
829
863
|
|
|
830
864
|
/**
|
|
@@ -839,7 +873,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
839
873
|
|
|
840
874
|
// Create event for focus out
|
|
841
875
|
self.el.addEventListener("focusout", (e) => {
|
|
842
|
-
|
|
876
|
+
let input = getInput();
|
|
877
|
+
if (e.relatedTarget !== input && ! self.el.contains(e.relatedTarget)) {
|
|
843
878
|
self.close();
|
|
844
879
|
}
|
|
845
880
|
});
|
|
@@ -847,23 +882,26 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
847
882
|
|
|
848
883
|
return `<div class="lm-calendar" :value="self.value">
|
|
849
884
|
<div class="lm-calendar-options">
|
|
850
|
-
<button onclick="self.reset">Reset</button>
|
|
851
|
-
<button onclick="self.update">Done</button>
|
|
885
|
+
<button type="button" onclick="self.reset">Reset</button>
|
|
886
|
+
<button type="button" onclick="self.update">Done</button>
|
|
852
887
|
</div>
|
|
853
888
|
<div class="lm-calendar-container" data-view="{{self.view}}">
|
|
854
889
|
<div class="lm-calendar-header">
|
|
855
890
|
<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"
|
|
891
|
+
<div class="lm-calendar-labels"><button type="button" onclick="self.setView" data-view="months">{{self.month}}</button> <button type="button" onclick="self.setView" data-view="years">{{self.year}}</button></div>
|
|
892
|
+
<div class="lm-calendar-navigation">
|
|
893
|
+
<button type="button" class="material-icons lm-ripple" onclick="self.prev" tabindex="0">arrow_drop_up</button>
|
|
894
|
+
<button type="button" class="material-icons lm-ripple" onclick="self.next" tabindex="0">arrow_drop_down</button>
|
|
895
|
+
</div>
|
|
858
896
|
</div>
|
|
859
897
|
<div class="lm-calendar-weekdays" :loop="self.weekdays"><div>{{self.title}}</div></div>
|
|
860
898
|
</div>
|
|
861
899
|
<div class="lm-calendar-content" :loop="self.options" tabindex="0" :ref="self.content">
|
|
862
900
|
<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
901
|
</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>
|
|
902
|
+
<div class="lm-calendar-footer" data-visible="{{self.footer}}">
|
|
903
|
+
<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>
|
|
904
|
+
<div class="lm-calendar-update"><input type="button" value="Update" onclick="self.update" class="lm-ripple"></div>
|
|
867
905
|
</div>
|
|
868
906
|
</div>
|
|
869
907
|
</div>`
|
package/dist/react.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import React, { useRef, useEffect } from "react";
|
|
3
3
|
import Component from './index';
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
// @ts-ignore
|
|
7
6
|
export default React.forwardRef((props, mainReference) => {
|
|
8
7
|
// Dom element
|
|
@@ -13,21 +12,27 @@ export default React.forwardRef((props, mainReference) => {
|
|
|
13
12
|
|
|
14
13
|
useEffect(() => {
|
|
15
14
|
// @ts-ignore
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
mainReference.current[key] = props[key];
|
|
15
|
+
if (Ref.current.innerHTML) {
|
|
16
|
+
for (let key in props) {
|
|
17
|
+
if (key === 'onchange' || key === 'onload') {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
|
|
21
|
+
if (props[key] !== mainReference.current[key]) {
|
|
22
|
+
mainReference.current[key] = props[key];
|
|
23
|
+
}
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
}, [props])
|
|
30
28
|
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
if (! Ref.current.innerHTML) {
|
|
32
|
+
mainReference.current = Component(Ref.current, options);
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
31
36
|
let prop = {
|
|
32
37
|
ref: Ref,
|
|
33
38
|
style: { height: '100%', width: '100%' }
|
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/dist/vue.js
CHANGED
|
@@ -5,13 +5,13 @@ import component from "./index";
|
|
|
5
5
|
export default {
|
|
6
6
|
inheritAttrs: false,
|
|
7
7
|
mounted() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
this.$nextTick(() => {
|
|
9
|
+
let options = {
|
|
10
|
+
...this.$attrs
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
this.current = component(this.$refs.container, options);
|
|
14
|
+
});
|
|
15
15
|
},
|
|
16
16
|
setup() {
|
|
17
17
|
let containerProps = {
|
|
@@ -33,10 +33,12 @@ export default {
|
|
|
33
33
|
},
|
|
34
34
|
methods: {
|
|
35
35
|
updateState() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (this.$attrs
|
|
39
|
-
this
|
|
36
|
+
if (this.current) {
|
|
37
|
+
for (let key in this.$attrs) {
|
|
38
|
+
if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
|
|
39
|
+
if (this.$attrs[key] !== this.current[key]) {
|
|
40
|
+
this.current[key] = this.$attrs[key];
|
|
41
|
+
}
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
}
|
package/package.json
CHANGED