@lazerlen/legend-calendar 1.4.1 → 1.5.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.
@@ -9,12 +9,12 @@
9
9
  CJS Build start
10
10
  ESM Build start
11
11
  DTS Build start
12
- CJS dist/index.js 75.71 KB
13
- CJS dist/index.js.map 144.96 KB
14
- CJS ⚡️ Build success in 1386ms
15
- ESM dist/index.mjs 72.61 KB
16
- ESM dist/index.mjs.map 144.42 KB
17
- ESM ⚡️ Build success in 1386ms
18
- DTS ⚡️ Build success in 1389ms
19
- DTS dist/index.d.ts 24.86 KB
20
- DTS dist/index.d.mts 24.86 KB
12
+ ESM dist/index.mjs 83.12 KB
13
+ ESM dist/index.mjs.map 158.68 KB
14
+ ESM ⚡️ Build success in 1304ms
15
+ CJS dist/index.js 86.17 KB
16
+ CJS dist/index.js.map 159.21 KB
17
+ CJS ⚡️ Build success in 1306ms
18
+ DTS ⚡️ Build success in 1368ms
19
+ DTS dist/index.d.ts 27.19 KB
20
+ DTS dist/index.d.mts 27.19 KB
@@ -5,213 +5,213 @@
5
5
  src/hooks/useDateRange.test.ts:
6
6
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
7
7
  The current testing environment is not configured to support act(...)
8
- ✓ useDateRange > should initialize with correct default values [7.17ms]
8
+ ✓ useDateRange > should initialize with correct default values [4.30ms]
9
9
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
10
10
  The current testing environment is not configured to support act(...)
11
11
  The current testing environment is not configured to support act(...)
12
12
  The current testing environment is not configured to support act(...)
13
13
  The current testing environment is not configured to support act(...)
14
14
  The current testing environment is not configured to support act(...)
15
- ✓ useDateRange > should update dateRange correctly on onCalendarDayPress [2.30ms]
15
+ ✓ useDateRange > should update dateRange correctly on onCalendarDayPress [0.60ms]
16
16
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
17
17
  The current testing environment is not configured to support act(...)
18
18
  The current testing environment is not configured to support act(...)
19
19
  The current testing environment is not configured to support act(...)
20
20
  The current testing environment is not configured to support act(...)
21
- ✓ useDateRange > should clear dateRange on onClearDateRange [1.38ms]
21
+ ✓ useDateRange > should clear dateRange on onClearDateRange [0.26ms]
22
22
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
23
23
  The current testing environment is not configured to support act(...)
24
24
  The current testing environment is not configured to support act(...)
25
25
  The current testing environment is not configured to support act(...)
26
26
  The current testing environment is not configured to support act(...)
27
- ✓ useDateRange > should update isDateRangeValid correctly [0.31ms]
27
+ ✓ useDateRange > should update isDateRangeValid correctly [0.42ms]
28
28
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
29
29
  The current testing environment is not configured to support act(...)
30
- ✓ useDateRange > can initialize a date range [0.19ms]
30
+ ✓ useDateRange > can initialize a date range [0.11ms]
31
31
  
32
32
  src/hooks/useCalendarList.test.ts:
33
- ✓ getHeightForMonth > Measures months with 5 weeks (no calendar spacing) [0.04ms]
34
- ✓ getHeightForMonth > Measures months with 5 weeks (with calendar spacing) [0.01ms]
33
+ ✓ getHeightForMonth > Measures months with 5 weeks (no calendar spacing) [0.21ms]
34
+ ✓ getHeightForMonth > Measures months with 5 weeks (with calendar spacing)
35
35
  ✓ getHeightForMonth > Accounts for additional height
36
- ✓ getHeightForMonth > Measures months with 6 weeks
37
- ✓ getHeightForMonth > February 24 has the right height with base options [0.39ms]
36
+ ✓ getHeightForMonth > Measures months with 6 weeks [0.01ms]
37
+ ✓ getHeightForMonth > February 24 has the right height with base options [0.37ms]
38
38
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
39
39
  The current testing environment is not configured to support act(...)
40
40
  The current testing environment is not configured to support act(...)
41
41
  The current testing environment is not configured to support act(...)
42
- ✓ useCalendarList > Min/Max dates > Max: virtualization still works as expected [1.86ms]
42
+ ✓ useCalendarList > Min/Max dates > Max: virtualization still works as expected [0.64ms]
43
43
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
44
44
  The current testing environment is not configured to support act(...)
45
45
  The current testing environment is not configured to support act(...)
46
46
  The current testing environment is not configured to support act(...)
