Skip to content

Commit 7e8917f

Browse files
authored
Merge branch 'onesine:master' into master
2 parents cac5cb4 + c74416e commit 7e8917f

File tree

5 files changed

+65
-63
lines changed

5 files changed

+65
-63
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-tailwindcss-datepicker",
3-
"version": "1.4.2",
3+
"version": "1.5.1",
44
"description": "A modern React Datepicker using Tailwind CSS 3",
55
"main": "dist/index.cjs.js",
66
"module": "dist/index.esm.js",
@@ -40,10 +40,11 @@
4040
"react": "^17.0.2 || ^18.2.0"
4141
},
4242
"devDependencies": {
43-
"@rollup/plugin-commonjs": "^22.0.1",
44-
"@rollup/plugin-node-resolve": "^13.3.0",
45-
"@rollup/plugin-typescript": "^9.0.2",
43+
"@rollup/plugin-commonjs": "^24.0.1",
44+
"@rollup/plugin-node-resolve": "^15.0.1",
45+
"@rollup/plugin-typescript": "^11.0.0",
4646
"@tailwindcss/forms": "^0.5.3",
47+
"@types/node": "18.14.5",
4748
"@types/react": "^18.0.21",
4849
"@typescript-eslint/eslint-plugin": "^5.45.0",
4950
"@typescript-eslint/parser": "^5.45.0",

src/components/Shortcuts.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import dayjs from "dayjs";
22
import React, { useCallback, useContext, useMemo } from "react";
33

4-
import { DEFAULT_SHORTCUTS, TEXT_COLOR } from "../constants";
4+
import { TEXT_COLOR } from "../constants";
5+
import DEFAULT_SHORTCUTS from "../constants/shortcuts";
56
import DatepickerContext from "../contexts/DatepickerContext";
67
import { Period, ShortcutsItem } from "../types";
78

src/constants/index.ts

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import dayjs from "dayjs";
2-
3-
import { formatDate, previousMonth } from "../helpers";
4-
5-
import { ShortcutsItem } from "types";
6-
71
export const COLORS = [
82
"blue",
93
"orange",
@@ -283,54 +277,3 @@ export const BUTTON_COLOR = {
283277
rose: "focus:ring-rose-500/50 focus:bg-rose-100/50"
284278
}
285279
};
286-
287-
export const DEFAULT_SHORTCUTS: {
288-
[key in string]: ShortcutsItem | ShortcutsItem[];
289-
} = {
290-
today: {
291-
text: "Today",
292-
period: {
293-
start: formatDate(dayjs()),
294-
end: formatDate(dayjs())
295-
}
296-
},
297-
yesterday: {
298-
text: "Yesterday",
299-
period: {
300-
start: formatDate(dayjs().subtract(1, "d")),
301-
end: formatDate(dayjs().subtract(1, "d"))
302-
}
303-
},
304-
past: [
305-
{
306-
daysNumber: 7,
307-
text: "Last 7 days",
308-
period: {
309-
start: formatDate(dayjs().subtract(7, "d")),
310-
end: formatDate(dayjs())
311-
}
312-
},
313-
{
314-
daysNumber: 30,
315-
text: "Last 30 days",
316-
period: {
317-
start: formatDate(dayjs().subtract(30, "d")),
318-
end: formatDate(dayjs())
319-
}
320-
}
321-
],
322-
currentMonth: {
323-
text: "This month",
324-
period: {
325-
start: formatDate(dayjs().startOf("month")),
326-
end: formatDate(dayjs().endOf("month"))
327-
}
328-
},
329-
pastMonth: {
330-
text: "Last month",
331-
period: {
332-
start: formatDate(previousMonth(dayjs()).startOf("month")),
333-
end: formatDate(previousMonth(dayjs()).endOf("month"))
334-
}
335-
}
336-
};

src/constants/shortcuts.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import dayjs from "dayjs";
2+
3+
import { formatDate, previousMonth } from "../helpers";
4+
import { ShortcutsItem } from "../types";
5+
6+
const DEFAULT_SHORTCUTS: {
7+
[key in string]: ShortcutsItem | ShortcutsItem[];
8+
} = {
9+
today: {
10+
text: "Today",
11+
period: {
12+
start: formatDate(dayjs()),
13+
end: formatDate(dayjs())
14+
}
15+
},
16+
yesterday: {
17+
text: "Yesterday",
18+
period: {
19+
start: formatDate(dayjs().subtract(1, "d")),
20+
end: formatDate(dayjs().subtract(1, "d"))
21+
}
22+
},
23+
past: [
24+
{
25+
daysNumber: 7,
26+
text: "Last 7 days",
27+
period: {
28+
start: formatDate(dayjs().subtract(7, "d")),
29+
end: formatDate(dayjs())
30+
}
31+
},
32+
{
33+
daysNumber: 30,
34+
text: "Last 30 days",
35+
period: {
36+
start: formatDate(dayjs().subtract(30, "d")),
37+
end: formatDate(dayjs())
38+
}
39+
}
40+
],
41+
currentMonth: {
42+
text: "This month",
43+
period: {
44+
start: formatDate(dayjs().startOf("month")),
45+
end: formatDate(dayjs().endOf("month"))
46+
}
47+
},
48+
pastMonth: {
49+
text: "Last month",
50+
period: {
51+
start: formatDate(previousMonth(dayjs()).startOf("month")),
52+
end: formatDate(previousMonth(dayjs()).endOf("month"))
53+
}
54+
}
55+
};
56+
57+
export default DEFAULT_SHORTCUTS;

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"esModuleInterop": true,
1313
"baseUrl": "src/",
1414
"declaration": true,
15-
"declarationDir": "dist",
15+
"outDir": "./dist",
1616
"inlineSources": true,
1717
"sourceMap": true,
1818
"rootDir": "src",

0 commit comments

Comments
 (0)