@lemonadejs/calendar 3.2.0 → 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 +10 -8
- package/dist/index.js +11 -2
- package/package.json +2 -2
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,14 +8,14 @@ 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
21
|
/** Onchange event */
|
|
@@ -25,14 +25,16 @@ declare namespace Calendar {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
interface Instance {
|
|
28
|
-
/** Range picker */
|
|
29
|
-
range?: boolean;
|
|
30
28
|
/** Calendar type */
|
|
31
29
|
type?: 'default' | 'inline';
|
|
32
|
-
/**
|
|
33
|
-
|
|
30
|
+
/** Range picker */
|
|
31
|
+
range?: boolean;
|
|
34
32
|
/** Value */
|
|
35
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;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
|
package/dist/index.js
CHANGED
|
@@ -690,8 +690,8 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
690
690
|
closed: true,
|
|
691
691
|
focus: false,
|
|
692
692
|
position: 'absolute',
|
|
693
|
-
'auto-adjust': true,
|
|
694
693
|
'auto-close': false,
|
|
694
|
+
'auto-adjust': true,
|
|
695
695
|
};
|
|
696
696
|
// Generate modal
|
|
697
697
|
Modal(self.el, self.modal);
|
|
@@ -717,19 +717,28 @@ if (! Modal && typeof (require) === 'function') {
|
|
|
717
717
|
* @param {object} e - event
|
|
718
718
|
*/
|
|
719
719
|
self.content.addEventListener('keydown', function(e){
|
|
720
|
+
let prevent = false;
|
|
720
721
|
if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
|
|
721
722
|
self.prev(e);
|
|
723
|
+
prevent = true;
|
|
722
724
|
} else if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
|
|
723
725
|
self.next(e);
|
|
726
|
+
prevent = true;
|
|
724
727
|
} else if (e.key === 'Enter') {
|
|
725
728
|
// Current view
|
|
726
729
|
let view = self.view;
|
|
727
730
|
// Select
|
|
728
731
|
self.select(e, self.options[self.cursor.index]);
|
|
729
|
-
// If is range do something
|
|
732
|
+
// If is range do something different
|
|
730
733
|
if (view === 'days' && ! self.range) {
|
|
731
734
|
self.update();
|
|
732
735
|
}
|
|
736
|
+
prevent = true;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
if (prevent) {
|
|
740
|
+
e.preventDefault();
|
|
741
|
+
e.stopImmediatePropagation();
|
|
733
742
|
}
|
|
734
743
|
});
|
|
735
744
|
|
package/package.json
CHANGED