@react-stately/calendar 3.0.0-nightly.1460 → 3.0.0-nightly.1474
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/dist/main.js +75 -12
- package/dist/main.js.map +1 -1
- package/dist/module.js +76 -13
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/types.ts +2 -0
- package/src/useCalendarState.ts +13 -7
- package/src/useRangeCalendarState.ts +64 -9
package/dist/main.js
CHANGED
|
@@ -147,7 +147,9 @@ function $6adad0c8536fc209$export$6d095e787d2b5e1f(props) {
|
|
|
147
147
|
setFocusedDate(newFocusedDate);
|
|
148
148
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
149
149
|
}
|
|
150
|
-
if (
|
|
150
|
+
if ($4301262d71f567b9$export$eac50920cf2fd59a(focusedDate, minValue, maxValue)) // If the focused date was moved to an invalid value, it can't be focused, so constrain it.
|
|
151
|
+
setFocusedDate($4301262d71f567b9$export$4f5203c0d889109e(focusedDate, minValue, maxValue));
|
|
152
|
+
else if (focusedDate.compare(startDate) < 0) setStartDate($4301262d71f567b9$export$530edbfc915b2b04(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
151
153
|
else if (focusedDate.compare(startDate.add(visibleDuration)) >= 0) setStartDate($4301262d71f567b9$export$144a00ba6044eb9(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
152
154
|
// Sets focus to a specific cell date
|
|
153
155
|
function focusCell(date) {
|
|
@@ -203,13 +205,13 @@ function $6adad0c8536fc209$export$6d095e787d2b5e1f(props) {
|
|
|
203
205
|
},
|
|
204
206
|
focusNextPage () {
|
|
205
207
|
let start = startDate.add(visibleDuration);
|
|
206
|
-
setStartDate($4301262d71f567b9$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
207
208
|
setFocusedDate($4301262d71f567b9$export$4f5203c0d889109e(focusedDate.add(visibleDuration), minValue, maxValue));
|
|
209
|
+
setStartDate($4301262d71f567b9$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
208
210
|
},
|
|
209
211
|
focusPreviousPage () {
|
|
210
212
|
let start = startDate.subtract(visibleDuration);
|
|
211
|
-
setStartDate($4301262d71f567b9$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
212
213
|
setFocusedDate($4301262d71f567b9$export$4f5203c0d889109e(focusedDate.subtract(visibleDuration), minValue, maxValue));
|
|
214
|
+
setStartDate($4301262d71f567b9$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
213
215
|
},
|
|
214
216
|
focusPageStart () {
|
|
215
217
|
focusCell(startDate);
|
|
@@ -247,21 +249,24 @@ function $6adad0c8536fc209$export$6d095e787d2b5e1f(props) {
|
|
|
247
249
|
return $4301262d71f567b9$export$eac50920cf2fd59a(date, minValue, maxValue);
|
|
248
250
|
},
|
|
249
251
|
isSelected (date) {
|
|
250
|
-
return calendarDateValue != null && $hEzMm$internationalizeddate.isSameDay(date, calendarDateValue) && !this.isCellDisabled(date);
|
|
252
|
+
return calendarDateValue != null && $hEzMm$internationalizeddate.isSameDay(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);
|
|
251
253
|
},
|
|
252
254
|
isCellFocused (date) {
|
|
253
255
|
return isFocused && focusedDate && $hEzMm$internationalizeddate.isSameDay(date, focusedDate);
|
|
254
256
|
},
|
|
255
257
|
isCellDisabled (date) {
|
|
256
|
-
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 ||
|
|
258
|
+
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date, minValue, maxValue);
|
|
259
|
+
},
|
|
260
|
+
isCellUnavailable (date) {
|
|
261
|
+
return props.isDateUnavailable && props.isDateUnavailable(date);
|
|
257
262
|
},
|
|
258
263
|
isPreviousVisibleRangeInvalid () {
|
|
259
|
-
return
|
|
264
|
+
return this.isInvalid(startDate.subtract({
|
|
260
265
|
days: 1
|
|
261
266
|
}), minValue, maxValue);
|
|
262
267
|
},
|
|
263
268
|
isNextVisibleRangeInvalid () {
|
|
264
|
-
return
|
|
269
|
+
return this.isInvalid(endDate.add({
|
|
265
270
|
days: 1
|
|
266
271
|
}), minValue, maxValue);
|
|
267
272
|
}
|
|
@@ -281,8 +286,8 @@ function $e49f7b861e5e8049$export$9a987164d97ecc90(props) {
|
|
|
281
286
|
let { value: valueProp , defaultValue: defaultValue , onChange: onChange , createCalendar: createCalendar , locale: locale , visibleDuration: visibleDuration = {
|
|
282
287
|
months: 1
|
|
283
288
|
} , minValue: minValue , maxValue: maxValue , ...calendarProps } = props;
|
|
284
|
-
let [value, setValue] = $hEzMm$reactstatelyutils.useControlledState(valueProp, defaultValue, onChange);
|
|
285
|
-
let [anchorDate,
|
|
289
|
+
let [value, setValue] = $hEzMm$reactstatelyutils.useControlledState(valueProp, defaultValue || null, onChange);
|
|
290
|
+
let [anchorDate, setAnchorDateState] = $hEzMm$react.useState(null);
|
|
286
291
|
let alignment = 'center';
|
|
287
292
|
if (value && value.start && value.end) {
|
|
288
293
|
let start = $4301262d71f567b9$export$f4a51ff076cc9a09($hEzMm$internationalizeddate.toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);
|
|
@@ -291,16 +296,58 @@ function $e49f7b861e5e8049$export$9a987164d97ecc90(props) {
|
|
|
291
296
|
});
|
|
292
297
|
if (value.end.compare(end) > 0) alignment = 'start';
|
|
293
298
|
}
|
|
299
|
+
// Available range must be stored in a ref so we have access to the updated version immediately in `isInvalid`.
|
|
300
|
+
let availableRangeRef = $hEzMm$react.useRef(null);
|
|
301
|
+
let [availableRange, setAvailableRange] = $hEzMm$react.useState(null);
|
|
302
|
+
let min = $hEzMm$react.useMemo(()=>{
|
|
303
|
+
return $hEzMm$internationalizeddate.maxDate(minValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.start);
|
|
304
|
+
}, [
|
|
305
|
+
minValue,
|
|
306
|
+
availableRange
|
|
307
|
+
]);
|
|
308
|
+
let max = $hEzMm$react.useMemo(()=>{
|
|
309
|
+
return $hEzMm$internationalizeddate.minDate(maxValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.end);
|
|
310
|
+
}, [
|
|
311
|
+
maxValue,
|
|
312
|
+
availableRange
|
|
313
|
+
]);
|
|
294
314
|
let calendar = $6adad0c8536fc209$export$6d095e787d2b5e1f({
|
|
295
315
|
...calendarProps,
|
|
296
316
|
value: value && value.start,
|
|
297
317
|
createCalendar: createCalendar,
|
|
298
318
|
locale: locale,
|
|
299
319
|
visibleDuration: visibleDuration,
|
|
300
|
-
minValue:
|
|
301
|
-
maxValue:
|
|
320
|
+
minValue: min,
|
|
321
|
+
maxValue: max,
|
|
302
322
|
selectionAlignment: alignment
|
|
303
323
|
});
|
|
324
|
+
let updateAvailableRange = (date)=>{
|
|
325
|
+
if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {
|
|
326
|
+
availableRangeRef.current = {
|
|
327
|
+
start: $e49f7b861e5e8049$var$nextUnavailableDate(date, calendar, -1),
|
|
328
|
+
end: $e49f7b861e5e8049$var$nextUnavailableDate(date, calendar, 1)
|
|
329
|
+
};
|
|
330
|
+
setAvailableRange(availableRangeRef.current);
|
|
331
|
+
} else {
|
|
332
|
+
availableRangeRef.current = null;
|
|
333
|
+
setAvailableRange(null);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
// If the visible range changes, we need to update the available range.
|
|
337
|
+
let lastVisibleRange = $hEzMm$react.useRef(calendar.visibleRange);
|
|
338
|
+
if (!$hEzMm$internationalizeddate.isEqualDay(calendar.visibleRange.start, lastVisibleRange.current.start) || !$hEzMm$internationalizeddate.isEqualDay(calendar.visibleRange.end, lastVisibleRange.current.end)) {
|
|
339
|
+
updateAvailableRange(anchorDate);
|
|
340
|
+
lastVisibleRange.current = calendar.visibleRange;
|
|
341
|
+
}
|
|
342
|
+
let setAnchorDate = (date)=>{
|
|
343
|
+
if (date) {
|
|
344
|
+
setAnchorDateState(date);
|
|
345
|
+
updateAvailableRange(date);
|
|
346
|
+
} else {
|
|
347
|
+
setAnchorDateState(null);
|
|
348
|
+
updateAvailableRange(null);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
304
351
|
let highlightedRange = anchorDate ? $e49f7b861e5e8049$var$makeRange(anchorDate, calendar.focusedDate) : value && $e49f7b861e5e8049$var$makeRange(value.start, value.end);
|
|
305
352
|
let selectDate = (date)=>{
|
|
306
353
|
if (props.isReadOnly) return;
|
|
@@ -330,7 +377,11 @@ function $e49f7b861e5e8049$export$9a987164d97ecc90(props) {
|
|
|
330
377
|
if (anchorDate) calendar.setFocusedDate(date);
|
|
331
378
|
},
|
|
332
379
|
isSelected (date) {
|
|
333
|
-
return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date);
|
|
380
|
+
return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date);
|
|
381
|
+
},
|
|
382
|
+
isInvalid (date) {
|
|
383
|
+
var ref, ref1;
|
|
384
|
+
return calendar.isInvalid(date) || $4301262d71f567b9$export$eac50920cf2fd59a(date, (ref = availableRangeRef.current) === null || ref === void 0 ? void 0 : ref.start, (ref1 = availableRangeRef.current) === null || ref1 === void 0 ? void 0 : ref1.end);
|
|
334
385
|
},
|
|
335
386
|
isDragging: isDragging,
|
|
336
387
|
setDragging: setDragging
|
|
@@ -355,6 +406,18 @@ function $e49f7b861e5e8049$var$convertValue(newValue, oldValue) {
|
|
|
355
406
|
if (oldValue && 'hour' in oldValue) return oldValue.set(newValue);
|
|
356
407
|
return newValue;
|
|
357
408
|
}
|
|
409
|
+
function $e49f7b861e5e8049$var$nextUnavailableDate(anchorDate, state, dir) {
|
|
410
|
+
let nextDate = anchorDate.add({
|
|
411
|
+
days: dir
|
|
412
|
+
});
|
|
413
|
+
while((dir < 0 ? nextDate.compare(state.visibleRange.start) >= 0 : nextDate.compare(state.visibleRange.end) <= 0) && !state.isCellUnavailable(nextDate))nextDate = nextDate.add({
|
|
414
|
+
days: dir
|
|
415
|
+
});
|
|
416
|
+
if (state.isCellUnavailable(nextDate)) return nextDate.add({
|
|
417
|
+
days: -dir
|
|
418
|
+
});
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
358
421
|
|
|
359
422
|
|
|
360
423
|
$parcel$exportWildcard(module.exports, $7a549489c00e7fe0$exports);
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SGuBgB,yCAAS,CAAC,IAAkB,EAAE,QAAmB,EAAE,QAAmB,EAAE,CAAC;IACvF,MAAM,CAAE,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IACnD,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC;AACnD,CAAC;SAEe,yCAAW,CAAC,IAAkB,EAAE,QAAsB,EAAE,MAAc,EAAE,QAAoB,EAAE,QAAoB,EAAE,CAAC;IACnI,GAAG,CAAC,YAAY,GAAiB,CAAC;IAAA,CAAC;IACnC,GAAG,CAAE,GAAG,CAAC,GAAG,IAAI,QAAQ,CAAE,CAAC;QACzB,YAAY,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;QAChD,EAAE,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC,IAAI,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAClD,YAAY,CAAC,GAAG;IAEpB,CAAC;IAED,GAAG,CAAC,OAAO,GAAG,wCAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,YAAY;IACtE,MA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GACvB,KAAK,EAAE,GAAG,IAAI,CAAC;QAAA,GAAG;QAAE,KAAK;IAAA,CAAC;IAG7B,MAAM,CAAC,CAAC;QAAA,KAAK,EAAE,2CAAc,CAAC,KAAK;QAAG,GAAG,EAAE,2CAAc,CAAC,GAAG;IAAC,CAAC;AACjE,CAAC;SAEQ,kCAAY,CAAC,QAAsB,EAAE,QAAmB,EAAE,CAAC;IAClE,EAAwE,AAAxE,sEAAwE;IACxE,EAAsF,AAAtF,oFAAsF;IACtF,QAAQ,GAAG,uCAAU,CAAC,QAAQ,GAAE,QAAQ,aAAR,QAAQ,KAAR,IAAI,CAAJ,CAAkB,GAAlB,IAAI,CAAJ,CAAkB,GAAlB,QAAQ,CAAE,QAAQ,KAAI,GAAG,CAAC,8CAAiB;IAE3E,EAA4C,AAA5C,0CAA4C;IAC5C,EAAE,EAAE,QAAQ,IAAI,CAAM,SAAI,QAAQ,EAChC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ;IAG9B,MAAM,CAAC,QAAQ;AACjB,CAAC;;","sources":["packages/@react-stately/calendar/src/index.ts","packages/@react-stately/calendar/src/types.ts","packages/@react-stately/calendar/src/useCalendarState.ts","packages/@react-stately/calendar/src/utils.ts","packages/@react-stately/calendar/src/useRangeCalendarState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './types';\nexport * from './useCalendarState';\nexport * from './useRangeCalendarState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\nimport {RangeValue} from '@react-types/shared';\n\nexport interface CalendarStateBase {\n /** Whether the calendar is disabled. */\n readonly isDisabled: boolean,\n /** Whether the calendar is in a read only state. */\n readonly isReadOnly: boolean,\n /** The date range that is currently visible in the calendar. */\n readonly visibleRange: RangeValue<CalendarDate>,\n /** The time zone of the dates currently being displayed. */\n readonly timeZone: string,\n /** The currently focused date. */\n readonly focusedDate: CalendarDate,\n /** Sets the focused date. */\n setFocusedDate(value: CalendarDate): void,\n /** Moves focus to the next calendar date. */\n focusNextDay(): void,\n /** Moves focus to the previous calendar date. */\n focusPreviousDay(): void,\n /** Moves focus to the next row of dates, e.g. the next week. */\n focusNextRow(): void,\n /** Moves focus to the previous row of dates, e.g. the previous work. */\n focusPreviousRow(): void,\n /** Moves focus to the next page of dates, e.g. the next month if one month is visible. */\n focusNextPage(): void,\n /** Moves focus to the previous page of dates, e.g. the previous month if one month is visible. */\n focusPreviousPage(): void,\n /** Moves focus to the start of the current page of dates, e.g. the start of the first visible month. */\n focusPageStart(): void,\n /** Moves focus to the end of the current page of dates, e.g. the end of the last visible month. */\n focusPageEnd(): void,\n /**\n * Moves focus to the next larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the next visible range. If weeks are displayed, then\n * moves to the next month. If months or years are displayed, moves to the next year.\n */\n focusNextSection(): void,\n /**\n * Moves focus to the previous larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the previous visible range. If weeks are displayed, then\n * moves to the previous month. If months or years are displayed, moves to the previous year.\n */\n focusPreviousSection(): void,\n /** Selects the currently focused date. */\n selectFocusedDate(): void,\n /** Selects the given date. */\n selectDate(date: CalendarDate): void,\n /** Whether focus is currently within the calendar. */\n readonly isFocused: boolean,\n /** Sets whether focus is currently within the calendar. */\n setFocused(value: boolean): void,\n /** Returns whether the given date is invalid according to the `minValue` and `maxValue` props. */\n isInvalid(date: CalendarDate): boolean,\n /** Returns whether the given date is currently selected. */\n isSelected(date: CalendarDate): boolean,\n /** Returns whether the given date is currently focused. */\n isCellFocused(date: CalendarDate): boolean,\n /** Returns whether the given date is disabled according to the `minValue, `maxValue`, and `isDisabled` props. */\n isCellDisabled(date: CalendarDate): boolean,\n /** Returns whether the previous visible date range is allowed to be selected according to the `minValue` prop. */\n isPreviousVisibleRangeInvalid(): boolean,\n /** Returns whether the next visible date range is allowed to be selected according to the `maxValue` prop. */\n isNextVisibleRangeInvalid(): boolean\n}\n\nexport interface CalendarState extends CalendarStateBase {\n /** The currently selected date. */\n readonly value: CalendarDate,\n /** Sets the currently selected date. */\n setValue(value: CalendarDate): void\n}\n\nexport interface RangeCalendarState extends CalendarStateBase {\n /** The currently selected date range. */\n readonly value: RangeValue<DateValue>,\n /** Sets the currently selected date range. */\n setValue(value: RangeValue<DateValue>): void,\n /** Highlights the given date during selection, e.g. by hovering or dragging. */\n highlightDate(date: CalendarDate): void,\n /** The current anchor date that the user clicked on to begin range selection. */\n readonly anchorDate: CalendarDate | null,\n /** Sets the anchor date that the user clicked on to begin range selection. */\n setAnchorDate(date: CalendarDate | null): void,\n /** The currently highlighted date range. */\n readonly highlightedRange: RangeValue<CalendarDate>,\n /** Whether the user is currently dragging over the calendar. */\n readonly isDragging: boolean,\n /** Sets whether the user is dragging over the calendar. */\n setDragging(isDragging: boolean): void\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter, alignEnd, alignStart, constrainStart, constrainValue, isInvalid} from './utils';\nimport {\n Calendar,\n CalendarDate,\n DateDuration,\n GregorianCalendar,\n isSameDay,\n toCalendar,\n toCalendarDate,\n today\n} from '@internationalized/date';\nimport {CalendarProps, DateValue} from '@react-types/calendar';\nimport {CalendarState} from './types';\nimport {useControlledState} from '@react-stately/utils';\nimport {useDateFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef, useState} from 'react';\n\ninterface CalendarStateOptions<T extends DateValue> extends CalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration,\n selectionAlignment?: 'start' | 'center' | 'end'\n}\n\nexport function useCalendarState<T extends DateValue>(props: CalendarStateOptions<T>): CalendarState {\n let defaultFormatter = useDateFormatter();\n let resolvedOptions = useMemo(() => defaultFormatter.resolvedOptions(), [defaultFormatter]);\n let {\n locale,\n createCalendar,\n visibleDuration = {months: 1},\n minValue,\n maxValue,\n selectionAlignment\n } = props;\n\n let calendar = useMemo(() => createCalendar(resolvedOptions.calendar), [createCalendar, resolvedOptions.calendar]);\n\n let [value, setControlledValue] = useControlledState<DateValue>(props.value, props.defaultValue, props.onChange);\n let calendarDateValue = useMemo(() => value ? toCalendar(toCalendarDate(value), calendar) : null, [value, calendar]);\n let timeZone = useMemo(() => value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone, [value, resolvedOptions.timeZone]);\n let focusedCalendarDate = useMemo(() => (\n props.focusedValue\n ? constrainValue(toCalendar(toCalendarDate(props.focusedValue), calendar), minValue, maxValue)\n : undefined\n ), [props.focusedValue, calendar, minValue, maxValue]);\n let defaultFocusedCalendarDate = useMemo(() => (\n constrainValue(\n props.defaultFocusedValue\n ? toCalendar(toCalendarDate(props.defaultFocusedValue), calendar)\n : calendarDateValue || toCalendar(today(timeZone), calendar),\n minValue,\n maxValue\n )\n ), [props.defaultFocusedValue, calendarDateValue, timeZone, calendar, minValue, maxValue]);\n let [focusedDate, setFocusedDate] = useControlledState(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);\n let [startDate, setStartDate] = useState(() => {\n switch (selectionAlignment) {\n case 'start':\n return alignStart(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'end':\n return alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'center':\n default:\n return alignCenter(focusedDate, visibleDuration, locale, minValue, maxValue);\n }\n });\n let [isFocused, setFocused] = useState(props.autoFocus || false);\n\n let endDate = useMemo(() => startDate.add(visibleDuration).subtract({days: 1}), [startDate, visibleDuration]);\n\n // Reset focused date and visible range when calendar changes.\n let lastCalendarIdentifier = useRef(calendar.identifier);\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n let newFocusedDate = toCalendar(focusedDate, calendar);\n setStartDate(alignCenter(newFocusedDate, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(newFocusedDate);\n lastCalendarIdentifier.current = calendar.identifier;\n }\n\n if (focusedDate.compare(startDate) < 0) {\n setStartDate(alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue));\n } else if (focusedDate.compare(startDate.add(visibleDuration)) >= 0) {\n setStartDate(alignStart(focusedDate, visibleDuration, locale, minValue, maxValue));\n }\n\n // Sets focus to a specific cell date\n function focusCell(date: CalendarDate) {\n date = constrainValue(date, minValue, maxValue);\n setFocusedDate(date);\n }\n\n function setValue(newValue: CalendarDate) {\n if (!props.isDisabled && !props.isReadOnly) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, value?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (value && 'hour' in value) {\n setControlledValue(value.set(newValue));\n } else {\n setControlledValue(newValue);\n }\n }\n }\n\n return {\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n value: calendarDateValue,\n setValue,\n visibleRange: {\n start: startDate,\n end: endDate\n },\n focusedDate,\n timeZone,\n setFocusedDate(date) {\n focusCell(date);\n setFocused(true);\n },\n focusNextDay() {\n focusCell(focusedDate.add({days: 1}));\n },\n focusPreviousDay() {\n focusCell(focusedDate.subtract({days: 1}));\n },\n focusNextRow() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({weeks: 1}));\n }\n },\n focusPreviousRow() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({weeks: 1}));\n }\n },\n focusNextPage() {\n let start = startDate.add(visibleDuration);\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(constrainValue(focusedDate.add(visibleDuration), minValue, maxValue));\n },\n focusPreviousPage() {\n let start = startDate.subtract(visibleDuration);\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(constrainValue(focusedDate.subtract(visibleDuration), minValue, maxValue));\n },\n focusPageStart() {\n focusCell(startDate);\n },\n focusPageEnd() {\n focusCell(endDate);\n },\n focusNextSection() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.add({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({years: 1}));\n }\n },\n focusPreviousSection() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.subtract({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({years: 1}));\n }\n },\n selectFocusedDate() {\n setValue(focusedDate);\n },\n selectDate(date) {\n setValue(date);\n },\n isFocused,\n setFocused,\n isInvalid(date) {\n return isInvalid(date, minValue, maxValue);\n },\n isSelected(date) {\n return calendarDateValue != null && isSameDay(date, calendarDateValue) && !this.isCellDisabled(date);\n },\n isCellFocused(date) {\n return isFocused && focusedDate && isSameDay(date, focusedDate);\n },\n isCellDisabled(date) {\n return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || isInvalid(date, minValue, maxValue) || (props.isDateDisabled && props.isDateDisabled(date));\n },\n isPreviousVisibleRangeInvalid() {\n return isInvalid(startDate.subtract({days: 1}), minValue, maxValue);\n },\n isNextVisibleRangeInvalid() {\n return isInvalid(endDate.add({days: 1}), minValue, maxValue);\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CalendarDate,\n DateDuration,\n maxDate,\n minDate,\n startOfMonth,\n startOfWeek,\n startOfYear,\n toCalendarDate\n} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\n\nexport function isInvalid(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n return (minValue != null && date.compare(minValue) < 0) ||\n (maxValue != null && date.compare(maxValue) > 0);\n}\n\nexport function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let halfDuration: DateDuration = {};\n for (let key in duration) {\n halfDuration[key] = Math.floor(duration[key] / 2);\n if (halfDuration[key] > 0 && duration[key] % 2 === 0) {\n halfDuration[key]--;\n }\n }\n\n let aligned = alignStart(date, duration, locale).subtract(halfDuration);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n // align to the start of the largest unit\n let aligned = date;\n if (duration.years) {\n aligned = startOfYear(date);\n } else if (duration.months) {\n aligned = startOfMonth(date);\n } else if (duration.weeks) {\n aligned = startOfWeek(date, locale);\n }\n\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let d = {...duration};\n // subtract 1 from the smallest unit\n if (duration.days) {\n d.days--;\n } else if (duration.weeks) {\n d.weeks--;\n } else if (duration.months) {\n d.months--;\n } else if (duration.years) {\n d.years--;\n }\n\n let aligned = alignStart(date, duration, locale).subtract(d);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function constrainStart(\n date: CalendarDate,\n aligned: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue: DateValue,\n maxValue: DateValue) {\n if (minValue && date.compare(minValue) >= 0) {\n aligned = maxDate(\n aligned,\n alignStart(toCalendarDate(minValue), duration, locale)\n );\n }\n\n if (maxValue && date.compare(maxValue) <= 0) {\n aligned = minDate(\n aligned,\n alignEnd(toCalendarDate(maxValue), duration, locale)\n );\n }\n\n return aligned;\n}\n\nexport function constrainValue(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n if (minValue) {\n date = maxDate(date, toCalendarDate(minValue));\n }\n\n if (maxValue) {\n date = minDate(date, toCalendarDate(maxValue));\n }\n\n return date;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter} from './utils';\nimport {Calendar, CalendarDate, DateDuration, GregorianCalendar, toCalendar, toCalendarDate} from '@internationalized/date';\nimport {DateRange, DateValue} from '@react-types/calendar';\nimport {RangeCalendarProps} from '@react-types/calendar';\nimport {RangeCalendarState} from './types';\nimport {RangeValue} from '@react-types/shared';\nimport {useCalendarState} from './useCalendarState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useState} from 'react';\n\ninterface RangeCalendarStateOptions<T extends DateValue> extends RangeCalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration\n}\n\nexport function useRangeCalendarState<T extends DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState {\n let {value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {months: 1}, minValue, maxValue, ...calendarProps} = props;\n let [value, setValue] = useControlledState<DateRange>(\n valueProp,\n defaultValue,\n onChange\n );\n\n let [anchorDate, setAnchorDate] = useState(null);\n let alignment: 'center' | 'start' = 'center';\n if (value && value.start && value.end) {\n let start = alignCenter(toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);\n let end = start.add(visibleDuration).subtract({days: 1});\n\n if (value.end.compare(end) > 0) {\n alignment = 'start';\n }\n }\n\n let calendar = useCalendarState({\n ...calendarProps,\n value: value && value.start,\n createCalendar,\n locale,\n visibleDuration,\n minValue,\n maxValue,\n selectionAlignment: alignment\n });\n\n let highlightedRange = anchorDate ? makeRange(anchorDate, calendar.focusedDate) : value && makeRange(value.start, value.end);\n let selectDate = (date: CalendarDate) => {\n if (props.isReadOnly) {\n return;\n }\n\n if (!anchorDate) {\n setAnchorDate(date);\n } else {\n let range = makeRange(anchorDate, date);\n setValue({\n start: convertValue(range.start, value?.start),\n end: convertValue(range.end, value?.end)\n });\n setAnchorDate(null);\n }\n };\n\n let [isDragging, setDragging] = useState(false);\n\n return {\n ...calendar,\n value,\n setValue,\n anchorDate,\n setAnchorDate,\n highlightedRange,\n selectFocusedDate() {\n selectDate(calendar.focusedDate);\n },\n selectDate,\n highlightDate(date) {\n if (anchorDate) {\n calendar.setFocusedDate(date);\n }\n },\n isSelected(date) {\n return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date);\n },\n isDragging,\n setDragging\n };\n}\n\nfunction makeRange(start: DateValue, end: DateValue): RangeValue<CalendarDate> {\n if (!start || !end) {\n return null;\n }\n\n if (end.compare(start) < 0) {\n [start, end] = [end, start];\n }\n\n return {start: toCalendarDate(start), end: toCalendarDate(end)};\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue: DateValue) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, oldValue?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (oldValue && 'hour' in oldValue) {\n return oldValue.set(newValue);\n }\n\n return newValue;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SGuBgB,yCAAS,CAAC,IAAkB,EAAE,QAAmB,EAAE,QAAmB,EAAE,CAAC;IACvF,MAAM,CAAE,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IACnD,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC;AACnD,CAAC;SAEe,yCAAW,CAAC,IAAkB,EAAE,QAAsB,EAAE,MAAc,EAAE,QAAoB,EAAE,QAAoB,EAAE,CAAC;IACnI,GAAG,CAAC,YAAY,GAAiB,CAAC;IAAA,CAAC;IACnC,GAAG,CAAE,GAAG,CAAC,GAAG,IAAI,QAAQ,CAAE,CAAC;QACzB,YAAY,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;QAChD,EAAE,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC,IAAI,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,EAClD,YAAY,CAAC,GAAG;IAEpB,CAAC;IAED,GAAG,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,EAAE,EAAE,KAAK,CAAC,iBAAiB,CAAC,QAAQ,GAClC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAAA,IAAI,GAAG,GAAG;IAAA,CAAC;IAGlC,MAAM,CAAC,IAAI;AACb,CAAC;;","sources":["packages/@react-stately/calendar/src/index.ts","packages/@react-stately/calendar/src/types.ts","packages/@react-stately/calendar/src/useCalendarState.ts","packages/@react-stately/calendar/src/utils.ts","packages/@react-stately/calendar/src/useRangeCalendarState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './types';\nexport * from './useCalendarState';\nexport * from './useRangeCalendarState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\nimport {RangeValue} from '@react-types/shared';\n\nexport interface CalendarStateBase {\n /** Whether the calendar is disabled. */\n readonly isDisabled: boolean,\n /** Whether the calendar is in a read only state. */\n readonly isReadOnly: boolean,\n /** The date range that is currently visible in the calendar. */\n readonly visibleRange: RangeValue<CalendarDate>,\n /** The time zone of the dates currently being displayed. */\n readonly timeZone: string,\n /** The currently focused date. */\n readonly focusedDate: CalendarDate,\n /** Sets the focused date. */\n setFocusedDate(value: CalendarDate): void,\n /** Moves focus to the next calendar date. */\n focusNextDay(): void,\n /** Moves focus to the previous calendar date. */\n focusPreviousDay(): void,\n /** Moves focus to the next row of dates, e.g. the next week. */\n focusNextRow(): void,\n /** Moves focus to the previous row of dates, e.g. the previous work. */\n focusPreviousRow(): void,\n /** Moves focus to the next page of dates, e.g. the next month if one month is visible. */\n focusNextPage(): void,\n /** Moves focus to the previous page of dates, e.g. the previous month if one month is visible. */\n focusPreviousPage(): void,\n /** Moves focus to the start of the current page of dates, e.g. the start of the first visible month. */\n focusPageStart(): void,\n /** Moves focus to the end of the current page of dates, e.g. the end of the last visible month. */\n focusPageEnd(): void,\n /**\n * Moves focus to the next larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the next visible range. If weeks are displayed, then\n * moves to the next month. If months or years are displayed, moves to the next year.\n */\n focusNextSection(): void,\n /**\n * Moves focus to the previous larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the previous visible range. If weeks are displayed, then\n * moves to the previous month. If months or years are displayed, moves to the previous year.\n */\n focusPreviousSection(): void,\n /** Selects the currently focused date. */\n selectFocusedDate(): void,\n /** Selects the given date. */\n selectDate(date: CalendarDate): void,\n /** Whether focus is currently within the calendar. */\n readonly isFocused: boolean,\n /** Sets whether focus is currently within the calendar. */\n setFocused(value: boolean): void,\n /** Returns whether the given date is invalid according to the `minValue` and `maxValue` props. */\n isInvalid(date: CalendarDate): boolean,\n /** Returns whether the given date is currently selected. */\n isSelected(date: CalendarDate): boolean,\n /** Returns whether the given date is currently focused. */\n isCellFocused(date: CalendarDate): boolean,\n /** Returns whether the given date is disabled according to the `minValue, `maxValue`, and `isDisabled` props. */\n isCellDisabled(date: CalendarDate): boolean,\n /** Returns whether the given date is unavailable according to the `isDateUnavailable` prop. */\n isCellUnavailable(date: CalendarDate): boolean,\n /** Returns whether the previous visible date range is allowed to be selected according to the `minValue` prop. */\n isPreviousVisibleRangeInvalid(): boolean,\n /** Returns whether the next visible date range is allowed to be selected according to the `maxValue` prop. */\n isNextVisibleRangeInvalid(): boolean\n}\n\nexport interface CalendarState extends CalendarStateBase {\n /** The currently selected date. */\n readonly value: CalendarDate,\n /** Sets the currently selected date. */\n setValue(value: CalendarDate): void\n}\n\nexport interface RangeCalendarState extends CalendarStateBase {\n /** The currently selected date range. */\n readonly value: RangeValue<DateValue>,\n /** Sets the currently selected date range. */\n setValue(value: RangeValue<DateValue>): void,\n /** Highlights the given date during selection, e.g. by hovering or dragging. */\n highlightDate(date: CalendarDate): void,\n /** The current anchor date that the user clicked on to begin range selection. */\n readonly anchorDate: CalendarDate | null,\n /** Sets the anchor date that the user clicked on to begin range selection. */\n setAnchorDate(date: CalendarDate | null): void,\n /** The currently highlighted date range. */\n readonly highlightedRange: RangeValue<CalendarDate>,\n /** Whether the user is currently dragging over the calendar. */\n readonly isDragging: boolean,\n /** Sets whether the user is dragging over the calendar. */\n setDragging(isDragging: boolean): void\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter, alignEnd, alignStart, constrainStart, constrainValue, isInvalid} from './utils';\nimport {\n Calendar,\n CalendarDate,\n DateDuration,\n GregorianCalendar,\n isSameDay,\n toCalendar,\n toCalendarDate,\n today\n} from '@internationalized/date';\nimport {CalendarProps, DateValue} from '@react-types/calendar';\nimport {CalendarState} from './types';\nimport {useControlledState} from '@react-stately/utils';\nimport {useDateFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef, useState} from 'react';\n\ninterface CalendarStateOptions<T extends DateValue> extends CalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration,\n selectionAlignment?: 'start' | 'center' | 'end'\n}\n\nexport function useCalendarState<T extends DateValue>(props: CalendarStateOptions<T>): CalendarState {\n let defaultFormatter = useDateFormatter();\n let resolvedOptions = useMemo(() => defaultFormatter.resolvedOptions(), [defaultFormatter]);\n let {\n locale,\n createCalendar,\n visibleDuration = {months: 1},\n minValue,\n maxValue,\n selectionAlignment\n } = props;\n\n let calendar = useMemo(() => createCalendar(resolvedOptions.calendar), [createCalendar, resolvedOptions.calendar]);\n\n let [value, setControlledValue] = useControlledState<DateValue>(props.value, props.defaultValue, props.onChange);\n let calendarDateValue = useMemo(() => value ? toCalendar(toCalendarDate(value), calendar) : null, [value, calendar]);\n let timeZone = useMemo(() => value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone, [value, resolvedOptions.timeZone]);\n let focusedCalendarDate = useMemo(() => (\n props.focusedValue\n ? constrainValue(toCalendar(toCalendarDate(props.focusedValue), calendar), minValue, maxValue)\n : undefined\n ), [props.focusedValue, calendar, minValue, maxValue]);\n let defaultFocusedCalendarDate = useMemo(() => (\n constrainValue(\n props.defaultFocusedValue\n ? toCalendar(toCalendarDate(props.defaultFocusedValue), calendar)\n : calendarDateValue || toCalendar(today(timeZone), calendar),\n minValue,\n maxValue\n )\n ), [props.defaultFocusedValue, calendarDateValue, timeZone, calendar, minValue, maxValue]);\n let [focusedDate, setFocusedDate] = useControlledState(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);\n let [startDate, setStartDate] = useState(() => {\n switch (selectionAlignment) {\n case 'start':\n return alignStart(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'end':\n return alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'center':\n default:\n return alignCenter(focusedDate, visibleDuration, locale, minValue, maxValue);\n }\n });\n let [isFocused, setFocused] = useState(props.autoFocus || false);\n\n let endDate = useMemo(() => startDate.add(visibleDuration).subtract({days: 1}), [startDate, visibleDuration]);\n\n // Reset focused date and visible range when calendar changes.\n let lastCalendarIdentifier = useRef(calendar.identifier);\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n let newFocusedDate = toCalendar(focusedDate, calendar);\n setStartDate(alignCenter(newFocusedDate, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(newFocusedDate);\n lastCalendarIdentifier.current = calendar.identifier;\n }\n\n if (isInvalid(focusedDate, minValue, maxValue)) {\n // If the focused date was moved to an invalid value, it can't be focused, so constrain it.\n setFocusedDate(constrainValue(focusedDate, minValue, maxValue));\n } else if (focusedDate.compare(startDate) < 0) {\n setStartDate(alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue));\n } else if (focusedDate.compare(startDate.add(visibleDuration)) >= 0) {\n setStartDate(alignStart(focusedDate, visibleDuration, locale, minValue, maxValue));\n }\n\n // Sets focus to a specific cell date\n function focusCell(date: CalendarDate) {\n date = constrainValue(date, minValue, maxValue);\n setFocusedDate(date);\n }\n\n function setValue(newValue: CalendarDate) {\n if (!props.isDisabled && !props.isReadOnly) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, value?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (value && 'hour' in value) {\n setControlledValue(value.set(newValue));\n } else {\n setControlledValue(newValue);\n }\n }\n }\n\n return {\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n value: calendarDateValue,\n setValue,\n visibleRange: {\n start: startDate,\n end: endDate\n },\n focusedDate,\n timeZone,\n setFocusedDate(date) {\n focusCell(date);\n setFocused(true);\n },\n focusNextDay() {\n focusCell(focusedDate.add({days: 1}));\n },\n focusPreviousDay() {\n focusCell(focusedDate.subtract({days: 1}));\n },\n focusNextRow() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({weeks: 1}));\n }\n },\n focusPreviousRow() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({weeks: 1}));\n }\n },\n focusNextPage() {\n let start = startDate.add(visibleDuration);\n setFocusedDate(constrainValue(focusedDate.add(visibleDuration), minValue, maxValue));\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n },\n focusPreviousPage() {\n let start = startDate.subtract(visibleDuration);\n setFocusedDate(constrainValue(focusedDate.subtract(visibleDuration), minValue, maxValue));\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n },\n focusPageStart() {\n focusCell(startDate);\n },\n focusPageEnd() {\n focusCell(endDate);\n },\n focusNextSection() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.add({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({years: 1}));\n }\n },\n focusPreviousSection() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.subtract({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({years: 1}));\n }\n },\n selectFocusedDate() {\n setValue(focusedDate);\n },\n selectDate(date) {\n setValue(date);\n },\n isFocused,\n setFocused,\n isInvalid(date) {\n return isInvalid(date, minValue, maxValue);\n },\n isSelected(date) {\n return calendarDateValue != null && isSameDay(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);\n },\n isCellFocused(date) {\n return isFocused && focusedDate && isSameDay(date, focusedDate);\n },\n isCellDisabled(date) {\n return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date, minValue, maxValue);\n },\n isCellUnavailable(date) {\n return props.isDateUnavailable && props.isDateUnavailable(date);\n },\n isPreviousVisibleRangeInvalid() {\n return this.isInvalid(startDate.subtract({days: 1}), minValue, maxValue);\n },\n isNextVisibleRangeInvalid() {\n return this.isInvalid(endDate.add({days: 1}), minValue, maxValue);\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CalendarDate,\n DateDuration,\n maxDate,\n minDate,\n startOfMonth,\n startOfWeek,\n startOfYear,\n toCalendarDate\n} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\n\nexport function isInvalid(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n return (minValue != null && date.compare(minValue) < 0) ||\n (maxValue != null && date.compare(maxValue) > 0);\n}\n\nexport function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let halfDuration: DateDuration = {};\n for (let key in duration) {\n halfDuration[key] = Math.floor(duration[key] / 2);\n if (halfDuration[key] > 0 && duration[key] % 2 === 0) {\n halfDuration[key]--;\n }\n }\n\n let aligned = alignStart(date, duration, locale).subtract(halfDuration);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n // align to the start of the largest unit\n let aligned = date;\n if (duration.years) {\n aligned = startOfYear(date);\n } else if (duration.months) {\n aligned = startOfMonth(date);\n } else if (duration.weeks) {\n aligned = startOfWeek(date, locale);\n }\n\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let d = {...duration};\n // subtract 1 from the smallest unit\n if (duration.days) {\n d.days--;\n } else if (duration.weeks) {\n d.weeks--;\n } else if (duration.months) {\n d.months--;\n } else if (duration.years) {\n d.years--;\n }\n\n let aligned = alignStart(date, duration, locale).subtract(d);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function constrainStart(\n date: CalendarDate,\n aligned: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue: DateValue,\n maxValue: DateValue) {\n if (minValue && date.compare(minValue) >= 0) {\n aligned = maxDate(\n aligned,\n alignStart(toCalendarDate(minValue), duration, locale)\n );\n }\n\n if (maxValue && date.compare(maxValue) <= 0) {\n aligned = minDate(\n aligned,\n alignEnd(toCalendarDate(maxValue), duration, locale)\n );\n }\n\n return aligned;\n}\n\nexport function constrainValue(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n if (minValue) {\n date = maxDate(date, toCalendarDate(minValue));\n }\n\n if (maxValue) {\n date = minDate(date, toCalendarDate(maxValue));\n }\n\n return date;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter, isInvalid} from './utils';\nimport {Calendar, CalendarDate, DateDuration, GregorianCalendar, isEqualDay, maxDate, minDate, toCalendar, toCalendarDate} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from './types';\nimport {DateRange, DateValue} from '@react-types/calendar';\nimport {RangeCalendarProps} from '@react-types/calendar';\nimport {RangeValue} from '@react-types/shared';\nimport {useCalendarState} from './useCalendarState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useRef, useState} from 'react';\n\ninterface RangeCalendarStateOptions<T extends DateValue> extends RangeCalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration\n}\n\nexport function useRangeCalendarState<T extends DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState {\n let {value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {months: 1}, minValue, maxValue, ...calendarProps} = props;\n let [value, setValue] = useControlledState<DateRange>(\n valueProp,\n defaultValue || null,\n onChange\n );\n\n let [anchorDate, setAnchorDateState] = useState(null);\n let alignment: 'center' | 'start' = 'center';\n if (value && value.start && value.end) {\n let start = alignCenter(toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);\n let end = start.add(visibleDuration).subtract({days: 1});\n\n if (value.end.compare(end) > 0) {\n alignment = 'start';\n }\n }\n\n // Available range must be stored in a ref so we have access to the updated version immediately in `isInvalid`.\n let availableRangeRef = useRef<RangeValue<DateValue>>(null);\n let [availableRange, setAvailableRange] = useState<RangeValue<DateValue>>(null);\n let min = useMemo(() => maxDate(minValue, availableRange?.start), [minValue, availableRange]);\n let max = useMemo(() => minDate(maxValue, availableRange?.end), [maxValue, availableRange]);\n\n let calendar = useCalendarState({\n ...calendarProps,\n value: value && value.start,\n createCalendar,\n locale,\n visibleDuration,\n minValue: min,\n maxValue: max,\n selectionAlignment: alignment\n });\n\n let updateAvailableRange = (date) => {\n if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {\n availableRangeRef.current = {\n start: nextUnavailableDate(date, calendar, -1),\n end: nextUnavailableDate(date, calendar, 1)\n };\n setAvailableRange(availableRangeRef.current);\n } else {\n availableRangeRef.current = null;\n setAvailableRange(null);\n }\n };\n\n // If the visible range changes, we need to update the available range.\n let lastVisibleRange = useRef(calendar.visibleRange);\n if (!isEqualDay(calendar.visibleRange.start, lastVisibleRange.current.start) || !isEqualDay(calendar.visibleRange.end, lastVisibleRange.current.end)) {\n updateAvailableRange(anchorDate);\n lastVisibleRange.current = calendar.visibleRange;\n }\n\n let setAnchorDate = (date: CalendarDate) => {\n if (date) {\n setAnchorDateState(date);\n updateAvailableRange(date);\n } else {\n setAnchorDateState(null);\n updateAvailableRange(null);\n }\n };\n\n let highlightedRange = anchorDate ? makeRange(anchorDate, calendar.focusedDate) : value && makeRange(value.start, value.end);\n let selectDate = (date: CalendarDate) => {\n if (props.isReadOnly) {\n return;\n }\n\n if (!anchorDate) {\n setAnchorDate(date);\n } else {\n let range = makeRange(anchorDate, date);\n setValue({\n start: convertValue(range.start, value?.start),\n end: convertValue(range.end, value?.end)\n });\n setAnchorDate(null);\n }\n };\n\n let [isDragging, setDragging] = useState(false);\n\n return {\n ...calendar,\n value,\n setValue,\n anchorDate,\n setAnchorDate,\n highlightedRange,\n selectFocusedDate() {\n selectDate(calendar.focusedDate);\n },\n selectDate,\n highlightDate(date) {\n if (anchorDate) {\n calendar.setFocusedDate(date);\n }\n },\n isSelected(date) {\n return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date);\n },\n isInvalid(date) {\n return calendar.isInvalid(date) || isInvalid(date, availableRangeRef.current?.start, availableRangeRef.current?.end);\n },\n isDragging,\n setDragging\n };\n}\n\nfunction makeRange(start: DateValue, end: DateValue): RangeValue<CalendarDate> {\n if (!start || !end) {\n return null;\n }\n\n if (end.compare(start) < 0) {\n [start, end] = [end, start];\n }\n\n return {start: toCalendarDate(start), end: toCalendarDate(end)};\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue: DateValue) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, oldValue?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (oldValue && 'hour' in oldValue) {\n return oldValue.set(newValue);\n }\n\n return newValue;\n}\n\nfunction nextUnavailableDate(anchorDate: CalendarDate, state: CalendarState, dir: number) {\n let nextDate = anchorDate.add({days: dir});\n while (\n (dir < 0 ? nextDate.compare(state.visibleRange.start) >= 0 : nextDate.compare(state.visibleRange.end) <= 0) &&\n !state.isCellUnavailable(nextDate)\n ) {\n nextDate = nextDate.add({days: dir});\n }\n\n if (state.isCellUnavailable(nextDate)) {\n return nextDate.add({days: -dir});\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {toCalendar as $keQhS$toCalendar, toCalendarDate as $keQhS$toCalendarDate, today as $keQhS$today, GregorianCalendar as $keQhS$GregorianCalendar, isSameDay as $keQhS$isSameDay, startOfYear as $keQhS$startOfYear, startOfMonth as $keQhS$startOfMonth, startOfWeek as $keQhS$startOfWeek, maxDate as $keQhS$maxDate, minDate as $keQhS$minDate} from "@internationalized/date";
|
|
1
|
+
import {toCalendar as $keQhS$toCalendar, toCalendarDate as $keQhS$toCalendarDate, today as $keQhS$today, GregorianCalendar as $keQhS$GregorianCalendar, isSameDay as $keQhS$isSameDay, startOfYear as $keQhS$startOfYear, startOfMonth as $keQhS$startOfMonth, startOfWeek as $keQhS$startOfWeek, maxDate as $keQhS$maxDate, minDate as $keQhS$minDate, isEqualDay as $keQhS$isEqualDay} from "@internationalized/date";
|
|
2
2
|
import {useControlledState as $keQhS$useControlledState} from "@react-stately/utils";
|
|
3
3
|
import {useDateFormatter as $keQhS$useDateFormatter} from "@react-aria/i18n";
|
|
4
4
|
import {useMemo as $keQhS$useMemo, useState as $keQhS$useState, useRef as $keQhS$useRef} from "react";
|
|
@@ -131,7 +131,9 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
131
131
|
setFocusedDate(newFocusedDate);
|
|
132
132
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
133
133
|
}
|
|
134
|
-
if (
|
|
134
|
+
if ($f62d864046160412$export$eac50920cf2fd59a(focusedDate, minValue, maxValue)) // If the focused date was moved to an invalid value, it can't be focused, so constrain it.
|
|
135
|
+
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate, minValue, maxValue));
|
|
136
|
+
else if (focusedDate.compare(startDate) < 0) setStartDate($f62d864046160412$export$530edbfc915b2b04(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
135
137
|
else if (focusedDate.compare(startDate.add(visibleDuration)) >= 0) setStartDate($f62d864046160412$export$144a00ba6044eb9(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
136
138
|
// Sets focus to a specific cell date
|
|
137
139
|
function focusCell(date) {
|
|
@@ -187,13 +189,13 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
187
189
|
},
|
|
188
190
|
focusNextPage () {
|
|
189
191
|
let start = startDate.add(visibleDuration);
|
|
190
|
-
setStartDate($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
191
192
|
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate.add(visibleDuration), minValue, maxValue));
|
|
193
|
+
setStartDate($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
192
194
|
},
|
|
193
195
|
focusPreviousPage () {
|
|
194
196
|
let start = startDate.subtract(visibleDuration);
|
|
195
|
-
setStartDate($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
196
197
|
setFocusedDate($f62d864046160412$export$4f5203c0d889109e(focusedDate.subtract(visibleDuration), minValue, maxValue));
|
|
198
|
+
setStartDate($f62d864046160412$export$5bb865b12696a77d(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
197
199
|
},
|
|
198
200
|
focusPageStart () {
|
|
199
201
|
focusCell(startDate);
|
|
@@ -231,21 +233,24 @@ function $131cf43a05231e1e$export$6d095e787d2b5e1f(props) {
|
|
|
231
233
|
return $f62d864046160412$export$eac50920cf2fd59a(date, minValue, maxValue);
|
|
232
234
|
},
|
|
233
235
|
isSelected (date) {
|
|
234
|
-
return calendarDateValue != null && $keQhS$isSameDay(date, calendarDateValue) && !this.isCellDisabled(date);
|
|
236
|
+
return calendarDateValue != null && $keQhS$isSameDay(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);
|
|
235
237
|
},
|
|
236
238
|
isCellFocused (date) {
|
|
237
239
|
return isFocused && focusedDate && $keQhS$isSameDay(date, focusedDate);
|
|
238
240
|
},
|
|
239
241
|
isCellDisabled (date) {
|
|
240
|
-
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 ||
|
|
242
|
+
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date, minValue, maxValue);
|
|
243
|
+
},
|
|
244
|
+
isCellUnavailable (date) {
|
|
245
|
+
return props.isDateUnavailable && props.isDateUnavailable(date);
|
|
241
246
|
},
|
|
242
247
|
isPreviousVisibleRangeInvalid () {
|
|
243
|
-
return
|
|
248
|
+
return this.isInvalid(startDate.subtract({
|
|
244
249
|
days: 1
|
|
245
250
|
}), minValue, maxValue);
|
|
246
251
|
},
|
|
247
252
|
isNextVisibleRangeInvalid () {
|
|
248
|
-
return
|
|
253
|
+
return this.isInvalid(endDate.add({
|
|
249
254
|
days: 1
|
|
250
255
|
}), minValue, maxValue);
|
|
251
256
|
}
|
|
@@ -265,8 +270,8 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
265
270
|
let { value: valueProp , defaultValue: defaultValue , onChange: onChange , createCalendar: createCalendar , locale: locale , visibleDuration: visibleDuration = {
|
|
266
271
|
months: 1
|
|
267
272
|
} , minValue: minValue , maxValue: maxValue , ...calendarProps } = props;
|
|
268
|
-
let [value, setValue] = $keQhS$useControlledState(valueProp, defaultValue, onChange);
|
|
269
|
-
let [anchorDate,
|
|
273
|
+
let [value, setValue] = $keQhS$useControlledState(valueProp, defaultValue || null, onChange);
|
|
274
|
+
let [anchorDate, setAnchorDateState] = $keQhS$useState(null);
|
|
270
275
|
let alignment = 'center';
|
|
271
276
|
if (value && value.start && value.end) {
|
|
272
277
|
let start = $f62d864046160412$export$f4a51ff076cc9a09($keQhS$toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);
|
|
@@ -275,16 +280,58 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
275
280
|
});
|
|
276
281
|
if (value.end.compare(end) > 0) alignment = 'start';
|
|
277
282
|
}
|
|
283
|
+
// Available range must be stored in a ref so we have access to the updated version immediately in `isInvalid`.
|
|
284
|
+
let availableRangeRef = $keQhS$useRef(null);
|
|
285
|
+
let [availableRange, setAvailableRange] = $keQhS$useState(null);
|
|
286
|
+
let min = $keQhS$useMemo(()=>{
|
|
287
|
+
return $keQhS$maxDate(minValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.start);
|
|
288
|
+
}, [
|
|
289
|
+
minValue,
|
|
290
|
+
availableRange
|
|
291
|
+
]);
|
|
292
|
+
let max = $keQhS$useMemo(()=>{
|
|
293
|
+
return $keQhS$minDate(maxValue, availableRange === null || availableRange === void 0 ? void 0 : availableRange.end);
|
|
294
|
+
}, [
|
|
295
|
+
maxValue,
|
|
296
|
+
availableRange
|
|
297
|
+
]);
|
|
278
298
|
let calendar = $131cf43a05231e1e$export$6d095e787d2b5e1f({
|
|
279
299
|
...calendarProps,
|
|
280
300
|
value: value && value.start,
|
|
281
301
|
createCalendar: createCalendar,
|
|
282
302
|
locale: locale,
|
|
283
303
|
visibleDuration: visibleDuration,
|
|
284
|
-
minValue:
|
|
285
|
-
maxValue:
|
|
304
|
+
minValue: min,
|
|
305
|
+
maxValue: max,
|
|
286
306
|
selectionAlignment: alignment
|
|
287
307
|
});
|
|
308
|
+
let updateAvailableRange = (date)=>{
|
|
309
|
+
if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {
|
|
310
|
+
availableRangeRef.current = {
|
|
311
|
+
start: $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, -1),
|
|
312
|
+
end: $9a36b6ba2fb1a7c5$var$nextUnavailableDate(date, calendar, 1)
|
|
313
|
+
};
|
|
314
|
+
setAvailableRange(availableRangeRef.current);
|
|
315
|
+
} else {
|
|
316
|
+
availableRangeRef.current = null;
|
|
317
|
+
setAvailableRange(null);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
// If the visible range changes, we need to update the available range.
|
|
321
|
+
let lastVisibleRange = $keQhS$useRef(calendar.visibleRange);
|
|
322
|
+
if (!$keQhS$isEqualDay(calendar.visibleRange.start, lastVisibleRange.current.start) || !$keQhS$isEqualDay(calendar.visibleRange.end, lastVisibleRange.current.end)) {
|
|
323
|
+
updateAvailableRange(anchorDate);
|
|
324
|
+
lastVisibleRange.current = calendar.visibleRange;
|
|
325
|
+
}
|
|
326
|
+
let setAnchorDate = (date)=>{
|
|
327
|
+
if (date) {
|
|
328
|
+
setAnchorDateState(date);
|
|
329
|
+
updateAvailableRange(date);
|
|
330
|
+
} else {
|
|
331
|
+
setAnchorDateState(null);
|
|
332
|
+
updateAvailableRange(null);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
288
335
|
let highlightedRange = anchorDate ? $9a36b6ba2fb1a7c5$var$makeRange(anchorDate, calendar.focusedDate) : value && $9a36b6ba2fb1a7c5$var$makeRange(value.start, value.end);
|
|
289
336
|
let selectDate = (date)=>{
|
|
290
337
|
if (props.isReadOnly) return;
|
|
@@ -314,7 +361,11 @@ function $9a36b6ba2fb1a7c5$export$9a987164d97ecc90(props) {
|
|
|
314
361
|
if (anchorDate) calendar.setFocusedDate(date);
|
|
315
362
|
},
|
|
316
363
|
isSelected (date) {
|
|
317
|
-
return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date);
|
|
364
|
+
return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date);
|
|
365
|
+
},
|
|
366
|
+
isInvalid (date) {
|
|
367
|
+
var ref, ref1;
|
|
368
|
+
return calendar.isInvalid(date) || $f62d864046160412$export$eac50920cf2fd59a(date, (ref = availableRangeRef.current) === null || ref === void 0 ? void 0 : ref.start, (ref1 = availableRangeRef.current) === null || ref1 === void 0 ? void 0 : ref1.end);
|
|
318
369
|
},
|
|
319
370
|
isDragging: isDragging,
|
|
320
371
|
setDragging: setDragging
|
|
@@ -339,6 +390,18 @@ function $9a36b6ba2fb1a7c5$var$convertValue(newValue, oldValue) {
|
|
|
339
390
|
if (oldValue && 'hour' in oldValue) return oldValue.set(newValue);
|
|
340
391
|
return newValue;
|
|
341
392
|
}
|
|
393
|
+
function $9a36b6ba2fb1a7c5$var$nextUnavailableDate(anchorDate, state, dir) {
|
|
394
|
+
let nextDate = anchorDate.add({
|
|
395
|
+
days: dir
|
|
396
|
+
});
|
|
397
|
+
while((dir < 0 ? nextDate.compare(state.visibleRange.start) >= 0 : nextDate.compare(state.visibleRange.end) <= 0) && !state.isCellUnavailable(nextDate))nextDate = nextDate.add({
|
|
398
|
+
days: dir
|
|
399
|
+
});
|
|
400
|
+
if (state.isCellUnavailable(nextDate)) return nextDate.add({
|
|
401
|
+
days: -dir
|
|
402
|
+
});
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
342
405
|
|
|
343
406
|
|
|
344
407
|
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;SGuBgB,yCAAS,CAAC,IAAkB,EAAE,QAAmB,EAAE,QAAmB,EAAE,CAAC;IACvF,MAAM,CAAE,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IACnD,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC;AACnD,CAAC;SAEe,yCAAW,CAAC,IAAkB,EAAE,QAAsB,EAAE,MAAc,EAAE,QAAoB,EAAE,QAAoB,EAAE,CAAC;IACnI,GAAG,CAAC,YAAY,GAAiB,CAAC;IAAA,CAAC;IACnC,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AgB,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,KAAK,QAAQ,CAAC,cAAc,CAAC,IAAI;QAClJ,CAAC;oBACD,UAAU;qBACV,WAAW;IACb,CAAC;AACH,CAAC;SAEQ,+BAAS,CAAC,KAAgB,EAAE,GAAc,EAA4B,CAAC;IAC9E,EAAE,GAAG,KAAK,KAAK,GAAG,EAChB,MAAM,CAAC,IAAI;IAGb,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,GACvB,KAAK,EAAE,GAAG,IAAI,CAAC;QAAA,GAAG;QAAE,KAAK;IAAA,CAAC;IAG7B,MAAM,CAAC,CAAC;QAAA,KAAK,EAAE,qBAAc,CAAC,KAAK;QAAG,GAAG,EAAE,qBAAc,CAAC,GAAG;IAAC,CAAC;AACjE,CAAC;SAEQ,kCAAY,CAAC,QAAsB,EAAE,QAAmB,EAAE,CAAC;IAClE,EAAwE,AAAxE,sEAAwE;IACxE,EAAsF,AAAtF,oFAAsF;IACtF,QAAQ,GAAG,iBAAU,CAAC,QAAQ,GAAE,QAAQ,aAAR,QAAQ,KAAR,IAAI,CAAJ,CAAkB,GAAlB,IAAI,CAAJ,CAAkB,GAAlB,QAAQ,CAAE,QAAQ,KAAI,GAAG,CAAC,wBAAiB;IAE3E,EAA4C,AAA5C,0CAA4C;IAC5C,EAAE,EAAE,QAAQ,IAAI,CAAM,SAAI,QAAQ,EAChC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ;IAG9B,MAAM,CAAC,QAAQ;AACjB,CAAC;;","sources":["packages/@react-stately/calendar/src/index.ts","packages/@react-stately/calendar/src/types.ts","packages/@react-stately/calendar/src/useCalendarState.ts","packages/@react-stately/calendar/src/utils.ts","packages/@react-stately/calendar/src/useRangeCalendarState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './types';\nexport * from './useCalendarState';\nexport * from './useRangeCalendarState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\nimport {RangeValue} from '@react-types/shared';\n\nexport interface CalendarStateBase {\n /** Whether the calendar is disabled. */\n readonly isDisabled: boolean,\n /** Whether the calendar is in a read only state. */\n readonly isReadOnly: boolean,\n /** The date range that is currently visible in the calendar. */\n readonly visibleRange: RangeValue<CalendarDate>,\n /** The time zone of the dates currently being displayed. */\n readonly timeZone: string,\n /** The currently focused date. */\n readonly focusedDate: CalendarDate,\n /** Sets the focused date. */\n setFocusedDate(value: CalendarDate): void,\n /** Moves focus to the next calendar date. */\n focusNextDay(): void,\n /** Moves focus to the previous calendar date. */\n focusPreviousDay(): void,\n /** Moves focus to the next row of dates, e.g. the next week. */\n focusNextRow(): void,\n /** Moves focus to the previous row of dates, e.g. the previous work. */\n focusPreviousRow(): void,\n /** Moves focus to the next page of dates, e.g. the next month if one month is visible. */\n focusNextPage(): void,\n /** Moves focus to the previous page of dates, e.g. the previous month if one month is visible. */\n focusPreviousPage(): void,\n /** Moves focus to the start of the current page of dates, e.g. the start of the first visible month. */\n focusPageStart(): void,\n /** Moves focus to the end of the current page of dates, e.g. the end of the last visible month. */\n focusPageEnd(): void,\n /**\n * Moves focus to the next larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the next visible range. If weeks are displayed, then\n * moves to the next month. If months or years are displayed, moves to the next year.\n */\n focusNextSection(): void,\n /**\n * Moves focus to the previous larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the previous visible range. If weeks are displayed, then\n * moves to the previous month. If months or years are displayed, moves to the previous year.\n */\n focusPreviousSection(): void,\n /** Selects the currently focused date. */\n selectFocusedDate(): void,\n /** Selects the given date. */\n selectDate(date: CalendarDate): void,\n /** Whether focus is currently within the calendar. */\n readonly isFocused: boolean,\n /** Sets whether focus is currently within the calendar. */\n setFocused(value: boolean): void,\n /** Returns whether the given date is invalid according to the `minValue` and `maxValue` props. */\n isInvalid(date: CalendarDate): boolean,\n /** Returns whether the given date is currently selected. */\n isSelected(date: CalendarDate): boolean,\n /** Returns whether the given date is currently focused. */\n isCellFocused(date: CalendarDate): boolean,\n /** Returns whether the given date is disabled according to the `minValue, `maxValue`, and `isDisabled` props. */\n isCellDisabled(date: CalendarDate): boolean,\n /** Returns whether the previous visible date range is allowed to be selected according to the `minValue` prop. */\n isPreviousVisibleRangeInvalid(): boolean,\n /** Returns whether the next visible date range is allowed to be selected according to the `maxValue` prop. */\n isNextVisibleRangeInvalid(): boolean\n}\n\nexport interface CalendarState extends CalendarStateBase {\n /** The currently selected date. */\n readonly value: CalendarDate,\n /** Sets the currently selected date. */\n setValue(value: CalendarDate): void\n}\n\nexport interface RangeCalendarState extends CalendarStateBase {\n /** The currently selected date range. */\n readonly value: RangeValue<DateValue>,\n /** Sets the currently selected date range. */\n setValue(value: RangeValue<DateValue>): void,\n /** Highlights the given date during selection, e.g. by hovering or dragging. */\n highlightDate(date: CalendarDate): void,\n /** The current anchor date that the user clicked on to begin range selection. */\n readonly anchorDate: CalendarDate | null,\n /** Sets the anchor date that the user clicked on to begin range selection. */\n setAnchorDate(date: CalendarDate | null): void,\n /** The currently highlighted date range. */\n readonly highlightedRange: RangeValue<CalendarDate>,\n /** Whether the user is currently dragging over the calendar. */\n readonly isDragging: boolean,\n /** Sets whether the user is dragging over the calendar. */\n setDragging(isDragging: boolean): void\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter, alignEnd, alignStart, constrainStart, constrainValue, isInvalid} from './utils';\nimport {\n Calendar,\n CalendarDate,\n DateDuration,\n GregorianCalendar,\n isSameDay,\n toCalendar,\n toCalendarDate,\n today\n} from '@internationalized/date';\nimport {CalendarProps, DateValue} from '@react-types/calendar';\nimport {CalendarState} from './types';\nimport {useControlledState} from '@react-stately/utils';\nimport {useDateFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef, useState} from 'react';\n\ninterface CalendarStateOptions<T extends DateValue> extends CalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration,\n selectionAlignment?: 'start' | 'center' | 'end'\n}\n\nexport function useCalendarState<T extends DateValue>(props: CalendarStateOptions<T>): CalendarState {\n let defaultFormatter = useDateFormatter();\n let resolvedOptions = useMemo(() => defaultFormatter.resolvedOptions(), [defaultFormatter]);\n let {\n locale,\n createCalendar,\n visibleDuration = {months: 1},\n minValue,\n maxValue,\n selectionAlignment\n } = props;\n\n let calendar = useMemo(() => createCalendar(resolvedOptions.calendar), [createCalendar, resolvedOptions.calendar]);\n\n let [value, setControlledValue] = useControlledState<DateValue>(props.value, props.defaultValue, props.onChange);\n let calendarDateValue = useMemo(() => value ? toCalendar(toCalendarDate(value), calendar) : null, [value, calendar]);\n let timeZone = useMemo(() => value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone, [value, resolvedOptions.timeZone]);\n let focusedCalendarDate = useMemo(() => (\n props.focusedValue\n ? constrainValue(toCalendar(toCalendarDate(props.focusedValue), calendar), minValue, maxValue)\n : undefined\n ), [props.focusedValue, calendar, minValue, maxValue]);\n let defaultFocusedCalendarDate = useMemo(() => (\n constrainValue(\n props.defaultFocusedValue\n ? toCalendar(toCalendarDate(props.defaultFocusedValue), calendar)\n : calendarDateValue || toCalendar(today(timeZone), calendar),\n minValue,\n maxValue\n )\n ), [props.defaultFocusedValue, calendarDateValue, timeZone, calendar, minValue, maxValue]);\n let [focusedDate, setFocusedDate] = useControlledState(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);\n let [startDate, setStartDate] = useState(() => {\n switch (selectionAlignment) {\n case 'start':\n return alignStart(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'end':\n return alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'center':\n default:\n return alignCenter(focusedDate, visibleDuration, locale, minValue, maxValue);\n }\n });\n let [isFocused, setFocused] = useState(props.autoFocus || false);\n\n let endDate = useMemo(() => startDate.add(visibleDuration).subtract({days: 1}), [startDate, visibleDuration]);\n\n // Reset focused date and visible range when calendar changes.\n let lastCalendarIdentifier = useRef(calendar.identifier);\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n let newFocusedDate = toCalendar(focusedDate, calendar);\n setStartDate(alignCenter(newFocusedDate, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(newFocusedDate);\n lastCalendarIdentifier.current = calendar.identifier;\n }\n\n if (focusedDate.compare(startDate) < 0) {\n setStartDate(alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue));\n } else if (focusedDate.compare(startDate.add(visibleDuration)) >= 0) {\n setStartDate(alignStart(focusedDate, visibleDuration, locale, minValue, maxValue));\n }\n\n // Sets focus to a specific cell date\n function focusCell(date: CalendarDate) {\n date = constrainValue(date, minValue, maxValue);\n setFocusedDate(date);\n }\n\n function setValue(newValue: CalendarDate) {\n if (!props.isDisabled && !props.isReadOnly) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, value?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (value && 'hour' in value) {\n setControlledValue(value.set(newValue));\n } else {\n setControlledValue(newValue);\n }\n }\n }\n\n return {\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n value: calendarDateValue,\n setValue,\n visibleRange: {\n start: startDate,\n end: endDate\n },\n focusedDate,\n timeZone,\n setFocusedDate(date) {\n focusCell(date);\n setFocused(true);\n },\n focusNextDay() {\n focusCell(focusedDate.add({days: 1}));\n },\n focusPreviousDay() {\n focusCell(focusedDate.subtract({days: 1}));\n },\n focusNextRow() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({weeks: 1}));\n }\n },\n focusPreviousRow() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({weeks: 1}));\n }\n },\n focusNextPage() {\n let start = startDate.add(visibleDuration);\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(constrainValue(focusedDate.add(visibleDuration), minValue, maxValue));\n },\n focusPreviousPage() {\n let start = startDate.subtract(visibleDuration);\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(constrainValue(focusedDate.subtract(visibleDuration), minValue, maxValue));\n },\n focusPageStart() {\n focusCell(startDate);\n },\n focusPageEnd() {\n focusCell(endDate);\n },\n focusNextSection() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.add({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({years: 1}));\n }\n },\n focusPreviousSection() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.subtract({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({years: 1}));\n }\n },\n selectFocusedDate() {\n setValue(focusedDate);\n },\n selectDate(date) {\n setValue(date);\n },\n isFocused,\n setFocused,\n isInvalid(date) {\n return isInvalid(date, minValue, maxValue);\n },\n isSelected(date) {\n return calendarDateValue != null && isSameDay(date, calendarDateValue) && !this.isCellDisabled(date);\n },\n isCellFocused(date) {\n return isFocused && focusedDate && isSameDay(date, focusedDate);\n },\n isCellDisabled(date) {\n return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || isInvalid(date, minValue, maxValue) || (props.isDateDisabled && props.isDateDisabled(date));\n },\n isPreviousVisibleRangeInvalid() {\n return isInvalid(startDate.subtract({days: 1}), minValue, maxValue);\n },\n isNextVisibleRangeInvalid() {\n return isInvalid(endDate.add({days: 1}), minValue, maxValue);\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CalendarDate,\n DateDuration,\n maxDate,\n minDate,\n startOfMonth,\n startOfWeek,\n startOfYear,\n toCalendarDate\n} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\n\nexport function isInvalid(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n return (minValue != null && date.compare(minValue) < 0) ||\n (maxValue != null && date.compare(maxValue) > 0);\n}\n\nexport function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let halfDuration: DateDuration = {};\n for (let key in duration) {\n halfDuration[key] = Math.floor(duration[key] / 2);\n if (halfDuration[key] > 0 && duration[key] % 2 === 0) {\n halfDuration[key]--;\n }\n }\n\n let aligned = alignStart(date, duration, locale).subtract(halfDuration);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n // align to the start of the largest unit\n let aligned = date;\n if (duration.years) {\n aligned = startOfYear(date);\n } else if (duration.months) {\n aligned = startOfMonth(date);\n } else if (duration.weeks) {\n aligned = startOfWeek(date, locale);\n }\n\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let d = {...duration};\n // subtract 1 from the smallest unit\n if (duration.days) {\n d.days--;\n } else if (duration.weeks) {\n d.weeks--;\n } else if (duration.months) {\n d.months--;\n } else if (duration.years) {\n d.years--;\n }\n\n let aligned = alignStart(date, duration, locale).subtract(d);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function constrainStart(\n date: CalendarDate,\n aligned: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue: DateValue,\n maxValue: DateValue) {\n if (minValue && date.compare(minValue) >= 0) {\n aligned = maxDate(\n aligned,\n alignStart(toCalendarDate(minValue), duration, locale)\n );\n }\n\n if (maxValue && date.compare(maxValue) <= 0) {\n aligned = minDate(\n aligned,\n alignEnd(toCalendarDate(maxValue), duration, locale)\n );\n }\n\n return aligned;\n}\n\nexport function constrainValue(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n if (minValue) {\n date = maxDate(date, toCalendarDate(minValue));\n }\n\n if (maxValue) {\n date = minDate(date, toCalendarDate(maxValue));\n }\n\n return date;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter} from './utils';\nimport {Calendar, CalendarDate, DateDuration, GregorianCalendar, toCalendar, toCalendarDate} from '@internationalized/date';\nimport {DateRange, DateValue} from '@react-types/calendar';\nimport {RangeCalendarProps} from '@react-types/calendar';\nimport {RangeCalendarState} from './types';\nimport {RangeValue} from '@react-types/shared';\nimport {useCalendarState} from './useCalendarState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useState} from 'react';\n\ninterface RangeCalendarStateOptions<T extends DateValue> extends RangeCalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration\n}\n\nexport function useRangeCalendarState<T extends DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState {\n let {value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {months: 1}, minValue, maxValue, ...calendarProps} = props;\n let [value, setValue] = useControlledState<DateRange>(\n valueProp,\n defaultValue,\n onChange\n );\n\n let [anchorDate, setAnchorDate] = useState(null);\n let alignment: 'center' | 'start' = 'center';\n if (value && value.start && value.end) {\n let start = alignCenter(toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);\n let end = start.add(visibleDuration).subtract({days: 1});\n\n if (value.end.compare(end) > 0) {\n alignment = 'start';\n }\n }\n\n let calendar = useCalendarState({\n ...calendarProps,\n value: value && value.start,\n createCalendar,\n locale,\n visibleDuration,\n minValue,\n maxValue,\n selectionAlignment: alignment\n });\n\n let highlightedRange = anchorDate ? makeRange(anchorDate, calendar.focusedDate) : value && makeRange(value.start, value.end);\n let selectDate = (date: CalendarDate) => {\n if (props.isReadOnly) {\n return;\n }\n\n if (!anchorDate) {\n setAnchorDate(date);\n } else {\n let range = makeRange(anchorDate, date);\n setValue({\n start: convertValue(range.start, value?.start),\n end: convertValue(range.end, value?.end)\n });\n setAnchorDate(null);\n }\n };\n\n let [isDragging, setDragging] = useState(false);\n\n return {\n ...calendar,\n value,\n setValue,\n anchorDate,\n setAnchorDate,\n highlightedRange,\n selectFocusedDate() {\n selectDate(calendar.focusedDate);\n },\n selectDate,\n highlightDate(date) {\n if (anchorDate) {\n calendar.setFocusedDate(date);\n }\n },\n isSelected(date) {\n return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date);\n },\n isDragging,\n setDragging\n };\n}\n\nfunction makeRange(start: DateValue, end: DateValue): RangeValue<CalendarDate> {\n if (!start || !end) {\n return null;\n }\n\n if (end.compare(start) < 0) {\n [start, end] = [end, start];\n }\n\n return {start: toCalendarDate(start), end: toCalendarDate(end)};\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue: DateValue) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, oldValue?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (oldValue && 'hour' in oldValue) {\n return oldValue.set(newValue);\n }\n\n return newValue;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;SGuBgB,yCAAS,CAAC,IAAkB,EAAE,QAAmB,EAAE,QAAmB,EAAE,CAAC;IACvF,MAAM,CAAE,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IACnD,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC;AACnD,CAAC;SAEe,yCAAW,CAAC,IAAkB,EAAE,QAAsB,EAAE,MAAc,EAAE,QAAoB,EAAE,QAAoB,EAAE,CAAC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A,CAAC;WAEtC,GAAG,GAAG,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,KAAK,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,MACzG,KAAK,CAAC,iBAAiB,CAAC,QAAQ,EAEjC,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;QAAA,IAAI,EAAE,GAAG;IAAA,CAAC;IAGrC,EAAE,EAAE,KAAK,CAAC,iBAAiB,CAAC,QAAQ,GAClC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAAA,IAAI,GAAG,GAAG;IAAA,CAAC;IAGlC,MAAM,CAAC,IAAI;AACb,CAAC;;","sources":["packages/@react-stately/calendar/src/index.ts","packages/@react-stately/calendar/src/types.ts","packages/@react-stately/calendar/src/useCalendarState.ts","packages/@react-stately/calendar/src/utils.ts","packages/@react-stately/calendar/src/useRangeCalendarState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './types';\nexport * from './useCalendarState';\nexport * from './useRangeCalendarState';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {CalendarDate} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\nimport {RangeValue} from '@react-types/shared';\n\nexport interface CalendarStateBase {\n /** Whether the calendar is disabled. */\n readonly isDisabled: boolean,\n /** Whether the calendar is in a read only state. */\n readonly isReadOnly: boolean,\n /** The date range that is currently visible in the calendar. */\n readonly visibleRange: RangeValue<CalendarDate>,\n /** The time zone of the dates currently being displayed. */\n readonly timeZone: string,\n /** The currently focused date. */\n readonly focusedDate: CalendarDate,\n /** Sets the focused date. */\n setFocusedDate(value: CalendarDate): void,\n /** Moves focus to the next calendar date. */\n focusNextDay(): void,\n /** Moves focus to the previous calendar date. */\n focusPreviousDay(): void,\n /** Moves focus to the next row of dates, e.g. the next week. */\n focusNextRow(): void,\n /** Moves focus to the previous row of dates, e.g. the previous work. */\n focusPreviousRow(): void,\n /** Moves focus to the next page of dates, e.g. the next month if one month is visible. */\n focusNextPage(): void,\n /** Moves focus to the previous page of dates, e.g. the previous month if one month is visible. */\n focusPreviousPage(): void,\n /** Moves focus to the start of the current page of dates, e.g. the start of the first visible month. */\n focusPageStart(): void,\n /** Moves focus to the end of the current page of dates, e.g. the end of the last visible month. */\n focusPageEnd(): void,\n /**\n * Moves focus to the next larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the next visible range. If weeks are displayed, then\n * moves to the next month. If months or years are displayed, moves to the next year.\n */\n focusNextSection(): void,\n /**\n * Moves focus to the previous larger section of dates based on what is currently displayed.\n * If days are displayed, then moves to the previous visible range. If weeks are displayed, then\n * moves to the previous month. If months or years are displayed, moves to the previous year.\n */\n focusPreviousSection(): void,\n /** Selects the currently focused date. */\n selectFocusedDate(): void,\n /** Selects the given date. */\n selectDate(date: CalendarDate): void,\n /** Whether focus is currently within the calendar. */\n readonly isFocused: boolean,\n /** Sets whether focus is currently within the calendar. */\n setFocused(value: boolean): void,\n /** Returns whether the given date is invalid according to the `minValue` and `maxValue` props. */\n isInvalid(date: CalendarDate): boolean,\n /** Returns whether the given date is currently selected. */\n isSelected(date: CalendarDate): boolean,\n /** Returns whether the given date is currently focused. */\n isCellFocused(date: CalendarDate): boolean,\n /** Returns whether the given date is disabled according to the `minValue, `maxValue`, and `isDisabled` props. */\n isCellDisabled(date: CalendarDate): boolean,\n /** Returns whether the given date is unavailable according to the `isDateUnavailable` prop. */\n isCellUnavailable(date: CalendarDate): boolean,\n /** Returns whether the previous visible date range is allowed to be selected according to the `minValue` prop. */\n isPreviousVisibleRangeInvalid(): boolean,\n /** Returns whether the next visible date range is allowed to be selected according to the `maxValue` prop. */\n isNextVisibleRangeInvalid(): boolean\n}\n\nexport interface CalendarState extends CalendarStateBase {\n /** The currently selected date. */\n readonly value: CalendarDate,\n /** Sets the currently selected date. */\n setValue(value: CalendarDate): void\n}\n\nexport interface RangeCalendarState extends CalendarStateBase {\n /** The currently selected date range. */\n readonly value: RangeValue<DateValue>,\n /** Sets the currently selected date range. */\n setValue(value: RangeValue<DateValue>): void,\n /** Highlights the given date during selection, e.g. by hovering or dragging. */\n highlightDate(date: CalendarDate): void,\n /** The current anchor date that the user clicked on to begin range selection. */\n readonly anchorDate: CalendarDate | null,\n /** Sets the anchor date that the user clicked on to begin range selection. */\n setAnchorDate(date: CalendarDate | null): void,\n /** The currently highlighted date range. */\n readonly highlightedRange: RangeValue<CalendarDate>,\n /** Whether the user is currently dragging over the calendar. */\n readonly isDragging: boolean,\n /** Sets whether the user is dragging over the calendar. */\n setDragging(isDragging: boolean): void\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter, alignEnd, alignStart, constrainStart, constrainValue, isInvalid} from './utils';\nimport {\n Calendar,\n CalendarDate,\n DateDuration,\n GregorianCalendar,\n isSameDay,\n toCalendar,\n toCalendarDate,\n today\n} from '@internationalized/date';\nimport {CalendarProps, DateValue} from '@react-types/calendar';\nimport {CalendarState} from './types';\nimport {useControlledState} from '@react-stately/utils';\nimport {useDateFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef, useState} from 'react';\n\ninterface CalendarStateOptions<T extends DateValue> extends CalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration,\n selectionAlignment?: 'start' | 'center' | 'end'\n}\n\nexport function useCalendarState<T extends DateValue>(props: CalendarStateOptions<T>): CalendarState {\n let defaultFormatter = useDateFormatter();\n let resolvedOptions = useMemo(() => defaultFormatter.resolvedOptions(), [defaultFormatter]);\n let {\n locale,\n createCalendar,\n visibleDuration = {months: 1},\n minValue,\n maxValue,\n selectionAlignment\n } = props;\n\n let calendar = useMemo(() => createCalendar(resolvedOptions.calendar), [createCalendar, resolvedOptions.calendar]);\n\n let [value, setControlledValue] = useControlledState<DateValue>(props.value, props.defaultValue, props.onChange);\n let calendarDateValue = useMemo(() => value ? toCalendar(toCalendarDate(value), calendar) : null, [value, calendar]);\n let timeZone = useMemo(() => value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone, [value, resolvedOptions.timeZone]);\n let focusedCalendarDate = useMemo(() => (\n props.focusedValue\n ? constrainValue(toCalendar(toCalendarDate(props.focusedValue), calendar), minValue, maxValue)\n : undefined\n ), [props.focusedValue, calendar, minValue, maxValue]);\n let defaultFocusedCalendarDate = useMemo(() => (\n constrainValue(\n props.defaultFocusedValue\n ? toCalendar(toCalendarDate(props.defaultFocusedValue), calendar)\n : calendarDateValue || toCalendar(today(timeZone), calendar),\n minValue,\n maxValue\n )\n ), [props.defaultFocusedValue, calendarDateValue, timeZone, calendar, minValue, maxValue]);\n let [focusedDate, setFocusedDate] = useControlledState(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);\n let [startDate, setStartDate] = useState(() => {\n switch (selectionAlignment) {\n case 'start':\n return alignStart(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'end':\n return alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue);\n case 'center':\n default:\n return alignCenter(focusedDate, visibleDuration, locale, minValue, maxValue);\n }\n });\n let [isFocused, setFocused] = useState(props.autoFocus || false);\n\n let endDate = useMemo(() => startDate.add(visibleDuration).subtract({days: 1}), [startDate, visibleDuration]);\n\n // Reset focused date and visible range when calendar changes.\n let lastCalendarIdentifier = useRef(calendar.identifier);\n if (calendar.identifier !== lastCalendarIdentifier.current) {\n let newFocusedDate = toCalendar(focusedDate, calendar);\n setStartDate(alignCenter(newFocusedDate, visibleDuration, locale, minValue, maxValue));\n setFocusedDate(newFocusedDate);\n lastCalendarIdentifier.current = calendar.identifier;\n }\n\n if (isInvalid(focusedDate, minValue, maxValue)) {\n // If the focused date was moved to an invalid value, it can't be focused, so constrain it.\n setFocusedDate(constrainValue(focusedDate, minValue, maxValue));\n } else if (focusedDate.compare(startDate) < 0) {\n setStartDate(alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue));\n } else if (focusedDate.compare(startDate.add(visibleDuration)) >= 0) {\n setStartDate(alignStart(focusedDate, visibleDuration, locale, minValue, maxValue));\n }\n\n // Sets focus to a specific cell date\n function focusCell(date: CalendarDate) {\n date = constrainValue(date, minValue, maxValue);\n setFocusedDate(date);\n }\n\n function setValue(newValue: CalendarDate) {\n if (!props.isDisabled && !props.isReadOnly) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, value?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (value && 'hour' in value) {\n setControlledValue(value.set(newValue));\n } else {\n setControlledValue(newValue);\n }\n }\n }\n\n return {\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n value: calendarDateValue,\n setValue,\n visibleRange: {\n start: startDate,\n end: endDate\n },\n focusedDate,\n timeZone,\n setFocusedDate(date) {\n focusCell(date);\n setFocused(true);\n },\n focusNextDay() {\n focusCell(focusedDate.add({days: 1}));\n },\n focusPreviousDay() {\n focusCell(focusedDate.subtract({days: 1}));\n },\n focusNextRow() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({weeks: 1}));\n }\n },\n focusPreviousRow() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({weeks: 1}));\n }\n },\n focusNextPage() {\n let start = startDate.add(visibleDuration);\n setFocusedDate(constrainValue(focusedDate.add(visibleDuration), minValue, maxValue));\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n },\n focusPreviousPage() {\n let start = startDate.subtract(visibleDuration);\n setFocusedDate(constrainValue(focusedDate.subtract(visibleDuration), minValue, maxValue));\n setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));\n },\n focusPageStart() {\n focusCell(startDate);\n },\n focusPageEnd() {\n focusCell(endDate);\n },\n focusNextSection() {\n if (visibleDuration.days) {\n this.focusNextPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.add({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.add({years: 1}));\n }\n },\n focusPreviousSection() {\n if (visibleDuration.days) {\n this.focusPreviousPage();\n } else if (visibleDuration.weeks) {\n focusCell(focusedDate.subtract({months: 1}));\n } else if (visibleDuration.months || visibleDuration.years) {\n focusCell(focusedDate.subtract({years: 1}));\n }\n },\n selectFocusedDate() {\n setValue(focusedDate);\n },\n selectDate(date) {\n setValue(date);\n },\n isFocused,\n setFocused,\n isInvalid(date) {\n return isInvalid(date, minValue, maxValue);\n },\n isSelected(date) {\n return calendarDateValue != null && isSameDay(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);\n },\n isCellFocused(date) {\n return isFocused && focusedDate && isSameDay(date, focusedDate);\n },\n isCellDisabled(date) {\n return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date, minValue, maxValue);\n },\n isCellUnavailable(date) {\n return props.isDateUnavailable && props.isDateUnavailable(date);\n },\n isPreviousVisibleRangeInvalid() {\n return this.isInvalid(startDate.subtract({days: 1}), minValue, maxValue);\n },\n isNextVisibleRangeInvalid() {\n return this.isInvalid(endDate.add({days: 1}), minValue, maxValue);\n }\n };\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nimport {\n CalendarDate,\n DateDuration,\n maxDate,\n minDate,\n startOfMonth,\n startOfWeek,\n startOfYear,\n toCalendarDate\n} from '@internationalized/date';\nimport {DateValue} from '@react-types/calendar';\n\nexport function isInvalid(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n return (minValue != null && date.compare(minValue) < 0) ||\n (maxValue != null && date.compare(maxValue) > 0);\n}\n\nexport function alignCenter(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let halfDuration: DateDuration = {};\n for (let key in duration) {\n halfDuration[key] = Math.floor(duration[key] / 2);\n if (halfDuration[key] > 0 && duration[key] % 2 === 0) {\n halfDuration[key]--;\n }\n }\n\n let aligned = alignStart(date, duration, locale).subtract(halfDuration);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignStart(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n // align to the start of the largest unit\n let aligned = date;\n if (duration.years) {\n aligned = startOfYear(date);\n } else if (duration.months) {\n aligned = startOfMonth(date);\n } else if (duration.weeks) {\n aligned = startOfWeek(date, locale);\n }\n\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function alignEnd(date: CalendarDate, duration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue) {\n let d = {...duration};\n // subtract 1 from the smallest unit\n if (duration.days) {\n d.days--;\n } else if (duration.weeks) {\n d.weeks--;\n } else if (duration.months) {\n d.months--;\n } else if (duration.years) {\n d.years--;\n }\n\n let aligned = alignStart(date, duration, locale).subtract(d);\n return constrainStart(date, aligned, duration, locale, minValue, maxValue);\n}\n\nexport function constrainStart(\n date: CalendarDate,\n aligned: CalendarDate,\n duration: DateDuration,\n locale: string,\n minValue: DateValue,\n maxValue: DateValue) {\n if (minValue && date.compare(minValue) >= 0) {\n aligned = maxDate(\n aligned,\n alignStart(toCalendarDate(minValue), duration, locale)\n );\n }\n\n if (maxValue && date.compare(maxValue) <= 0) {\n aligned = minDate(\n aligned,\n alignEnd(toCalendarDate(maxValue), duration, locale)\n );\n }\n\n return aligned;\n}\n\nexport function constrainValue(date: CalendarDate, minValue: DateValue, maxValue: DateValue) {\n if (minValue) {\n date = maxDate(date, toCalendarDate(minValue));\n }\n\n if (maxValue) {\n date = minDate(date, toCalendarDate(maxValue));\n }\n\n return date;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {alignCenter, isInvalid} from './utils';\nimport {Calendar, CalendarDate, DateDuration, GregorianCalendar, isEqualDay, maxDate, minDate, toCalendar, toCalendarDate} from '@internationalized/date';\nimport {CalendarState, RangeCalendarState} from './types';\nimport {DateRange, DateValue} from '@react-types/calendar';\nimport {RangeCalendarProps} from '@react-types/calendar';\nimport {RangeValue} from '@react-types/shared';\nimport {useCalendarState} from './useCalendarState';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useRef, useState} from 'react';\n\ninterface RangeCalendarStateOptions<T extends DateValue> extends RangeCalendarProps<T> {\n locale: string,\n createCalendar: (name: string) => Calendar,\n visibleDuration?: DateDuration\n}\n\nexport function useRangeCalendarState<T extends DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState {\n let {value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {months: 1}, minValue, maxValue, ...calendarProps} = props;\n let [value, setValue] = useControlledState<DateRange>(\n valueProp,\n defaultValue || null,\n onChange\n );\n\n let [anchorDate, setAnchorDateState] = useState(null);\n let alignment: 'center' | 'start' = 'center';\n if (value && value.start && value.end) {\n let start = alignCenter(toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);\n let end = start.add(visibleDuration).subtract({days: 1});\n\n if (value.end.compare(end) > 0) {\n alignment = 'start';\n }\n }\n\n // Available range must be stored in a ref so we have access to the updated version immediately in `isInvalid`.\n let availableRangeRef = useRef<RangeValue<DateValue>>(null);\n let [availableRange, setAvailableRange] = useState<RangeValue<DateValue>>(null);\n let min = useMemo(() => maxDate(minValue, availableRange?.start), [minValue, availableRange]);\n let max = useMemo(() => minDate(maxValue, availableRange?.end), [maxValue, availableRange]);\n\n let calendar = useCalendarState({\n ...calendarProps,\n value: value && value.start,\n createCalendar,\n locale,\n visibleDuration,\n minValue: min,\n maxValue: max,\n selectionAlignment: alignment\n });\n\n let updateAvailableRange = (date) => {\n if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {\n availableRangeRef.current = {\n start: nextUnavailableDate(date, calendar, -1),\n end: nextUnavailableDate(date, calendar, 1)\n };\n setAvailableRange(availableRangeRef.current);\n } else {\n availableRangeRef.current = null;\n setAvailableRange(null);\n }\n };\n\n // If the visible range changes, we need to update the available range.\n let lastVisibleRange = useRef(calendar.visibleRange);\n if (!isEqualDay(calendar.visibleRange.start, lastVisibleRange.current.start) || !isEqualDay(calendar.visibleRange.end, lastVisibleRange.current.end)) {\n updateAvailableRange(anchorDate);\n lastVisibleRange.current = calendar.visibleRange;\n }\n\n let setAnchorDate = (date: CalendarDate) => {\n if (date) {\n setAnchorDateState(date);\n updateAvailableRange(date);\n } else {\n setAnchorDateState(null);\n updateAvailableRange(null);\n }\n };\n\n let highlightedRange = anchorDate ? makeRange(anchorDate, calendar.focusedDate) : value && makeRange(value.start, value.end);\n let selectDate = (date: CalendarDate) => {\n if (props.isReadOnly) {\n return;\n }\n\n if (!anchorDate) {\n setAnchorDate(date);\n } else {\n let range = makeRange(anchorDate, date);\n setValue({\n start: convertValue(range.start, value?.start),\n end: convertValue(range.end, value?.end)\n });\n setAnchorDate(null);\n }\n };\n\n let [isDragging, setDragging] = useState(false);\n\n return {\n ...calendar,\n value,\n setValue,\n anchorDate,\n setAnchorDate,\n highlightedRange,\n selectFocusedDate() {\n selectDate(calendar.focusedDate);\n },\n selectDate,\n highlightDate(date) {\n if (anchorDate) {\n calendar.setFocusedDate(date);\n }\n },\n isSelected(date) {\n return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date);\n },\n isInvalid(date) {\n return calendar.isInvalid(date) || isInvalid(date, availableRangeRef.current?.start, availableRangeRef.current?.end);\n },\n isDragging,\n setDragging\n };\n}\n\nfunction makeRange(start: DateValue, end: DateValue): RangeValue<CalendarDate> {\n if (!start || !end) {\n return null;\n }\n\n if (end.compare(start) < 0) {\n [start, end] = [end, start];\n }\n\n return {start: toCalendarDate(start), end: toCalendarDate(end)};\n}\n\nfunction convertValue(newValue: CalendarDate, oldValue: DateValue) {\n // The display calendar should not have any effect on the emitted value.\n // Emit dates in the same calendar as the original value, if any, otherwise gregorian.\n newValue = toCalendar(newValue, oldValue?.calendar || new GregorianCalendar());\n\n // Preserve time if the input value had one.\n if (oldValue && 'hour' in oldValue) {\n return oldValue.set(newValue);\n }\n\n return newValue;\n}\n\nfunction nextUnavailableDate(anchorDate: CalendarDate, state: CalendarState, dir: number) {\n let nextDate = anchorDate.add({days: dir});\n while (\n (dir < 0 ? nextDate.compare(state.visibleRange.start) >= 0 : nextDate.compare(state.visibleRange.end) <= 0) &&\n !state.isCellUnavailable(nextDate)\n ) {\n nextDate = nextDate.add({days: dir});\n }\n\n if (state.isCellUnavailable(nextDate)) {\n return nextDate.add({days: -dir});\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export interface CalendarStateBase {
|
|
|
58
58
|
isCellFocused(date: CalendarDate): boolean;
|
|
59
59
|
/** Returns whether the given date is disabled according to the `minValue, `maxValue`, and `isDisabled` props. */
|
|
60
60
|
isCellDisabled(date: CalendarDate): boolean;
|
|
61
|
+
/** Returns whether the given date is unavailable according to the `isDateUnavailable` prop. */
|
|
62
|
+
isCellUnavailable(date: CalendarDate): boolean;
|
|
61
63
|
/** Returns whether the previous visible date range is allowed to be selected according to the `minValue` prop. */
|
|
62
64
|
isPreviousVisibleRangeInvalid(): boolean;
|
|
63
65
|
/** Returns whether the next visible date range is allowed to be selected according to the `maxValue` prop. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAgBA;IACE,wCAAwC;IACxC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,YAAY,EAAE,WAAW,YAAY,CAAC,CAAC;IAChD,4DAA4D;IAC5D,QAAQ,CAAC,Q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AED,sCAAsC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,0BAA0B,CAAC,CAAC,GAAG,kBAAkB,CA+GlH","sources":["packages/@react-stately/calendar/src/packages/@react-stately/calendar/src/types.ts","packages/@react-stately/calendar/src/packages/@react-stately/calendar/src/utils.ts","packages/@react-stately/calendar/src/packages/@react-stately/calendar/src/useCalendarState.ts","packages/@react-stately/calendar/src/packages/@react-stately/calendar/src/useRangeCalendarState.ts","packages/@react-stately/calendar/src/packages/@react-stately/calendar/src/index.ts","packages/@react-stately/calendar/src/index.ts"],"sourcesContent":[null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './types';\nexport * from './useCalendarState';\nexport * from './useRangeCalendarState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/calendar",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.1474+fe4148bea",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@internationalized/date": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
23
|
-
"@react-stately/utils": "3.0.0-nightly.
|
|
24
|
-
"@react-types/calendar": "3.0.0-nightly.
|
|
25
|
-
"@react-types/datepicker": "3.0.0-nightly.
|
|
26
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
21
|
+
"@internationalized/date": "3.0.0-nightly.3173+fe4148bea",
|
|
22
|
+
"@react-aria/i18n": "3.0.0-nightly.1474+fe4148bea",
|
|
23
|
+
"@react-stately/utils": "3.0.0-nightly.1474+fe4148bea",
|
|
24
|
+
"@react-types/calendar": "3.0.0-nightly.3173+fe4148bea",
|
|
25
|
+
"@react-types/datepicker": "3.0.0-nightly.3173+fe4148bea",
|
|
26
|
+
"@react-types/shared": "3.0.0-nightly.1474+fe4148bea",
|
|
27
27
|
"date-fns": "^1.30.1"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "fe4148beaf7f63a1ea486aecc139747a666f8c3a"
|
|
36
36
|
}
|
package/src/types.ts
CHANGED
|
@@ -71,6 +71,8 @@ export interface CalendarStateBase {
|
|
|
71
71
|
isCellFocused(date: CalendarDate): boolean,
|
|
72
72
|
/** Returns whether the given date is disabled according to the `minValue, `maxValue`, and `isDisabled` props. */
|
|
73
73
|
isCellDisabled(date: CalendarDate): boolean,
|
|
74
|
+
/** Returns whether the given date is unavailable according to the `isDateUnavailable` prop. */
|
|
75
|
+
isCellUnavailable(date: CalendarDate): boolean,
|
|
74
76
|
/** Returns whether the previous visible date range is allowed to be selected according to the `minValue` prop. */
|
|
75
77
|
isPreviousVisibleRangeInvalid(): boolean,
|
|
76
78
|
/** Returns whether the next visible date range is allowed to be selected according to the `maxValue` prop. */
|
package/src/useCalendarState.ts
CHANGED
|
@@ -90,7 +90,10 @@ export function useCalendarState<T extends DateValue>(props: CalendarStateOption
|
|
|
90
90
|
lastCalendarIdentifier.current = calendar.identifier;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
if (focusedDate
|
|
93
|
+
if (isInvalid(focusedDate, minValue, maxValue)) {
|
|
94
|
+
// If the focused date was moved to an invalid value, it can't be focused, so constrain it.
|
|
95
|
+
setFocusedDate(constrainValue(focusedDate, minValue, maxValue));
|
|
96
|
+
} else if (focusedDate.compare(startDate) < 0) {
|
|
94
97
|
setStartDate(alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
95
98
|
} else if (focusedDate.compare(startDate.add(visibleDuration)) >= 0) {
|
|
96
99
|
setStartDate(alignStart(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
@@ -154,13 +157,13 @@ export function useCalendarState<T extends DateValue>(props: CalendarStateOption
|
|
|
154
157
|
},
|
|
155
158
|
focusNextPage() {
|
|
156
159
|
let start = startDate.add(visibleDuration);
|
|
157
|
-
setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
158
160
|
setFocusedDate(constrainValue(focusedDate.add(visibleDuration), minValue, maxValue));
|
|
161
|
+
setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
159
162
|
},
|
|
160
163
|
focusPreviousPage() {
|
|
161
164
|
let start = startDate.subtract(visibleDuration);
|
|
162
|
-
setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
163
165
|
setFocusedDate(constrainValue(focusedDate.subtract(visibleDuration), minValue, maxValue));
|
|
166
|
+
setStartDate(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue));
|
|
164
167
|
},
|
|
165
168
|
focusPageStart() {
|
|
166
169
|
focusCell(startDate);
|
|
@@ -198,19 +201,22 @@ export function useCalendarState<T extends DateValue>(props: CalendarStateOption
|
|
|
198
201
|
return isInvalid(date, minValue, maxValue);
|
|
199
202
|
},
|
|
200
203
|
isSelected(date) {
|
|
201
|
-
return calendarDateValue != null && isSameDay(date, calendarDateValue) && !this.isCellDisabled(date);
|
|
204
|
+
return calendarDateValue != null && isSameDay(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);
|
|
202
205
|
},
|
|
203
206
|
isCellFocused(date) {
|
|
204
207
|
return isFocused && focusedDate && isSameDay(date, focusedDate);
|
|
205
208
|
},
|
|
206
209
|
isCellDisabled(date) {
|
|
207
|
-
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || isInvalid(date, minValue, maxValue)
|
|
210
|
+
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date, minValue, maxValue);
|
|
211
|
+
},
|
|
212
|
+
isCellUnavailable(date) {
|
|
213
|
+
return props.isDateUnavailable && props.isDateUnavailable(date);
|
|
208
214
|
},
|
|
209
215
|
isPreviousVisibleRangeInvalid() {
|
|
210
|
-
return isInvalid(startDate.subtract({days: 1}), minValue, maxValue);
|
|
216
|
+
return this.isInvalid(startDate.subtract({days: 1}), minValue, maxValue);
|
|
211
217
|
},
|
|
212
218
|
isNextVisibleRangeInvalid() {
|
|
213
|
-
return isInvalid(endDate.add({days: 1}), minValue, maxValue);
|
|
219
|
+
return this.isInvalid(endDate.add({days: 1}), minValue, maxValue);
|
|
214
220
|
}
|
|
215
221
|
};
|
|
216
222
|
}
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {alignCenter} from './utils';
|
|
14
|
-
import {Calendar, CalendarDate, DateDuration, GregorianCalendar, toCalendar, toCalendarDate} from '@internationalized/date';
|
|
13
|
+
import {alignCenter, isInvalid} from './utils';
|
|
14
|
+
import {Calendar, CalendarDate, DateDuration, GregorianCalendar, isEqualDay, maxDate, minDate, toCalendar, toCalendarDate} from '@internationalized/date';
|
|
15
|
+
import {CalendarState, RangeCalendarState} from './types';
|
|
15
16
|
import {DateRange, DateValue} from '@react-types/calendar';
|
|
16
17
|
import {RangeCalendarProps} from '@react-types/calendar';
|
|
17
|
-
import {RangeCalendarState} from './types';
|
|
18
18
|
import {RangeValue} from '@react-types/shared';
|
|
19
19
|
import {useCalendarState} from './useCalendarState';
|
|
20
20
|
import {useControlledState} from '@react-stately/utils';
|
|
21
|
-
import {useState} from 'react';
|
|
21
|
+
import {useMemo, useRef, useState} from 'react';
|
|
22
22
|
|
|
23
23
|
interface RangeCalendarStateOptions<T extends DateValue> extends RangeCalendarProps<T> {
|
|
24
24
|
locale: string,
|
|
@@ -30,11 +30,11 @@ export function useRangeCalendarState<T extends DateValue>(props: RangeCalendarS
|
|
|
30
30
|
let {value: valueProp, defaultValue, onChange, createCalendar, locale, visibleDuration = {months: 1}, minValue, maxValue, ...calendarProps} = props;
|
|
31
31
|
let [value, setValue] = useControlledState<DateRange>(
|
|
32
32
|
valueProp,
|
|
33
|
-
defaultValue,
|
|
33
|
+
defaultValue || null,
|
|
34
34
|
onChange
|
|
35
35
|
);
|
|
36
36
|
|
|
37
|
-
let [anchorDate,
|
|
37
|
+
let [anchorDate, setAnchorDateState] = useState(null);
|
|
38
38
|
let alignment: 'center' | 'start' = 'center';
|
|
39
39
|
if (value && value.start && value.end) {
|
|
40
40
|
let start = alignCenter(toCalendarDate(value.start), visibleDuration, locale, minValue, maxValue);
|
|
@@ -45,17 +45,53 @@ export function useRangeCalendarState<T extends DateValue>(props: RangeCalendarS
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// Available range must be stored in a ref so we have access to the updated version immediately in `isInvalid`.
|
|
49
|
+
let availableRangeRef = useRef<RangeValue<DateValue>>(null);
|
|
50
|
+
let [availableRange, setAvailableRange] = useState<RangeValue<DateValue>>(null);
|
|
51
|
+
let min = useMemo(() => maxDate(minValue, availableRange?.start), [minValue, availableRange]);
|
|
52
|
+
let max = useMemo(() => minDate(maxValue, availableRange?.end), [maxValue, availableRange]);
|
|
53
|
+
|
|
48
54
|
let calendar = useCalendarState({
|
|
49
55
|
...calendarProps,
|
|
50
56
|
value: value && value.start,
|
|
51
57
|
createCalendar,
|
|
52
58
|
locale,
|
|
53
59
|
visibleDuration,
|
|
54
|
-
minValue,
|
|
55
|
-
maxValue,
|
|
60
|
+
minValue: min,
|
|
61
|
+
maxValue: max,
|
|
56
62
|
selectionAlignment: alignment
|
|
57
63
|
});
|
|
58
64
|
|
|
65
|
+
let updateAvailableRange = (date) => {
|
|
66
|
+
if (date && props.isDateUnavailable && !props.allowsNonContiguousRanges) {
|
|
67
|
+
availableRangeRef.current = {
|
|
68
|
+
start: nextUnavailableDate(date, calendar, -1),
|
|
69
|
+
end: nextUnavailableDate(date, calendar, 1)
|
|
70
|
+
};
|
|
71
|
+
setAvailableRange(availableRangeRef.current);
|
|
72
|
+
} else {
|
|
73
|
+
availableRangeRef.current = null;
|
|
74
|
+
setAvailableRange(null);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// If the visible range changes, we need to update the available range.
|
|
79
|
+
let lastVisibleRange = useRef(calendar.visibleRange);
|
|
80
|
+
if (!isEqualDay(calendar.visibleRange.start, lastVisibleRange.current.start) || !isEqualDay(calendar.visibleRange.end, lastVisibleRange.current.end)) {
|
|
81
|
+
updateAvailableRange(anchorDate);
|
|
82
|
+
lastVisibleRange.current = calendar.visibleRange;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let setAnchorDate = (date: CalendarDate) => {
|
|
86
|
+
if (date) {
|
|
87
|
+
setAnchorDateState(date);
|
|
88
|
+
updateAvailableRange(date);
|
|
89
|
+
} else {
|
|
90
|
+
setAnchorDateState(null);
|
|
91
|
+
updateAvailableRange(null);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
59
95
|
let highlightedRange = anchorDate ? makeRange(anchorDate, calendar.focusedDate) : value && makeRange(value.start, value.end);
|
|
60
96
|
let selectDate = (date: CalendarDate) => {
|
|
61
97
|
if (props.isReadOnly) {
|
|
@@ -93,7 +129,10 @@ export function useRangeCalendarState<T extends DateValue>(props: RangeCalendarS
|
|
|
93
129
|
}
|
|
94
130
|
},
|
|
95
131
|
isSelected(date) {
|
|
96
|
-
return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date);
|
|
132
|
+
return highlightedRange && date.compare(highlightedRange.start) >= 0 && date.compare(highlightedRange.end) <= 0 && !calendar.isCellDisabled(date) && !calendar.isCellUnavailable(date);
|
|
133
|
+
},
|
|
134
|
+
isInvalid(date) {
|
|
135
|
+
return calendar.isInvalid(date) || isInvalid(date, availableRangeRef.current?.start, availableRangeRef.current?.end);
|
|
97
136
|
},
|
|
98
137
|
isDragging,
|
|
99
138
|
setDragging
|
|
@@ -124,3 +163,19 @@ function convertValue(newValue: CalendarDate, oldValue: DateValue) {
|
|
|
124
163
|
|
|
125
164
|
return newValue;
|
|
126
165
|
}
|
|
166
|
+
|
|
167
|
+
function nextUnavailableDate(anchorDate: CalendarDate, state: CalendarState, dir: number) {
|
|
168
|
+
let nextDate = anchorDate.add({days: dir});
|
|
169
|
+
while (
|
|
170
|
+
(dir < 0 ? nextDate.compare(state.visibleRange.start) >= 0 : nextDate.compare(state.visibleRange.end) <= 0) &&
|
|
171
|
+
!state.isCellUnavailable(nextDate)
|
|
172
|
+
) {
|
|
173
|
+
nextDate = nextDate.add({days: dir});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (state.isCellUnavailable(nextDate)) {
|
|
177
|
+
return nextDate.add({days: -dir});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return null;
|
|
181
|
+
}
|