47
- ✓ useCalendarList > Min/Max dates > Min: virtualization still works as expected [0.79ms]
47
+ ✓ useCalendarList > Min/Max dates > Min: virtualization still works as expected [0.43ms]
48
48
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
49
49
  The current testing environment is not configured to support act(...)
50
- ✓ useCalendarList > Min/Max dates > Returns a single month when min and max are in the same month [0.17ms]
50
+ ✓ useCalendarList > Min/Max dates > Returns a single month when min and max are in the same month [0.09ms]
51
51
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
52
52
  The current testing environment is not configured to support act(...)
53
- ✓ useCalendarList > Min/Max dates > Returns a range of months bounded by the min and max dates [0.26ms]
53
+ ✓ useCalendarList > Min/Max dates > Returns a range of months bounded by the min and max dates [0.28ms]
54
54
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
55
55
  The current testing environment is not configured to support act(...)
56
- ✓ useCalendarList > Min/Max dates > Ignores past/future scroll ranges when min/max dates are used [0.11ms]
56
+ ✓ useCalendarList > Min/Max dates > Ignores past/future scroll ranges when min/max dates are used [0.22ms]
57
57
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
58
58
  The current testing environment is not configured to support act(...)
59
- ✓ useCalendarList > Min/Max dates > Append/Prepend are no-op if min/max are reached [0.14ms]
59
+ ✓ useCalendarList > Min/Max dates > Append/Prepend are no-op if min/max are reached [0.19ms]
60
60
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
61
61
  The current testing environment is not configured to support act(...)
62
62
  The current testing environment is not configured to support act(...)
63
63
  The current testing environment is not configured to support act(...)
64
- ✓ useCalendarList > Min/Max dates > Prepend does not trigger a state update when starting month is already present [0.47ms]
64
+ ✓ useCalendarList > Min/Max dates > Prepend does not trigger a state update when starting month is already present [0.19ms]
65
65
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
66
66
  The current testing environment is not configured to support act(...)
67
- ✓ useCalendarList > github issues > #16: Incorrect scroll position when setting calendarMinDateId [0.17ms]
67
+ ✓ useCalendarList > github issues > #16: Incorrect scroll position when setting calendarMinDateId [0.14ms]
68
68
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
69
69
  The current testing environment is not configured to support act(...)
70
- ✓ useCalendarList > Data is correctly built when future/past ranges are 0 [0.08ms]
70
+ ✓ useCalendarList > Data is correctly built when future/past ranges are 0 [0.05ms]
71
71
  
72
72
  src/hooks/useCalendar.test.ts:
73
- ✓ buildCalendar > isLastDayOfWeek > isLastDayOfWeek respects "sunday" as last day of week [9.75ms]
74
- ✓ buildCalendar > isLastDayOfWeek > isLastDayOfWeek respects "monday" as last day of week [1.26ms]
75
- ✓ buildCalendar > isWeekend > starting on sunday [1.36ms]
76
- ✓ buildCalendar > isWeekend > starting on monday [1.20ms]
77
- ✓ buildCalendar > state > active: supersedes today [1.35ms]
78
- ✓ buildCalendar > state > active: supersedes disabled (with calendarDisabledDateIds) [1.54ms]
79
- ✓ buildCalendar > state > active: supersedes disabled (with min) [1.21ms]
80
- ✓ buildCalendar > state > active: supersedes disabled (with max) [1.11ms]
81
- ✓ buildCalendar > state > active: supersedes idle [1.21ms]
82
- ✓ buildCalendar > state > disabled: supersedes idle [1.17ms]
83
- ✓ buildCalendar > state > today: supersedes idle [1.28ms]
84
- ✓ buildCalendar > state > idle: serves as the base state [1.30ms]
85
- ✓ buildCalendar > builds the month row [1.10ms]
86
- ✓ buildCalendar > build the month row with custom formatting [2.66ms]
87
- ✓ buildCalendar > builds the week days row starting on sunday [1.21ms]
88
- ✓ buildCalendar > builds the week days row starting on monday [1.20ms]
89
- ✓ buildCalendar > builds the weeks row [2.25ms]
90
- ✓ buildCalendar > build the weeks row with custom formatting [1.31ms]
91
- ✓ buildCalendar > handles the expected range [1.20ms]
92
- ✓ buildCalendar > calendarMinDate [1.24ms]
93
- ✓ buildCalendar > calendarMaxDate [1.43ms]
73
+ ✓ buildCalendar > isLastDayOfWeek > isLastDayOfWeek respects "sunday" as last day of week [8.56ms]
74
+ ✓ buildCalendar > isLastDayOfWeek > isLastDayOfWeek respects "monday" as last day of week [1.89ms]
75
+ ✓ buildCalendar > isWeekend > starting on sunday [1.22ms]
76
+ ✓ buildCalendar > isWeekend > starting on monday [2.17ms]
77
+ ✓ buildCalendar > state > active: supersedes today [2.89ms]
78
+ ✓ buildCalendar > state > active: supersedes disabled (with calendarDisabledDateIds) [1.37ms]
79
+ ✓ buildCalendar > state > active: supersedes disabled (with min) [1.16ms]
80
+ ✓ buildCalendar > state > active: supersedes disabled (with max) [0.86ms]
81
+ ✓ buildCalendar > state > active: supersedes idle [2.39ms]
82
+ ✓ buildCalendar > state > disabled: supersedes idle [1.70ms]
83
+ ✓ buildCalendar > state > today: supersedes idle [2.19ms]
84
+ ✓ buildCalendar > state > idle: serves as the base state [1.28ms]
85
+ ✓ buildCalendar > builds the month row [1.48ms]
86
+ ✓ buildCalendar > build the month row with custom formatting [2.44ms]
87
+ ✓ buildCalendar > builds the week days row starting on sunday [2.16ms]
88
+ ✓ buildCalendar > builds the week days row starting on monday [1.58ms]
89
+ ✓ buildCalendar > builds the weeks row [1.63ms]
90
+ ✓ buildCalendar > build the weeks row with custom formatting [0.85ms]
91
+ ✓ buildCalendar > handles the expected range [1.57ms]
92
+ ✓ buildCalendar > calendarMinDate [1.31ms]
93
+ ✓ buildCalendar > calendarMaxDate [2.69ms]
94
94
  
