@lemonadejs/calendar 3.1.1 → 3.2.1
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/README.md +37 -27
- package/dist/index.d.ts +14 -8
- package/dist/index.js +18 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# JavaScript Calendar
|
|
2
2
|
|
|
3
|
-
[Official website and documentation is here](https://lemonadejs.net/
|
|
3
|
+
[Official website and documentation is here](https://lemonadejs.net/docs/plugins/calendar)
|
|
4
4
|
|
|
5
5
|
Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# JavaScript Calendar
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Leverage the power of the LemonadeJS Calendar, a lightweight and versatile JavaScript component compatible with React, VueJS, and Angular. Designed to enhance web applications, it offers an embeddable calendar for easy date, time, and range selections. Key features include:
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
11
|
+
- Intuitive keyboard navigation.
|
|
12
|
+
- A reactive and responsive design for seamless device adaptation.
|
|
13
|
+
- Flexible range selection for various applications.
|
|
14
|
+
- Customizable options to match your project needs.
|
|
13
15
|
|
|
14
16
|
## Getting Started
|
|
15
17
|
|
|
@@ -25,26 +27,34 @@ $ npm install @lemonadejs/calendar
|
|
|
25
27
|
|
|
26
28
|
### CDN
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
For immediate use without NPM, include these script tags in your HTML for access to the calendar and its dependencies:
|
|
29
31
|
|
|
30
32
|
```html
|
|
31
|
-
<
|
|
32
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@lemonadejs/calendar/dist/index.min.js"></script>
|
|
33
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/modal/dist/style.min.css" />
|
|
33
34
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/calendar/dist/style.min.css" />
|
|
35
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
|
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
|
|
37
|
+
<script src="https://cdn.jsdelivr.net/npm/@lemonadejs/modal/dist/index.min.js"></script>
|
|
38
|
+
<script src="https://cdn.jsdelivr.net/npm/@lemonadejs/calendar/dist/index.min.js"></script>
|
|
34
39
|
```
|
|
35
40
|
|
|
36
41
|
### Usage
|
|
37
42
|
|
|
38
|
-
Quick example with
|
|
43
|
+
Quick example with ReactJS.
|
|
39
44
|
|
|
40
45
|
```javascript
|
|
41
|
-
import
|
|
42
|
-
import
|
|
46
|
+
import React, { useRef } from 'react';
|
|
47
|
+
import Calendar from '@lemonadejs/calendar/dist/react';
|
|
48
|
+
|
|
49
|
+
import "@lemonadejs/calendar/dist/style.css";
|
|
50
|
+
import "@lemonadejs/modal/dist/style.css";
|
|
43
51
|
|
|
44
52
|
export default function App() {
|
|
45
|
-
const
|
|
53
|
+
const calendarRef = useRef();
|
|
46
54
|
|
|
47
|
-
return
|
|
55
|
+
return (<>
|
|
56
|
+
<Calendar type={'inline'} ref={calendarRef} value={new Date()} />
|
|
57
|
+
</>);
|
|
48
58
|
}
|
|
49
59
|
```
|
|
50
60
|
|
|
@@ -54,25 +64,25 @@ You can configure things such as calendar starting date, calendar events, and cu
|
|
|
54
64
|
|
|
55
65
|
#### Calendar Properties
|
|
56
66
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
| range
|
|
61
|
-
|
|
|
62
|
-
| numeric
|
|
63
|
-
| input?
|
|
67
|
+
| Attribute | Type | Description |
|
|
68
|
+
| --------- |------------------|-------------------------------------------------------------------------------------------------------------------|
|
|
69
|
+
| type? | string | Determines the rendering type for the calendar. Options: 'inline', 'default'. |
|
|
70
|
+
| range? | boolean | Enables the range mode for date selection. |
|
|
71
|
+
| value? | number or string | Represents the currently selected date. |
|
|
72
|
+
| numeric? | boolean | Enables the use of numeric dates, treating them as serial numbers. |
|
|
73
|
+
| input? | HTML element | An optional reference to control the calendar opening. The value is automatically bound when using this property. |
|
|
64
74
|
|
|
65
75
|
### Calendar Events
|
|
66
76
|
|
|
67
|
-
| Event
|
|
68
|
-
|
|
69
|
-
|
|
|
77
|
+
| Event | Description |
|
|
78
|
+
|----------------------------------|-------------------------------------|
|
|
79
|
+
| onchange?: (self, value) => void | Called when a new date is selected. |
|
|
70
80
|
|
|
71
81
|
## License
|
|
72
82
|
|
|
73
|
-
The [
|
|
83
|
+
The LemonadeJS [Reactive JavaScript Calendar](https://lemonadejs.net) is released under the MIT.
|
|
74
84
|
|
|
75
85
|
## Other Tools
|
|
76
86
|
|
|
77
|
-
- [jSuites](https://jsuites.net/
|
|
78
|
-
- [Jspreadsheet](https://jspreadsheet.com)
|
|
87
|
+
- [jSuites JavaScript Calendar](https://jsuites.net/docs/javascript-calendar)
|
|
88
|
+
- [Jspreadsheet](https://jspreadsheet.com/)
|
package/dist/index.d.ts
CHANGED
|
@@ -8,27 +8,33 @@ declare function Calendar(el: HTMLElement, options?: Calendar.Options): Calendar
|
|
|
8
8
|
|
|
9
9
|
declare namespace Calendar {
|
|
10
10
|
interface Options {
|
|
11
|
-
/** Range picker */
|
|
12
|
-
range?: boolean;
|
|
13
11
|
/** Calendar type */
|
|
14
12
|
type?: 'default' | 'inline';
|
|
15
|
-
/**
|
|
16
|
-
|
|
13
|
+
/** Range picker */
|
|
14
|
+
range?: boolean;
|
|
17
15
|
/** Value */
|
|
18
16
|
value?: number | string;
|
|
17
|
+
/** Calendar value will be a excel-like number or a ISO string. Default false */
|
|
18
|
+
numeric?: boolean;
|
|
19
19
|
/** Bind the calendar to na HTML input element */
|
|
20
20
|
input?: HTMLElement;
|
|
21
|
+
/** Onchange event */
|
|
22
|
+
onchange: (self: object, value: string) => void;
|
|
23
|
+
/** On update event */
|
|
24
|
+
onupdate: (self: object, value: string) => void;
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
interface Instance {
|
|
24
|
-
/** Range picker */
|
|
25
|
-
range?: boolean;
|
|
26
28
|
/** Calendar type */
|
|
27
29
|
type?: 'default' | 'inline';
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
+
/** Range picker */
|
|
31
|
+
range?: boolean;
|
|
30
32
|
/** Value */
|
|
31
33
|
value?: number | string;
|
|
34
|
+
/** Calendar value will be a excel-like number or a ISO string. Default false */
|
|
35
|
+
numeric?: boolean;
|
|
36
|
+
/** Bind the calendar to na HTML input element */
|
|
37
|
+
input?: HTMLElement;
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
|
package/dist/index.js
CHANGED
|
@@ -272,6 +272,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
272
272
|
const Calendar = function() {
|
|
273
273
|
let self = this;
|
|
274
274
|
|
|
275
|
+
const onchange = self.onchange;
|
|
276
|
+
|
|
275
277
|
// Weekdays
|
|
276
278
|
self.weekdays = getWeekdays();
|
|
277
279
|
|
|
@@ -647,8 +649,12 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
647
649
|
self.options = views[self.view].call(self, date);
|
|
648
650
|
}
|
|
649
651
|
} else if (prop === 'value') {
|
|
652
|
+
// TODO: onchange only when the component value really changes
|
|
653
|
+
if (typeof(onchange) === 'function') {
|
|
654
|
+
onchange(self, self.value);
|
|
655
|
+
}
|
|
650
656
|
if (typeof(self.onupdate) === 'function') {
|
|
651
|
-
self.onupdate
|
|
657
|
+
self.onupdate(self, self.value);
|
|
652
658
|
}
|
|
653
659
|
} else if (prop === 'options') {
|
|
654
660
|
self.content.focus();
|
|
@@ -684,8 +690,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
684
690
|
closed: true,
|
|
685
691
|
focus: false,
|
|
686
692
|
position: 'absolute',
|
|
687
|
-
'auto-adjust': true,
|
|
688
693
|
'auto-close': false,
|
|
694
|
+
'auto-adjust': true,
|
|
689
695
|
};
|
|
690
696
|
// Generate modal
|
|
691
697
|
Modal(self.el, self.modal);
|
|
@@ -711,19 +717,28 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
711
717
|
* @param {object} e - event
|
|
712
718
|
*/
|
|
713
719
|
self.content.addEventListener('keydown', function(e){
|
|
720
|
+
let prevent = false;
|
|
714
721
|
if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
|
|
715
722
|
self.prev(e);
|
|
723
|
+
prevent = true;
|
|
716
724
|
} else if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
|
|
717
725
|
self.next(e);
|
|
726
|
+
prevent = true;
|
|
718
727
|
} else if (e.key === 'Enter') {
|
|
719
728
|
// Current view
|
|
720
729
|
let view = self.view;
|
|
721
730
|
// Select
|
|
722
731
|
self.select(e, self.options[self.cursor.index]);
|
|
723
|
-
// If is range do something
|
|
732
|
+
// If is range do something different
|
|
724
733
|
if (view === 'days' && ! self.range) {
|
|
725
734
|
self.update();
|
|
726
735
|
}
|
|
736
|
+
prevent = true;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (prevent) {
|
|
740
|
+
e.preventDefault();
|
|
741
|
+
e.stopImmediatePropagation();
|
|
727
742
|
}
|
|
728
743
|
});
|
|
729
744
|
|
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"javascript plugins"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"lemonadejs": "^4.
|
|
18
|
-
"@lemonadejs/modal": "^2.7.
|
|
17
|
+
"lemonadejs": "^4.1.1",
|
|
18
|
+
"@lemonadejs/modal": "^2.7.2"
|
|
19
19
|
},
|
|
20
20
|
"main": "dist/index.js",
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"version": "3.
|
|
22
|
+
"version": "3.2.1"
|
|
23
23
|
}
|