@react-stately/calendar 3.9.2 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +3 -3
- package/dist/main.js +4 -4
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -3
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +4 -0
- package/package.json +17 -16
- package/src/index.ts +4 -5
- package/dist/types.d.ts +0 -165
- package/dist/types.d.ts.map +0 -1
- package/dist/useCalendarState.main.js +0 -300
- package/dist/useCalendarState.main.js.map +0 -1
- package/dist/useCalendarState.mjs +0 -295
- package/dist/useCalendarState.module.js +0 -295
- package/dist/useCalendarState.module.js.map +0 -1
- package/dist/useRangeCalendarState.main.js +0 -182
- package/dist/useRangeCalendarState.main.js.map +0 -1
- package/dist/useRangeCalendarState.mjs +0 -177
- package/dist/useRangeCalendarState.module.js +0 -177
- package/dist/useRangeCalendarState.module.js.map +0 -1
- package/dist/utils.main.js +0 -90
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -79
- package/dist/utils.module.js +0 -79
- package/dist/utils.module.js.map +0 -1
- package/src/types.ts +0 -126
- package/src/useCalendarState.ts +0 -373
- package/src/useRangeCalendarState.ts +0 -236
- package/src/utils.ts +0 -134
package/dist/import.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {useCalendarState as $
|
|
2
|
-
import {useRangeCalendarState as $
|
|
1
|
+
import {useCalendarState as $39c906b017afad51$re_export$useCalendarState} from "react-stately/useCalendarState";
|
|
2
|
+
import {useRangeCalendarState as $39c906b017afad51$re_export$useRangeCalendarState} from "react-stately/useRangeCalendarState";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,5 +15,5 @@ import {useRangeCalendarState as $9a36b6ba2fb1a7c5$export$9a987164d97ecc90} from
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
export {$
|
|
18
|
+
export {$39c906b017afad51$re_export$useCalendarState as useCalendarState, $39c906b017afad51$re_export$useRangeCalendarState as useRangeCalendarState};
|
|
19
19
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
1
|
+
var $6M98w$reactstatelyuseCalendarState = require("react-stately/useCalendarState");
|
|
2
|
+
var $6M98w$reactstatelyuseRangeCalendarState = require("react-stately/useRangeCalendarState");
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
function $parcel$export(e, n, v, s) {
|
|
6
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
$parcel$export(module.exports, "useCalendarState", ()
|
|
10
|
-
$parcel$export(module.exports, "useRangeCalendarState", ()
|
|
9
|
+
$parcel$export(module.exports, "useCalendarState", function () { return $6M98w$reactstatelyuseCalendarState.useCalendarState; });
|
|
10
|
+
$parcel$export(module.exports, "useRangeCalendarState", function () { return $6M98w$reactstatelyuseRangeCalendarState.useRangeCalendarState; });
|
|
11
11
|
/*
|
|
12
12
|
* Copyright 2020 Adobe. All rights reserved.
|
|
13
13
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/calendar/src/index.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 {useCalendarState} from '
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/calendar/src/index.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 {useCalendarState} from 'react-stately/useCalendarState';\n\nexport {useRangeCalendarState} from 'react-stately/useRangeCalendarState';\nexport type {CalendarProps, CalendarStateOptions, CalendarPropsBase, CalendarState, DateValue, PageBehavior} from 'react-stately/useCalendarState';\nexport type {DateRange, RangeCalendarProps, RangeCalendarState, RangeCalendarStateOptions} from 'react-stately/useRangeCalendarState';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {useCalendarState as $
|
|
2
|
-
import {useRangeCalendarState as $
|
|
1
|
+
import {useCalendarState as $39c906b017afad51$re_export$useCalendarState} from "react-stately/useCalendarState";
|
|
2
|
+
import {useRangeCalendarState as $39c906b017afad51$re_export$useRangeCalendarState} from "react-stately/useRangeCalendarState";
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -15,5 +15,5 @@ import {useRangeCalendarState as $9a36b6ba2fb1a7c5$export$9a987164d97ecc90} from
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
export {$
|
|
18
|
+
export {$39c906b017afad51$re_export$useCalendarState as useCalendarState, $39c906b017afad51$re_export$useRangeCalendarState as useRangeCalendarState};
|
|
19
19
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/calendar/src/index.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 {useCalendarState} from '
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/calendar/src/index.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 {useCalendarState} from 'react-stately/useCalendarState';\n\nexport {useRangeCalendarState} from 'react-stately/useRangeCalendarState';\nexport type {CalendarProps, CalendarStateOptions, CalendarPropsBase, CalendarState, DateValue, PageBehavior} from 'react-stately/useCalendarState';\nexport type {DateRange, RangeCalendarProps, RangeCalendarState, RangeCalendarStateOptions} from 'react-stately/useRangeCalendarState';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useCalendarState } from 'react-stately/useCalendarState';
|
|
2
|
+
export { useRangeCalendarState } from 'react-stately/useRangeCalendarState';
|
|
3
|
+
export type { CalendarProps, CalendarStateOptions, CalendarPropsBase, CalendarState, DateValue, PageBehavior } from 'react-stately/useCalendarState';
|
|
4
|
+
export type { DateRange, RangeCalendarProps, RangeCalendarState, RangeCalendarStateOptions } from 'react-stately/useRangeCalendarState';
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/calendar",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"./dist/types.d.ts",
|
|
12
|
-
"./
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/types/src/index.d.ts",
|
|
12
|
+
"import": "./dist/import.mjs",
|
|
13
|
+
"require": "./dist/main.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
|
-
"types": "dist/types.d.ts",
|
|
17
|
+
"types": "dist/types/src/index.d.ts",
|
|
18
18
|
"source": "src/index.ts",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
@@ -26,17 +26,18 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"@react-types/calendar": "^3.8.2",
|
|
32
|
-
"@react-types/shared": "^3.33.0",
|
|
33
|
-
"@swc/helpers": "^0.5.0"
|
|
29
|
+
"@swc/helpers": "^0.5.0",
|
|
30
|
+
"react-stately": "3.46.0"
|
|
34
31
|
},
|
|
35
32
|
"peerDependencies": {
|
|
36
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
33
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
34
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
37
35
|
},
|
|
38
36
|
"publishConfig": {
|
|
39
37
|
"access": "public"
|
|
40
38
|
},
|
|
41
|
-
"
|
|
39
|
+
"targets": {
|
|
40
|
+
"types": false
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
|
|
42
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export {useCalendarState} from '
|
|
14
|
-
export {useRangeCalendarState} from './useRangeCalendarState';
|
|
13
|
+
export {useCalendarState} from 'react-stately/useCalendarState';
|
|
15
14
|
|
|
16
|
-
export
|
|
17
|
-
export type {
|
|
18
|
-
export type {
|
|
15
|
+
export {useRangeCalendarState} from 'react-stately/useRangeCalendarState';
|
|
16
|
+
export type {CalendarProps, CalendarStateOptions, CalendarPropsBase, CalendarState, DateValue, PageBehavior} from 'react-stately/useCalendarState';
|
|
17
|
+
export type {DateRange, RangeCalendarProps, RangeCalendarState, RangeCalendarStateOptions} from 'react-stately/useRangeCalendarState';
|
package/dist/types.d.ts
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { CalendarDate, Calendar, CalendarIdentifier, DateDuration } from "@internationalized/date";
|
|
2
|
-
import { DateValue, CalendarProps, RangeCalendarProps } from "@react-types/calendar";
|
|
3
|
-
import { RangeValue, ValidationState } from "@react-types/shared";
|
|
4
|
-
interface CalendarStateBase {
|
|
5
|
-
/** Whether the calendar is disabled. */
|
|
6
|
-
readonly isDisabled: boolean;
|
|
7
|
-
/** Whether the calendar is in a read only state. */
|
|
8
|
-
readonly isReadOnly: boolean;
|
|
9
|
-
/** The date range that is currently visible in the calendar. */
|
|
10
|
-
readonly visibleRange: RangeValue<CalendarDate>;
|
|
11
|
-
/** The minimum allowed date that a user may select. */
|
|
12
|
-
readonly minValue?: DateValue | null;
|
|
13
|
-
/** The maximum allowed date that a user may select. */
|
|
14
|
-
readonly maxValue?: DateValue | null;
|
|
15
|
-
/** The time zone of the dates currently being displayed. */
|
|
16
|
-
readonly timeZone: string;
|
|
17
|
-
/**
|
|
18
|
-
* The current validation state of the selected value.
|
|
19
|
-
* @deprecated Use `isValueInvalid` instead.
|
|
20
|
-
*/
|
|
21
|
-
readonly validationState: ValidationState | null;
|
|
22
|
-
/** Whether the calendar is invalid. */
|
|
23
|
-
readonly isValueInvalid: boolean;
|
|
24
|
-
/** The currently focused date. */
|
|
25
|
-
readonly focusedDate: CalendarDate;
|
|
26
|
-
/** Sets the focused date. */
|
|
27
|
-
setFocusedDate(value: CalendarDate): void;
|
|
28
|
-
/** Moves focus to the next calendar date. */
|
|
29
|
-
focusNextDay(): void;
|
|
30
|
-
/** Moves focus to the previous calendar date. */
|
|
31
|
-
focusPreviousDay(): void;
|
|
32
|
-
/** Moves focus to the next row of dates, e.g. the next week. */
|
|
33
|
-
focusNextRow(): void;
|
|
34
|
-
/** Moves focus to the previous row of dates, e.g. the previous work. */
|
|
35
|
-
focusPreviousRow(): void;
|
|
36
|
-
/** Moves focus to the next page of dates, e.g. the next month if one month is visible. */
|
|
37
|
-
focusNextPage(): void;
|
|
38
|
-
/** Moves focus to the previous page of dates, e.g. the previous month if one month is visible. */
|
|
39
|
-
focusPreviousPage(): void;
|
|
40
|
-
/** Moves focus to the start of the current section of dates, e.g. the start of the current month. */
|
|
41
|
-
focusSectionStart(): void;
|
|
42
|
-
/** Moves focus to the end of the current section of dates, e.g. the end of the current month month. */
|
|
43
|
-
focusSectionEnd(): void;
|
|
44
|
-
/**
|
|
45
|
-
* Moves focus to the next section of dates based on what is currently displayed.
|
|
46
|
-
* By default, focus is moved by one of the currently displayed unit. For example, if
|
|
47
|
-
* one or more months are displayed, then focus is moved forward by one month.
|
|
48
|
-
* If the `larger` option is `true`, the focus is moved by the next larger unit than
|
|
49
|
-
* the one displayed. For example, if months are displayed, then focus moves to the next year.
|
|
50
|
-
*/
|
|
51
|
-
focusNextSection(larger?: boolean): void;
|
|
52
|
-
/**
|
|
53
|
-
* Moves focus to the previous section of dates based on what is currently displayed.
|
|
54
|
-
* By default, focus is moved by one of the currently displayed unit. For example, if
|
|
55
|
-
* one or more months are displayed, then focus is moved backward by one month.
|
|
56
|
-
* If the `larger` option is `true`, the focus is moved by the next larger unit than
|
|
57
|
-
* the one displayed. For example, if months are displayed, then focus moves to the previous year.
|
|
58
|
-
*/
|
|
59
|
-
focusPreviousSection(larger?: boolean): void;
|
|
60
|
-
/** Selects the currently focused date. */
|
|
61
|
-
selectFocusedDate(): void;
|
|
62
|
-
/** Selects the given date. */
|
|
63
|
-
selectDate(date: CalendarDate): void;
|
|
64
|
-
/** Whether focus is currently within the calendar. */
|
|
65
|
-
readonly isFocused: boolean;
|
|
66
|
-
/** Sets whether focus is currently within the calendar. */
|
|
67
|
-
setFocused(value: boolean): void;
|
|
68
|
-
/** Returns whether the given date is invalid according to the `minValue` and `maxValue` props. */
|
|
69
|
-
isInvalid(date: CalendarDate): boolean;
|
|
70
|
-
/** Returns whether the given date is currently selected. */
|
|
71
|
-
isSelected(date: CalendarDate): boolean;
|
|
72
|
-
/** Returns whether the given date is currently focused. */
|
|
73
|
-
isCellFocused(date: CalendarDate): boolean;
|
|
74
|
-
/** Returns whether the given date is disabled according to the `minValue, `maxValue`, and `isDisabled` props. */
|
|
75
|
-
isCellDisabled(date: CalendarDate): boolean;
|
|
76
|
-
/** Returns whether the given date is unavailable according to the `isDateUnavailable` prop. */
|
|
77
|
-
isCellUnavailable(date: CalendarDate): boolean;
|
|
78
|
-
/** Returns whether the previous visible date range is allowed to be selected according to the `minValue` prop. */
|
|
79
|
-
isPreviousVisibleRangeInvalid(): boolean;
|
|
80
|
-
/** Returns whether the next visible date range is allowed to be selected according to the `maxValue` prop. */
|
|
81
|
-
isNextVisibleRangeInvalid(): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Returns an array of dates in the week index counted from the provided start date, or the first visible date if not given.
|
|
84
|
-
* The returned array always has 7 elements, but may include null if the date does not exist according to the calendar system.
|
|
85
|
-
*/
|
|
86
|
-
getDatesInWeek(weekIndex: number, startDate?: CalendarDate): Array<CalendarDate | null>;
|
|
87
|
-
}
|
|
88
|
-
export interface CalendarState extends CalendarStateBase {
|
|
89
|
-
/** The currently selected date. */
|
|
90
|
-
readonly value: CalendarDate | null;
|
|
91
|
-
/** Sets the currently selected date. */
|
|
92
|
-
setValue(value: CalendarDate | null): void;
|
|
93
|
-
}
|
|
94
|
-
export interface RangeCalendarState<T extends DateValue = DateValue> extends CalendarStateBase {
|
|
95
|
-
/** The currently selected date range. */
|
|
96
|
-
readonly value: RangeValue<T> | null;
|
|
97
|
-
/** Sets the currently selected date range. */
|
|
98
|
-
setValue(value: RangeValue<T> | null): void;
|
|
99
|
-
/** Highlights the given date during selection, e.g. by hovering or dragging. */
|
|
100
|
-
highlightDate(date: CalendarDate): void;
|
|
101
|
-
/** The current anchor date that the user clicked on to begin range selection. */
|
|
102
|
-
readonly anchorDate: CalendarDate | null;
|
|
103
|
-
/** Sets the anchor date that the user clicked on to begin range selection. */
|
|
104
|
-
setAnchorDate(date: CalendarDate | null): void;
|
|
105
|
-
/** The currently highlighted date range. */
|
|
106
|
-
readonly highlightedRange: RangeValue<CalendarDate> | null;
|
|
107
|
-
/** Whether the user is currently dragging over the calendar. */
|
|
108
|
-
readonly isDragging: boolean;
|
|
109
|
-
/** Sets whether the user is dragging over the calendar. */
|
|
110
|
-
setDragging(isDragging: boolean): void;
|
|
111
|
-
}
|
|
112
|
-
export interface CalendarStateOptions<T extends DateValue = DateValue> extends CalendarProps<T> {
|
|
113
|
-
/** The locale to display and edit the value according to. */
|
|
114
|
-
locale: string;
|
|
115
|
-
/**
|
|
116
|
-
* A function that creates a [Calendar](../internationalized/date/Calendar.html)
|
|
117
|
-
* object for a given calendar identifier. Such a function may be imported from the
|
|
118
|
-
* `@internationalized/date` package, or manually implemented to include support for
|
|
119
|
-
* only certain calendars.
|
|
120
|
-
*/
|
|
121
|
-
createCalendar: (name: CalendarIdentifier) => Calendar;
|
|
122
|
-
/**
|
|
123
|
-
* The amount of days that will be displayed at once. This affects how pagination works.
|
|
124
|
-
* @default {months: 1}
|
|
125
|
-
*/
|
|
126
|
-
visibleDuration?: DateDuration;
|
|
127
|
-
/**
|
|
128
|
-
* Determines the alignment of the visible months on initial render based on the current selection or current date if there is no selection.
|
|
129
|
-
* @default 'center'
|
|
130
|
-
*/
|
|
131
|
-
selectionAlignment?: 'start' | 'center' | 'end';
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Provides state management for a calendar component.
|
|
135
|
-
* A calendar displays one or more date grids and allows users to select a single date.
|
|
136
|
-
*/
|
|
137
|
-
export function useCalendarState<T extends DateValue = DateValue>(props: CalendarStateOptions<T>): CalendarState;
|
|
138
|
-
export interface RangeCalendarStateOptions<T extends DateValue = DateValue> extends RangeCalendarProps<T> {
|
|
139
|
-
/** The locale to display and edit the value according to. */
|
|
140
|
-
locale: string;
|
|
141
|
-
/**
|
|
142
|
-
* A function that creates a [Calendar](../internationalized/date/Calendar.html)
|
|
143
|
-
* object for a given calendar identifier. Such a function may be imported from the
|
|
144
|
-
* `@internationalized/date` package, or manually implemented to include support for
|
|
145
|
-
* only certain calendars.
|
|
146
|
-
*/
|
|
147
|
-
createCalendar: (name: CalendarIdentifier) => Calendar;
|
|
148
|
-
/**
|
|
149
|
-
* The amount of days that will be displayed at once. This affects how pagination works.
|
|
150
|
-
* @default {months: 1}
|
|
151
|
-
*/
|
|
152
|
-
visibleDuration?: DateDuration;
|
|
153
|
-
/**
|
|
154
|
-
* Determines the alignment of the visible months on initial render based on the current selection or current date if there is no selection.
|
|
155
|
-
* @default 'center'
|
|
156
|
-
*/
|
|
157
|
-
selectionAlignment?: 'start' | 'center' | 'end';
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Provides state management for a range calendar component.
|
|
161
|
-
* A range calendar displays one or more date grids and allows users to select a contiguous range of dates.
|
|
162
|
-
*/
|
|
163
|
-
export function useRangeCalendarState<T extends DateValue = DateValue>(props: RangeCalendarStateOptions<T>): RangeCalendarState<T>;
|
|
164
|
-
|
|
165
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"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","sources":["packages/@react-stately/calendar/src/packages/@react-stately/calendar/src/utils.ts","packages/@react-stately/calendar/src/packages/@react-stately/calendar/src/types.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 {useCalendarState} from './useCalendarState';\nexport {useRangeCalendarState} from './useRangeCalendarState';\n\nexport type {CalendarStateOptions} from './useCalendarState';\nexport type {RangeCalendarStateOptions} from './useRangeCalendarState';\nexport type {CalendarState, RangeCalendarState} from './types'; \n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
var $4301262d71f567b9$exports = require("./utils.main.js");
|
|
2
|
-
var $cpRwL$internationalizeddate = require("@internationalized/date");
|
|
3
|
-
var $cpRwL$reactstatelyutils = require("@react-stately/utils");
|
|
4
|
-
var $cpRwL$react = require("react");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function $parcel$export(e, n, v, s) {
|
|
8
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
$parcel$export(module.exports, "useCalendarState", () => $6adad0c8536fc209$export$6d095e787d2b5e1f);
|
|
12
|
-
/*
|
|
13
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
14
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
16
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
*
|
|
18
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
19
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
20
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
21
|
-
* governing permissions and limitations under the License.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
function $6adad0c8536fc209$export$6d095e787d2b5e1f(props) {
|
|
27
|
-
let defaultFormatter = (0, $cpRwL$react.useMemo)(()=>new (0, $cpRwL$internationalizeddate.DateFormatter)(props.locale), [
|
|
28
|
-
props.locale
|
|
29
|
-
]);
|
|
30
|
-
let resolvedOptions = (0, $cpRwL$react.useMemo)(()=>defaultFormatter.resolvedOptions(), [
|
|
31
|
-
defaultFormatter
|
|
32
|
-
]);
|
|
33
|
-
let { locale: locale, createCalendar: createCalendar, visibleDuration: visibleDuration = {
|
|
34
|
-
months: 1
|
|
35
|
-
}, minValue: minValue, maxValue: maxValue, selectionAlignment: selectionAlignment, isDateUnavailable: isDateUnavailable, pageBehavior: pageBehavior = 'visible', firstDayOfWeek: firstDayOfWeek } = props;
|
|
36
|
-
let calendar = (0, $cpRwL$react.useMemo)(()=>createCalendar(resolvedOptions.calendar), [
|
|
37
|
-
createCalendar,
|
|
38
|
-
resolvedOptions.calendar
|
|
39
|
-
]);
|
|
40
|
-
var _props_defaultValue;
|
|
41
|
-
let [value, setControlledValue] = (0, $cpRwL$reactstatelyutils.useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
42
|
-
let calendarDateValue = (0, $cpRwL$react.useMemo)(()=>value ? (0, $cpRwL$internationalizeddate.toCalendar)((0, $cpRwL$internationalizeddate.toCalendarDate)(value), calendar) : null, [
|
|
43
|
-
value,
|
|
44
|
-
calendar
|
|
45
|
-
]);
|
|
46
|
-
let timeZone = (0, $cpRwL$react.useMemo)(()=>value && 'timeZone' in value ? value.timeZone : resolvedOptions.timeZone, [
|
|
47
|
-
value,
|
|
48
|
-
resolvedOptions.timeZone
|
|
49
|
-
]);
|
|
50
|
-
let focusedCalendarDate = (0, $cpRwL$react.useMemo)(()=>props.focusedValue ? (0, $4301262d71f567b9$exports.constrainValue)((0, $cpRwL$internationalizeddate.toCalendar)((0, $cpRwL$internationalizeddate.toCalendarDate)(props.focusedValue), calendar), minValue, maxValue) : undefined, [
|
|
51
|
-
props.focusedValue,
|
|
52
|
-
calendar,
|
|
53
|
-
minValue,
|
|
54
|
-
maxValue
|
|
55
|
-
]);
|
|
56
|
-
let defaultFocusedCalendarDate = (0, $cpRwL$react.useMemo)(()=>(0, $4301262d71f567b9$exports.constrainValue)(props.defaultFocusedValue ? (0, $cpRwL$internationalizeddate.toCalendar)((0, $cpRwL$internationalizeddate.toCalendarDate)(props.defaultFocusedValue), calendar) : calendarDateValue || (0, $cpRwL$internationalizeddate.toCalendar)((0, $cpRwL$internationalizeddate.today)(timeZone), calendar), minValue, maxValue), [
|
|
57
|
-
props.defaultFocusedValue,
|
|
58
|
-
calendarDateValue,
|
|
59
|
-
timeZone,
|
|
60
|
-
calendar,
|
|
61
|
-
minValue,
|
|
62
|
-
maxValue
|
|
63
|
-
]);
|
|
64
|
-
let [focusedDate, setFocusedDate] = (0, $cpRwL$reactstatelyutils.useControlledState)(focusedCalendarDate, defaultFocusedCalendarDate, props.onFocusChange);
|
|
65
|
-
let [startDate, setStartDate] = (0, $cpRwL$react.useState)(()=>{
|
|
66
|
-
switch(selectionAlignment){
|
|
67
|
-
case 'start':
|
|
68
|
-
return (0, $4301262d71f567b9$exports.alignStart)(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
69
|
-
case 'end':
|
|
70
|
-
return (0, $4301262d71f567b9$exports.alignEnd)(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
71
|
-
case 'center':
|
|
72
|
-
default:
|
|
73
|
-
return (0, $4301262d71f567b9$exports.alignCenter)(focusedDate, visibleDuration, locale, minValue, maxValue);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
let [isFocused, setFocused] = (0, $cpRwL$react.useState)(props.autoFocus || false);
|
|
77
|
-
let endDate = (0, $cpRwL$react.useMemo)(()=>{
|
|
78
|
-
let duration = {
|
|
79
|
-
...visibleDuration
|
|
80
|
-
};
|
|
81
|
-
if (duration.days) duration.days--;
|
|
82
|
-
else duration.days = -1;
|
|
83
|
-
return startDate.add(duration);
|
|
84
|
-
}, [
|
|
85
|
-
startDate,
|
|
86
|
-
visibleDuration
|
|
87
|
-
]);
|
|
88
|
-
// Reset focused date and visible range when calendar changes.
|
|
89
|
-
let [lastCalendar, setLastCalendar] = (0, $cpRwL$react.useState)(calendar);
|
|
90
|
-
if (!(0, $cpRwL$internationalizeddate.isEqualCalendar)(calendar, lastCalendar)) {
|
|
91
|
-
let newFocusedDate = (0, $cpRwL$internationalizeddate.toCalendar)(focusedDate, calendar);
|
|
92
|
-
setStartDate((0, $4301262d71f567b9$exports.alignCenter)(newFocusedDate, visibleDuration, locale, minValue, maxValue));
|
|
93
|
-
setFocusedDate(newFocusedDate);
|
|
94
|
-
setLastCalendar(calendar);
|
|
95
|
-
}
|
|
96
|
-
if ((0, $4301262d71f567b9$exports.isInvalid)(focusedDate, minValue, maxValue)) // If the focused date was moved to an invalid value, it can't be focused, so constrain it.
|
|
97
|
-
setFocusedDate((0, $4301262d71f567b9$exports.constrainValue)(focusedDate, minValue, maxValue));
|
|
98
|
-
else if (focusedDate.compare(startDate) < 0) setStartDate((0, $4301262d71f567b9$exports.alignEnd)(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
99
|
-
else if (focusedDate.compare(endDate) > 0) setStartDate((0, $4301262d71f567b9$exports.alignStart)(focusedDate, visibleDuration, locale, minValue, maxValue));
|
|
100
|
-
// Sets focus to a specific cell date
|
|
101
|
-
function focusCell(date) {
|
|
102
|
-
date = (0, $4301262d71f567b9$exports.constrainValue)(date, minValue, maxValue);
|
|
103
|
-
setFocusedDate(date);
|
|
104
|
-
}
|
|
105
|
-
function setValue(newValue) {
|
|
106
|
-
if (!props.isDisabled && !props.isReadOnly) {
|
|
107
|
-
let localValue = newValue;
|
|
108
|
-
if (localValue === null) {
|
|
109
|
-
setControlledValue(null);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
localValue = (0, $4301262d71f567b9$exports.constrainValue)(localValue, minValue, maxValue);
|
|
113
|
-
localValue = (0, $4301262d71f567b9$exports.previousAvailableDate)(localValue, startDate, isDateUnavailable);
|
|
114
|
-
if (!localValue) return;
|
|
115
|
-
// The display calendar should not have any effect on the emitted value.
|
|
116
|
-
// Emit dates in the same calendar as the original value, if any, otherwise gregorian.
|
|
117
|
-
localValue = (0, $cpRwL$internationalizeddate.toCalendar)(localValue, (value === null || value === void 0 ? void 0 : value.calendar) || new (0, $cpRwL$internationalizeddate.GregorianCalendar)());
|
|
118
|
-
// Preserve time if the input value had one.
|
|
119
|
-
if (value && 'hour' in value) setControlledValue(value.set(localValue));
|
|
120
|
-
else setControlledValue(localValue);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
let isUnavailable = (0, $cpRwL$react.useMemo)(()=>{
|
|
124
|
-
if (!calendarDateValue) return false;
|
|
125
|
-
if (isDateUnavailable && isDateUnavailable(calendarDateValue)) return true;
|
|
126
|
-
return (0, $4301262d71f567b9$exports.isInvalid)(calendarDateValue, minValue, maxValue);
|
|
127
|
-
}, [
|
|
128
|
-
calendarDateValue,
|
|
129
|
-
isDateUnavailable,
|
|
130
|
-
minValue,
|
|
131
|
-
maxValue
|
|
132
|
-
]);
|
|
133
|
-
let isValueInvalid = props.isInvalid || props.validationState === 'invalid' || isUnavailable;
|
|
134
|
-
let validationState = isValueInvalid ? 'invalid' : null;
|
|
135
|
-
let pageDuration = (0, $cpRwL$react.useMemo)(()=>{
|
|
136
|
-
if (pageBehavior === 'visible') return visibleDuration;
|
|
137
|
-
return $6adad0c8536fc209$var$unitDuration(visibleDuration);
|
|
138
|
-
}, [
|
|
139
|
-
pageBehavior,
|
|
140
|
-
visibleDuration
|
|
141
|
-
]);
|
|
142
|
-
var _props_isDisabled, _props_isReadOnly;
|
|
143
|
-
return {
|
|
144
|
-
isDisabled: (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : false,
|
|
145
|
-
isReadOnly: (_props_isReadOnly = props.isReadOnly) !== null && _props_isReadOnly !== void 0 ? _props_isReadOnly : false,
|
|
146
|
-
value: calendarDateValue,
|
|
147
|
-
setValue: setValue,
|
|
148
|
-
visibleRange: {
|
|
149
|
-
start: startDate,
|
|
150
|
-
end: endDate
|
|
151
|
-
},
|
|
152
|
-
minValue: minValue,
|
|
153
|
-
maxValue: maxValue,
|
|
154
|
-
focusedDate: focusedDate,
|
|
155
|
-
timeZone: timeZone,
|
|
156
|
-
validationState: validationState,
|
|
157
|
-
isValueInvalid: isValueInvalid,
|
|
158
|
-
setFocusedDate (date) {
|
|
159
|
-
focusCell(date);
|
|
160
|
-
setFocused(true);
|
|
161
|
-
},
|
|
162
|
-
focusNextDay () {
|
|
163
|
-
focusCell(focusedDate.add({
|
|
164
|
-
days: 1
|
|
165
|
-
}));
|
|
166
|
-
},
|
|
167
|
-
focusPreviousDay () {
|
|
168
|
-
focusCell(focusedDate.subtract({
|
|
169
|
-
days: 1
|
|
170
|
-
}));
|
|
171
|
-
},
|
|
172
|
-
focusNextRow () {
|
|
173
|
-
if (visibleDuration.days) this.focusNextPage();
|
|
174
|
-
else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) focusCell(focusedDate.add({
|
|
175
|
-
weeks: 1
|
|
176
|
-
}));
|
|
177
|
-
},
|
|
178
|
-
focusPreviousRow () {
|
|
179
|
-
if (visibleDuration.days) this.focusPreviousPage();
|
|
180
|
-
else if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) focusCell(focusedDate.subtract({
|
|
181
|
-
weeks: 1
|
|
182
|
-
}));
|
|
183
|
-
},
|
|
184
|
-
focusNextPage () {
|
|
185
|
-
let start = startDate.add(pageDuration);
|
|
186
|
-
setFocusedDate((0, $4301262d71f567b9$exports.constrainValue)(focusedDate.add(pageDuration), minValue, maxValue));
|
|
187
|
-
setStartDate((0, $4301262d71f567b9$exports.alignStart)((0, $4301262d71f567b9$exports.constrainStart)(focusedDate, start, pageDuration, locale, minValue, maxValue), pageDuration, locale));
|
|
188
|
-
},
|
|
189
|
-
focusPreviousPage () {
|
|
190
|
-
let start = startDate.subtract(pageDuration);
|
|
191
|
-
setFocusedDate((0, $4301262d71f567b9$exports.constrainValue)(focusedDate.subtract(pageDuration), minValue, maxValue));
|
|
192
|
-
setStartDate((0, $4301262d71f567b9$exports.alignStart)((0, $4301262d71f567b9$exports.constrainStart)(focusedDate, start, pageDuration, locale, minValue, maxValue), pageDuration, locale));
|
|
193
|
-
},
|
|
194
|
-
focusSectionStart () {
|
|
195
|
-
if (visibleDuration.days) focusCell(startDate);
|
|
196
|
-
else if (visibleDuration.weeks) focusCell((0, $cpRwL$internationalizeddate.startOfWeek)(focusedDate, locale));
|
|
197
|
-
else if (visibleDuration.months || visibleDuration.years) focusCell((0, $cpRwL$internationalizeddate.startOfMonth)(focusedDate));
|
|
198
|
-
},
|
|
199
|
-
focusSectionEnd () {
|
|
200
|
-
if (visibleDuration.days) focusCell(endDate);
|
|
201
|
-
else if (visibleDuration.weeks) focusCell((0, $cpRwL$internationalizeddate.endOfWeek)(focusedDate, locale));
|
|
202
|
-
else if (visibleDuration.months || visibleDuration.years) focusCell((0, $cpRwL$internationalizeddate.endOfMonth)(focusedDate));
|
|
203
|
-
},
|
|
204
|
-
focusNextSection (larger) {
|
|
205
|
-
if (!larger && !visibleDuration.days) {
|
|
206
|
-
focusCell(focusedDate.add($6adad0c8536fc209$var$unitDuration(visibleDuration)));
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (visibleDuration.days) this.focusNextPage();
|
|
210
|
-
else if (visibleDuration.weeks) focusCell(focusedDate.add({
|
|
211
|
-
months: 1
|
|
212
|
-
}));
|
|
213
|
-
else if (visibleDuration.months || visibleDuration.years) focusCell(focusedDate.add({
|
|
214
|
-
years: 1
|
|
215
|
-
}));
|
|
216
|
-
},
|
|
217
|
-
focusPreviousSection (larger) {
|
|
218
|
-
if (!larger && !visibleDuration.days) {
|
|
219
|
-
focusCell(focusedDate.subtract($6adad0c8536fc209$var$unitDuration(visibleDuration)));
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
if (visibleDuration.days) this.focusPreviousPage();
|
|
223
|
-
else if (visibleDuration.weeks) focusCell(focusedDate.subtract({
|
|
224
|
-
months: 1
|
|
225
|
-
}));
|
|
226
|
-
else if (visibleDuration.months || visibleDuration.years) focusCell(focusedDate.subtract({
|
|
227
|
-
years: 1
|
|
228
|
-
}));
|
|
229
|
-
},
|
|
230
|
-
selectFocusedDate () {
|
|
231
|
-
if (!(isDateUnavailable && isDateUnavailable(focusedDate))) setValue(focusedDate);
|
|
232
|
-
},
|
|
233
|
-
selectDate (date) {
|
|
234
|
-
setValue(date);
|
|
235
|
-
},
|
|
236
|
-
isFocused: isFocused,
|
|
237
|
-
setFocused: setFocused,
|
|
238
|
-
isInvalid (date) {
|
|
239
|
-
return (0, $4301262d71f567b9$exports.isInvalid)(date, minValue, maxValue);
|
|
240
|
-
},
|
|
241
|
-
isSelected (date) {
|
|
242
|
-
return calendarDateValue != null && (0, $cpRwL$internationalizeddate.isSameDay)(date, calendarDateValue) && !this.isCellDisabled(date) && !this.isCellUnavailable(date);
|
|
243
|
-
},
|
|
244
|
-
isCellFocused (date) {
|
|
245
|
-
return isFocused && focusedDate && (0, $cpRwL$internationalizeddate.isSameDay)(date, focusedDate);
|
|
246
|
-
},
|
|
247
|
-
isCellDisabled (date) {
|
|
248
|
-
return props.isDisabled || date.compare(startDate) < 0 || date.compare(endDate) > 0 || this.isInvalid(date);
|
|
249
|
-
},
|
|
250
|
-
isCellUnavailable (date) {
|
|
251
|
-
return props.isDateUnavailable ? props.isDateUnavailable(date) : false;
|
|
252
|
-
},
|
|
253
|
-
isPreviousVisibleRangeInvalid () {
|
|
254
|
-
let prev = startDate.subtract({
|
|
255
|
-
days: 1
|
|
256
|
-
});
|
|
257
|
-
return (0, $cpRwL$internationalizeddate.isSameDay)(prev, startDate) || this.isInvalid(prev);
|
|
258
|
-
},
|
|
259
|
-
isNextVisibleRangeInvalid () {
|
|
260
|
-
// Adding may return the same date if we reached the end of time
|
|
261
|
-
// according to the calendar system (e.g. 9999-12-31).
|
|
262
|
-
let next = endDate.add({
|
|
263
|
-
days: 1
|
|
264
|
-
});
|
|
265
|
-
return (0, $cpRwL$internationalizeddate.isSameDay)(next, endDate) || this.isInvalid(next);
|
|
266
|
-
},
|
|
267
|
-
getDatesInWeek (weekIndex, from = startDate) {
|
|
268
|
-
let date = from.add({
|
|
269
|
-
weeks: weekIndex
|
|
270
|
-
});
|
|
271
|
-
let dates = [];
|
|
272
|
-
date = (0, $cpRwL$internationalizeddate.startOfWeek)(date, locale, firstDayOfWeek);
|
|
273
|
-
// startOfWeek will clamp dates within the calendar system's valid range, which may
|
|
274
|
-
// start in the middle of a week. In this case, add null placeholders.
|
|
275
|
-
let dayOfWeek = (0, $cpRwL$internationalizeddate.getDayOfWeek)(date, locale, firstDayOfWeek);
|
|
276
|
-
for(let i = 0; i < dayOfWeek; i++)dates.push(null);
|
|
277
|
-
while(dates.length < 7){
|
|
278
|
-
dates.push(date);
|
|
279
|
-
let nextDate = date.add({
|
|
280
|
-
days: 1
|
|
281
|
-
});
|
|
282
|
-
if ((0, $cpRwL$internationalizeddate.isSameDay)(date, nextDate)) break;
|
|
283
|
-
date = nextDate;
|
|
284
|
-
}
|
|
285
|
-
// Add null placeholders if at the end of the calendar system.
|
|
286
|
-
while(dates.length < 7)dates.push(null);
|
|
287
|
-
return dates;
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
function $6adad0c8536fc209$var$unitDuration(duration) {
|
|
292
|
-
let unit = {
|
|
293
|
-
...duration
|
|
294
|
-
};
|
|
295
|
-
for(let key in duration)unit[key] = 1;
|
|
296
|
-
return unit;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
//# sourceMappingURL=useCalendarState.main.js.map
|