@lemonadejs/calendar 3.4.0 → 3.5.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 CHANGED
@@ -10,6 +10,8 @@ declare namespace Calendar {
10
10
  interface Options {
11
11
  /** Calendar type */
12
12
  type?: 'default' | 'inline';
13
+ /** Date format */
14
+ format?: string;
13
15
  /** Range picker */
14
16
  range?: boolean;
15
17
  /** Value */
@@ -17,15 +19,21 @@ declare namespace Calendar {
17
19
  /** Calendar value will be a excel-like number or a ISO string. Default false */
18
20
  numeric?: boolean;
19
21
  /** Bind the calendar to na HTML input element */
20
- input?: HTMLElement | object;
21
- /** Onchange event */
22
- onchange?: (self: object, value: string) => void;
23
- /** On update event */
24
- onupdate?: (self: object, value: string) => void;
25
- /** Footer **/
22
+ input?: HTMLElement | object | 'auto';
23
+ /** Footer. Default: true **/
26
24
  footer?: boolean;
27
25
  /** Show hour and minute picker **/
28
26
  time?: boolean;
27
+ /** Show grid mode. Default: false */
28
+ grid?: boolean;
29
+ /** Update view on mouse wheel. Default: true */
30
+ wheel?: boolean;
31
+ /** LemonadeJS on change event */
32
+ onchange?: (self: object, value: string) => void;
33
+ /** LemonadeJS on update event */
34
+ onupdate?: (self: object, value: string) => void;
35
+ /** React dedicated onChange event */
36
+ onChange?: (e: Event) => void;
29
37
  }
30
38
 
31
39
  interface Instance {
package/dist/index.js CHANGED
@@ -13,31 +13,88 @@ if (! Modal && typeof (require) === 'function') {
13
13
  var Modal = require('@lemonadejs/modal');
14
14
  }
15
15
 
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 () {
21
-
22
- // Weekdays
23
- const Weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
16
+ const Helpers = (function() {
17
+ const component = {};
24
18
 
25
- // Months
26
- const Months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
19
+ component.weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
20
+ component.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
27
21
 
28
22
  // Excel like dates
29
23
  const excelInitialTime = Date.UTC(1900, 0, 0);
30
24
  const excelLeapYearBug = Date.UTC(1900, 1, 29);
31
25
  const millisecondsPerDay = 86400000;
32
26
 
33
- function isValidDate(d) {
27
+ // Transform in two digits
28
+ component.Two = function(value) {
29
+ value = '' + value;
30
+ if (value.length === 1) {
31
+ value = '0' + value;
32
+ }
33
+ return value;
34
+ }
35
+
36
+ component.isValidDate = function(d) {
34
37
  return d instanceof Date && !isNaN(d.getTime());
35
38
  }
36
39
 
37
- /**
38
- * Date to number
39
- */
40
- const dateToNum = function (jsDate) {
40
+ component.toString = function (date, dateOnly) {
41
+ let y = null;
42
+ let m = null;
43
+ let d = null;
44
+ let h = null;
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();
58
+ }
59
+ y = date.getFullYear();
60
+ m = date.getMonth() + 1;
61
+ d = date.getDate();
62
+ h = date.getHours();
63
+ i = date.getMinutes();
64
+ s = date.getSeconds();
65
+ }
66
+
67
+ if (dateOnly === true) {
68
+ return component.Two(y) + '-' + component.Two(m) + '-' + component.Two(d);
69
+ } else {
70
+ return component.Two(y) + '-' + component.Two(m) + '-' + component.Two(d) + ' ' + component.Two(h) + ':' + component.Two(i) + ':' + component.Two(s);
71
+ }
72
+ }
73
+
74
+ component.toArray = function (value) {
75
+ let date = value.split(((value.indexOf('T') !== -1) ? 'T' : ' '));
76
+ let time = date[1];
77
+
78
+ date = date[0].split('-');
79
+ let y = parseInt(date[0]);
80
+ let m = parseInt(date[1]);
81
+ let d = parseInt(date[2]);
82
+ let h = 0;
83
+ let i = 0;
84
+
85
+ if (time) {
86
+ time = time.split(':');
87
+ h = parseInt(time[0]);
88
+ i = parseInt(time[1]);
89
+ }
90
+ return [y, m, d, h, i, 0];
91
+ }
92
+
93
+ component.arrayToStringDate = function(arr) {
94
+ return component.toString(arr, true);
95
+ }
96
+
97
+ component.dateToNum = function(jsDate) {
41
98
  if (typeof(jsDate) === 'string') {
42
99
  jsDate = new Date(jsDate + ' GMT+0');
43
100
  }
@@ -50,7 +107,7 @@ if (! Modal && typeof (require) === 'function') {
50
107
  return jsDateInMilliseconds / millisecondsPerDay;
51
108
  }
52
109
 
53
- const numToDate = function (excelSerialNumber, asString) {
110
+ component.numToDate = function(excelSerialNumber, asString){
54
111
  if (! excelSerialNumber) {
55
112
  return '';
56
113
  }
@@ -64,20 +121,29 @@ if (! Modal && typeof (require) === 'function') {
64
121
 
65
122
  let arr = [
66
123
  d.getUTCFullYear(),
67
- Two(d.getUTCMonth() + 1),
68
- Two(d.getUTCDate()),
69
- Two(d.getUTCHours()),
70
- Two(d.getUTCMinutes()),
71
- Two(d.getUTCSeconds()),
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()),
72
129
  ];
73
130
 
74
131
  if (asString) {
75
- return arrayToStringDate(arr);
132
+ return component.arrayToStringDate(arr);
76
133
  } else {
77
134
  return arr;
78
135
  }
79
136
  }
80
137
 
138
+ return component;
139
+ })();
140
+
141
+ ; (function (global, factory) {
142
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
143
+ typeof define === 'function' && define.amd ? define(factory) :
144
+ global.Calendar = factory();
145
+ }(this, (function () {
146
+
81
147
  const isNumber = function (num) {
82
148
  if (typeof(num) === 'string') {
83
149
  num = num.trim();
@@ -85,10 +151,6 @@ if (! Modal && typeof (require) === 'function') {
85
151
  return !isNaN(num) && num !== null && num !== '';
86
152
  }
87
153
 
88
- const arrayToStringDate = function(arr) {
89
- return [arr[0],Two(arr[1]),Two(arr[2])].join('-');
90
- }
91
-
92
154
  /**
93
155
  * Create a data calendar object based on the view
94
156
  */
@@ -120,7 +182,7 @@ if (! Modal && typeof (require) === 'function') {
120
182
  let result = [];
121
183
  for (let i = 0; i < 12; i++) {
122
184
  let item = {
123
- title: Months[i].substring(0,3),
185
+ title: Helpers.months[i].substring(0,3),
124
186
  value: i
125
187
  }
126
188
  // Add the item to the data
@@ -155,7 +217,7 @@ if (! Modal && typeof (require) === 'function') {
155
217
  let item = {
156
218
  title: day,
157
219
  value: i,
158
- number: dateToNum(tmp.toString())
220
+ number: Helpers.dateToNum(tmp.toString())
159
221
  }
160
222
  // Add the item to the date
161
223
  result.push(item);
@@ -165,7 +227,7 @@ if (! Modal && typeof (require) === 'function') {
165
227
  item.grey = true;
166
228
  } else {
167
229
  // Check for data
168
- let d = [ year, Two(month+1), Two(day)].join('-');
230
+ let d = [ year, Helpers.Two(month+1), Helpers.Two(day)].join('-');
169
231
  if (data && data[d]) {
170
232
  item.data = data[d];
171
233
  }
@@ -205,7 +267,7 @@ if (! Modal && typeof (require) === 'function') {
205
267
  let result = [];
206
268
  for (let i = 0; i < 24; i++) {
207
269
  let item = {
208
- title: Two(i),
270
+ title: Helpers.Two(i),
209
271
  value: i
210
272
  };
211
273
  result.push(item);
@@ -216,7 +278,7 @@ if (! Modal && typeof (require) === 'function') {
216
278
  let result = [];
217
279
  for (let i = 0; i < 60; i=i+5) {
218
280
  let item = {
219
- title: Two(i),
281
+ title: Helpers.Two(i),
220
282
  value: i
221
283
  };
222
284
  result.push(item);
@@ -230,7 +292,7 @@ if (! Modal && typeof (require) === 'function') {
230
292
  let data = {};
231
293
  if (Array.isArray(this.data)) {
232
294
  this.data.map(function (v) {
233
- let d = year + '-' + Two(month + 1);
295
+ let d = year + '-' + Helpers.Two(month + 1);
234
296
  if (v.date.substring(0, 7) === d) {
235
297
  if (!data[v.date]) {
236
298
  data[v.date] = [];
@@ -241,9 +303,10 @@ if (! Modal && typeof (require) === 'function') {
241
303
  }
242
304
  return data;
243
305
  }
306
+
244
307
  // Get the short weekdays name
245
308
  const getWeekdays = function() {
246
- return Weekdays.map(w => {
309
+ return Helpers.weekdays.map(w => {
247
310
  return { title: w.substring(0, 1) };
248
311
  })
249
312
  }
@@ -268,14 +331,6 @@ if (! Modal && typeof (require) === 'function') {
268
331
  return position;
269
332
  }
270
333
 
271
- // Transform in two digits
272
- const Two = function(value) {
273
- value = '' + value;
274
- if (value.length === 1) {
275
- value = '0' + value;
276
- }
277
- return value;
278
- }
279
334
 
280
335
  const Calendar = function() {
281
336
  let self = this;
@@ -310,7 +365,7 @@ if (! Modal && typeof (require) === 'function') {
310
365
  // Update the headers of the calendar
311
366
  let value = d.toISOString().substring(0,10).split('-');
312
367
  // Update the month label
313
- self.month = Months[parseInt(value[1])-1];
368
+ self.month = Helpers.months[parseInt(value[1])-1];
314
369
  // Update the year label
315
370
  self.year = parseInt(value[0]);
316
371
  // Load data
@@ -478,7 +533,7 @@ if (! Modal && typeof (require) === 'function') {
478
533
  if (self.view === 'days' && self.range) {
479
534
  let d = getDate();
480
535
  // Date to number
481
- let number = dateToNum(d);
536
+ let number = Helpers.dateToNum(d);
482
537
  // Start a new range
483
538
  if (self.rangeValues && (self.rangeValues[0] >= number || self.rangeValues[1])) {
484
539
  destroyRange();
@@ -538,15 +593,15 @@ if (! Modal && typeof (require) === 'function') {
538
593
  value = self.rangeValues;
539
594
  } else {
540
595
  value = [
541
- numToDate(self.rangeValues[0], true),
542
- numToDate(self.rangeValues[1], true)
596
+ Helpers.numToDate(self.rangeValues[0], true),
597
+ Helpers.numToDate(self.rangeValues[1], true)
543
598
  ];
544
599
  }
545
600
  }
546
601
  } else {
547
602
  value = getDate();
548
603
  if (self.numeric) {
549
- value = dateToNum(value);
604
+ value = Helpers.dateToNum(value);
550
605
  }
551
606
  }
552
607
  return value;
@@ -558,13 +613,13 @@ if (! Modal && typeof (require) === 'function') {
558
613
  if (! Array.isArray(v)) {
559
614
  v = v.split(',');
560
615
  }
561
- self.rangeValues = v;
616
+ self.rangeValues = [...v];
562
617
 
563
618
  if (v[0] && typeof(v[0]) === 'string' && v[0].indexOf('-')) {
564
- self.rangeValues[0] = dateToNum(v[0]);
619
+ self.rangeValues[0] = Helpers.dateToNum(v[0]);
565
620
  }
566
621
  if (v[1] && typeof(v[1]) === 'string' && v[1].indexOf('-')) {
567
- self.rangeValues[1] = dateToNum(v[1]);
622
+ self.rangeValues[1] = Helpers.dateToNum(v[1]);
568
623
  }
569
624
 
570
625
  v = v[0];
@@ -573,11 +628,11 @@ if (! Modal && typeof (require) === 'function') {
573
628
 
574
629
  let d;
575
630
  if (v) {
576
- v = isNumber(v) ? numToDate(v, true) : v;
631
+ v = isNumber(v) ? Helpers.numToDate(v, true) : v;
577
632
  d = new Date(v);
578
633
  }
579
634
  // if no date is defined
580
- if (! isValidDate(d)) {
635
+ if (! Helpers.isValidDate(d)) {
581
636
  d = new Date();
582
637
  }
583
638
  // Update my index
@@ -590,26 +645,32 @@ if (! Modal && typeof (require) === 'function') {
590
645
  setDate(d);
591
646
  }
592
647
 
648
+ let autoInput = null;
649
+
593
650
  const getInput = function() {
594
651
  let input = self.input;
595
652
  if (input && input.current) {
596
653
  input = input.current;
597
- }
598
- return input;
599
- }
600
-
601
- const applyValue = function(reset) {
602
- if (reset) {
603
- self.value = '';
604
- destroyRange();
605
654
  } else {
606
- // Set the internal value
607
- self.value = renderValue();
608
- }
609
- if (self.input) {
610
- let input = getInput();
611
- input.value = self.value;
655
+ if (input === 'auto') {
656
+ if (! autoInput) {
657
+ autoInput = document.createElement('input');
658
+ autoInput.type = 'text';
659
+ if (self.class) {
660
+ autoInput.class = self.class;
661
+ }
662
+ if (self.name) {
663
+ autoInput.name = self.name;
664
+ }
665
+ if (self.placeholder) {
666
+ autoInput.placeholder = self.placeholder;
667
+ }
668
+ self.el.parentNode.insertBefore(autoInput, self.el);
669
+ }
670
+ input = autoInput;
671
+ }
612
672
  }
673
+ return input;
613
674
  }
614
675
 
615
676
  /**
@@ -626,6 +687,10 @@ if (! Modal && typeof (require) === 'function') {
626
687
  setDate(value);
627
688
  // Back to the days
628
689
  self.view = 'days';
690
+ } else {
691
+ if (! self.range) {
692
+ self.update();
693
+ }
629
694
  }
630
695
  }
631
696
 
@@ -678,12 +743,11 @@ if (! Modal && typeof (require) === 'function') {
678
743
  if (! (input && e.target.getAttribute('readonly') === null)) {
679
744
  self.content.focus();
680
745
  }
681
-
682
- // Update the internal date values
683
- updateValue(self.value);
684
746
  // Populate components
685
747
  self.hours = views.hours();
686
748
  self.minutes = views.minutes();
749
+ // Update the internal date values
750
+ updateValue(self.value);
687
751
  }
688
752
  }
689
753
 
@@ -700,12 +764,12 @@ if (! Modal && typeof (require) === 'function') {
700
764
  }
701
765
 
702
766
  self.reset = function() {
703
- applyValue(true);
767
+ self.setValue('');
704
768
  self.close();
705
769
  }
706
770
 
707
771
  self.update = function() {
708
- applyValue();
772
+ self.setValue(renderValue());
709
773
  self.close();
710
774
  }
711
775
 
@@ -728,16 +792,19 @@ if (! Modal && typeof (require) === 'function') {
728
792
  }
729
793
 
730
794
  self.setValue = function(v) {
731
- // Destroy range
732
- destroyRange();
733
795
  // Update the internal controllers
734
796
  updateValue(v);
735
- // Update value
736
- self.value = v;
797
+ // Destroy range
798
+ destroyRange();
737
799
  // Update input
738
800
  if (self.input) {
739
801
  let input = getInput();
740
- input.value = self.value;
802
+ input.value = v;
803
+ }
804
+
805
+ if (v !== self.value) {
806
+ // Update value
807
+ self.value = v;
741
808
  }
742
809
  }
743
810
 
@@ -754,14 +821,20 @@ if (! Modal && typeof (require) === 'function') {
754
821
  if (typeof (self.onupdate) === 'function') {
755
822
  self.onupdate(self, self.value);
756
823
  }
824
+ if (typeof(self.onChange) === 'function') {
825
+ let input = getInput();
826
+ if (input) {
827
+ input.dispatchEvent(new Event('change', {bubbles: true, cancelable: true}));
828
+ }
829
+ }
830
+
831
+ self.setValue(self.value);
757
832
  } else if (prop === 'options') {
758
833
  self.content.focus();
759
834
  }
760
835
  }
761
836
 
762
837
  self.onload = function() {
763
- // Update the internal date values
764
- updateValue(self.value);
765
838
  // Populate components
766
839
  self.hours = views.hours();
767
840
  self.minutes = views.minutes();
@@ -788,14 +861,21 @@ if (! Modal && typeof (require) === 'function') {
788
861
  input.addEventListener('click', self.open);
789
862
  input.addEventListener('blur', blur);
790
863
 
864
+ if (self.onChange) {
865
+ input.addEventListener('change', self.onChange);
866
+ }
867
+
791
868
  // Retrieve the value
792
869
  if (self.value) {
793
870
  input.value = self.value;
794
- } else if (input.value) {
871
+ } else if (input.value && input.value !== self.value) {
795
872
  self.value = input.value;
796
873
  }
797
874
  }
798
875
 
876
+ // Update the internal date values
877
+ updateValue(self.value);
878
+
799
879
  /**
800
880
  * Handler keyboard
801
881
  * @param {object} e - event
@@ -819,6 +899,10 @@ if (! Modal && typeof (require) === 'function') {
819
899
  self.update();
820
900
  }
821
901
  prevent = true;
902
+ } else {
903
+ if (self.input) {
904
+ jSuites.mask(e);
905
+ }
822
906
  }
823
907
 
824
908
  if (prevent) {
@@ -832,12 +916,14 @@ if (! Modal && typeof (require) === 'function') {
832
916
  * @param {object} e - mouse event
833
917
  */
834
918
  self.content.addEventListener('wheel', function(e){
835
- if (e.deltaY < 0) {
836
- self.prev();
837
- } else {
838
- self.next();
919
+ if (self.wheel !== false) {
920
+ if (e.deltaY < 0) {
921
+ self.prev();
922
+ } else {
923
+ self.next();
924
+ }
925
+ e.preventDefault();
839
926
  }
840
- e.preventDefault();
841
927
  });
842
928
 
843
929
  /**
@@ -845,8 +931,10 @@ if (! Modal && typeof (require) === 'function') {
845
931
  * @param {object} e - mouse event
846
932
  */
847
933
  self.content.addEventListener('mouseover', function(e){
848
- if (e.target.lemon) {
849
- updateRange(e.target.lemon.self);
934
+ let parent = e.target.parentNode
935
+ if (parent === self.content) {
936
+ let index = Array.prototype.indexOf.call(parent.children, e.target);
937
+ updateRange(self.options[index]);
850
938
  }
851
939
  });
852
940
 
@@ -859,16 +947,19 @@ if (! Modal && typeof (require) === 'function') {
859
947
  });
860
948
  }
861
949
 
862
- return `<div class="lm-calendar" :value="self.value">
950
+ return `<div class="lm-calendar" :value="self.value" data-grid="{{self.grid}}">
863
951
  <div class="lm-calendar-options">
864
- <button onclick="self.reset">Reset</button>
865
- <button onclick="self.update">Done</button>
952
+ <button type="button" onclick="self.reset">Reset</button>
953
+ <button type="button" onclick="self.update">Done</button>
866
954
  </div>
867
955
  <div class="lm-calendar-container" data-view="{{self.view}}">
868
956
  <div class="lm-calendar-header">
869
957
  <div>
870
- <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>
871
- <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>
958
+ <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>
959
+ <div class="lm-calendar-navigation">
960
+ <button type="button" class="material-icons lm-ripple" onclick="self.prev" tabindex="0">arrow_drop_up</button>
961
+ <button type="button" class="material-icons lm-ripple" onclick="self.next" tabindex="0">arrow_drop_down</button>
962
+ </div>
872
963
  </div>
873
964
  <div class="lm-calendar-weekdays" :loop="self.weekdays"><div>{{self.title}}</div></div>
874
965
  </div>
@@ -883,7 +974,10 @@ if (! Modal && typeof (require) === 'function') {
883
974
  </div>`
884
975
  }
885
976
 
977
+ // Register the LemonadeJS Component
886
978
  lemonade.setComponents({ Calendar: Calendar });
979
+ // Register the web component
980
+ lemonade.createWebComponent('calendar', Calendar);
887
981
 
888
982
  return function (root, options) {
889
983
  if (typeof (root) === 'object') {
package/dist/react.d.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  /**
2
2
  * Official Type definitions for the LemonadeJS plugins
3
- * https://lemonadejs.net
3
+ * https://lemonadejs.net/docs/plugins/calendar
4
4
  * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
5
  */
6
6
  import Component from './index';
7
+
7
8
  interface Calendar {
9
+ ref?: MutableRefObject<undefined>;
8
10
  (): any
9
11
  [key: string]: any
10
12
  }
11
13
 
12
- declare function Calendar<Calendar>(props: Component.Options): any;
14
+ type Props = IntrinsicAttributes & Component.Options & Calendar;
15
+
16
+ declare function Calendar<Calendar>(props: Props): any;
17
+
13
18
  export default Calendar;
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 (!Ref.current.innerHTML) {
17
- mainReference.current = Component(Ref.current, options);
18
- }
19
- }, []);
20
-
21
- useEffect(() => {
22
- for (let key in props) {
23
- if (props.hasOwnProperty(key) && mainReference.current.hasOwnProperty(key)) {
24
- if (props[key] !== mainReference.current[key]) {
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
@@ -57,6 +57,7 @@
57
57
  border: 0;
58
58
  padding: 4px;
59
59
  background-color: transparent;
60
+ font-weight: bold;
60
61
  }
61
62
 
62
63
  .lm-calendar-navigation button {
@@ -74,27 +75,28 @@
74
75
  .lm-calendar-weekdays {
75
76
  display: none;
76
77
  grid-template-columns: repeat(7, 1fr);
77
- grid-gap: 2px;
78
- padding: 0 10px 0 10px;
78
+ padding: 0 8px 0 8px;
79
79
  font-size: 0.8em;
80
80
  }
81
81
 
82
82
  .lm-calendar-container[data-view="days"] .lm-calendar-weekdays {
83
83
  display: grid;
84
+ align-items: center;
85
+ flex: 1;
84
86
  }
85
87
 
86
88
  .lm-calendar-weekdays > div {
87
89
  display: inline-block;
88
- padding: 10px;
90
+ padding: 6px;
89
91
  box-sizing: border-box;
90
92
  text-align: center;
91
93
  font-weight: bold;
94
+ line-height: 2em;
92
95
  }
93
96
 
94
97
  .lm-calendar-content {
95
98
  display: grid;
96
99
  grid-template-columns: repeat(7, 1fr);
97
- grid-gap: 0;
98
100
  padding: 8px;
99
101
  font-size: 0.8em;
100
102
  outline: none;
@@ -108,7 +110,7 @@
108
110
  flex-direction: column;
109
111
  justify-content: center;
110
112
  align-items: center;
111
- padding: 10px;
113
+ padding: 6px;
112
114
  cursor: pointer;
113
115
  border-radius: 100px;
114
116
  background-origin: padding-box;
@@ -171,8 +173,8 @@
171
173
  position: absolute;
172
174
  left: 0;
173
175
  right: 0;
174
- top: 8px;
175
- bottom: 8px;
176
+ top: calc(25%);
177
+ height: 50%;
176
178
  background-color: var(--lm-main-color-alpha, #2196f388);
177
179
  }
178
180
 
@@ -193,7 +195,7 @@
193
195
  margin: 0 10px 0 10px;
194
196
  padding: 8px 0 8px 0;
195
197
  line-height: 34px;
196
- border-top: 1px solid var(--lm-border-color, #ccc);
198
+ border-top: 1px solid var(--lm-border-color-light, #e9e9e9);
197
199
  }
198
200
 
199
201
  .lm-calendar-footer[data-visible="false"] {
@@ -221,6 +223,7 @@
221
223
  padding: 8px;
222
224
  width: 100%;
223
225
  cursor: pointer;
226
+ background-color: var(--lm-border-color-light, #e9e9e9);
224
227
  }
225
228
 
226
229
  .lm-calendar-input {
@@ -267,3 +270,25 @@
267
270
  .lm-dark-mode .lm-calendar-footer select:focus {
268
271
  background-color: #3a3a45;
269
272
  }
273
+
274
+ .lm-calendar[data-grid="true"] .lm-calendar-weekdays {
275
+ padding: 0;
276
+ }
277
+
278
+ .lm-calendar[data-grid="true"] .lm-calendar-content {
279
+ border-top: 1px solid transparent;
280
+ border-left: 1px solid transparent;
281
+ border-right: 1px solid #ccc;
282
+ border-bottom: 1px solid #ccc;
283
+ padding: 0;
284
+ }
285
+
286
+ .lm-calendar[data-grid="true"] .lm-calendar-content > div {
287
+ border-top: 1px solid #ccc;
288
+ border-left: 1px solid #ccc;
289
+ border-right: 1px solid transparent;
290
+ border-bottom: 1px solid transparent;
291
+ border-radius: 0;
292
+ justify-content: start;
293
+ align-items: end;
294
+ }
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
- let options = {
9
- ...this.$attrs
10
- };
11
-
12
- this.el = this.$refs.container;
13
-
14
- this.current = component(this.$refs.container, options);
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
- for (let key in this.$attrs) {
37
- if (this.$attrs.hasOwnProperty(key) && this.current.hasOwnProperty(key)) {
38
- if (this.$attrs[key] !== this.current[key]) {
39
- this.current[key] = this.$attrs[key];
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
@@ -14,10 +14,10 @@
14
14
  "javascript plugins"
15
15
  ],
16
16
  "dependencies": {
17
- "lemonadejs": "^4.2.2",
18
- "@lemonadejs/modal": "^2.8.1"
17
+ "lemonadejs": "^4.3.3",
18
+ "@lemonadejs/modal": "^3.2.0"
19
19
  },
20
20
  "main": "dist/index.js",
21
21
  "types": "dist/index.d.ts",
22
- "version": "3.4.0"
22
+ "version": "3.5.0"
23
23
  }