Skip to content
This repository was archived by the owner on Apr 19, 2022. It is now read-only.

Commit f69be66

Browse files
committed
Release v6.0.8
2 parents 97cfdb7 + 021b5b4 commit f69be66

10 files changed

Lines changed: 6496 additions & 483 deletions

File tree

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ DatePicker build with typescript
3232
2. Support double views,flat view and single view
3333
3. Support multi selection
3434

35-
## RUN DEMO
36-
37-
yarn start or npm run start
38-
3935
## OPTIONS
4036

4137
| OPTION | REQUIRED | TYPE | DESC | Default /Possible Value |

dist/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typepicker.esm.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/typepicker.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/app.js

Lines changed: 0 additions & 179 deletions
This file was deleted.

example/example.js

Lines changed: 0 additions & 275 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "datepicker",
3-
"version": "6.0.6",
3+
"version": "6.0.8",
44
"description": "A Typescript Datepicker",
55
"author": "Fi2zzz <wenjingbiao@outlook.com>",
66
"repository": {
@@ -30,6 +30,5 @@
3030
"gulp": "^4.0.2",
3131
"through2": "^3.0.1",
3232
"webpack-stream": "^5.2.1"
33-
},
34-
"dependencies": {}
33+
}
3534
}

src/index.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class TypePicker {
180180
return;
181181
}
182182
let _date = this.date;
183-
let _views = this.views as any;
183+
let _views: string | number = this.views;
184184
const partial: Partial<TypePickerState> = {};
185185
match({ condition: isDef, value: option.format })(
186186
format => (partial.format = format)
@@ -191,14 +191,15 @@ class TypePicker {
191191
match({ condition: isNumber, value: option.selection })(
192192
size => (partial.selection = size)
193193
);
194-
match({ condition: isDate, value: option.startDate })(date => {
195-
partial.startDate = date;
196-
_date = date;
197-
});
198-
match({ condition: isDate, value: option.endDate })(
194+
match({ condition: isDate, value: useParseDate(option.startDate) })(
195+
date => {
196+
partial.startDate = date;
197+
_date = date;
198+
}
199+
);
200+
match({ condition: isDate, value: useParseDate(option.endDate) })(
199201
(date: Date) => (partial.endDate = date)
200202
);
201-
202203
match({ condition: isNumberOrTrue, value: option.limit })(
203204
limit => (partial.limit = limit)
204205
);
@@ -225,8 +226,8 @@ class TypePicker {
225226
match({
226227
condition: (dates: any) => List.every(dates, isDate),
227228
value: [partial.startDate, partial.endDate]
228-
})(() => {
229-
const date = partial.startDate;
229+
})(([startDate, endDate]) => {
230+
const date = startDate;
230231
const firstDate = new Date(date.getFullYear(), date.getMonth(), 1);
231232
const dateBeforeStartDate = new Date(
232233
date.getFullYear(),
@@ -235,8 +236,8 @@ class TypePicker {
235236
);
236237
disables.set({
237238
dates: findDisabledBeforeStartDate(firstDate, dateBeforeStartDate),
238-
startDate: partial.startDate,
239-
endDate: partial.endDate
239+
startDate,
240+
endDate
240241
});
241242
});
242243
match({ condition: isBool, value: option.useInvalidAsSelected })(value => {
@@ -260,7 +261,7 @@ class TypePicker {
260261

261262
protected element: HTMLElement = null;
262263

263-
protected update(partial, next?: Function) {
264+
protected update(partial) {
264265
if (partial && Object.keys(partial).length <= 0) {
265266
return;
266267
}
@@ -272,13 +273,10 @@ class TypePicker {
272273
reachEnd,
273274
reachStart
274275
});
275-
276276
const select = selector => DOMHelpers.select(this.element, selector);
277-
278277
const prevActionDOM = select(".calendar-action.prev");
279278
const nextActionDOM = select(".calendar-action.next");
280279
const nodeList = select(".calendar-cell");
281-
282280
if (prevActionDOM && nextActionDOM) {
283281
const listener = (disabled: any, step: number) => {
284282
const now = new Date(
@@ -297,7 +295,6 @@ class TypePicker {
297295
);
298296
nextActionDOM.addEventListener(events.click, () => listener(reachEnd, 1));
299297
}
300-
301298
List.loop(nodeList, node => {
302299
node.addEventListener(events.click, () => {
303300
const value = DOMHelpers.attr(node, dataset.date);

src/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export class Selection {
123123
*/
124124
export const checkSwitchable = (date: Date) => {
125125
const { startDate, endDate } = getState();
126+
126127
if (!startDate || !endDate) {
127128
return [false, false];
128129
}
@@ -131,7 +132,6 @@ export const checkSwitchable = (date: Date) => {
131132

132133
return [diffStart <= 0 && diffEnd > 0, diffStart > 0 && diffEnd <= 1];
133134
};
134-
135135
export function useFormatDate(date: Date): string {
136136
return format(date, getState().format);
137137
}

0 commit comments

Comments
 (0)