bookingsync-calendar-widget 2.1.6 → 3.1.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 CHANGED
@@ -1,28 +1,32 @@
1
- # Calendar Widget [![CircleCI](https://circleci.com/gh/BookingSync/calendar-widget.svg?style=svg&circle-token=8c6343e12779072713c394d9be543728012efc92)](https://circleci.com/gh/BookingSync/calendar-widget)
1
+ # Smily Calendar Widget (formerly BookingSync) [![CircleCI](https://circleci.com/gh/BookingSync/calendar-widget.svg?style=svg&circle-token=8c6343e12779072713c394d9be543728012efc92)](https://circleci.com/gh/BookingSync/calendar-widget)
2
2
 
3
3
  ## TL;DR
4
4
  ### Development
5
- * `npm`
6
- * `npm start`
7
- * `npm run mock-server`
8
- * `npm run test-ci`
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-bookingsync-calendar-widget></div>` tag to the place you would like to put the widget.
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 BookingSyncCalendarWidget({ el: document.querySelector('.my-widget') });
16
+ const calendar = new SmilyCalendarWidget({ el: document.querySelector('.my-widget') });
17
17
  ````
18
18
 
19
- * Or as module
19
+ * Or as module
20
20
  ```javascript
21
21
  import Calendar from 'bookingsync-calendar-widget';
22
22
 
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,76 +37,96 @@ 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
- * `npm` to get the project's dependencies.
37
- * `npm start` to start development server with live-reload and hot module replacement
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
- * `npm run mock-server` it serve maps api for local development. Mocks are in `db.json` file.
45
+ * `pnpm run mock-server` serves the maps API for local development. Mocks are in `db.json`.
42
46
 
43
47
  ## Scripts
44
- * `npm start` - starts development server with live-reload and hot module replacement
45
- * `npm run build` - produces production version under the `dist` folder
46
- * `npm run test` - runs tests.
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
51
+
52
+ ## Positioning
53
+ The widget no longer bundles Popper. For dropdown and invalid-range tooltip positioning it will use the first runtime it finds:
54
+
55
+ 1. `window.Popper` with a Popper 2 style `createPopper()`
56
+ 2. `window.FloatingUIDOM`, `window.FloatingUI`, or `window.floatingUI` with `computePosition()`
57
+ 3. a built-in fallback
58
+
59
+ The built-in fallback is intentionally basic. It supports `top` / `bottom` / `left` / `right` placement, `-start` / `-end` alignment, tooltip arrow positioning, and repositioning on `resize` and `scroll`. It does not implement collision-aware behavior such as flip, shift, or advanced hide handling. If you need that, expose Popper or Floating UI in the page runtime.
47
60
 
48
61
  ## Config
49
62
  | __Option__ | __Description__ | __Type__ | __Default__ |
50
63
  | --- | --- | --- | --- |
