@acusti/date-picker 0.8.1 → 0.9.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
@@ -11,7 +11,7 @@ support for ranges via a two-up month calendar view.
11
11
  See the [storybook docs and demo][] to get a feel for what it can do.
12
12
 
13
13
  [storybook docs and demo]:
14
- https://acusti-uikit.netlify.app/?path=/docs/uikit-controls-datepicker-datepicker--docs
14
+ https://uikit.acusti.ca/?path=/docs/uikit-controls-datepicker-datepicker--docs
15
15
 
16
16
  ## Usage
17
17
 
@@ -8,7 +8,10 @@ export type Props = {
8
8
  isTwoUp?: boolean;
9
9
  monthLimitFirst?: number;
10
10
  monthLimitLast?: number;
11
- onChange: (payload: { dateEnd?: null | string; dateStart: string }) => void;
11
+ onChange: (payload: {
12
+ dateEnd?: null | string;
13
+ dateStart: string;
14
+ }) => void;
12
15
  /**
13
16
  * Boolean to specify that date picker should initially render with the
14
17
  * end date’s month visible. The default behavior is to initially render
@@ -17,16 +20,4 @@ export type Props = {
17
20
  showEndInitially?: boolean;
18
21
  useMonthAbbreviations?: boolean;
19
22
  };
20
- export default function DatePicker({
21
- className,
22
- dateEnd: _dateEnd,
23
- dateStart: _dateStart,
24
- initialMonth,
25
- isRange,
26
- isTwoUp,
27
- monthLimitFirst,
28
- monthLimitLast,
29
- onChange,
30
- showEndInitially,
31
- useMonthAbbreviations,
32
- }: Props): React.JSX.Element;
23
+ export default function DatePicker({ className, dateEnd: _dateEnd, dateStart: _dateStart, initialMonth, isRange, isTwoUp, monthLimitFirst, monthLimitLast, onChange, showEndInitially, useMonthAbbreviations, }: Props): React.JSX.Element;
@@ -2,54 +2,29 @@
2
2
  import { Style } from '@acusti/styling';
3
3
  import clsx from 'clsx';
4
4
  import * as React from 'react';
5
- import MonthCalendar from './MonthCalendar.js';
6
- import { ROOT_CLASS_NAME, STYLES } from './styles/date-picker.js';
7
- import {
8
- getMonthAbbreviationFromMonth,
9
- getMonthFromDate,
10
- getYearFromMonth,
11
- } from './utils.js';
5
+ import MonthCalendar from './MonthCalendar.tsx';
6
+ import { ROOT_CLASS_NAME, STYLES } from './styles/date-picker.ts';
7
+ import { getMonthAbbreviationFromMonth, getMonthFromDate, getYearFromMonth, } from './utils.ts';
12
8
  const { Fragment, useCallback, useEffect, useRef, useState } = React;
13
- const getAbbreviatedMonthTitle = (month) =>
14
- `${getMonthAbbreviationFromMonth(month)} ${getYearFromMonth(month)}`;
15
- export default function DatePicker({
16
- className,
17
- dateEnd: _dateEnd,
18
- dateStart: _dateStart,
19
- initialMonth,
20
- isRange = _dateEnd != null,
21
- isTwoUp,
22
- monthLimitFirst,
23
- monthLimitLast,
24
- onChange,
25
- showEndInitially,
26
- useMonthAbbreviations,
27
- }) {
28
- const dateEndFromProps =
29
- _dateEnd != null && typeof _dateEnd !== 'string'
30
- ? new Date(_dateEnd).toISOString()
31
- : _dateEnd;
32
- const dateStartFromProps =
33
- _dateStart != null && typeof _dateStart !== 'string'
34
- ? new Date(_dateStart).toISOString()
35
- : _dateStart;
36
- const [dateEnd, setDateEnd] = useState(
37
- dateEndFromProps !== null && dateEndFromProps !== void 0
38
- ? dateEndFromProps
39
- : null,
40
- );
41
- const [dateStart, setDateStart] = useState(
42
- dateStartFromProps !== null && dateStartFromProps !== void 0
43
- ? dateStartFromProps
44
- : null,
45
- );
9
+ const getAbbreviatedMonthTitle = (month) => `${getMonthAbbreviationFromMonth(month)} ${getYearFromMonth(month)}`;
10
+ export default function DatePicker({ className, dateEnd: _dateEnd, dateStart: _dateStart, initialMonth, isRange = _dateEnd != null, isTwoUp, monthLimitFirst, monthLimitLast, onChange, showEndInitially, useMonthAbbreviations, }) {
11
+ const dateEndFromProps = _dateEnd != null && typeof _dateEnd !== 'string'
12
+ ? new Date(_dateEnd).toISOString()
13
+ : _dateEnd;
14
+ const dateStartFromProps = _dateStart != null && typeof _dateStart !== 'string'
15
+ ? new Date(_dateStart).toISOString()
16
+ : _dateStart;
17
+ const [dateEnd, setDateEnd] = useState(dateEndFromProps !== null && dateEndFromProps !== void 0 ? dateEndFromProps : null);
18
+ const [dateStart, setDateStart] = useState(dateStartFromProps !== null && dateStartFromProps !== void 0 ? dateStartFromProps : null);
46
19
  const updatingDateEndRef = useRef(false);
47
20
  useEffect(() => {
48
- if (dateEndFromProps == null) return;
21
+ if (dateEndFromProps == null)
22
+ return;
49
23
  setDateEnd(dateEndFromProps);
50
24
  }, [dateEndFromProps]);
51
25
  useEffect(() => {
52
- if (dateStartFromProps == null) return;
26
+ if (dateStartFromProps == null)
27
+ return;
53
28
  setDateStart(dateStartFromProps);
54
29
  }, [dateStartFromProps]);
55
30
  if (initialMonth == null) {
@@ -57,9 +32,7 @@ export default function DatePicker({
57
32
  const useDateEnd = dateStart == null || Boolean(showEndInitially && dateEnd);
58
33
  // use date from props if set
59
34
  const initialDate = useDateEnd ? dateEnd : dateStart;
60
- initialMonth = getMonthFromDate(
61
- initialDate == null ? new Date() : new Date(initialDate),
62
- );
35
+ initialMonth = getMonthFromDate(initialDate == null ? new Date() : new Date(initialDate));
63
36
  if (useDateEnd && isTwoUp) {
64
37
  initialMonth -= 1;
65
38
  }
@@ -71,111 +44,65 @@ export default function DatePicker({
71
44
  monthLimitLast -= 1;
72
45
  }
73
46
  const handleClickLeftArrow = useCallback(() => {
74
- setMonth((existingMonth) =>
75
- monthLimitFirst == null || existingMonth > monthLimitFirst
76
- ? existingMonth - 1
77
- : existingMonth,
78
- );
47
+ setMonth((existingMonth) => monthLimitFirst == null || existingMonth > monthLimitFirst
48
+ ? existingMonth - 1
49
+ : existingMonth);
79
50
  }, [monthLimitFirst]);
80
51
  const handleClickRightArrow = useCallback(() => {
81
- setMonth((existingMonth) =>
82
- monthLimitLast == null || existingMonth < monthLimitLast
83
- ? existingMonth + 1
84
- : existingMonth,
85
- );
52
+ setMonth((existingMonth) => monthLimitLast == null || existingMonth < monthLimitLast
53
+ ? existingMonth + 1
54
+ : existingMonth);
86
55
  }, [monthLimitLast]);
87
- const handleChange = useCallback(
88
- (date) => {
89
- // If we last set the dateStart or we have a dateStart but no dateEnd, set dateEnd
90
- if (
91
- isRange &&
92
- dateStart != null &&
93
- (updatingDateEndRef.current || dateEnd == null)
94
- ) {
95
- // Ensure that dateEnd is after dateStart; if not, swap them
96
- if (date < dateStart) {
97
- setDateStart(date);
98
- setDateEnd(dateStart);
99
- onChange({ dateEnd: dateStart, dateStart: date });
100
- } else {
101
- setDateEnd(date);
102
- onChange({ dateEnd: date, dateStart });
103
- }
104
- updatingDateEndRef.current = false;
105
- } else {
56
+ const handleChange = useCallback((date) => {
57
+ // If we last set the dateStart or we have a dateStart but no dateEnd, set dateEnd
58
+ if (isRange &&
59
+ dateStart != null &&
60
+ (updatingDateEndRef.current || dateEnd == null)) {
61
+ // Ensure that dateEnd is after dateStart; if not, swap them
62
+ if (date < dateStart) {
106
63
  setDateStart(date);
107
- setDateEnd(null);
108
- if (isRange) {
109
- onChange({ dateEnd: null, dateStart: date });
110
- updatingDateEndRef.current = true;
111
- } else {
112
- onChange({ dateStart: date });
113
- }
64
+ setDateEnd(dateStart);
65
+ onChange({ dateEnd: dateStart, dateStart: date });
114
66
  }
115
- },
116
- [dateEnd, dateStart, isRange, onChange],
117
- );
67
+ else {
68
+ setDateEnd(date);
69
+ onChange({ dateEnd: date, dateStart });
70
+ }
71
+ updatingDateEndRef.current = false;
72
+ }
73
+ else {
74
+ setDateStart(date);
75
+ setDateEnd(null);
76
+ if (isRange) {
77
+ onChange({ dateEnd: null, dateStart: date });
78
+ updatingDateEndRef.current = true;
79
+ }
80
+ else {
81
+ onChange({ dateStart: date });
82
+ }
83
+ }
84
+ }, [dateEnd, dateStart, isRange, onChange]);
118
85
  const handleChangeEndPreview = useCallback((date) => {
119
86
  setDateEndPreview(date);
120
87
  }, []);
121
- return React.createElement(
122
- Fragment,
123
- null,
124
- React.createElement(Style, { href: '@acusti/date-picker/DatePicker' }, STYLES),
125
- React.createElement(
126
- 'div',
127
- {
128
- className: clsx(ROOT_CLASS_NAME, className, {
129
- 'two-up': isTwoUp,
130
- }),
131
- },
132
- React.createElement(
133
- 'div',
134
- { className: `${ROOT_CLASS_NAME}-range-arrow-wrap` },
135
- React.createElement('div', {
136
- className: clsx(`${ROOT_CLASS_NAME}-range-arrow left-arrow`, {
88
+ return (React.createElement(Fragment, null,
89
+ React.createElement(Style, { href: "@acusti/date-picker/DatePicker" }, STYLES),
90
+ React.createElement("div", { className: clsx(ROOT_CLASS_NAME, className, {
91
+ 'two-up': isTwoUp,
92
+ }) },
93
+ React.createElement("div", { className: `${ROOT_CLASS_NAME}-range-arrow-wrap` },
94
+ React.createElement("div", { className: clsx(`${ROOT_CLASS_NAME}-range-arrow left-arrow`, {
137
95
  disabled: monthLimitFirst != null && month <= monthLimitFirst,
138
- }),
139
- onClick: handleClickLeftArrow,
140
- }),
141
- React.createElement('div', {
142
- className: clsx(`${ROOT_CLASS_NAME}-range-arrow right-arrow`, {
96
+ }), onClick: handleClickLeftArrow }),
97
+ React.createElement("div", { className: clsx(`${ROOT_CLASS_NAME}-range-arrow right-arrow`, {
143
98
  disabled: monthLimitLast != null && month >= monthLimitLast,
144
- }),
145
- onClick: handleClickRightArrow,
146
- }),
147
- ),
148
- React.createElement(
149
- 'div',
150
- { className: `${ROOT_CLASS_NAME}-month-container` },
151
- React.createElement(MonthCalendar, {
152
- dateEnd: dateEnd,
153
- dateEndPreview: dateEndPreview,
154
- dateStart: dateStart,
155
- isRange: isRange,
156
- month: month,
157
- onChange: handleChange,
158
- onChangeEndPreview: handleChangeEndPreview,
159
- title: useMonthAbbreviations
99
+ }), onClick: handleClickRightArrow })),
100
+ React.createElement("div", { className: `${ROOT_CLASS_NAME}-month-container` },
101
+ React.createElement(MonthCalendar, { dateEnd: dateEnd, dateEndPreview: dateEndPreview, dateStart: dateStart, isRange: isRange, month: month, onChange: handleChange, onChangeEndPreview: handleChangeEndPreview, title: useMonthAbbreviations
160
102
  ? getAbbreviatedMonthTitle(month)
161
- : undefined,
162
- }),
163
- isTwoUp
164
- ? React.createElement(MonthCalendar, {
165
- dateEnd: dateEnd,
166
- dateEndPreview: dateEndPreview,
167
- dateStart: dateStart,
168
- isRange: isRange,
169
- month: month + 1,
170
- onChange: handleChange,
171
- onChangeEndPreview: handleChangeEndPreview,
172
- title: useMonthAbbreviations
173
- ? getAbbreviatedMonthTitle(month + 1)
174
- : undefined,
175
- })
176
- : null,
177
- ),
178
- ),
179
- );
103
+ : undefined }),
104
+ isTwoUp ? (React.createElement(MonthCalendar, { dateEnd: dateEnd, dateEndPreview: dateEndPreview, dateStart: dateStart, isRange: isRange, month: month + 1, onChange: handleChange, onChangeEndPreview: handleChangeEndPreview, title: useMonthAbbreviations
105
+ ? getAbbreviatedMonthTitle(month + 1)
106
+ : undefined })) : null))));
180
107
  }
181
- //# sourceMappingURL=DatePicker.js.map
108
+ //# sourceMappingURL=DatePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../src/DatePicker.tsx"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACH,6BAA6B,EAC7B,gBAAgB,EAChB,gBAAgB,GACnB,MAAM,YAAY,CAAC;AAqBpB,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;AAErE,MAAM,wBAAwB,GAAG,CAAC,KAAa,EAAE,EAAE,CAC/C,GAAG,6BAA6B,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;AAEzE,MAAM,CAAC,OAAO,U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E;wBAC1D,QAAQ,EAAE,cAAc,IAAI,IAAI,IAAI,KAAK,IAAI,cAAc;qBAC9D,CAAC,EACF,OAAO,EAAE,qBAAqB,GAChC,CACA;YACN,6BAAK,SAAS,EAAE,GAAG,eAAe,kBAAkB;gBAChD,oBAAC,aAAa,IACV,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,YAAY,EACtB,kBAAkB,EAAE,sBAAsB,EAC1C,KAAK,EACD,qBAAqB;wBACjB,CAAC,CAAC,wBAAwB,CAAC,KAAK,CAAC;wBACjC,CAAC,CAAC,SAAS,GAErB;gBACD,OAAO,CAAC,CAAC,CAAC,CACP,oBAAC,aAAa,IACV,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,cAAc,EAC9B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,GAAG,CAAC,EAChB,QAAQ,EAAE,YAAY,EACtB,kBAAkB,EAAE,sBAAsB,EAC1C,KAAK,EACD,qBAAqB;wBACjB,CAAC,CAAC,wBAAwB,CAAC,KAAK,GAAG,CAAC,CAAC;wBACrC,CAAC,CAAC,SAAS,GAErB,CACL,CAAC,CAAC,CAAC,IAAI,CACN,CACJ,CACC,CACd,CAAC;AACN,CAAC"}
@@ -10,14 +10,4 @@ export type Props = {
10
10
  onChangeEndPreview?: (date: string) => void;
11
11
  title?: string;
12
12
  };
13
- export default function MonthCalendar({
14
- className,
15
- dateEnd,
16
- dateEndPreview,
17
- dateStart,
18
- isRange,
19
- month,
20
- onChange,
21
- onChangeEndPreview,
22
- title,
23
- }: Props): React.JSX.Element;
13
+ export default function MonthCalendar({ className, dateEnd, dateEndPreview, dateStart, isRange, month, onChange, onChangeEndPreview, title, }: Props): React.JSX.Element;
@@ -1,32 +1,13 @@
1
1
  import { Style } from '@acusti/styling';
2
2
  import clsx from 'clsx';
3
3
  import * as React from 'react';
4
- import { ROOT_CLASS_NAME, STYLES } from './styles/month-calendar.js';
5
- import {
6
- getDateFromMonthAndDay,
7
- getLastDateFromMonth,
8
- getMonthFromDate,
9
- getMonthNameFromMonth,
10
- getYearFromMonth,
11
- } from './utils.js';
4
+ import { ROOT_CLASS_NAME, STYLES } from './styles/month-calendar.ts';
5
+ import { getDateFromMonthAndDay, getLastDateFromMonth, getMonthFromDate, getMonthNameFromMonth, getYearFromMonth, } from './utils.ts';
12
6
  const { Fragment, useCallback } = React;
13
7
  const DAYS = Array(7).fill(null);
14
- export default function MonthCalendar({
15
- className,
16
- dateEnd,
17
- dateEndPreview,
18
- dateStart,
19
- isRange,
20
- month,
21
- onChange,
22
- onChangeEndPreview,
23
- title,
24
- }) {
8
+ export default function MonthCalendar({ className, dateEnd, dateEndPreview, dateStart, isRange, month, onChange, onChangeEndPreview, title, }) {
25
9
  const year = getYearFromMonth(month);
26
- title =
27
- title !== null && title !== void 0
28
- ? title
29
- : `${getMonthNameFromMonth(month)} ${year}`;
10
+ title = title !== null && title !== void 0 ? title : `${getMonthNameFromMonth(month)} ${year}`;
30
11
  const firstDate = getDateFromMonthAndDay(month, 1);
31
12
  const lastDate = getLastDateFromMonth(month);
32
13
  const totalDays = lastDate.getDate();
@@ -37,198 +18,88 @@ export default function MonthCalendar({
37
18
  dateStart,
38
19
  dateEnd,
39
20
  dateEndPreview,
40
- ].reduce(
41
- (acc, date, index) => {
42
- if (date != null && !(date instanceof Date)) {
43
- date = new Date(date);
44
- }
45
- if (date == null || Number.isNaN(date.getTime())) return acc;
46
- const dateMonth = getMonthFromDate(date);
47
- if (dateMonth < month) acc[index] = -1;
48
- else if (dateMonth > month) acc[index] = totalDays + 1;
49
- else acc[index] = date.getDate();
50
- if (index === 1) {
51
- const startDay = acc[index - 1];
52
- const endDay = acc[index];
53
- // Ensure that end date is after start date and swap them if not
54
- if (startDay != null && endDay != null && startDay > endDay) {
55
- acc[index - 1] = endDay;
56
- acc[index] = startDay;
57
- }
58
- }
21
+ ].reduce((acc, date, index) => {
22
+ if (date != null && !(date instanceof Date)) {
23
+ date = new Date(date);
24
+ }
25
+ if (date == null || Number.isNaN(date.getTime()))
59
26
  return acc;
60
- },
61
- [null, null, null],
62
- );
63
- const handleClickDay = useCallback(
64
- (event) => {
65
- const { date } = event.currentTarget.dataset;
66
- if (date && onChange) onChange(date);
67
- },
68
- [onChange],
69
- );
70
- const handleMouseEnterDay = useCallback(
71
- (event) => {
72
- if (isRange && onChangeEndPreview) {
73
- const { date } = event.currentTarget.dataset;
74
- if (date) onChangeEndPreview(date);
27
+ const dateMonth = getMonthFromDate(date);
28
+ if (dateMonth < month)
29
+ acc[index] = -1;
30
+ else if (dateMonth > month)
31
+ acc[index] = totalDays + 1;
32
+ else
33
+ acc[index] = date.getDate();
34
+ if (index === 1) {
35
+ const startDay = acc[index - 1];
36
+ const endDay = acc[index];
37
+ // Ensure that end date is after start date and swap them if not
38
+ if (startDay != null && endDay != null && startDay > endDay) {
39
+ acc[index - 1] = endDay;
40
+ acc[index] = startDay;
75
41
  }
76
- },
77
- [isRange, onChangeEndPreview],
78
- );
79
- return React.createElement(
80
- Fragment,
81
- null,
82
- React.createElement(Style, { href: '@acusti/date-picker/MonthCalendar' }, STYLES),
83
- React.createElement(
84
- 'div',
85
- { className: clsx(ROOT_CLASS_NAME, className) },
86
- React.createElement(
87
- 'div',
88
- { className: `${ROOT_CLASS_NAME}-month-title` },
89
- React.createElement(
90
- 'h3',
91
- { className: `${ROOT_CLASS_NAME}-month-title-text` },
92
- title,
93
- ),
94
- ),
95
- React.createElement(
96
- 'div',
97
- { className: `${ROOT_CLASS_NAME}-month-week` },
98
- React.createElement(
99
- 'div',
100
- { className: 'week-day-item' },
101
- React.createElement(
102
- 'span',
103
- { className: 'week-day-item-text' },
104
- 'Su',
105
- ),
106
- ),
107
- React.createElement(
108
- 'div',
109
- { className: 'week-day-item' },
110
- React.createElement(
111
- 'span',
112
- { className: 'week-day-item-text' },
113
- 'Mo',
114
- ),
115
- ),
116
- React.createElement(
117
- 'div',
118
- { className: 'week-day-item' },
119
- React.createElement(
120
- 'span',
121
- { className: 'week-day-item-text' },
122
- 'Tu',
123
- ),
124
- ),
125
- React.createElement(
126
- 'div',
127
- { className: 'week-day-item' },
128
- React.createElement(
129
- 'span',
130
- { className: 'week-day-item-text' },
131
- 'We',
132
- ),
133
- ),
134
- React.createElement(
135
- 'div',
136
- { className: 'week-day-item' },
137
- React.createElement(
138
- 'span',
139
- { className: 'week-day-item-text' },
140
- 'Th',
141
- ),
142
- ),
143
- React.createElement(
144
- 'div',
145
- { className: 'week-day-item' },
146
- React.createElement(
147
- 'span',
148
- { className: 'week-day-item-text' },
149
- 'Fr',
150
- ),
151
- ),
152
- React.createElement(
153
- 'div',
154
- { className: 'week-day-item' },
155
- React.createElement(
156
- 'span',
157
- { className: 'week-day-item-text' },
158
- 'Sa',
159
- ),
160
- ),
161
- ),
162
- React.createElement(
163
- 'div',
164
- { className: `${ROOT_CLASS_NAME}-month-days` },
165
- Array(Math.floor(daySpaces / 7))
166
- .fill(null)
167
- .map((_, weekIndex) =>
168
- React.createElement(
169
- 'div',
170
- {
171
- className: `${ROOT_CLASS_NAME}-month-row`,
172
- key: `MonthRow-${weekIndex}`,
173
- },
174
- DAYS.map((__, dayIndex) => {
175
- dayIndex += weekIndex * 7;
176
- const dayNumber = (dayIndex - firstDay) + 1; // prettier-ignore
177
- const isEmpty = dayNumber < 1 || dayNumber > totalDays;
178
- const date = isEmpty
179
- ? null
180
- : getDateFromMonthAndDay(month, dayNumber);
181
- const isAfterDateRangeStart =
182
- dateRangeStartDay != null &&
183
- dayNumber > dateRangeStartDay;
184
- const isBeforeDateRangeEnd =
185
- (dateRangeEndDay == null &&
186
- dateRangeEndPreviewDay != null &&
187
- dayNumber < dateRangeEndPreviewDay) ||
188
- (dateRangeEndDay != null &&
189
- dayNumber < dateRangeEndDay);
190
- return React.createElement(
191
- 'button',
192
- {
193
- className: clsx(
194
- `${ROOT_CLASS_NAME}-month-day-item`,
195
- {
196
- 'end-date':
197
- !isEmpty &&
198
- dayNumber === dateRangeEndDay,
199
- 'is-empty': isEmpty,
200
- 'is-selected':
201
- !isEmpty &&
202
- isAfterDateRangeStart &&
203
- isBeforeDateRangeEnd,
204
- 'start-date':
205
- !isEmpty &&
206
- dayNumber === dateRangeStartDay,
207
- },
208
- ),
209
- 'data-date':
210
- date === null || date === void 0
211
- ? void 0
212
- : date.toISOString(),
213
- disabled: isEmpty,
214
- key: `MonthDayItem-${dayNumber}`,
215
- onClick: handleClickDay,
216
- onMouseEnter: handleMouseEnterDay,
217
- type: 'button',
218
- },
219
- isEmpty
220
- ? null
221
- : React.createElement(
222
- 'span',
223
- { className: 'month-day-item-text' },
224
- dayNumber,
225
- ),
226
- );
227
- }),
228
- ),
229
- ),
230
- ),
231
- ),
232
- );
42
+ }
43
+ return acc;
44
+ }, [null, null, null]);
45
+ const handleClickDay = useCallback((event) => {
46
+ const { date } = event.currentTarget.dataset;
47
+ if (date && onChange)
48
+ onChange(date);
49
+ }, [onChange]);
50
+ const handleMouseEnterDay = useCallback((event) => {
51
+ if (isRange && onChangeEndPreview) {
52
+ const { date } = event.currentTarget.dataset;
53
+ if (date)
54
+ onChangeEndPreview(date);
55
+ }
56
+ }, [isRange, onChangeEndPreview]);
57
+ return (React.createElement(Fragment, null,
58
+ React.createElement(Style, { href: "@acusti/date-picker/MonthCalendar" }, STYLES),
59
+ React.createElement("div", { className: clsx(ROOT_CLASS_NAME, className) },
60
+ React.createElement("div", { className: `${ROOT_CLASS_NAME}-month-title` },
61
+ React.createElement("h3", { className: `${ROOT_CLASS_NAME}-month-title-text` }, title)),
62
+ React.createElement("div", { className: `${ROOT_CLASS_NAME}-month-week` },
63
+ React.createElement("div", { className: "week-day-item" },
64
+ React.createElement("span", { className: "week-day-item-text" }, "Su")),
65
+ React.createElement("div", { className: "week-day-item" },
66
+ React.createElement("span", { className: "week-day-item-text" }, "Mo")),
67
+ React.createElement("div", { className: "week-day-item" },
68
+ React.createElement("span", { className: "week-day-item-text" }, "Tu")),
69
+ React.createElement("div", { className: "week-day-item" },
70
+ React.createElement("span", { className: "week-day-item-text" }, "We")),
71
+ React.createElement("div", { className: "week-day-item" },
72
+ React.createElement("span", { className: "week-day-item-text" }, "Th")),
73
+ React.createElement("div", { className: "week-day-item" },
74
+ React.createElement("span", { className: "week-day-item-text" }, "Fr")),
75
+ React.createElement("div", { className: "week-day-item" },
76
+ React.createElement("span", { className: "week-day-item-text" }, "Sa"))),
77
+ React.createElement("div", { className: `${ROOT_CLASS_NAME}-month-days` }, Array(Math.floor(daySpaces / 7))
78
+ .fill(null)
79
+ .map((_, weekIndex) => (React.createElement("div", { className: `${ROOT_CLASS_NAME}-month-row`, key: `MonthRow-${weekIndex}` }, DAYS.map((__, dayIndex) => {
80
+ dayIndex += weekIndex * 7;
81
+ const dayNumber = (dayIndex - firstDay) + 1; // prettier-ignore
82
+ const isEmpty = dayNumber < 1 || dayNumber > totalDays;
83
+ const date = isEmpty
84
+ ? null
85
+ : getDateFromMonthAndDay(month, dayNumber);
86
+ const isAfterDateRangeStart = dateRangeStartDay != null &&
87
+ dayNumber > dateRangeStartDay;
88
+ const isBeforeDateRangeEnd = (dateRangeEndDay == null &&
89
+ dateRangeEndPreviewDay != null &&
90
+ dayNumber < dateRangeEndPreviewDay) ||
91
+ (dateRangeEndDay != null &&
92
+ dayNumber < dateRangeEndDay);
93
+ return (React.createElement("button", { className: clsx(`${ROOT_CLASS_NAME}-month-day-item`, {
94
+ 'end-date': !isEmpty &&
95
+ dayNumber === dateRangeEndDay,
96
+ 'is-empty': isEmpty,
97
+ 'is-selected': !isEmpty &&
98
+ isAfterDateRangeStart &&
99
+ isBeforeDateRangeEnd,
100
+ 'start-date': !isEmpty &&
101
+ dayNumber === dateRangeStartDay,
102
+ }), "data-date": date === null || date === void 0 ? void 0 : date.toISOString(), disabled: isEmpty, key: `MonthDayItem-${dayNumber}`, onClick: handleClickDay, onMouseEnter: handleMouseEnterDay, type: "button" }, isEmpty ? null : (React.createElement("span", { className: "month-day-item-text" }, dayNumber))));
103
+ }))))))));
233
104
  }
234
- //# sourceMappingURL=MonthCalendar.js.map
105
+ //# sourceMappingURL=MonthCalendar.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { default as DatePicker } from './DatePicker.js';
2
- export { default as MonthCalendar } from './MonthCalendar.js';
3
- export * from './utils.js';
1
+ export { default as DatePicker } from './DatePicker.tsx';
2
+ export { default as MonthCalendar } from './MonthCalendar.tsx';
3
+ export * from './utils.ts';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { default as DatePicker } from './DatePicker.js';
2
- export { default as MonthCalendar } from './MonthCalendar.js';
3
- export * from './utils.js';
4
- //# sourceMappingURL=index.js.map
1
+ export { default as DatePicker } from './DatePicker.tsx';
2
+ export { default as MonthCalendar } from './MonthCalendar.tsx';
3
+ export * from './utils.ts';
4
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC/D,cAAc,YAAY,CAAC"}
@@ -1,3 +1,2 @@
1
- export declare const ROOT_CLASS_NAME = 'uktdatepicker';
2
- export declare const STYLES =
3
- '\n.uktdatepicker {\n display: flex;\n box-sizing: border-box;\n padding: 40px 60px 60px;\n flex: 1 1 auto;\n position: relative;\n max-width: 450px;\n}\n\n.uktdatepicker.two-up {\n max-width: 820px;\n}\n\n.uktdatepicker-range-arrow-wrap {\n position: absolute;\n top: 30px;\n left: 0px;\n display: flex;\n justify-content: space-between;\n height: 0px;\n width: 100%;\n padding: 0px 60px;\n box-sizing: border-box;\n}\n\n.uktdatepicker-range-arrow {\n width: 35px;\n height: 35px;\n text-align: center;\n cursor: pointer;\n}\n\n.uktdatepicker-range-arrow.disabled {\n color: #ccc;\n cursor: default;\n}\n\n.uktdatepicker-range-arrow:active {\n transform: translateY(1px);\n}\n\n.uktdatepicker-range-arrow.left-arrow:after,\n.uktdatepicker-range-arrow.right-arrow:after {\n content: "\u2039";\n font-size: 24px;\n line-height: 35px;\n font-weight: bold;\n}\n\n.uktdatepicker-range-arrow.right-arrow:after {\n content: "\u203A";\n}\n\n.uktdatepicker-month-container {\n display: flex;\n flex: 1 1 auto;\n justify-content: space-between;\n}\n';
1
+ export declare const ROOT_CLASS_NAME = "uktdatepicker";
2
+ export declare const STYLES = "\n.uktdatepicker {\n display: flex;\n box-sizing: border-box;\n padding: 40px 60px 60px;\n flex: 1 1 auto;\n position: relative;\n max-width: 450px;\n}\n\n.uktdatepicker.two-up {\n max-width: 820px;\n}\n\n.uktdatepicker-range-arrow-wrap {\n position: absolute;\n top: 30px;\n left: 0px;\n display: flex;\n justify-content: space-between;\n height: 0px;\n width: 100%;\n padding: 0px 60px;\n box-sizing: border-box;\n}\n\n.uktdatepicker-range-arrow {\n width: 35px;\n height: 35px;\n text-align: center;\n cursor: pointer;\n}\n\n.uktdatepicker-range-arrow.disabled {\n color: #ccc;\n cursor: default;\n}\n\n.uktdatepicker-range-arrow:active {\n transform: translateY(1px);\n}\n\n.uktdatepicker-range-arrow.left-arrow:after,\n.uktdatepicker-range-arrow.right-arrow:after {\n content: \"\u2039\";\n font-size: 24px;\n line-height: 35px;\n font-weight: bold;\n}\n\n.uktdatepicker-range-arrow.right-arrow:after {\n content: \"\u203A\";\n}\n\n.uktdatepicker-month-container {\n display: flex;\n flex: 1 1 auto;\n justify-content: space-between;\n}\n";
@@ -59,4 +59,4 @@ export const STYLES = `
59
59
  justify-content: space-between;
60
60
  }
61
61
  `;
62
- //# sourceMappingURL=date-picker.js.map
62
+ //# sourceMappingURL=date-picker.js.map
@@ -1,3 +1,2 @@
1
- export declare const ROOT_CLASS_NAME = 'uktmonthcalendar';
2
- export declare const STYLES =
3
- '\n.uktmonthcalendar {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n box-sizing: border-box;\n max-width: 325px;\n}\n\n.uktmonthcalendar-month-title {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n box-sizing: border-box;\n padding-bottom: 25px;\n}\n\nh3.uktmonthcalendar-month-title-text {\n font-size: 18px;\n line-height: 23px;\n font-weight: 600;\n color: #000;\n margin: 0px;\n text-align: center;\n}\n\n.uktmonthcalendar-month-week {\n flex: 0 0 auto;\n display: grid;\n grid-column-gap: 0px;\n grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));\n grid-auto-flow: dense;\n box-sizing: border-box;\n padding-bottom: 12px;\n}\n\n.uktmonthcalendar-month-week .week-day-item {\n flex: 1 1 auto;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.uktmonthcalendar-month-week span.week-day-item-text {\n text-align: center;\n font-size: 13px;\n line-height: 21px;\n margin: 0px;\n color: #9a9a9a;\n}\n\n.uktmonthcalendar-month-days {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n}\n\n.uktmonthcalendar-month-row {\n flex: 1 1 auto;\n display: grid;\n grid-column-gap: 0px;\n grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));\n grid-auto-flow: dense;\n margin-bottom: 1px;\n}\n\n.uktmonthcalendar-month-day-item {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n height: 46px;\n width: 46px;\n cursor: pointer;\n border: none;\n background-color: transparent;\n}\n\n.uktmonthcalendar-month-day-item:disabled {\n cursor: auto;\n}\n\n.uktmonthcalendar-month-day-item.is-selected {\n background-color: #f8f8f8;\n}\n\n.uktmonthcalendar-month-day-item.start-date {\n background-color: #f8f8f8;\n border-top-left-radius: 50%;\n border-bottom-left-radius: 50%;\n}\n\n.uktmonthcalendar-month-day-item.start-date:after {\n background-color: #000;\n opacity: 1;\n visibility: visible;\n}\n.uktmonthcalendar-month-day-item.start-date span.month-day-item-text {\n color: #fff;\n}\n\n.uktmonthcalendar-month-day-item.end-date {\n background-color: #f8f8f8;\n border-top-right-radius: 50%;\n border-bottom-right-radius: 50%;\n}\n\n.uktmonthcalendar-month-day-item.end-date:after {\n background-color: #000;\n opacity: 1;\n visibility: visible;\n}\n.uktmonthcalendar-month-day-item.end-date span.month-day-item-text {\n color: #fff;\n}\n\n.uktmonthcalendar-month-day-item:hover:after {\n opacity: 1;\n visibility: visible;\n}\n\n.uktmonthcalendar-month-day-item:after {\n content: "";\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n border-radius: 50%;\n border: 1px solid #000;\n width: 43px;\n height: 43px;\n transition: opacity 0.25s ease-in-out;\n opacity: 0;\n visibility: hidden;\n}\n\n.uktmonthcalendar-month-day-item.is-empty:after {\n content: none;\n}\n\n.uktmonthcalendar-month-day-item span.month-day-item-text {\n text-align: center;\n font-size: 13px;\n line-height: 21px;\n margin: 0px;\n color: #000;\n position: relative;\n z-index: 1;\n}\n';
1
+ export declare const ROOT_CLASS_NAME = "uktmonthcalendar";
2
+ export declare const STYLES = "\n.uktmonthcalendar {\n display: flex;\n flex-direction: column;\n flex: 1 1 auto;\n box-sizing: border-box;\n max-width: 325px;\n}\n\n.uktmonthcalendar-month-title {\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 auto;\n box-sizing: border-box;\n padding-bottom: 25px;\n}\n\nh3.uktmonthcalendar-month-title-text {\n font-size: 18px;\n line-height: 23px;\n font-weight: 600;\n color: #000;\n margin: 0px;\n text-align: center;\n}\n\n.uktmonthcalendar-month-week {\n flex: 0 0 auto;\n display: grid;\n grid-column-gap: 0px;\n grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));\n grid-auto-flow: dense;\n box-sizing: border-box;\n padding-bottom: 12px;\n}\n\n.uktmonthcalendar-month-week .week-day-item {\n flex: 1 1 auto;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.uktmonthcalendar-month-week span.week-day-item-text {\n text-align: center;\n font-size: 13px;\n line-height: 21px;\n margin: 0px;\n color: #9a9a9a;\n}\n\n.uktmonthcalendar-month-days {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n}\n\n.uktmonthcalendar-month-row {\n flex: 1 1 auto;\n display: grid;\n grid-column-gap: 0px;\n grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));\n grid-auto-flow: dense;\n margin-bottom: 1px;\n}\n\n.uktmonthcalendar-month-day-item {\n display: flex;\n justify-content: center;\n align-items: center;\n position: relative;\n height: 46px;\n width: 46px;\n cursor: pointer;\n border: none;\n background-color: transparent;\n}\n\n.uktmonthcalendar-month-day-item:disabled {\n cursor: auto;\n}\n\n.uktmonthcalendar-month-day-item.is-selected {\n background-color: #f8f8f8;\n}\n\n.uktmonthcalendar-month-day-item.start-date {\n background-color: #f8f8f8;\n border-top-left-radius: 50%;\n border-bottom-left-radius: 50%;\n}\n\n.uktmonthcalendar-month-day-item.start-date:after {\n background-color: #000;\n opacity: 1;\n visibility: visible;\n}\n.uktmonthcalendar-month-day-item.start-date span.month-day-item-text {\n color: #fff;\n}\n\n.uktmonthcalendar-month-day-item.end-date {\n background-color: #f8f8f8;\n border-top-right-radius: 50%;\n border-bottom-right-radius: 50%;\n}\n\n.uktmonthcalendar-month-day-item.end-date:after {\n background-color: #000;\n opacity: 1;\n visibility: visible;\n}\n.uktmonthcalendar-month-day-item.end-date span.month-day-item-text {\n color: #fff;\n}\n\n.uktmonthcalendar-month-day-item:hover:after {\n opacity: 1;\n visibility: visible;\n}\n\n.uktmonthcalendar-month-day-item:after {\n content: \"\";\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n border-radius: 50%;\n border: 1px solid #000;\n width: 43px;\n height: 43px;\n transition: opacity 0.25s ease-in-out;\n opacity: 0;\n visibility: hidden;\n}\n\n.uktmonthcalendar-month-day-item.is-empty:after {\n content: none;\n}\n\n.uktmonthcalendar-month-day-item span.month-day-item-text {\n text-align: center;\n font-size: 13px;\n line-height: 21px;\n margin: 0px;\n color: #000;\n position: relative;\n z-index: 1;\n}\n";
@@ -151,4 +151,4 @@ h3.${ROOT_CLASS_NAME}-month-title-text {
151
151
  z-index: 1;
152
152
  }
153
153
  `;
154
- //# sourceMappingURL=month-calendar.js.map
154
+ //# sourceMappingURL=month-calendar.js.map
package/dist/utils.d.ts CHANGED
@@ -2,9 +2,5 @@ export declare const getMonthFromDate: (date: Date, asUTC?: boolean) => number;
2
2
  export declare const getYearFromMonth: (month: number) => number;
3
3
  export declare const getMonthNameFromMonth: (month: number) => string;
4
4
  export declare const getMonthAbbreviationFromMonth: (month: number) => string;
5
- export declare const getDateFromMonthAndDay: (
6
- month: number,
7
- day: number,
8
- asUTC?: boolean,
9
- ) => Date;
5
+ export declare const getDateFromMonthAndDay: (month: number, day: number, asUTC?: boolean) => Date;
10
6
  export declare const getLastDateFromMonth: (month: number, asUTC?: boolean) => Date;
package/dist/utils.js CHANGED
@@ -15,8 +15,7 @@ const MONTH_NAMES = [
15
15
  'November',
16
16
  'December',
17
17
  ];
18
- const getYearFromDate = (date, asUTC) =>
19
- (asUTC ? date.getUTCFullYear() : date.getFullYear()) - START_YEAR;
18
+ const getYearFromDate = (date, asUTC) => (asUTC ? date.getUTCFullYear() : date.getFullYear()) - START_YEAR;
20
19
  export const getMonthFromDate = (date, asUTC) => {
21
20
  const yearAsMonths = getYearFromDate(date, asUTC) * 12;
22
21
  return yearAsMonths + (asUTC ? date.getUTCMonth() : date.getMonth());
@@ -24,13 +23,16 @@ export const getMonthFromDate = (date, asUTC) => {
24
23
  export const getYearFromMonth = (month) => Math.floor(month / 12) + START_YEAR;
25
24
  export const getMonthNameFromMonth = (month) => {
26
25
  let index = month % 12;
27
- if (Number.isNaN(index)) return '';
28
- if (index < 0) index = 12 + index;
26
+ if (Number.isNaN(index))
27
+ return '';
28
+ if (index < 0)
29
+ index = 12 + index;
29
30
  return MONTH_NAMES[index];
30
31
  };
31
32
  export const getMonthAbbreviationFromMonth = (month) => {
32
33
  const monthName = getMonthNameFromMonth(month);
33
- if (monthName === 'September') return 'Sept';
34
+ if (monthName === 'September')
35
+ return 'Sept';
34
36
  return monthName.substring(0, 3);
35
37
  };
36
38
  export const getDateFromMonthAndDay = (month, day, asUTC) => {
@@ -44,4 +46,4 @@ export const getLastDateFromMonth = (month, asUTC) => {
44
46
  // day 0 of the next month is the last day of the current month
45
47
  return getDateFromMonthAndDay(month + 1, 0, asUTC);
46
48
  };
47
- //# sourceMappingURL=utils.js.map
49
+ //# sourceMappingURL=utils.js.map
@@ -1,11 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import {
3
- getDateFromMonthAndDay,
4
- getLastDateFromMonth,
5
- getMonthFromDate,
6
- getMonthNameFromMonth,
7
- getYearFromMonth,
8
- } from './utils.js';
2
+ import { getDateFromMonthAndDay, getLastDateFromMonth, getMonthFromDate, getMonthNameFromMonth, getYearFromMonth, } from './utils.ts';
9
3
  const INVALID_DATE = new Date('');
10
4
  describe('@acusti/date-picker', () => {
11
5
  describe('utils', () => {
@@ -23,9 +17,7 @@ describe('@acusti/date-picker', () => {
23
17
  expect(getMonthFromDate(date, true)).toBe(0);
24
18
  // if test is run in a timezone behind UTC, ommitting asUTC returns -1
25
19
  // if not, the month should be the same with or without asUTC flag
26
- expect(getMonthFromDate(date)).toBe(
27
- date.getTimezoneOffset() >= 60 ? -1 : 0,
28
- );
20
+ expect(getMonthFromDate(date)).toBe(date.getTimezoneOffset() >= 60 ? -1 : 0);
29
21
  });
30
22
  it('returns NaN for an Invalid Date', () => {
31
23
  expect(getMonthFromDate(INVALID_DATE)).toBe(NaN);
@@ -33,20 +25,12 @@ describe('@acusti/date-picker', () => {
33
25
  });
34
26
  describe('getYearFromMonth', () => {
35
27
  it('returns the correct year for a post-unix epoch date', () => {
36
- expect(getYearFromMonth(getMonthFromDate(new Date(1970, 0, 1)))).toBe(
37
- 1970,
38
- );
39
- expect(getYearFromMonth(getMonthFromDate(new Date(2048, 4, 31)))).toBe(
40
- 2048,
41
- );
28
+ expect(getYearFromMonth(getMonthFromDate(new Date(1970, 0, 1)))).toBe(1970);
29
+ expect(getYearFromMonth(getMonthFromDate(new Date(2048, 4, 31)))).toBe(2048);
42
30
  });
43
31
  it('returns the correct year digit for a pre-unix epoch date', () => {
44
- expect(getYearFromMonth(getMonthFromDate(new Date(1970, 0, 0)))).toBe(
45
- 1969,
46
- );
47
- expect(getYearFromMonth(getMonthFromDate(new Date(100, 11, 31)))).toBe(
48
- 100,
49
- );
32
+ expect(getYearFromMonth(getMonthFromDate(new Date(1970, 0, 0)))).toBe(1969);
33
+ expect(getYearFromMonth(getMonthFromDate(new Date(100, 11, 31)))).toBe(100);
50
34
  });
51
35
  it('returns NaN for an Invalid Date', () => {
52
36
  expect(getYearFromMonth(getMonthFromDate(INVALID_DATE))).toBe(NaN);
@@ -54,14 +38,10 @@ describe('@acusti/date-picker', () => {
54
38
  });
55
39
  describe('getMonthNameFromMonth', () => {
56
40
  it('returns the correct month name for a post-unix epoch month', () => {
57
- expect(
58
- getMonthNameFromMonth(getMonthFromDate(new Date(2023, 5, 19))),
59
- ).toBe('June');
41
+ expect(getMonthNameFromMonth(getMonthFromDate(new Date(2023, 5, 19)))).toBe('June');
60
42
  });
61
43
  it('returns the correct month name for a pre-unix epoch month', () => {
62
- expect(
63
- getMonthNameFromMonth(getMonthFromDate(new Date(1865, 5, 2))),
64
- ).toBe('June');
44
+ expect(getMonthNameFromMonth(getMonthFromDate(new Date(1865, 5, 2)))).toBe('June');
65
45
  });
66
46
  it('returns an empty string if given NaN (e.g. if dealing with an Invalid Date)', () => {
67
47
  expect(getMonthNameFromMonth(getMonthFromDate(INVALID_DATE))).toBe('');
@@ -69,76 +49,40 @@ describe('@acusti/date-picker', () => {
69
49
  });
70
50
  describe('getDateFromMonthAndDay', () => {
71
51
  it('returns the date of the specified day for a post-unix epoch month', () => {
72
- expect(
73
- getDateFromMonthAndDay(getMonthFromDate(new Date(2008, 2, 13)), 1),
74
- ).toEqual(new Date(2008, 2, 1));
75
- expect(
76
- getDateFromMonthAndDay(getMonthFromDate(new Date(1999, 11, 1)), 31),
77
- ).toEqual(new Date(1999, 11, 31));
78
- expect(
79
- getDateFromMonthAndDay(getMonthFromDate(new Date(2000, 0, 0)), 31),
80
- ).toEqual(new Date(1999, 11, 31));
52
+ expect(getDateFromMonthAndDay(getMonthFromDate(new Date(2008, 2, 13)), 1)).toEqual(new Date(2008, 2, 1));
53
+ expect(getDateFromMonthAndDay(getMonthFromDate(new Date(1999, 11, 1)), 31)).toEqual(new Date(1999, 11, 31));
54
+ expect(getDateFromMonthAndDay(getMonthFromDate(new Date(2000, 0, 0)), 31)).toEqual(new Date(1999, 11, 31));
81
55
  });
82
56
  it('returns the correct date for a pre-unix epoch month', () => {
83
- expect(
84
- getDateFromMonthAndDay(getMonthFromDate(new Date(1865, 5, 2)), 30),
85
- ).toEqual(new Date(1865, 5, 30));
86
- expect(
87
- getDateFromMonthAndDay(getMonthFromDate(new Date(101, 0, 0)), 1),
88
- ).toEqual(new Date(100, 11, 1));
57
+ expect(getDateFromMonthAndDay(getMonthFromDate(new Date(1865, 5, 2)), 30)).toEqual(new Date(1865, 5, 30));
58
+ expect(getDateFromMonthAndDay(getMonthFromDate(new Date(101, 0, 0)), 1)).toEqual(new Date(100, 11, 1));
89
59
  });
90
60
  it('returns date for start of day as UTC time if asUTC is true', () => {
91
- expect(
92
- getDateFromMonthAndDay(
93
- getMonthFromDate(new Date(1865, 5, 2)),
94
- 30,
95
- true,
96
- ),
97
- ).toEqual(new Date(Date.UTC(1865, 5, 30)));
98
- expect(
99
- getDateFromMonthAndDay(
100
- getMonthFromDate(new Date(101, 0, 0)),
101
- 1,
102
- true,
103
- ),
104
- ).toEqual(new Date(Date.UTC(100, 11, 1)));
61
+ expect(getDateFromMonthAndDay(getMonthFromDate(new Date(1865, 5, 2)), 30, true)).toEqual(new Date(Date.UTC(1865, 5, 30)));
62
+ expect(getDateFromMonthAndDay(getMonthFromDate(new Date(101, 0, 0)), 1, true)).toEqual(new Date(Date.UTC(100, 11, 1)));
105
63
  });
106
64
  it('returns an invalid date if given NaN (e.g. if dealing with an Invalid Date)', () => {
107
- expect(getDateFromMonthAndDay(getMonthFromDate(INVALID_DATE), 1)).toEqual(
108
- INVALID_DATE,
109
- );
65
+ expect(getDateFromMonthAndDay(getMonthFromDate(INVALID_DATE), 1)).toEqual(INVALID_DATE);
110
66
  });
111
67
  });
112
68
  describe('getLastDateFromMonth', () => {
113
69
  it('returns the date of the last day for a post-unix epoch month', () => {
114
- expect(
115
- getLastDateFromMonth(getMonthFromDate(new Date(2008, 2, 13))),
116
- ).toEqual(new Date(2008, 2, 31));
70
+ expect(getLastDateFromMonth(getMonthFromDate(new Date(2008, 2, 13)))).toEqual(new Date(2008, 2, 31));
117
71
  // february in a leap year
118
- expect(
119
- getLastDateFromMonth(getMonthFromDate(new Date(2024, 1, 23))),
120
- ).toEqual(new Date(2024, 1, 29));
72
+ expect(getLastDateFromMonth(getMonthFromDate(new Date(2024, 1, 23)))).toEqual(new Date(2024, 1, 29));
121
73
  // february in a non-leap year
122
- expect(
123
- getLastDateFromMonth(getMonthFromDate(new Date(1985, 1, 1))),
124
- ).toEqual(new Date(1985, 1, 28));
74
+ expect(getLastDateFromMonth(getMonthFromDate(new Date(1985, 1, 1)))).toEqual(new Date(1985, 1, 28));
125
75
  });
126
76
  it('returns the correct date for a pre-unix epoch month', () => {
127
- expect(
128
- getLastDateFromMonth(getMonthFromDate(new Date(1865, 5, 2))),
129
- ).toEqual(new Date(1865, 5, 30));
77
+ expect(getLastDateFromMonth(getMonthFromDate(new Date(1865, 5, 2)))).toEqual(new Date(1865, 5, 30));
130
78
  });
131
79
  it('returns date for start of day as UTC time if asUTC is true', () => {
132
- expect(
133
- getLastDateFromMonth(getMonthFromDate(new Date(1865, 5, 2)), true),
134
- ).toEqual(new Date(Date.UTC(1865, 5, 30)));
80
+ expect(getLastDateFromMonth(getMonthFromDate(new Date(1865, 5, 2)), true)).toEqual(new Date(Date.UTC(1865, 5, 30)));
135
81
  });
136
82
  it('returns an invalid date if given NaN (e.g. if dealing with an Invalid Date)', () => {
137
- expect(getLastDateFromMonth(getMonthFromDate(INVALID_DATE))).toEqual(
138
- INVALID_DATE,
139
- );
83
+ expect(getLastDateFromMonth(getMonthFromDate(INVALID_DATE))).toEqual(INVALID_DATE);
140
84
  });
141
85
  });
142
86
  });
143
87
  });
144
- //# sourceMappingURL=utils.test.js.map
88
+ //# sourceMappingURL=utils.test.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acusti/date-picker",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": "./dist/index.js",
@@ -45,15 +45,15 @@
45
45
  "@testing-library/dom": "^10.4.0",
46
46
  "@testing-library/react": "^16.1.0",
47
47
  "@testing-library/user-event": "^14.5.2",
48
- "@types/react": "^19.0.2",
49
- "happy-dom": "^15.11.7",
48
+ "@types/react": "^19.0.7",
49
+ "happy-dom": "^17.4.4",
50
50
  "react": "^19.0.0",
51
51
  "react-dom": "^19.0.0",
52
52
  "typescript": "5.7.3",
53
- "vitest": "^2.1.8"
53
+ "vitest": "^3"
54
54
  },
55
55
  "dependencies": {
56
- "@acusti/styling": "^1.0.1",
56
+ "@acusti/styling": "^0.7.2 || ^1.0.1",
57
57
  "clsx": "^2"
58
58
  },
59
59
  "peerDependencies": {