95
95
  src/hooks/useOptimizedDayMetadata.test.ts:
96
96
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
97
97
  The current testing environment is not configured to support act(...)
98
- ✓ useOptimizedDayMetadata > return the base metadata as the initial value [0.93ms]
98
+ ✓ useOptimizedDayMetadata > return the base metadata as the initial value [1.70ms]
99
99
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
100
100
  The current testing environment is not configured to support act(...)
101
101
  The current testing environment is not configured to support act(...)
102
- ✓ useOptimizedDayMetadata > if the base changes, the returned value should match it. [0.41ms]
102
+ ✓ useOptimizedDayMetadata > if the base changes, the returned value should match it. [0.52ms]
103
103
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
104
104
  The current testing environment is not configured to support act(...)
105
105
  The current testing environment is not configured to support act(...)
106
- ✓ useOptimizedDayMetadata > endOfRange: returns the updated metadata once an event is emitted [0.50ms]
106
+ ✓ useOptimizedDayMetadata > endOfRange: returns the updated metadata once an event is emitted [0.61ms]
107
107
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
108
108
  The current testing environment is not configured to support act(...)
109
109
  The current testing environment is not configured to support act(...)
110
- ✓ useOptimizedDayMetadata > startOfRange: returns the updated metadata once an event is emitted [0.19ms]
110
+ ✓ useOptimizedDayMetadata > startOfRange: returns the updated metadata once an event is emitted [0.62ms]
111
111
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
112
112
  The current testing environment is not configured to support act(...)
113
113
  The current testing environment is not configured to support act(...)
114
- ✓ useOptimizedDayMetadata > startOfRange|endOfRange: returns the updated metadata once an event is emitted [0.13ms]
114
+ ✓ useOptimizedDayMetadata > startOfRange|endOfRange: returns the updated metadata once an event is emitted [0.67ms]
115
115
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
116
116
  The current testing environment is not configured to support act(...)
117
117
  The current testing environment is not configured to support act(...)
118
- ✓ useOptimizedDayMetadata > doesn't re-render if the active dates don't overlap [0.15ms]
118
+ ✓ useOptimizedDayMetadata > doesn't re-render if the active dates don't overlap [0.75ms]
119
119
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
120
120
  The current testing environment is not configured to support act(...)
121
121
  The current testing environment is not configured to support act(...)
122
122
  The current testing environment is not configured to support act(...)
123
- ✓ useOptimizedDayMetadata > resets the state once a new range is selected [0.14ms]
123
+ ✓ useOptimizedDayMetadata > resets the state once a new range is selected [0.45ms]
124
124
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
125
125
  The current testing environment is not configured to support act(...)
126
126
  The current testing environment is not configured to support act(...)
127
- ✓ useOptimizedDayMetadata with calendarInstanceId > uses the default instance ID when not provided [0.11ms]
127
+ ✓ useOptimizedDayMetadata with calendarInstanceId > uses the default instance ID when not provided [0.15ms]
128
128
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
129
129
  The current testing environment is not configured to support act(...)
130
130
  The current testing environment is not configured to support act(...)
