@lemonadejs/calendar 5.0.0 → 5.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,88 +1,90 @@
1
- # JavaScript Calendar
2
-
3
- [Official website and documentation is here](https://lemonadejs.net/docs/plugins/calendar)
4
-
5
- Compatible with Vanilla JavaScript, LemonadeJS, React, Vue or Angular.
6
-
7
- # JavaScript Calendar
8
-
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
-
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.
15
-
16
- ## Getting Started
17
-
18
- You can install using NPM or using directly from a CDN.
19
-
20
- ### npm Installation
21
-
22
- To install it in your project using npm, run the following command:
23
-
24
- ```bash
25
- $ npm install @lemonadejs/calendar
26
- ```
27
-
28
- ### CDN
29
-
30
- For immediate use without NPM, include these script tags in your HTML for access to the calendar and its dependencies:
31
-
32
- ```html
33
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/modal/dist/style.min.css" />
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>
39
- ```
40
-
41
- ### Usage
42
-
43
- Quick example with ReactJS.
44
-
45
- ```javascript
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";
51
-
52
- export default function App() {
53
- const calendarRef = useRef();
54
-
55
- return (<>
56
- <Calendar type={'inline'} ref={calendarRef} value={new Date()} />
57
- </>);
58
- }
59
- ```
60
-
61
- ### Configuration
62
-
63
- You can configure things such as calendar starting date, calendar events, and customize functions.
64
-
65
- #### Calendar Properties
66
-
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. |
74
-
75
- ### Calendar Events
76
-
77
- | Event | Description |
78
- |----------------------------------|-------------------------------------|
79
- | onchange?: (self, value) => void | Called when a new date is selected. |
80
-
81
- ## License
82
-
83
- The LemonadeJS [Reactive JavaScript Calendar](https://lemonadejs.net) is released under the MIT.
84
-
85
- ## Other Tools
86
-
87
- - [jSuites Plugins - JavaScript Calendar](https://jsuites.net/docs/javascript-calendar)
88
- - [Jspreadsheet - JavaScript Spreadsheet](https://jspreadsheet.com/)
1
+ # JavaScript Calendar
2
+
3
+ [Official JavaScript Calendar Documenation](https://lemonadejs.com/docs/plugins/calendar)
4
+
5
+ Compatible with Vanilla JavaScript, LemonadeJS, React, VueJS or Angular.
6
+
7
+ # JavaScript Calendar
8
+
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
+
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.
15
+
16
+ ## Getting Started
17
+
18
+ You can install using NPM or using directly from a CDN.
19
+
20
+ ### npm Installation
21
+
22
+ To install it in your project using npm, run the following command:
23
+
24
+ ```bash
25
+ $ npm install @lemonadejs/calendar
26
+ ```
27
+
28
+ ### CDN
29
+
30
+ For immediate use without NPM, include these script tags in your HTML for access to the calendar and its dependencies:
31
+
32
+ ```html
33
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@lemonadejs/modal/dist/style.min.css" />
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>
39
+ ```
40
+
41
+ ### Usage
42
+
43
+ Quick example with ReactJS.
44
+
45
+ ```javascript
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';
51
+
52
+ export default function App() {
53
+ const calendarRef = useRef();
54
+
55
+ return (
56
+ <>
57
+ <Calendar type={'inline'} ref={calendarRef} value={new Date()} />
58
+ </>
59
+ );
60
+ }
61
+ ```
62
+
63
+ ### Configuration
64
+
65
+ You can configure things such as calendar starting date, calendar events, and customize functions.
66
+
67
+ #### Calendar Properties
68
+
69
+ | Attribute | Type | Description |
70
+ | --------- | ---------------- | ----------------------------------------------------------------------------------------------------------------- |
71
+ | type? | string | Determines the rendering type for the calendar. Options: 'inline', 'default'. |
72
+ | range? | boolean | Enables the range mode for date selection. |
73
+ | value? | number or string | Represents the currently selected date. |
74
+ | numeric? | boolean | Enables the use of numeric dates, treating them as serial numbers. |
75
+ | input? | HTML element | An optional reference to control the calendar opening. The value is automatically bound when using this property. |
76
+
77
+ ### Calendar Events
78
+
79
+ | Event | Description |
80
+ | -------------------------------- | ----------------------------------- |
81
+ | onchange?: (self, value) => void | Called when a new date is selected. |
82
+
83
+ ## License
84
+
85
+ The LemonadeJS [Reactive JavaScript Calendar](https://lemonadejs.com/docs/plugins/calendar) is released under the MIT.
86
+
87
+ ## Other Tools
88
+
89
+ - [jSuites Plugins - JavaScript Calendar](https://jsuites.net/docs/javascript-calendar)
90
+ - [Jspreadsheet - JavaScript Spreadsheet](https://jspreadsheet.com/)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Official Type definitions for LemonadeJS plugins
3
- * https://lemonadejs.net
3
+ * https://lemonadejs.com
4
4
  * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
5
  */
6
6
 
@@ -8,9 +8,9 @@ declare function Calendar(el: HTMLElement, options?: Calendar.Options): Calendar
8
8
 
9
9
  declare namespace Calendar {
10
10
  interface Options {
11
- /** Calendar type */
12
- type?: 'default' | 'inline';
13
- /** Date format */
11
+ /** Calendar type. Use picker for a responsive modal, auto to automatic detect screen size and open between default or picker. */
12
+ type?: 'default' | 'auto' | 'picker' | 'inline';
13
+ /** Date format. Excel like format dd/mm/yyyy */
14
14
  format?: string;
15
15
  /** Range picker */
16
16
  range?: boolean;
@@ -18,35 +18,85 @@ declare namespace Calendar {
18
18
  value?: number | string;
19
19
  /** Calendar value will be a excel-like number or a ISO string. Default false */
20
20
  numeric?: boolean;
21
- /** Bind the calendar to na HTML input element */
22
- input?: HTMLElement | object | 'auto';
23
- /** Footer. Default: true **/
21
+ /** Show Footer. Default: true **/
24
22
  footer?: boolean;
25
23
  /** Show hour and minute picker **/
26
24
  time?: boolean;
27
25
  /** Show grid mode. Default: false */
28
26
  grid?: boolean;
27
+ /** Placeholder */
28
+ placeholder?: string;
29
+ /** Disabled. Default false **/
30
+ disabled?: boolean;
31
+ /** Starting day. From 0-6 where zero is Sunday and six is Saturday */
32
+ startingDay?: number;
33
+ /** Valid range **/
34
+ validRange?: number[] | string[];
35
+ /** Calendar events data */
36
+ data?: Array<{date: string, [key: string]: any}>;
29
37
  /** Update view on mouse wheel. Default: true */
30
38
  wheel?: boolean;
31
- /** LemonadeJS on change event */
39
+ /** Bind the calendar to na HTML input element */
40
+ input?: HTMLElement | 'auto';
41
+ /** Create events and assing the calendar classes for the input. Default true */
42
+ initInput?: boolean;
43
+ /** Change value event */
32
44
  onchange?: (self: object, value: string) => void;
33
- /** LemonadeJS on update event */
45
+ /** Update view event */
34
46
  onupdate?: (self: object, value: string) => void;
47
+ /** Close event */
48
+ onclose?: (self: object, origin: string) => void;
49
+ /** Open event */
50
+ onopen?: (self: object) => void;
35
51
  /** React dedicated onChange event */
36
52
  onChange?: (e: Event) => void;
37
53
  }
38
54
 
39
55
  interface Instance {
40
56
  /** Calendar type */
41
- type?: 'default' | 'inline';
57
+ type?: 'default' | 'auto' | 'picker' | 'inline';
58
+ /** Date format */
59
+ format: string;
42
60
  /** Range picker */
43
- range?: boolean;
61
+ range: boolean;
44
62
  /** Value */
45
- value?: number | string;
63
+ value: number | string;
46
64
  /** Calendar value will be a excel-like number or a ISO string. Default false */
47
- numeric?: boolean;
65
+ numeric: boolean;
66
+ /** Footer. Default: true **/
67
+ footer: boolean;
68
+ /** Show hour and minute picker **/
69
+ time: boolean;
70
+ /** Show grid mode. Default: false */
71
+ grid: boolean;
72
+ /** Placeholder */
73
+ placeholder: string;
74
+ /** Disabled. Default false **/
75
+ disabled: boolean;
76
+ /** Update view on mouse wheel. Default: true */
77
+ wheel: boolean;
48
78
  /** Bind the calendar to na HTML input element */
49
- input?: HTMLElement;
79
+ input: HTMLElement;
80
+ /** Open the calendar modal */
81
+ open: () => void;
82
+ /** Open the calendar modal */
83
+ close: (options?: object) => void;
84
+ /** Calendar is closed */
85
+ isClosed?: () => boolean;
86
+ /** Change the view */
87
+ setView: (view: 'days' | 'months' | 'years') => void;
88
+ /** Go to the next month or year depending on the view */
89
+ next?: () => void;
90
+ /** Go to the previous month or year depending on the view */
91
+ prev?: () => void;
92
+ /** Reset the calendar value and close the modal when applicable */
93
+ reset?: () => void;
94
+ /** Get the current calendar value */
95
+ getValue?: () => string | number;
96
+ /** Set the current calendar value. Use number for Excel like numbers */
97
+ setValue?: (value: string | number) => void;
98
+ /** Accept the selected value on the calendar */
99
+ update?: () => void;
50
100
  }
51
101
  }
52
102