51
- | `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://www.bookingsync.com` for production |
53
- | `apiNamespace` | API namespase | String | `/api/v2/public` |
54
- | `apiMapsRoute` | route for maps | String | `/maps.json?rental_id={params}` - `{params}` is replaced with `rentalId` |
55
- | `rentalURL` | URL route for maps | Function | |
56
- | `rentalId` | parameter to pass in API request for availability maps | String or Number | null
57
- | `currency` | Set currency conversion | String | null
58
- | `minStay` | Minimum selectable range | Number | 1
59
- | `maxStay` | Maximum selectable range | Number | Infinity
60
- | `allowShorterMinStaySelection` | Force minimum selection to `opts.minStay` | Boolean | false
61
- | `allowShorterMaxStaySelection` | Force maximum selection to `opts.maxStay` | Boolean | false
62
- | `monthStart` | Calendar starts months, the left up most, 0 - 11 range | Number | Current month
63
- | `yearStart` | Calendar start year, YYYY format (2016) | Number | Current year
64
- | `displayMonths` | How many months to render | Number | 2
65
- | `selectable` | Allow to select range | Boolean | false
66
- | `showRates` | Show rates from availability map | Boolean | false
67
- | `showMinStay` | Show minimum stay per single day (be careful to use together with `showRates` or `showMaxStay`, can be too munch information) | Boolean | false
68
- | `showMaxStay` | Show maximum stay per single day (be careful to use together with `showRates` or `showMinStay`, can be too munch information) | Boolean | false
69
- | `isReverseSelectable` | User selects end date first | Boolean | false
70
- | `isBackDisabled` | Disable back button for past months | Boolean | true
71
- | `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 `.bookingsyncCalendarWidget__start-at` if null)
73
- | `elEndAt` | Input field to show end selected, open drop-down on focus | HTMLElement | null (will try to find `.bookingsyncCalendarWidget__end-at` if null)
74
- | `elSingleInput` | Single input field to show start/end selected, open drop-down on focus | HTMLElement | null (will try to find `.bookingsyncCalendarWidget__single-input` if null)
75
- | `isSingleInput` | Allow to use the single input, hides start/end inputs | Boolean | null
76
- | `elReset` | Any element on click resets calendar selections and input values | HTMLElement | null
77
- | `formatDate` | Overwrite locale defined date format | String | `%m/%d/%y` (https://github.com/pineapplemachine/strtime-js/blob/HEAD/directives.md)
78
- | `hiddenElFormat` | Duplicate start/end inputs with a different date format | String | null
79
- | `disableAvailabityMap` | Overwrite each days to be available | Boolean | false
80
- | `enableAllDays` | Force past days/months to be selectable | Boolean | false
81
- | `currentDate` | Current date Date object | Date | `new Date()`
64
+ | `el` | Calendar container element. This is the only required option. | HTMLElement | `null` |
65
+ | `lang` | Locale key such as `en-US` or `fr-FR`. Invalid values fall back to `en-US`. | String | `en-US` |
66
+ | `theme` | Theme name stored in `data-theme`. The bundled stylesheet currently ships `basic` only. | String | `basic` |
67
+ | `apiHost` | API host name. | String | `http://localhost:3000` in development, `https://secure.smily.com` otherwise |
68
+ | `apiNamespace` | API namespace prefix. | String | `/api/v2/public` |
69
+ | `apiMapsRoute` | Maps route template used by the default `rentalUrl()` implementation. | String | `/maps.json?{apiRentalId}{apiCurrency}` |
70
+ | `rentalUrl(ids)` | Function used to build the maps URL. By default it derives the URL from `apiHost`, `apiNamespace`, `apiMapsRoute`, `apiRentalId`, and `apiCurrency`. | Function | built-in implementation |
71
+ | `rentalId` | Rental identifier used when loading availability maps. | String or Number | `null` |
72
+ | `currency` | Target currency for rate conversion and display. | String | `null` |
73
+ | `startOfWeek` | First weekday index, `0` for Sunday through `6` for Saturday. If omitted, the locale value is used. | Number | locale default |
74
+ | `minStay` | Minimum selectable range in nights. | Number | `1` |
75
+ | `maxStay` | Maximum selectable range in nights. | Number | `Infinity` |
76
+ | `allowShorterMinStaySelection` | Ignore per-day minimum-stay constraints and use `minStay` only. | Boolean | `false` |
77
+ | `allowLongerMaxStaySelection` | Ignore per-day maximum-stay constraints and use `maxStay` only. | Boolean | `false` |
78
+ | `monthStart` | First visible month, `0` through `11`. If omitted, the current month is used. | Number | current month |
79
+ | `yearStart` | First visible year. If omitted, the current year is used. | Number | current year |
80
+ | `displayMonths` | Number of visible months on desktop. | Number | `2` |
81
+ | `displayMonthsMobile` | Number of visible months on mobile. If omitted, `displayMonths` is used. | Number | `null` |
82
+ | `mobileBreakpoint` | Mobile viewport max width in px. `<=` this breakpoint is treated as mobile. | Number | `767` |
83
+ | `showPaginationMobile` | Keep the month pagination controls visible in mobile mode. | Boolean | `true` |
84
+ | `monthsPaginationJump` | Number of months to move when the forward/back controls are used. | Number | `1` |
85
+ | `selectable` | Enable range selection. | Boolean | `false` |
86
+ | `showRates` | Show rates from the availability map. | Boolean | `false` |
87
+ | `showMinStay` | Show minimum-stay text per day cell. | Boolean | `false` |
88
+ | `showMaxStay` | Show maximum-stay text per day cell. | Boolean | `false` |
89
+ | `isReverseSelectable` | Start selection from the end date instead of the start date. | Boolean | `false` |
90
+ | `isBackDisabled` | Prevent month navigation into the past. | Boolean | `true` |
91
+ | `enableAllDays` | Make past days and months selectable even when maps are not loaded. | Boolean | `false` |
92
+ | `isDropDown` | Render the widget as a dropdown anchored to an input or trigger element. | Boolean | `false` |
93
+ | `dropPlacement` | Preferred dropdown placement passed to the active positioning engine. | String | `bottom-start` |
94
+ | `elStartAt` | Start-date input. Also used as the dropdown opener when `isDropDown` is enabled. | HTMLElement | `null`, then `.SmilyCalendar__start-at` if found |
95
+ | `elEndAt` | End-date input. Also used as the dropdown opener when `isDropDown` is enabled. | HTMLElement | `null`, then `.SmilyCalendar__end-at` if found |
96
+ | `elSingleInput` | Single combined input used for dropdown mode. | HTMLElement | `null`, then `.SmilyCalendar__single-input` if found |
97
+ | `isSingleInput` | Use the single input and hide the start/end inputs. | Boolean | `null` |
98
+ | `singleInputDateFormat` | Date format used when filling the combined single input. | String | locale date format |
99
+ | `singleInputSeparator` | Separator inserted between start and end dates in the single input. | String | `→` |
100
+ | `elReset` | Element that clears the current selection when clicked. | HTMLElement | `null` |
101
+ | `formatDate` | Date format used for parsing and formatting visible input values. | String | locale date format |
102
+ | `hiddenElFormat` | If set, duplicates the start/end inputs into hidden fields formatted with this pattern. | String | `null` |
103
+ | `disableAvailabityMap` | Treat every mapped day as available. | Boolean | `false` |
104
+ | `currentDate` | Date used as "today" for disabling and clamping logic. | Date | `new Date()` |
82
105
 