131
- ✓ useOptimizedDayMetadata with calendarInstanceId > responds to events for the correct instance ID [0.09ms]
131
+ ✓ useOptimizedDayMetadata with calendarInstanceId > responds to events for the correct instance ID [0.11ms]
132
132
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
133
133
  The current testing environment is not configured to support act(...)
134
- ✓ useOptimizedDayMetadata with calendarInstanceId > ignores events for different instance IDs [0.04ms]
134
+ ✓ useOptimizedDayMetadata with calendarInstanceId > ignores events for different instance IDs [0.06ms]
135
135
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
136
136
  The current testing environment is not configured to support act(...)
137
137
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
138
138
  The current testing environment is not configured to support act(...)
139
139
  The current testing environment is not configured to support act(...)
140
140
  The current testing environment is not configured to support act(...)
141
- ✓ useOptimizedDayMetadata with calendarInstanceId > handles multiple instances correctly [0.19ms]
141
+ ✓ useOptimizedDayMetadata with calendarInstanceId > handles multiple instances correctly [0.04ms]
142
142
  react-test-renderer is deprecated. See https://react.dev/warnings/react-test-renderer
143
143
  The current testing environment is not configured to support act(...)
144
144
  The current testing environment is not configured to support act(...)
145
145
  The current testing environment is not configured to support act(...)
146
- ✓ useOptimizedDayMetadata with calendarInstanceId > resets state for the correct instance when a new range is selected [0.09ms]
146
+ ✓ useOptimizedDayMetadata with calendarInstanceId > resets state for the correct instance when a new range is selected [0.24ms]
147
147
  
148
148
  src/helpers/dates.test.ts:
149
- ✓ toDateId: UTC time zone > January 1st, 2024
149
+ ✓ toDateId: UTC time zone > January 1st, 2024 [0.05ms]
150
150
  ✓ toDateId: UTC time zone > January 31th, 2024
151
- ✓ toDateId: UTC time zone > February 1st, 2024
152
- ✓ toDateId: UTC time zone > February 10th, 2024 [0.20ms]
153
- ✓ toDateId: UTC time zone > convert between ID -> Date -> ID returns the original result [0.01ms]
154
- ✓ toDateId: Brasilia time zone  > January 1st, 2024 [0.02ms]
155
- ✓ toDateId: Brasilia time zone  > January 31th, 2024 [0.04ms]
156
- ✓ toDateId: Brasilia time zone  > February 1st, 2024 [0.06ms]
157
- ✓ toDateId: Brasilia time zone  > February 10th, 2024
158
- ✓ toDateId: Brasilia time zone  > February 29th, 2024 [0.05ms]
159
- ✓ toDateId: Brasilia time zone  > convert between ID -> Date -> ID returns the original result [0.03ms]
160
- ✓ fromDateId: UTC time zone > parse Jan 1st [0.02ms]
161
- ✓ fromDateId: UTC time zone > parses March 1st
162
- ✓ fromDateId: Brasilia time zone > parse Jan 1st [0.02ms]
151
+ ✓ toDateId: UTC time zone > February 1st, 2024 [0.05ms]
152
+ ✓ toDateId: UTC time zone > February 10th, 2024
153
+ ✓ toDateId: UTC time zone > convert between ID -> Date -> ID returns the original result [0.02ms]
154
+ ✓ toDateId: Brasilia time zone  > January 1st, 2024
155
+ ✓ toDateId: Brasilia time zone  > January 31th, 2024 [0.07ms]
156
+ ✓ toDateId: Brasilia time zone  > February 1st, 2024 [0.04ms]
157
+ ✓ toDateId: Brasilia time zone  > February 10th, 2024 [0.07ms]
158
+ ✓ toDateId: Brasilia time zone  > February 29th, 2024 [0.06ms]
159
+ ✓ toDateId: Brasilia time zone  > convert between ID -> Date -> ID returns the original result [0.04ms]
160
+ ✓ fromDateId: UTC time zone > parse Jan 1st [0.06ms]
161
+ ✓ fromDateId: UTC time zone > parses March 1st [0.03ms]
162
+ ✓ fromDateId: Brasilia time zone > parse Jan 1st
163
163
  ✓ fromDateId: Brasilia time zone > parses March 1st
164
- ✓ startOfMonth > January [0.01ms]
164
+ ✓ startOfMonth > January [0.02ms]
165
165
  ✓ startOfMonth > February
