Skip to content

Commit bfb93ff

Browse files
committed
Merge branch 'v3'
2 parents d1d80f7 + afc3b2c commit bfb93ff

35 files changed

+762
-236
lines changed

.eslintrc.js

-5
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,5 @@ module.exports = {
5050
'keyword-spacing': 'error',
5151
'arrow-spacing': 'error',
5252
'space-before-blocks': 'error',
53-
'no-magic-numbers': ['warn', {
54-
ignore: [0, 1, -1],
55-
ignoreArrayIndexes: true,
56-
ignoreDefaultValues: true,
57-
}],
5853
},
5954
};

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
### v3.4.0
4+
* added new options `onFocus` and `onBeforeSelect` grant you more control over range selection behaviour and more [#526](https://github.com/t1m0n/air-datepicker/issues/526)
5+
* added new method `getViewDates()` allows you to get all dates that should be currently displayed in calendar [#536](https://github.com/t1m0n/air-datepicker/issues/536)
6+
* `toggleSelected` now can be a function [#534](https://github.com/t1m0n/air-datepicker/issues/534)
7+
* fixed `clear` method [#546](https://github.com/t1m0n/air-datepicker/issues/546)
8+
* added Bulgarian locale, thanks to [tonytomov](https://github.com/tonytomov), in [#531](https://github.com/t1m0n/air-datepicker/pull/531)
9+
* added Catalan locale, thanks to [joatb](https://github.com/joatb), in [#542](https://github.com/t1m0n/air-datepicker/pull/542)
10+
* added Croatian Locale, thanks to [diomed](https://github.com/diomed), in [#551](https://github.com/t1m0n/air-datepicker/pull/551)
11+
312
### v3.3.5
413
* added handling of optional chaining operator in dist package [#518](https://github.com/t1m0n/air-datepicker/issues/518)
514
* added Indonesian locale, thanks to [BariqDharmawan](https://github.com/BariqDharmawan), in [#517](https://github.com/t1m0n/air-datepicker/pull/517)

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ new AirDatepicker('#el' [, options]);
2626

2727
## Recent updates
2828

29+
### v3.4.0
30+
* added new options `onFocus` and `onBeforeSelect` grant you more control over range selection behaviour and more [#526](https://github.com/t1m0n/air-datepicker/issues/526)
31+
* added new method `getViewDates()` allows you to get all dates that should be currently displayed in calendar [#536](https://github.com/t1m0n/air-datepicker/issues/536)
32+
* `toggleSelected` now can be a function [#534](https://github.com/t1m0n/air-datepicker/issues/534)
33+
* fixed `clear` method [#546](https://github.com/t1m0n/air-datepicker/issues/546)
34+
* added Bulgarian locale, thanks to [tonytomov](https://github.com/tonytomov), in [#531](https://github.com/t1m0n/air-datepicker/pull/531)
35+
* added Catalan locale, thanks to [joatb](https://github.com/joatb), in [#542](https://github.com/t1m0n/air-datepicker/pull/542)
36+
* added Croatian Locale, thanks to [diomed](https://github.com/diomed), in [#551](https://github.com/t1m0n/air-datepicker/pull/551)
37+
2938
### v3.3.5
3039
* added handling of optional chaining operator in dist package [#518](https://github.com/t1m0n/air-datepicker/issues/518)
3140
* added Indonesian locale, thanks to [BariqDharmawan](https://github.com/BariqDharmawan), in [#517](https://github.com/t1m0n/air-datepicker/pull/517)

dist/air-datepicker.d.ts

+61-59
Original file line numberDiff line numberDiff line change
@@ -44,78 +44,80 @@ export declare type AirDatepickerPositionCallback = (
4444
done: () => void
4545
}) => void | (() => void)
4646

47-
export declare type AirDatepickerOptions = {
48-
classes: string
49-
inline: boolean,
50-
locale: Partial<AirDatepickerLocale>,
51-
startDate: AirDatepickerDate,
52-
firstDay: number,
53-
isMobile: boolean,
54-
visible: boolean,
55-
weekends: [number, number],
56-
dateFormat: string | ((d: Date) => string),
57-
altField: AirDatepickerSelector,
58-
altFieldDateFormat: string,
59-
toggleSelected: boolean,
60-
keyboardNav: boolean,
61-
selectedDates: AirDatepickerDate[] | false,
62-
container: AirDatepickerSelector,
63-
position: AirDatepickerPosition | AirDatepickerPositionCallback,
64-
offset: number,
65-
view: AirDatepickerViews,
66-
minView: AirDatepickerViews,
67-
showOtherMonths: boolean,
68-
selectOtherMonths: boolean,
69-
moveToOtherMonthsOnSelect: boolean,
70-
showOtherYears: boolean,
71-
selectOtherYears: boolean,
72-
moveToOtherYearsOnSelect: boolean,
73-
minDate: AirDatepickerDate | false,
74-
maxDate: AirDatepickerDate | false,
75-
disableNavWhenOutOfRange: true,
76-
multipleDates: number | true | false,
77-
multipleDatesSeparator: string,
78-
range: boolean,
79-
dynamicRange: boolean,
80-
buttons: AirDatepickerButtonPresets | AirDatepickerButton | (AirDatepickerButtonPresets| AirDatepickerButton)[] | false,
81-
monthsField: keyof AirDatepickerLocale,
82-
showEvent: string,
83-
autoClose: boolean,
84-
prevHtml: string,
85-
nextHtml: string,
86-
navTitles: {
47+
export declare type AirDatepickerOptions<E extends HTMLElement = HTMLInputElement> = {
48+
classes?: string
49+
inline?: boolean,
50+
locale?: Partial<AirDatepickerLocale>,
51+
startDate?: AirDatepickerDate,
52+
firstDay?: number,
53+
isMobile?: boolean,
54+
visible?: boolean,
55+
weekends?: [number, number],
56+
dateFormat?: string | ((d: Date) => string),
57+
altField?: AirDatepickerSelector,
58+
altFieldDateFormat?: string,
59+
toggleSelected?: boolean | (({datepicker, date}:{datepicker: AirDatepicker<E>, date: Date}) => boolean),
60+
keyboardNav?: boolean,
61+
selectedDates?: AirDatepickerDate[] | false,
62+
container?: AirDatepickerSelector,
63+
position?: AirDatepickerPosition | AirDatepickerPositionCallback,
64+
offset?: number,
65+
view?: AirDatepickerViews,
66+
minView?: AirDatepickerViews,
67+
showOtherMonths?: boolean,
68+
selectOtherMonths?: boolean,
69+
moveToOtherMonthsOnSelect?: boolean,
70+
showOtherYears?: boolean,
71+
selectOtherYears?: boolean,
72+
moveToOtherYearsOnSelect?: boolean,
73+
minDate?: AirDatepickerDate | false,
74+
maxDate?: AirDatepickerDate | false,
75+
disableNavWhenOutOfRange?: true,
76+
multipleDates?: number | true | false,
77+
multipleDatesSeparator?: string,
78+
range?: boolean,
79+
dynamicRange?: boolean,
80+
buttons?: AirDatepickerButtonPresets | AirDatepickerButton | (AirDatepickerButtonPresets| AirDatepickerButton)[] | false,
81+
monthsField?: keyof AirDatepickerLocale,
82+
showEvent?: string,
83+
autoClose?: boolean,
84+
prevHtml?: string,
85+
nextHtml?: string,
86+
navTitles?: {
8787
days?: AirDatepickerNavEntry,
8888
months?: AirDatepickerNavEntry,
8989
years?: AirDatepickerNavEntry
9090
},
91-
timepicker: boolean,
92-
onlyTimepicker: boolean,
93-
dateTimeSeparator: string,
94-
timeFormat: string,
95-
minHours: number,
96-
maxHours: number,
97-
minMinutes: number,
98-
maxMinutes: number,
99-
hoursStep: number,
100-
minutesStep: number,
91+
timepicker?: boolean,
92+
onlyTimepicker?: boolean,
93+
dateTimeSeparator?: string,
94+
timeFormat?: string,
95+
minHours?: number,
96+
maxHours?: number,
97+
minMinutes?: number,
98+
maxMinutes?: number,
99+
hoursStep?: number,
100+
minutesStep?: number,
101101

102-
onSelect: ({date, formattedDate, datepicker}: {date: Date | Date[], formattedDate: string | string[], datepicker: AirDatepicker}) => void,
103-
onChangeViewDate: ({month, year, decade}: {month: number, year: number, decade: AirDatepickerDecade}) => void,
104-
onChangeView: (view: AirDatepickerViews) => void,
105-
onRenderCell: (params: {date: Date, cellType: AirDatepickerViewsSingle, datepicker: AirDatepicker}) => ({
102+
onSelect?: ({date, formattedDate, datepicker}: {date: Date | Date[], formattedDate: string | string[], datepicker: AirDatepicker<E>}) => void,
103+
onChangeViewDate?: ({month, year, decade}: {month: number, year: number, decade: AirDatepickerDecade}) => void,
104+
onChangeView?: (view: AirDatepickerViews) => void,
105+
onRenderCell?: (params: {date: Date, cellType: AirDatepickerViewsSingle, datepicker: AirDatepicker<E>}) => ({
106106
disabled?: boolean,
107107
classes?: string,
108108
html?: string
109109
attrs?: Record<string, string | number | undefined>
110110
} | void),
111-
onShow: (isAnimationComplete: boolean) => void,
112-
onHide: (isAnimationComplete: boolean) => void,
113-
onClickDayName: ({dayIndex, datepicker}: {dayIndex: number, datepicker: AirDatepicker}) => void
111+
onShow?: (isAnimationComplete: boolean) => void,
112+
onHide?: (isAnimationComplete: boolean) => void,
113+
onClickDayName?: ({dayIndex, datepicker}: {dayIndex: number, datepicker: AirDatepicker<E>}) => void
114+
onBeforeSelect?: ({date, datepicker}: {date: Date, datepicker: AirDatepicker}) => boolean;
115+
onFocus?: ({date, datepicker}: {date: Date, datepicker: AirDatepicker}) => void;
114116
}
115117

116118

117119
declare class AirDatepicker<E extends HTMLElement = HTMLInputElement> {
118-
constructor(el: string | E, opts? : Partial<AirDatepickerOptions>)
120+
constructor(el: string | E, opts? : AirDatepickerOptions<E>)
119121
static defaults: AirDatepickerOptions
120122
static version: string
121123
static defaultGlobalContainerId: string
@@ -129,7 +131,7 @@ declare class AirDatepicker<E extends HTMLElement = HTMLInputElement> {
129131
clear: () => void
130132
formatDate: (date: AirDatepickerDate, format: string) => string
131133
destroy: () => void
132-
update: (newOpts: Partial<AirDatepickerOptions>) => void
134+
update: (newOpts?: AirDatepickerOptions) => void
133135
setCurrentView: (newView: AirDatepickerViews) => void
134136
setViewDate: (newViewDate: AirDatepickerDate) => void
135137
setFocusDate: (date: AirDatepickerDate | false, opts?: {viewDateTransition?: boolean}) => void

dist/air-datepicker.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/locale/bg.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'air-datepicker/locale/bg' {
2+
import {AirDatepickerLocale} from 'air-datepicker';
3+
const bg: AirDatepickerLocale;
4+
5+
export default bg;
6+
}

dist/locale/bg.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.default = void 0;
7+
var _default = {
8+
days: ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота"],
9+
daysShort: ["Нед", "Пон", "Вто", "Сря", "Чет", "Пет", "Съб"],
10+
daysMin: ["Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"],
11+
months: ["Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"],
12+
monthsShort: ["Яну", "Фев", "Мар", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Ное", "Дек"],
13+
today: "Днес",
14+
clear: "Изчисти",
15+
dateFormat: "dd.MM.yyyy",
16+
timeFormat: 'HH:mm',
17+
firstDay: 1
18+
};
19+
exports.default = _default;

dist/locale/ca.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'air-datepicker/locale/ca' {
2+
import {AirDatepickerLocale} from 'air-datepicker';
3+
const ca: AirDatepickerLocale;
4+
5+
export default ca;
6+
}

dist/locale/ca.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.default = void 0;
7+
var _default = {
8+
days: ["Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte"],
9+
daysShort: ["Diu", "Dil", "Dmt", "Dmc", "Dij", "Div", "Dis"],
10+
daysMin: ["dg", "dl", "dt", "dc", "dj", "dv", "ds"],
11+
months: ["Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"],
12+
monthsShort: ["Gen", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Oct", "Nov", "Des"],
13+
today: "Avui",
14+
clear: 'Neteja',
15+
dateFormat: 'dd/MM/yyyy',
16+
timeFormat: 'hh:mm aa',
17+
firstDay: 1
18+
};
19+
exports.default = _default;

dist/locale/hr.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
declare module 'air-datepicker/locale/hr' {
2+
import {AirDatepickerLocale} from 'air-datepicker';
3+
const hr: AirDatepickerLocale;
4+
5+
export default hr;
6+
}

dist/locale/hr.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.default = void 0;
7+
var _default = {
8+
days: ['Nedjelja', 'Ponedjeljak', 'Utorak', 'Srijeda', 'Četvrtak', 'Petak', 'Subota'],
9+
daysShort: ['Ned', 'Pon', 'Uto', 'Sri', 'Čet', 'Pet', 'Sub'],
10+
daysMin: ['Ne', 'Po', 'Ut', 'Sr', 'Če', 'Pe', 'Su'],
11+
months: ['Siječanj', 'Veljača', 'Ožujak', 'Travanj', 'Svibanj', 'Lipanj', 'Srpanj', 'Kolovoz', 'Rujan', 'Listopad', 'Studeni', 'Prosinac'],
12+
monthsShort: ['Sij', 'Velj', 'Ožu', 'Tra', 'Svi', 'Lip', 'Srp', 'Kol', 'Ruj', 'Lis', 'Stu', 'Pro'],
13+
today: 'Danas',
14+
clear: 'Očisti',
15+
dateFormat: 'dd.MM.yyyy',
16+
timeFormat: 'HH:mm',
17+
firstDay: 1
18+
};
19+
exports.default = _default;

dist/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
{
22
"name": "air-datepicker",
3-
"version": "3.3.5",
3+
"version": "3.4.0",
44
"scripts": {
55
"dev": "set NODE_ENV=development&& webpack",
66
"dev:serve": "npm run browser&& set NODE_ENV=development&& webpack serve",
77
"prod": "set NODE_ENV=production&& webpack",
88
"browser": "open-cli http://localhost:8080 -- 'chrome' ",
99
"build": "node scripts/build.js",
1010
"lint-js": "eslint --fix ./src/*.js",
11-
"test": "jest"
11+
"test": "jest",
12+
"check-gzip-size": "node scripts/checkGzipSize.js"
1213
},
1314
"devDependencies": {
1415
"@babel/cli": "^7.20.7",
1516
"@babel/core": "^7.20.12",
1617
"@babel/plugin-proposal-class-properties": "^7.18.6",
18+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
1719
"@babel/plugin-proposal-private-methods": "^7.18.6",
1820
"@babel/preset-env": "^7.20.2",
1921
"@popperjs/core": "^2.10.2",
@@ -32,12 +34,13 @@
3234
"html-webpack-plugin": "^5.3.1",
3335
"jest": "^26.6.3",
3436
"mini-css-extract-plugin": "^1.6.0",
37+
"node-gzip": "^1.1.2",
3538
"open-cli": "^6.0.1",
3639
"postcss": "^8.4.21",
3740
"postcss-loader": "^6.2.1",
3841
"pug": "^3.0.2",
3942
"rimraf": "^2.7.1",
40-
"sass": "^1.57.1",
43+
"sass": "^1.63.4",
4144
"sass-loader": "^13.2.0",
4245
"style-loader": "^3.3.1",
4346
"typescript": "^4.5.4",
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
export const disabledRangeDateExample = (msg) =>
2+
`import AirDatepicker from 'air-datepicker';
3+
4+
import isWithinInterval from 'date-fns/isWithinInterval';
5+
import isEqual from 'date-fns/isEqual';
6+
7+
const disabledDate = new Date('2023-07-13T00:00:00');
8+
9+
// ${msg.exampleRangeDisabledComment}
10+
const isDisabledDateIsInRange = ({date, datepicker}) => {
11+
const selectedDate = datepicker.selectedDates[0];
12+
if (selectedDate && datepicker.selectedDates.length === 1) {
13+
const sortedDates = [selectedDate, date].toSorted((a, b) => {
14+
if (a.getTime() > b.getTime()) {
15+
return 1;
16+
}
17+
return -1;
18+
})
19+
20+
return (isWithinInterval(disabledDate, {
21+
start: sortedDates[0],
22+
end: sortedDates[1]
23+
}))
24+
}
25+
}
26+
27+
new AirDatepicker('#el', {
28+
startDate: '2023-07-19',
29+
range: true,
30+
onBeforeSelect: ({date, datepicker}) => {
31+
// ${msg.exampleRangeDisabledComment2}
32+
return !isDisabledDateIsInRange({date, datepicker});
33+
},
34+
onFocus: ({date, datepicker}) => {
35+
if (isDisabledDateIsInRange({date, datepicker}) || isEqual(date, disabledDate)) {
36+
datepicker.$datepicker.classList.add('-disabled-range-')
37+
} else {
38+
datepicker.$datepicker.classList.remove('-disabled-range-')
39+
}
40+
}
41+
onRenderCell: ({date}) => {
42+
if (date.toLocaleDateString() === disabledDate.toLocaleDateString()) {
43+
return {
44+
disabled: true
45+
}
46+
}
47+
}}
48+
49+
});
50+
`
51+
52+
53+
export const disabledRangeDateExampleCSS =
54+
`
55+
.air-datepicker.-disabled-range- {
56+
--adp-cell-background-color-in-range: #eeeeee;
57+
--adp-cell-background-color-selected: #d0d0d0;
58+
}
59+
`

0 commit comments

Comments
 (0)