@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 CHANGED
@@ -1,15 +1,17 @@
1
- # LemonadeJS Calendar
1
+ # JavaScript Calendar
2
2
 
3
- [Official website and documentation is here](https://lemonadejs.net/components/calendar)
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
- The LemonadeJS Calendar Component is a lightweight and agile calendar solution that empowers developers with efficient date management capabilities. With seamless navigation between months and years, intuitive day selection, and the ability to attach values and events, this highly customizable component provides a versatile foundation for scheduling applications, booking systems, and more. Its optimized codebase ensures fast performance, while its responsive design guarantees a consistent user experience across devices. Streamline your date management with the LemonadeJS Calendar Component and unlock enhanced productivity for your users.
7
+ # JavaScript Calendar
8
8
 
9
- ## Features
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
- - Lightweight: The JavaScript Calendar is only about 2 KBytes;
12
- - Integration: It can be used as a standalone library or integrated with any modern framework;
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
- To use calendar via a CDN, include the following script tags in your HTML file:
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
- <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lemonadejs/dist/lemonade.min.js"></script>
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 Lemonade
43
+ Quick example with ReactJS.
39
44
 
40
45
  ```javascript
41
- import Calendar from "@lemonadejs/calendar";
42
- import "@lemonadejs/calendar/dist/style.css"
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 self = this;
53
+ const calendarRef = useRef();
46
54
 
47
- return `<Calendar type="inline" />`;
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
- | Property | Type | Description |
58
- | -------- | ---- | ----------- |
59
- | value | date | The value currently attached to the calendar. |
60
- | range | Boolean | Activates the range mode in the calendar, enabling users to select two dates and represent the range between them as a value. |
61
- | type | string | Specifies the parameters for controlling the rendering behavior of the calendar. |
62
- | numeric | boolean | Enables the use of numeric dates, treating them as serial numbers. |
63
- | input? | HTML element | An optional reference to control the calendar opening. The value is automatically bound when using this property. |
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 | Type | Description |
68
- | -------- | ---- | ----------- |
69
- | onupdate?: (self, value) => void | Called when a new date is selected. |
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 [LemonadeJS](https://lemonadejs.net) Calendar is released under the MIT.
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/v4/)
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
- /** Calendar value will be a excel-like number or a ISO string. Default false */
16
- numeric?: boolean;
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
- /** Calendar value will be a excel-like number or a ISO string. Default false */
33
- numeric?: boolean;
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 diferent
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
@@ -15,9 +15,9 @@
15
15
  ],
16
16
  "dependencies": {
17
17
  "lemonadejs": "^4.1.1",
18
- "@lemonadejs/modal": "^2.7.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.2.0"
22
+ "version": "3.2.1"
23
23
  }