166
- ✓ startOfMonth > matches date-fns [1.68ms]
167
- ✓ endOfMonth > January [0.03ms]
168
- ✓ endOfMonth > February
169
- ✓ endOfMonth > matches date-fns [1.19ms]
170
- ✓ startOfWeek > sunday: week of February 17th [0.03ms]
171
- ✓ startOfWeek > sunday: week of February 11th [0.02ms]
172
- ✓ startOfWeek > monday: week of February 17th [0.01ms]
166
+ ✓ startOfMonth > matches date-fns [1.02ms]
167
+ ✓ endOfMonth > January [0.12ms]
168
+ ✓ endOfMonth > February [0.02ms]
169
+ ✓ endOfMonth > matches date-fns [1.98ms]
170
+ ✓ startOfWeek > sunday: week of February 17th [0.10ms]
171
+ ✓ startOfWeek > sunday: week of February 11th [0.03ms]
172
+ ✓ startOfWeek > monday: week of February 17th [0.05ms]
173
173
  ✓ startOfWeek > monday: week of February 11th [0.01ms]
174
- ✓ startOfWeek > matches date-fns [1.25ms]
175
- ✓ addMonths > add 1 month [0.10ms]
176
- ✓ addMonths > add 10 months [0.01ms]
177
- ✓ addMonths > matches date-fns [0.42ms]
178
- ✓ subMonths > sub 1 month [0.11ms]
179
- ✓ subMonths > sub 10 months [0.04ms]
180
- ✓ subMonths > matches date-fns [0.22ms]
181
- ✓ addDays > add 1 day [0.05ms]
174
+ ✓ startOfWeek > matches date-fns [1.82ms]
175
+ ✓ addMonths > add 1 month [0.04ms]
176
+ ✓ addMonths > add 10 months [0.04ms]
177
+ ✓ addMonths > matches date-fns [0.21ms]
178
+ ✓ subMonths > sub 1 month [0.02ms]
179
+ ✓ subMonths > sub 10 months [0.05ms]
180
+ ✓ subMonths > matches date-fns [0.28ms]
181
+ ✓ addDays > add 1 day
182
182
  ✓ addDays > add 10 days
183
- ✓ addDays > matches date-fns [0.11ms]
184
- ✓ subDays > sub 1 day
183
+ ✓ addDays > matches date-fns [0.19ms]
184
+ ✓ subDays > sub 1 day [0.09ms]
185
185
  ✓ subDays > sub 10 days
186
- ✓ subDays > matches date-fns [0.16ms]
187
- ✓ isWeekend > Friday [0.02ms]
188
- ✓ isWeekend > Saturday
189
- ✓ isWeekend > Sunday
186
+ ✓ subDays > matches date-fns [0.12ms]
187
+ ✓ isWeekend > Friday
188
+ ✓ isWeekend > Saturday [0.08ms]
189
+ ✓ isWeekend > Sunday [0.02ms]
190
190
  ✓ isWeekend > Monday
191
- ✓ differenceInMonths  > edge cases > it returns diff of 1 month between Feb 28 2021 and Jan 30 2021 [0.01ms]
192
- ✓ differenceInMonths  > edge cases > it returns diff of 1 month between Feb 28 2021 and Jan 31 2021 [0.01ms]
191
+ ✓ differenceInMonths  > edge cases > it returns diff of 1 month between Feb 28 2021 and Jan 30 2021
192
+ ✓ differenceInMonths  > edge cases > it returns diff of 1 month between Feb 28 2021 and Jan 31 2021
193
193
  ✓ differenceInMonths  > edge cases > it returns diff of 1 month between Nov, 30 2021 and Oct, 31 2021
194
194
  ✓ differenceInMonths  > edge cases > it returns diff of 1 month between Oct, 31 2021 and Sep, 30 2021
195
195
  ✓ differenceInMonths  > edge cases > it returns diff of 6 month between Oct, 31 2021 and Apr, 30 2021
