bookingsync-calendar-widget 2.1.6 → 3.0.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/README.md +26 -20
- package/dist/bookingsync-calendar-widget.js +3487 -3283
- package/dist/bookingsync-calendar-widget.min.js +1 -1
- package/package.json +26 -25
- package/src/calendar-tree.js +19 -9
- package/src/calendar.js +195 -36
- package/src/config.js +6 -5
- package/src/index.js +6 -3
- package/src/styles/_variables.scss +8 -8
- package/src/styles/calendar.scss +147 -22
- package/src/styles/loading.scss +4 -4
- package/src/styles/theme-basic.scss +2 -2
- package/src/templates.js +49 -33
- package/src/styles/theme-skew.scss +0 -206
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# Calendar Widget [](https://circleci.com/gh/BookingSync/calendar-widget)
|
|
1
|
+
# Smily Calendar Widget (formerly BookingSync) [](https://circleci.com/gh/BookingSync/calendar-widget)
|
|
2
2
|
|
|
3
3
|
## TL;DR
|
|
4
4
|
### Development
|
|
5
|
-
* `
|
|
6
|
-
* `
|
|
7
|
-
* `
|
|
8
|
-
* `
|
|
5
|
+
* `pnpm install`
|
|
6
|
+
* `pnpm dev`
|
|
7
|
+
* `pnpm run mock-server`
|
|
8
|
+
* `pnpm run test-ci`
|
|
9
9
|
|
|
10
10
|
### Usage
|
|
11
11
|
* load `dist/bookingsync-calendar-widget.js` script
|
|
12
|
-
* add `<div data-
|
|
12
|
+
* add `<div data-smily-calendar-widget></div>` tag to the place you would like to put the widget.
|
|
13
13
|
|
|
14
14
|
* Or as global.
|
|
15
15
|
```javascript
|
|
16
|
-
const calendar = new
|
|
16
|
+
const calendar = new SmilyCalendarWidget({ el: document.querySelector('.my-widget') });
|
|
17
17
|
````
|
|
18
18
|
|
|
19
19
|
* Or as module
|
|
@@ -23,6 +23,10 @@ import Calendar from 'bookingsync-calendar-widget';
|
|
|
23
23
|
const calendar = new Calendar({ el: document.querySelector('.my-widget') });
|
|
24
24
|
````
|
|
25
25
|
|
|
26
|
+
Note: npm package name and dist filename remain `bookingsync-calendar-widget`.
|
|
27
|
+
|
|
28
|
+
Theme note: the built-in default is now `data-theme="basic"` only. If you need the previous skew look, use `SKEW_THEME_CSS.md`.
|
|
29
|
+
|
|
26
30
|
@see `index.html` for more examples.
|
|
27
31
|
|
|
28
32
|
### Setup
|
|
@@ -33,23 +37,23 @@ const calendar = new Calendar({ el: document.querySelector('.my-widget') });
|
|
|
33
37
|
* Linting with [Airbnb eslint](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base)
|
|
34
38
|
|
|
35
39
|
## Getting started with Development
|
|
36
|
-
* `
|
|
37
|
-
* `
|
|
40
|
+
* `pnpm install` to get the project's dependencies.
|
|
41
|
+
* `pnpm dev` to start development server with live-reload and hot module replacement
|
|
38
42
|
* go to [http://localhost:8080/index.html](http://localhost:8080/index.html)
|
|
39
43
|
|
|
40
44
|
Additionally you can run json-mock server
|
|
41
|
-
* `
|
|
45
|
+
* `pnpm run mock-server` it serve maps api for local development. Mocks are in `db.json` file.
|
|
42
46
|
|
|
43
47
|
## Scripts
|
|
44
|
-
* `
|
|
45
|
-
* `
|
|
46
|
-
* `
|
|
48
|
+
* `pnpm dev` - starts development server with live-reload and hot module replacement
|
|
49
|
+
* `pnpm run build` - produces production version under the `dist` folder
|
|
50
|
+
* `pnpm run test` - runs tests.
|
|
47
51
|
|
|
48
52
|
## Config
|
|
49
53
|
| __Option__ | __Description__ | __Type__ | __Default__ |
|
|
50
54
|
| --- | --- | --- | --- |
|
|
51
55
|
| `el` | HTMLElement to act as a container (only this one is MANDATORY) | HTMLElement | null
|
|
52
|
-
| `apiHost` | API host name | String | `http://localhost:3000` for development, `https://
|
|
56
|
+
| `apiHost` | API host name | String | `http://localhost:3000` for development, `https://secure.smily.com` for production |
|
|
53
57
|
| `apiNamespace` | API namespase | String | `/api/v2/public` |
|
|
54
58
|
| `apiMapsRoute` | route for maps | String | `/maps.json?rental_id={params}` - `{params}` is replaced with `rentalId` |
|
|
55
59
|
| `rentalURL` | URL route for maps | Function | |
|
|
@@ -61,7 +65,9 @@ Additionally you can run json-mock server
|
|
|
61
65
|
| `allowShorterMaxStaySelection` | Force maximum selection to `opts.maxStay` | Boolean | false
|
|
62
66
|
| `monthStart` | Calendar starts months, the left up most, 0 - 11 range | Number | Current month
|
|
63
67
|
| `yearStart` | Calendar start year, YYYY format (2016) | Number | Current year
|
|
64
|
-
| `displayMonths` |
|
|
68
|
+
| `displayMonths` | Desktop/base months count | Number | 2
|
|
69
|
+
| `displayMonthsMobile` | Mobile months count. If not set, uses `displayMonths` | Number | null
|
|
70
|
+
| `mobileBreakpoint` | Mobile viewport max width in px (`<=` means mobile) | Number | 767
|
|
65
71
|
| `selectable` | Allow to select range | Boolean | false
|
|
66
72
|
| `showRates` | Show rates from availability map | Boolean | false
|
|
67
73
|
| `showMinStay` | Show minimum stay per single day (be careful to use together with `showRates` or `showMaxStay`, can be too munch information) | Boolean | false
|
|
@@ -69,9 +75,9 @@ Additionally you can run json-mock server
|
|
|
69
75
|
| `isReverseSelectable` | User selects end date first | Boolean | false
|
|
70
76
|
| `isBackDisabled` | Disable back button for past months | Boolean | true
|
|
71
77
|
| `isDropDown` | Act like drop down, good idea to specify `elStartAt` and `elEndAt` | Boolean | false
|
|
72
|
-
| `elStartAt` | Input field to show start selected, open drop-down on focus| HTMLElement | null (will try to find `.
|
|
73
|
-
| `elEndAt` | Input field to show end selected, open drop-down on focus | HTMLElement | null (will try to find `.
|
|
74
|
-
| `elSingleInput` | Single input field to show start/end selected, open drop-down on focus | HTMLElement | null (will try to find `.
|
|
78
|
+
| `elStartAt` | Input field to show start selected, open drop-down on focus| HTMLElement | null (will try to find `.SmilyCalendar__start-at` if null)
|
|
79
|
+
| `elEndAt` | Input field to show end selected, open drop-down on focus | HTMLElement | null (will try to find `.SmilyCalendar__end-at` if null)
|
|
80
|
+
| `elSingleInput` | Single input field to show start/end selected, open drop-down on focus | HTMLElement | null (will try to find `.SmilyCalendar__single-input` if null)
|
|
75
81
|
| `isSingleInput` | Allow to use the single input, hides start/end inputs | Boolean | null
|
|
76
82
|
| `elReset` | Any element on click resets calendar selections and input values | HTMLElement | null
|
|
77
83
|
| `formatDate` | Overwrite locale defined date format | String | `%m/%d/%y` (https://github.com/pineapplemachine/strtime-js/blob/HEAD/directives.md)
|
|
@@ -92,7 +98,7 @@ e.g.
|
|
|
92
98
|
|
|
93
99
|
```html
|
|
94
100
|
<div
|
|
95
|
-
data-
|
|
101
|
+
data-smily-calendar-widget
|
|
96
102
|
data-selectable="true"
|
|
97
103
|
data-format-date="%m/%d/%y">
|
|
98
104
|
</div>
|
|
@@ -102,7 +108,7 @@ e.g.
|
|
|
102
108
|
Calendar implements event Emitter, receiver can subscribe/unsubscribe to events and subscribe one-time.
|
|
103
109
|
|
|
104
110
|
```javascript
|
|
105
|
-
var cal = new
|
|
111
|
+
var cal = new SmilyCalendarWidget({
|
|
106
112
|
el: document.querySelector('.calendar-wrapper'),
|
|
107
113
|
});
|
|
108
114
|
|