Skip to content

Commit

Permalink
Merge branch 'v3'
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0n committed Jul 24, 2023
2 parents d1d80f7 + afc3b2c commit bfb93ff
Show file tree
Hide file tree
Showing 35 changed files with 762 additions and 236 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,5 @@ module.exports = {
'keyword-spacing': 'error',
'arrow-spacing': 'error',
'space-before-blocks': 'error',
'no-magic-numbers': ['warn', {
ignore: [0, 1, -1],
ignoreArrayIndexes: true,
ignoreDefaultValues: true,
}],
},
};
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

### v3.4.0
* 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)
* 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)
* `toggleSelected` now can be a function [#534](https://github.com/t1m0n/air-datepicker/issues/534)
* fixed `clear` method [#546](https://github.com/t1m0n/air-datepicker/issues/546)
* added Bulgarian locale, thanks to [tonytomov](https://github.com/tonytomov), in [#531](https://github.com/t1m0n/air-datepicker/pull/531)
* added Catalan locale, thanks to [joatb](https://github.com/joatb), in [#542](https://github.com/t1m0n/air-datepicker/pull/542)
* added Croatian Locale, thanks to [diomed](https://github.com/diomed), in [#551](https://github.com/t1m0n/air-datepicker/pull/551)

### v3.3.5
* added handling of optional chaining operator in dist package [#518](https://github.com/t1m0n/air-datepicker/issues/518)
* added Indonesian locale, thanks to [BariqDharmawan](https://github.com/BariqDharmawan), in [#517](https://github.com/t1m0n/air-datepicker/pull/517)
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ new AirDatepicker('#el' [, options]);

## Recent updates

### v3.4.0
* 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)
* 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)
* `toggleSelected` now can be a function [#534](https://github.com/t1m0n/air-datepicker/issues/534)
* fixed `clear` method [#546](https://github.com/t1m0n/air-datepicker/issues/546)
* added Bulgarian locale, thanks to [tonytomov](https://github.com/tonytomov), in [#531](https://github.com/t1m0n/air-datepicker/pull/531)
* added Catalan locale, thanks to [joatb](https://github.com/joatb), in [#542](https://github.com/t1m0n/air-datepicker/pull/542)
* added Croatian Locale, thanks to [diomed](https://github.com/diomed), in [#551](https://github.com/t1m0n/air-datepicker/pull/551)

### v3.3.5
* added handling of optional chaining operator in dist package [#518](https://github.com/t1m0n/air-datepicker/issues/518)
* added Indonesian locale, thanks to [BariqDharmawan](https://github.com/BariqDharmawan), in [#517](https://github.com/t1m0n/air-datepicker/pull/517)
Expand Down
120 changes: 61 additions & 59 deletions dist/air-datepicker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,78 +44,80 @@ export declare type AirDatepickerPositionCallback = (
done: () => void
}) => void | (() => void)

export declare type AirDatepickerOptions = {
classes: string
inline: boolean,
locale: Partial<AirDatepickerLocale>,
startDate: AirDatepickerDate,
firstDay: number,
isMobile: boolean,
visible: boolean,
weekends: [number, number],
dateFormat: string | ((d: Date) => string),
altField: AirDatepickerSelector,
altFieldDateFormat: string,
toggleSelected: boolean,
keyboardNav: boolean,
selectedDates: AirDatepickerDate[] | false,
container: AirDatepickerSelector,
position: AirDatepickerPosition | AirDatepickerPositionCallback,
offset: number,
view: AirDatepickerViews,
minView: AirDatepickerViews,
showOtherMonths: boolean,
selectOtherMonths: boolean,
moveToOtherMonthsOnSelect: boolean,
showOtherYears: boolean,
selectOtherYears: boolean,
moveToOtherYearsOnSelect: boolean,
minDate: AirDatepickerDate | false,
maxDate: AirDatepickerDate | false,
disableNavWhenOutOfRange: true,
multipleDates: number | true | false,
multipleDatesSeparator: string,
range: boolean,
dynamicRange: boolean,
buttons: AirDatepickerButtonPresets | AirDatepickerButton | (AirDatepickerButtonPresets| AirDatepickerButton)[] | false,
monthsField: keyof AirDatepickerLocale,
showEvent: string,
autoClose: boolean,
prevHtml: string,
nextHtml: string,
navTitles: {
export declare type AirDatepickerOptions<E extends HTMLElement = HTMLInputElement> = {
classes?: string
inline?: boolean,
locale?: Partial<AirDatepickerLocale>,
startDate?: AirDatepickerDate,
firstDay?: number,
isMobile?: boolean,
visible?: boolean,
weekends?: [number, number],
dateFormat?: string | ((d: Date) => string),
altField?: AirDatepickerSelector,
altFieldDateFormat?: string,
toggleSelected?: boolean | (({datepicker, date}:{datepicker: AirDatepicker<E>, date: Date}) => boolean),
keyboardNav?: boolean,
selectedDates?: AirDatepickerDate[] | false,
container?: AirDatepickerSelector,
position?: AirDatepickerPosition | AirDatepickerPositionCallback,
offset?: number,
view?: AirDatepickerViews,
minView?: AirDatepickerViews,
showOtherMonths?: boolean,
selectOtherMonths?: boolean,
moveToOtherMonthsOnSelect?: boolean,
showOtherYears?: boolean,
selectOtherYears?: boolean,
moveToOtherYearsOnSelect?: boolean,
minDate?: AirDatepickerDate | false,
maxDate?: AirDatepickerDate | false,
disableNavWhenOutOfRange?: true,
multipleDates?: number | true | false,
multipleDatesSeparator?: string,
range?: boolean,
dynamicRange?: boolean,
buttons?: AirDatepickerButtonPresets | AirDatepickerButton | (AirDatepickerButtonPresets| AirDatepickerButton)[] | false,
monthsField?: keyof AirDatepickerLocale,
showEvent?: string,
autoClose?: boolean,
prevHtml?: string,
nextHtml?: string,
navTitles?: {
days?: AirDatepickerNavEntry,
months?: AirDatepickerNavEntry,
years?: AirDatepickerNavEntry
},
timepicker: boolean,
onlyTimepicker: boolean,
dateTimeSeparator: string,
timeFormat: string,
minHours: number,
maxHours: number,
minMinutes: number,
maxMinutes: number,
hoursStep: number,
minutesStep: number,
timepicker?: boolean,
onlyTimepicker?: boolean,
dateTimeSeparator?: string,
timeFormat?: string,
minHours?: number,
maxHours?: number,
minMinutes?: number,
maxMinutes?: number,
hoursStep?: number,
minutesStep?: number,

onSelect: ({date, formattedDate, datepicker}: {date: Date | Date[], formattedDate: string | string[], datepicker: AirDatepicker}) => void,
onChangeViewDate: ({month, year, decade}: {month: number, year: number, decade: AirDatepickerDecade}) => void,
onChangeView: (view: AirDatepickerViews) => void,
onRenderCell: (params: {date: Date, cellType: AirDatepickerViewsSingle, datepicker: AirDatepicker}) => ({
onSelect?: ({date, formattedDate, datepicker}: {date: Date | Date[], formattedDate: string | string[], datepicker: AirDatepicker<E>}) => void,
onChangeViewDate?: ({month, year, decade}: {month: number, year: number, decade: AirDatepickerDecade}) => void,
onChangeView?: (view: AirDatepickerViews) => void,
onRenderCell?: (params: {date: Date, cellType: AirDatepickerViewsSingle, datepicker: AirDatepicker<E>}) => ({
disabled?: boolean,
classes?: string,
html?: string
attrs?: Record<string, string | number | undefined>
} | void),
onShow: (isAnimationComplete: boolean) => void,
onHide: (isAnimationComplete: boolean) => void,
onClickDayName: ({dayIndex, datepicker}: {dayIndex: number, datepicker: AirDatepicker}) => void
onShow?: (isAnimationComplete: boolean) => void,
onHide?: (isAnimationComplete: boolean) => void,
onClickDayName?: ({dayIndex, datepicker}: {dayIndex: number, datepicker: AirDatepicker<E>}) => void
onBeforeSelect?: ({date, datepicker}: {date: Date, datepicker: AirDatepicker}) => boolean;
onFocus?: ({date, datepicker}: {date: Date, datepicker: AirDatepicker}) => void;
}


declare class AirDatepicker<E extends HTMLElement = HTMLInputElement> {
constructor(el: string | E, opts? : Partial<AirDatepickerOptions>)
constructor(el: string | E, opts? : AirDatepickerOptions<E>)
static defaults: AirDatepickerOptions
static version: string
static defaultGlobalContainerId: string
Expand All @@ -129,7 +131,7 @@ declare class AirDatepicker<E extends HTMLElement = HTMLInputElement> {
clear: () => void
formatDate: (date: AirDatepickerDate, format: string) => string
destroy: () => void
update: (newOpts: Partial<AirDatepickerOptions>) => void
update: (newOpts?: AirDatepickerOptions) => void
setCurrentView: (newView: AirDatepickerViews) => void
setViewDate: (newViewDate: AirDatepickerDate) => void
setFocusDate: (date: AirDatepickerDate | false, opts?: {viewDateTransition?: boolean}) => void
Expand Down
2 changes: 1 addition & 1 deletion dist/air-datepicker.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/locale/bg.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'air-datepicker/locale/bg' {
import {AirDatepickerLocale} from 'air-datepicker';
const bg: AirDatepickerLocale;

export default bg;
}
19 changes: 19 additions & 0 deletions dist/locale/bg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
days: ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота"],
daysShort: ["Нед", "Пон", "Вто", "Сря", "Чет", "Пет", "Съб"],
daysMin: ["Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"],
months: ["Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"],
monthsShort: ["Яну", "Фев", "Мар", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Ное", "Дек"],
today: "Днес",
clear: "Изчисти",
dateFormat: "dd.MM.yyyy",
timeFormat: 'HH:mm',
firstDay: 1
};
exports.default = _default;
6 changes: 6 additions & 0 deletions dist/locale/ca.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'air-datepicker/locale/ca' {
import {AirDatepickerLocale} from 'air-datepicker';
const ca: AirDatepickerLocale;

export default ca;
}
19 changes: 19 additions & 0 deletions dist/locale/ca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
days: ["Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte"],
daysShort: ["Diu", "Dil", "Dmt", "Dmc", "Dij", "Div", "Dis"],
daysMin: ["dg", "dl", "dt", "dc", "dj", "dv", "ds"],
months: ["Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"],
monthsShort: ["Gen", "Feb", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Oct", "Nov", "Des"],
today: "Avui",
clear: 'Neteja',
dateFormat: 'dd/MM/yyyy',
timeFormat: 'hh:mm aa',
firstDay: 1
};
exports.default = _default;
6 changes: 6 additions & 0 deletions dist/locale/hr.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare module 'air-datepicker/locale/hr' {
import {AirDatepickerLocale} from 'air-datepicker';
const hr: AirDatepickerLocale;

export default hr;
}
19 changes: 19 additions & 0 deletions dist/locale/hr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
days: ['Nedjelja', 'Ponedjeljak', 'Utorak', 'Srijeda', 'Četvrtak', 'Petak', 'Subota'],
daysShort: ['Ned', 'Pon', 'Uto', 'Sri', 'Čet', 'Pet', 'Sub'],
daysMin: ['Ne', 'Po', 'Ut', 'Sr', 'Če', 'Pe', 'Su'],
months: ['Siječanj', 'Veljača', 'Ožujak', 'Travanj', 'Svibanj', 'Lipanj', 'Srpanj', 'Kolovoz', 'Rujan', 'Listopad', 'Studeni', 'Prosinac'],
monthsShort: ['Sij', 'Velj', 'Ožu', 'Tra', 'Svi', 'Lip', 'Srp', 'Kol', 'Ruj', 'Lis', 'Stu', 'Pro'],
today: 'Danas',
clear: 'Očisti',
dateFormat: 'dd.MM.yyyy',
timeFormat: 'HH:mm',
firstDay: 1
};
exports.default = _default;
9 changes: 6 additions & 3 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"name": "air-datepicker",
"version": "3.3.5",
"version": "3.4.0",
"scripts": {
"dev": "set NODE_ENV=development&& webpack",
"dev:serve": "npm run browser&& set NODE_ENV=development&& webpack serve",
"prod": "set NODE_ENV=production&& webpack",
"browser": "open-cli http://localhost:8080 -- 'chrome' ",
"build": "node scripts/build.js",
"lint-js": "eslint --fix ./src/*.js",
"test": "jest"
"test": "jest",
"check-gzip-size": "node scripts/checkGzipSize.js"
},
"devDependencies": {
"@babel/cli": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/preset-env": "^7.20.2",
"@popperjs/core": "^2.10.2",
Expand All @@ -32,12 +34,13 @@
"html-webpack-plugin": "^5.3.1",
"jest": "^26.6.3",
"mini-css-extract-plugin": "^1.6.0",
"node-gzip": "^1.1.2",
"open-cli": "^6.0.1",
"postcss": "^8.4.21",
"postcss-loader": "^6.2.1",
"pug": "^3.0.2",
"rimraf": "^2.7.1",
"sass": "^1.57.1",
"sass": "^1.63.4",
"sass-loader": "^13.2.0",
"style-loader": "^3.3.1",
"typescript": "^4.5.4",
Expand Down
File renamed without changes.
59 changes: 59 additions & 0 deletions docs/examples/code/disabledRangeDateExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export const disabledRangeDateExample = (msg) =>
`import AirDatepicker from 'air-datepicker';
import isWithinInterval from 'date-fns/isWithinInterval';
import isEqual from 'date-fns/isEqual';
const disabledDate = new Date('2023-07-13T00:00:00');
// ${msg.exampleRangeDisabledComment}
const isDisabledDateIsInRange = ({date, datepicker}) => {
const selectedDate = datepicker.selectedDates[0];
if (selectedDate && datepicker.selectedDates.length === 1) {
const sortedDates = [selectedDate, date].toSorted((a, b) => {
if (a.getTime() > b.getTime()) {
return 1;
}
return -1;
})
return (isWithinInterval(disabledDate, {
start: sortedDates[0],
end: sortedDates[1]
}))
}
}
new AirDatepicker('#el', {
startDate: '2023-07-19',
range: true,
onBeforeSelect: ({date, datepicker}) => {
// ${msg.exampleRangeDisabledComment2}
return !isDisabledDateIsInRange({date, datepicker});
},
onFocus: ({date, datepicker}) => {
if (isDisabledDateIsInRange({date, datepicker}) || isEqual(date, disabledDate)) {
datepicker.$datepicker.classList.add('-disabled-range-')
} else {
datepicker.$datepicker.classList.remove('-disabled-range-')
}
}
onRenderCell: ({date}) => {
if (date.toLocaleDateString() === disabledDate.toLocaleDateString()) {
return {
disabled: true
}
}
}}
});
`


export const disabledRangeDateExampleCSS =
`
.air-datepicker.-disabled-range- {
--adp-cell-background-color-in-range: #eeeeee;
--adp-cell-background-color-selected: #d0d0d0;
}
`
Loading

1 comment on commit bfb93ff

@vercel
Copy link

@vercel vercel bot commented on bfb93ff Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.