196
- ✓ differenceInMonths  > edge cases > it returns diff of -1 month between Sep, 30 2021 and Oct, 31 2021 [0.01ms]
197
- ✓ differenceInMonths  > edge cases > the days of months of the given dates are the same [0.01ms]
198
- ✓ differenceInMonths  > edge cases > the given dates are the same [0.01ms]
199
- ✓ differenceInMonths  > edge cases > does not return -0 when the given dates are the same [0.02ms]
200
- ✓ differenceInMonths  > edge cases > returns the number of full months between the given dates - end of Feb [0.02ms]
201
- ✓ differenceInMonths  > returns the number of full months between the given dates
202
- ✓ differenceInMonths  > returns a negative number if the time value of the first date is smaller
203
- ✓ differenceInMonths  > returns NaN if the first date is `Invalid Date` [0.16ms]
204
- ✓ differenceInMonths  > returns NaN if the second date is `Invalid Date`
205
- ✓ differenceInMonths  > returns NaN if the both dates are `Invalid Date`
206
- ✓ getWeeksInMonth > sunday: Month with 5 weeks [0.06ms]
207
- ✓ getWeeksInMonth > sunday: Month with 6 weeks [0.03ms]
208
- ✓ getWeeksInMonth > monday: Month with 5 weeks [0.05ms]
209
- ✓ getWeeksInMonth > matches date-fns [3.12ms]
210
- ✓ getWeekOfMonth > sunday: June [0.20ms]
211
- ✓ getWeekOfMonth > monday: June [0.02ms]
212
- ✓ getWeekOfMonth > matches date-fns [0.83ms]
196
+ ✓ differenceInMonths  > edge cases > it returns diff of -1 month between Sep, 30 2021 and Oct, 31 2021
197
+ ✓ differenceInMonths  > edge cases > the days of months of the given dates are the same
198
+ ✓ differenceInMonths  > edge cases > the given dates are the same
199
+ ✓ differenceInMonths  > edge cases > does not return -0 when the given dates are the same
200
+ ✓ differenceInMonths  > edge cases > returns the number of full months between the given dates - end of Feb [0.10ms]
201
+ ✓ differenceInMonths  > returns the number of full months between the given dates [0.01ms]
202
+ ✓ differenceInMonths  > returns a negative number if the time value of the first date is smaller [0.02ms]
203
+ ✓ differenceInMonths  > returns NaN if the first date is `Invalid Date` [0.02ms]
204
+ ✓ differenceInMonths  > returns NaN if the second date is `Invalid Date` [0.02ms]
205
+ ✓ differenceInMonths  > returns NaN if the both dates are `Invalid Date` [0.02ms]
206
+ ✓ getWeeksInMonth > sunday: Month with 5 weeks [0.03ms]
207
+ ✓ getWeeksInMonth > sunday: Month with 6 weeks
208
+ ✓ getWeeksInMonth > monday: Month with 5 weeks
209
+ ✓ getWeeksInMonth > matches date-fns [3.41ms]
210
+ ✓ getWeekOfMonth > sunday: June [0.15ms]
211
+ ✓ getWeekOfMonth > monday: June [0.03ms]
212
+ ✓ getWeekOfMonth > matches date-fns [0.98ms]
213
213
 
214
214
   116 pass
215
215
   0 fail
216
216
  8696 expect() calls
217
- Ran 116 tests across 5 files. [195.00ms]
217
+ Ran 116 tests across 5 files. [140.00ms]
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import { TextProps, ViewStyle, TextStyle, PressableProps, ColorSchemeName } from 'react-native';
4
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TextProps, ViewStyle, TextStyle, PressableProps, ColorSchemeName } from 'react-native';
3
+ import { ReactNode } from 'react';
5
4
  import { LegendListProps } from '@legendapp/list/react-native';
6
5
 
7
6
  type CalendarTextProps = Omit<TextProps, "onPress" | "onLongPress" | "onPressIn" | "onPressOut">;