83
106
  ## Callbacks
84
107
 
85
- * `onSelectStart(ISO String, Date)`
86
- * `onSelectEnd(ISO String, Date)`
87
- * `onSelectionCompleted(ISO String, ISO String)`
108
+ * `onSelectStart(ISO DateTime String, ISO Date String)`
109
+ * `onSelectEnd(ISO DateTime String, ISO Date String)`
110
+ * `onSelectionCompleted(ISO DateTime String, ISO DateTime String)`
111
+ * `onClearSelection([yyyy, m, dd] | null, [yyyy, m, dd] | null)`
88
112
 
89
- see `index.html` for more examples.
90
- All options can be passed as `data-` attributes to HTMLElement calendar placeholders, with dasherized way.
113
+ See `index.html` for more examples.
114
+ All options can be passed as `data-` attributes to HTMLElement calendar placeholders, with camelCase options converted to kebab-case.
91
115
  e.g.
92
116
 
93
117
  ```html
94
- <div
95
- data-bookingsync-calendar-widget
118
+ <div
119
+ data-smily-calendar-widget
96
120
  data-selectable="true"
97
- data-format-date="%m/%d/%y">
121
+ data-format-date="%m/%d/%Y">
98
122
  </div>
99
123
  ```
100
124
 
101
125
  ## Events
102
- Calendar implements event Emitter, receiver can subscribe/unsubscribe to events and subscribe one-time.
126
+ Calendar implements event Emitter, receiver can subscribe, unsubscribe, and subscribe one-time.
103
127
 
104
128
  ```javascript
105
- var cal = new bookingsyncCalendarWidget({
129
+ var cal = new SmilyCalendarWidget({
106
130
  el: document.querySelector('.calendar-wrapper'),
107
131
  });
108
132
 
@@ -116,22 +140,22 @@ cal.on('selection-start', function(a, b) {
116
140
  cal.once('selection-end', function(a, b) {
117
141
  console.log('selection-end', a, b)
118
142
  });
119
-
143
+
120
144
  cal.off('selection-end', function(a, b) {
121
145
  console.log('selection-end', a, b)
122
- });
146
+ });
123
147
  ```
124
148
 
125
149
  | __Event__ | __Description__ | __Params__ |
126
150
  | --- | --- | --- |
127
- | `init` | Finished initializing, data is NOT loaded | |
128
- | `maps-loaded` | Availability, rates and minimum stay maps are loaded and added to calendar | {Object} raw response from the server |
151
+ | `init` | Finished initializing, data is NOT loaded | |
152
+ | `maps-loaded` | Availability, rates and minimum stay maps are loaded and added to calendar | `{Object}` raw response from the server |
129
153
  | `maps-error` | Error when loading maps | |
130
154
  | `loading-show` | Loading indicator shows | |
131
155
  | `loading-hide` | Loading indicator hides | |
132
- | `selection-start` | User selected start date | {String} {Date}, ISO format '2016-01-01', Date |
133
- | `selection-end` | User selected end date | {String} {Date}, ISO format '2016-01-01', Date |
134
- | `selection-reset` | Selection reset | {Array}, {Array}, selection start, selection end ([yyyy, m, dd]) |
135
- | `selection-completed` | User selects end date when start date was already selected | {Array}, {Array}, selection start, selection end ([yyyy, m, dd]) |
136
- | `drop-open` | Calendar-drop open | |
137
- | `drop-close` | Calendar-drop close | |
156
+ | `selection-start` | User selected start date | `{String}`, `{String}`: ISO datetime, ISO date |
157
+ | `selection-end` | User selected end date | `{String}`, `{String}`: ISO datetime, ISO date |
158
+ | `selection-reset` | Selection reset | `{Array}`, `{Array}`: selection start, selection end (`[yyyy, m, dd]`) |
159
+ | `selection-completed` | User selects end date when start date was already selected | `{Array}`, `{Array}`: selection start, selection end (`[yyyy, m, dd]`) |
160
+ | `drop-open` | Calendar-drop open | |
161
+ | `drop-close` | Calendar-drop close | |