@@ -158,7 +157,7 @@ interface CalendarItemDayProps {
158
157
  * `CalendarItemDayWithContainer`, since it also includes the spacing between
159
158
  * each day.
160
159
  */
161
- declare const CalendarItemDay: react.NamedExoticComponent<CalendarItemDayProps>;
160
+ declare const CalendarItemDay: ({ onPress, children, theme, height, metadata, textProps, CalendarPressableComponent, }: CalendarItemDayProps) => react_jsx_runtime.JSX.Element;
162
161
  interface CalendarItemDayContainerTheme {
163
162
  /** An empty view that acts as a spacer between each day. The spacing is
164
163
  * controlled by the `daySpacing` prop. */
@@ -189,7 +188,7 @@ interface CalendarItemDayContainerProps {
189
188
  /** The metadata for the day, extracted from the calendar's state. */
190
189
  metadata?: CalendarDayMetadata;
191
190
  }
192
- declare const CalendarItemDayContainer: react.NamedExoticComponent<CalendarItemDayContainerProps>;
191
+ declare const CalendarItemDayContainer: ({ children, isStartOfWeek, shouldShowActiveDayFiller, theme, daySpacing, dayHeight, metadata, }: CalendarItemDayContainerProps) => react_jsx_runtime.JSX.Element;
193
192
  interface CalendarItemDayWithContainerProps extends Omit<CalendarItemDayProps, "height">, Pick<CalendarItemDayContainerProps, "daySpacing" | "dayHeight"> {
194
193
  containerTheme?: CalendarItemDayContainerTheme;
195
194
  /**
@@ -205,7 +204,7 @@ interface CalendarItemDayWithContainerProps extends Omit<CalendarItemDayProps, "
205
204
  */
206
205
  calendarInstanceId?: string;
207
206
  }
208
- declare const CalendarItemDayWithContainer: react.NamedExoticComponent<CalendarItemDayWithContainerProps>;
207
+ declare const CalendarItemDayWithContainer: ({ children, metadata: baseMetadata, onPress, theme, dayHeight, daySpacing, containerTheme, calendarInstanceId, CalendarPressableComponent, }: CalendarItemDayWithContainerProps) => react_jsx_runtime.JSX.Element;
209
208
 
210
209
  interface CalendarItemEmptyProps {
211
210
  /** The height of the cell. Should be the same as `CalendarItemDay`. */
@@ -215,7 +214,7 @@ interface CalendarItemEmptyProps {
215
214
  container?: ViewStyle;
216
215
  };
217
216
  }
218
- declare const CalendarItemEmpty: react.NamedExoticComponent<CalendarItemEmptyProps>;
217
+ declare const CalendarItemEmpty: (props: CalendarItemEmptyProps) => react_jsx_runtime.JSX.Element;
219
218
 
220
219
  interface CalendarItemWeekNameTheme {
221
220
  container?: ViewStyle;
@@ -232,7 +231,7 @@ interface CalendarItemWeekNameProps {
232
231
  /** Optional TextProps to spread to the <Text> component. */
233
232
  textProps?: Omit<CalendarTextProps, "children">;
234
233
  }
235
- declare const CalendarItemWeekName: react.NamedExoticComponent<CalendarItemWeekNameProps>;
234
+ declare const CalendarItemWeekName: ({ children, height, theme, textProps, }: CalendarItemWeekNameProps) => react_jsx_runtime.JSX.Element;
236
235
 
237
236
  interface CalendarRowMonthTheme {
238
237
  container?: ViewStyle;
@@ -248,7 +247,7 @@ interface CalendarRowMonthProps {
248
247
  /** The theme of the month row, useful for customizing the component. */
249
248
  theme?: CalendarRowMonthTheme;
250
249
  }
251
- declare const CalendarRowMonth: react.NamedExoticComponent<CalendarRowMonthProps>;
250
+ declare const CalendarRowMonth: ({ children, height, theme, }: CalendarRowMonthProps) => react_jsx_runtime.JSX.Element;
252
251
 
253
252
  /**
254
253
  * Minimal theme for the Legend Calendar component.
@@ -334,7 +333,7 @@ interface CalendarRowWeekProps {
334
333
  interface CalendarRowWeekTheme {
335
334
  container?: ViewStyle;
336
335
  }
337
- declare const CalendarRowWeek: react.NamedExoticComponent<CalendarRowWeekProps>;
336
+ declare const CalendarRowWeek: ({ children, spacing, theme, }: CalendarRowWeekProps) => react_jsx_runtime.JSX.Element;
338
337
 
339
338
  type PressableLike = React.ComponentType<Pick<PressableProps, "children" | "style" | "disabled"> & {
340
339
  onPress: () => void;
@@ -410,7 +409,7 @@ interface CalendarProps extends UseCalendarParams {
410
409
  /** Optional component to replace the default <Pressable> component. */
411
410
  CalendarPressableComponent?: PressableLike;
412
411
  }
413
- declare const Calendar$1: react.NamedExoticComponent<CalendarProps>;
412
+ declare const Calendar$1: (props: CalendarProps) => react_jsx_runtime.JSX.Element;
414
413
 
415
414
  interface CalendarMonth {
416
415
  id: string;
@@ -480,6 +479,29 @@ declare const getHeightForMonth: ({ calendarRowVerticalSpacing: vSpacing, calend
480
479
  * `Calendar` props to simplify building custom `Calendar` components.
481
480
  */
482
481
  type CalendarMonthEnhanced = CalendarMonth & {
482
+ /**
483
+ * The calendar configuration props for this item. Available when using a
484
+ * custom `renderItem` for backwards compatibility.
485
+ *
486
+ * @deprecated Prefer reading calendar config from context via
487
+ * `useCalendarListConfig()` instead of spreading `item.calendarProps`.
488
+ * This avoids creating a new data array each render and lets LegendList
489
+ * skip unnecessary item re-renders.
490
+ *
491
+ * **Before (slower):**
492
+ * ```tsx
493
+ * renderItem={({ item }) => (
494
+ * <MyCalendar calendarMonthId={item.id} {...item.calendarProps} />
495
+ * )}
496
+ * ```
497
+ *
498
+ * **After (faster):**
499
+ * ```tsx
500
+ * // Inside your custom calendar component:
501
+ * const listConfig = useCalendarListConfig();
502
+ * // Merge: { ...listConfig, ...props }
503
+ * ```
504
+ */
483
505
  calendarProps: Omit<CalendarProps, "calendarMonthId">;
484
506
  };
485
507
  interface CalendarListProps extends Omit<CalendarProps, "calendarMonthId">, Omit<LegendListProps<CalendarMonthEnhanced>, "renderItem" | "data" | "children"> {
@@ -540,6 +562,12 @@ interface CalendarListProps extends Omit<CalendarProps, "calendarMonthId">, Omit
540
562
  * - calendarAdditionalHeight
541
563
  * - calendarRowVerticalSpacing
542
564
  * - calendarSpacing
565
+ *
566
+ * **Performance tip**: Using `item.calendarProps` is provided for
567
+ * backwards compatibility but creates a new data array each render.
568
+ * For better performance, have your custom component call
569
+ * `useCalendarListConfig()` to read the shared config from context
570
+ * and only use `item.id` as `calendarMonthId`.
543
571
  */
544
572
  renderItem?: LegendListProps<CalendarMonthEnhanced>["renderItem"];
545
573
  }
@@ -555,7 +583,7 @@ interface CalendarListRef {
555
583
  scrollToDate: (date: Date, animated: boolean, params?: ImperativeScrollParams) => void;
556
584
  scrollToOffset: (offset: number, animated: boolean) => void;
557
585
  }
558
- declare function CalendarList({ ref, ...props }: CalendarListProps & {
586
+ declare function CalendarList(props: CalendarListProps & {
559
587
  ref?: React.Ref<CalendarListRef>;
560
588
  }): react_jsx_runtime.JSX.Element;
561
589
 
@@ -583,6 +611,23 @@ interface VStackProps {
583
611
  }
584
612
  declare function VStack({ children, spacing, alignItems, justifyContent, grow, }: VStackProps): react_jsx_runtime.JSX.Element;
585
613
 
614
+ /**
615
+ * The calendar configuration props shared across all items in a
616
+ * `CalendarList`. When `Calendar` is rendered inside `CalendarList`, it reads
617
+ * these values from context instead of receiving them through the list item's
618
+ * data, which keeps the `data` array identity stable and allows LegendList to
619
+ * skip unnecessary re-renders.
620
+ *
621
+ * When `Calendar` is used standalone (outside a list), the context is `null`
622
+ * and all props are passed directly.
623
+ */
624
+ type CalendarListConfig = Omit<CalendarProps, "calendarMonthId">;
625
+ /**
626
+ * Returns the shared calendar configuration from the nearest
627
+ * `CalendarListConfigProvider`, or `null` when used outside a `CalendarList`.
628
+ */
629
+ declare const useCalendarListConfig: () => CalendarListConfig | null;
630
+
586
631
  /**
587
632
  * This file houses the public API for the legend-calendar package.
588
633
  */
@@ -704,4 +749,4 @@ declare const useDateRange: (initialDateRange?: CalendarActiveDateRange) => {
704
749
  isDateRangeValid: boolean;
705
750
  };
706
751
 
707
- export { Calendar, type CalendarActiveDateRange, type CalendarDayMetadata, type CalendarItemDayContainerProps, type CalendarItemDayProps, type CalendarItemDayWithContainerProps, type CalendarItemEmptyProps, type CalendarItemWeekNameProps, type CalendarListProps, type CalendarListRef, type CalendarMonth, type CalendarMonthEnhanced, type CalendarOnDayPress, type CalendarProps, type CalendarRowMonthProps, type CalendarRowWeekProps, type CalendarTextProps, type CalendarTheme, type HStackProps, type UseCalendarListParams, type UseCalendarParams, type VStackProps, activeDateRangesStore, buildCalendar, fromDateId, getHeightForMonth, toDateId, useCalendar, useCalendarList, useDateRange, useOptimizedDayMetadata };
752
+ export { Calendar, type CalendarActiveDateRange, type CalendarDayMetadata, type CalendarItemDayContainerProps, type CalendarItemDayProps, type CalendarItemDayWithContainerProps, type CalendarItemEmptyProps, type CalendarItemWeekNameProps, type CalendarListConfig, type CalendarListProps, type CalendarListRef, type CalendarMonth, type CalendarMonthEnhanced, type CalendarOnDayPress, type CalendarProps, type CalendarRowMonthProps, type CalendarRowWeekProps, type CalendarTextProps, type CalendarTheme, type HStackProps, type UseCalendarListParams, type UseCalendarParams, type VStackProps, activeDateRangesStore, buildCalendar, fromDateId, getHeightForMonth, toDateId, useCalendar, useCalendarList, useCalendarListConfig, useDateRange, useOptimizedDayMetadata };