@react-aria/datepicker 3.16.0 → 3.17.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 +6 -6
- package/dist/main.js +11 -11
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -6
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +12 -0
- package/package.json +16 -28
- package/src/index.ts +13 -11
- package/dist/ar-AE.main.js +0 -21
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -23
- package/dist/ar-AE.module.js +0 -23
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -21
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -23
- package/dist/bg-BG.module.js +0 -23
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -21
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -23
- package/dist/cs-CZ.module.js +0 -23
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -21
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -23
- package/dist/da-DK.module.js +0 -23
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -21
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -23
- package/dist/de-DE.module.js +0 -23
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -21
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -23
- package/dist/el-GR.module.js +0 -23
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -21
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -23
- package/dist/en-US.module.js +0 -23
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -21
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -23
- package/dist/es-ES.module.js +0 -23
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -21
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -23
- package/dist/et-EE.module.js +0 -23
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -21
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -23
- package/dist/fi-FI.module.js +0 -23
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -21
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -23
- package/dist/fr-FR.module.js +0 -23
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -21
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -23
- package/dist/he-IL.module.js +0 -23
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -21
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -23
- package/dist/hr-HR.module.js +0 -23
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -21
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -23
- package/dist/hu-HU.module.js +0 -23
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -21
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -23
- package/dist/it-IT.module.js +0 -23
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -21
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -23
- package/dist/ja-JP.module.js +0 -23
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -21
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -23
- package/dist/ko-KR.module.js +0 -23
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -21
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -23
- package/dist/lt-LT.module.js +0 -23
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -21
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -23
- package/dist/lv-LV.module.js +0 -23
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -21
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -23
- package/dist/nb-NO.module.js +0 -23
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -21
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -23
- package/dist/nl-NL.module.js +0 -23
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -21
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -23
- package/dist/pl-PL.module.js +0 -23
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -21
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -23
- package/dist/pt-BR.module.js +0 -23
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -21
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -23
- package/dist/pt-PT.module.js +0 -23
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -21
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -23
- package/dist/ro-RO.module.js +0 -23
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -21
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -23
- package/dist/ru-RU.module.js +0 -23
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -21
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -23
- package/dist/sk-SK.module.js +0 -23
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -21
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -23
- package/dist/sl-SI.module.js +0 -23
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -21
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -23
- package/dist/sr-SP.module.js +0 -23
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -21
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -23
- package/dist/sv-SE.module.js +0 -23
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -21
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -23
- package/dist/tr-TR.module.js +0 -23
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -108
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -21
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -23
- package/dist/uk-UA.module.js +0 -23
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useDateField.main.js +0 -181
- package/dist/useDateField.main.js.map +0 -1
- package/dist/useDateField.mjs +0 -172
- package/dist/useDateField.module.js +0 -172
- package/dist/useDateField.module.js.map +0 -1
- package/dist/useDatePicker.main.js +0 -178
- package/dist/useDatePicker.main.js.map +0 -1
- package/dist/useDatePicker.mjs +0 -173
- package/dist/useDatePicker.module.js +0 -173
- package/dist/useDatePicker.module.js.map +0 -1
- package/dist/useDatePickerGroup.main.js +0 -121
- package/dist/useDatePickerGroup.main.js.map +0 -1
- package/dist/useDatePickerGroup.mjs +0 -116
- package/dist/useDatePickerGroup.module.js +0 -116
- package/dist/useDatePickerGroup.module.js.map +0 -1
- package/dist/useDateRangePicker.main.js +0 -224
- package/dist/useDateRangePicker.main.js.map +0 -1
- package/dist/useDateRangePicker.mjs +0 -219
- package/dist/useDateRangePicker.module.js +0 -219
- package/dist/useDateRangePicker.module.js.map +0 -1
- package/dist/useDateSegment.main.js +0 -370
- package/dist/useDateSegment.main.js.map +0 -1
- package/dist/useDateSegment.mjs +0 -361
- package/dist/useDateSegment.module.js +0 -361
- package/dist/useDateSegment.module.js.map +0 -1
- package/dist/useDisplayNames.main.js +0 -58
- package/dist/useDisplayNames.main.js.map +0 -1
- package/dist/useDisplayNames.mjs +0 -53
- package/dist/useDisplayNames.module.js +0 -53
- package/dist/useDisplayNames.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -21
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -23
- package/dist/zh-CN.module.js +0 -23
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -21
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -23
- package/dist/zh-TW.module.js +0 -23
- package/dist/zh-TW.module.js.map +0 -1
- package/src/useDateField.ts +0 -213
- package/src/useDatePicker.ts +0 -192
- package/src/useDatePickerGroup.ts +0 -138
- package/src/useDateRangePicker.ts +0 -243
- package/src/useDateSegment.ts +0 -413
- package/src/useDisplayNames.ts +0 -51
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
var $4acc2f407c169e55$exports = require("./useDateField.main.js");
|
|
2
|
-
var $c1905b78f6d2f5bf$exports = require("./intlStrings.main.js");
|
|
3
|
-
var $715562ad3b4cced4$exports = require("./useDatePickerGroup.main.js");
|
|
4
|
-
var $Xt1Bd$reactariafocus = require("@react-aria/focus");
|
|
5
|
-
var $Xt1Bd$reactstatelyform = require("@react-stately/form");
|
|
6
|
-
var $Xt1Bd$reactariautils = require("@react-aria/utils");
|
|
7
|
-
var $Xt1Bd$reactarialabel = require("@react-aria/label");
|
|
8
|
-
var $Xt1Bd$reactariainteractions = require("@react-aria/interactions");
|
|
9
|
-
var $Xt1Bd$reactariai18n = require("@react-aria/i18n");
|
|
10
|
-
var $Xt1Bd$react = require("react");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function $parcel$interopDefault(a) {
|
|
14
|
-
return a && a.__esModule ? a.default : a;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function $parcel$export(e, n, v, s) {
|
|
18
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
$parcel$export(module.exports, "useDateRangePicker", () => $20f695b1b69e6b9e$export$12fd5f0e9f4bb192);
|
|
22
|
-
/*
|
|
23
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
24
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
25
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
26
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
-
*
|
|
28
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
29
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
30
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
31
|
-
* governing permissions and limitations under the License.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function $20f695b1b69e6b9e$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
43
|
-
var _state_value, _state_defaultValue, _state_value1, _state_defaultValue1, _state_dateRange;
|
|
44
|
-
let stringFormatter = (0, $Xt1Bd$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($c1905b78f6d2f5bf$exports))), '@react-aria/datepicker');
|
|
45
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
46
|
-
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $Xt1Bd$reactarialabel.useField)({
|
|
47
|
-
...props,
|
|
48
|
-
labelElementType: 'span',
|
|
49
|
-
isInvalid: isInvalid,
|
|
50
|
-
errorMessage: props.errorMessage || validationErrors
|
|
51
|
-
});
|
|
52
|
-
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
53
|
-
let { locale: locale } = (0, $Xt1Bd$reactariai18n.useLocale)();
|
|
54
|
-
let range = state.formatValue(locale, {
|
|
55
|
-
month: 'long'
|
|
56
|
-
});
|
|
57
|
-
let description = range ? stringFormatter.format('selectedRangeDescription', {
|
|
58
|
-
startDate: range.start,
|
|
59
|
-
endDate: range.end
|
|
60
|
-
}) : '';
|
|
61
|
-
let descProps = (0, $Xt1Bd$reactariautils.useDescription)(description);
|
|
62
|
-
let startFieldProps = {
|
|
63
|
-
'aria-label': stringFormatter.format('startDate'),
|
|
64
|
-
'aria-labelledby': labelledBy
|
|
65
|
-
};
|
|
66
|
-
let endFieldProps = {
|
|
67
|
-
'aria-label': stringFormatter.format('endDate'),
|
|
68
|
-
'aria-labelledby': labelledBy
|
|
69
|
-
};
|
|
70
|
-
let buttonId = (0, $Xt1Bd$reactariautils.useId)();
|
|
71
|
-
let dialogId = (0, $Xt1Bd$reactariautils.useId)();
|
|
72
|
-
let groupProps = (0, $715562ad3b4cced4$exports.useDatePickerGroup)(state, ref);
|
|
73
|
-
let ariaDescribedBy = [
|
|
74
|
-
descProps['aria-describedby'],
|
|
75
|
-
fieldProps['aria-describedby']
|
|
76
|
-
].filter(Boolean).join(' ') || undefined;
|
|
77
|
-
let focusManager = (0, $Xt1Bd$react.useMemo)(()=>(0, $Xt1Bd$reactariafocus.createFocusManager)(ref, {
|
|
78
|
-
// Exclude the button from the focus manager.
|
|
79
|
-
accept: (element)=>element.id !== buttonId
|
|
80
|
-
}), [
|
|
81
|
-
ref,
|
|
82
|
-
buttonId
|
|
83
|
-
]);
|
|
84
|
-
let commonFieldProps = {
|
|
85
|
-
[(0, $4acc2f407c169e55$exports.focusManagerSymbol)]: focusManager,
|
|
86
|
-
[(0, $4acc2f407c169e55$exports.roleSymbol)]: 'presentation',
|
|
87
|
-
'aria-describedby': ariaDescribedBy,
|
|
88
|
-
placeholderValue: props.placeholderValue,
|
|
89
|
-
hideTimeZone: props.hideTimeZone,
|
|
90
|
-
hourCycle: props.hourCycle,
|
|
91
|
-
granularity: props.granularity,
|
|
92
|
-
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
|
|
93
|
-
isDisabled: props.isDisabled,
|
|
94
|
-
isReadOnly: props.isReadOnly,
|
|
95
|
-
isRequired: props.isRequired,
|
|
96
|
-
validationBehavior: props.validationBehavior
|
|
97
|
-
};
|
|
98
|
-
let domProps = (0, $Xt1Bd$reactariautils.filterDOMProps)(props);
|
|
99
|
-
let isFocused = (0, $Xt1Bd$react.useRef)(false);
|
|
100
|
-
let { focusWithinProps: focusWithinProps } = (0, $Xt1Bd$reactariainteractions.useFocusWithin)({
|
|
101
|
-
...props,
|
|
102
|
-
isDisabled: state.isOpen,
|
|
103
|
-
onBlurWithin: (e)=>{
|
|
104
|
-
// Ignore when focus moves into the popover.
|
|
105
|
-
let dialog = document.getElementById(dialogId);
|
|
106
|
-
if (!(0, $Xt1Bd$reactariautils.nodeContains)(dialog, e.relatedTarget)) {
|
|
107
|
-
var _props_onBlur, _props_onFocusChange;
|
|
108
|
-
isFocused.current = false;
|
|
109
|
-
(_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
|
|
110
|
-
(_props_onFocusChange = props.onFocusChange) === null || _props_onFocusChange === void 0 ? void 0 : _props_onFocusChange.call(props, false);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
onFocusWithin: (e)=>{
|
|
114
|
-
if (!isFocused.current) {
|
|
115
|
-
var _props_onFocus, _props_onFocusChange;
|
|
116
|
-
isFocused.current = true;
|
|
117
|
-
(_props_onFocus = props.onFocus) === null || _props_onFocus === void 0 ? void 0 : _props_onFocus.call(props, e);
|
|
118
|
-
(_props_onFocusChange = props.onFocusChange) === null || _props_onFocusChange === void 0 ? void 0 : _props_onFocusChange.call(props, true);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
let startFieldValidation = (0, $Xt1Bd$react.useRef)((0, $Xt1Bd$reactstatelyform.DEFAULT_VALIDATION_RESULT));
|
|
123
|
-
let endFieldValidation = (0, $Xt1Bd$react.useRef)((0, $Xt1Bd$reactstatelyform.DEFAULT_VALIDATION_RESULT));
|
|
124
|
-
var _state_value_start, _state_value_end;
|
|
125
|
-
return {
|
|
126
|
-
groupProps: (0, $Xt1Bd$reactariautils.mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
127
|
-
role: 'group',
|
|
128
|
-
'aria-disabled': props.isDisabled || null,
|
|
129
|
-
'aria-describedby': ariaDescribedBy,
|
|
130
|
-
onKeyDown (e) {
|
|
131
|
-
if (state.isOpen) return;
|
|
132
|
-
if (props.onKeyDown) props.onKeyDown(e);
|
|
133
|
-
},
|
|
134
|
-
onKeyUp (e) {
|
|
135
|
-
if (state.isOpen) return;
|
|
136
|
-
if (props.onKeyUp) props.onKeyUp(e);
|
|
137
|
-
}
|
|
138
|
-
}),
|
|
139
|
-
labelProps: {
|
|
140
|
-
...labelProps,
|
|
141
|
-
onClick: ()=>{
|
|
142
|
-
focusManager.focusFirst();
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
buttonProps: {
|
|
146
|
-
...descProps,
|
|
147
|
-
id: buttonId,
|
|
148
|
-
'aria-haspopup': 'dialog',
|
|
149
|
-
'aria-label': stringFormatter.format('calendar'),
|
|
150
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
151
|
-
'aria-describedby': ariaDescribedBy,
|
|
152
|
-
'aria-expanded': state.isOpen,
|
|
153
|
-
isDisabled: props.isDisabled || props.isReadOnly,
|
|
154
|
-
onPress: ()=>state.setOpen(true)
|
|
155
|
-
},
|
|
156
|
-
dialogProps: {
|
|
157
|
-
id: dialogId,
|
|
158
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
159
|
-
},
|
|
160
|
-
startFieldProps: {
|
|
161
|
-
...startFieldProps,
|
|
162
|
-
...commonFieldProps,
|
|
163
|
-
value: (_state_value_start = (_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.start) !== null && _state_value_start !== void 0 ? _state_value_start : null,
|
|
164
|
-
defaultValue: (_state_defaultValue = state.defaultValue) === null || _state_defaultValue === void 0 ? void 0 : _state_defaultValue.start,
|
|
165
|
-
onChange: (start)=>state.setDateTime('start', start),
|
|
166
|
-
autoFocus: props.autoFocus,
|
|
167
|
-
name: props.startName,
|
|
168
|
-
form: props.form,
|
|
169
|
-
[(0, $Xt1Bd$reactstatelyform.privateValidationStateProp)]: {
|
|
170
|
-
realtimeValidation: state.realtimeValidation,
|
|
171
|
-
displayValidation: state.displayValidation,
|
|
172
|
-
updateValidation (e) {
|
|
173
|
-
startFieldValidation.current = e;
|
|
174
|
-
state.updateValidation((0, $Xt1Bd$reactstatelyform.mergeValidation)(e, endFieldValidation.current));
|
|
175
|
-
},
|
|
176
|
-
resetValidation: state.resetValidation,
|
|
177
|
-
commitValidation: state.commitValidation
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
endFieldProps: {
|
|
181
|
-
...endFieldProps,
|
|
182
|
-
...commonFieldProps,
|
|
183
|
-
value: (_state_value_end = (_state_value1 = state.value) === null || _state_value1 === void 0 ? void 0 : _state_value1.end) !== null && _state_value_end !== void 0 ? _state_value_end : null,
|
|
184
|
-
defaultValue: (_state_defaultValue1 = state.defaultValue) === null || _state_defaultValue1 === void 0 ? void 0 : _state_defaultValue1.end,
|
|
185
|
-
onChange: (end)=>state.setDateTime('end', end),
|
|
186
|
-
name: props.endName,
|
|
187
|
-
form: props.form,
|
|
188
|
-
[(0, $Xt1Bd$reactstatelyform.privateValidationStateProp)]: {
|
|
189
|
-
realtimeValidation: state.realtimeValidation,
|
|
190
|
-
displayValidation: state.displayValidation,
|
|
191
|
-
updateValidation (e) {
|
|
192
|
-
endFieldValidation.current = e;
|
|
193
|
-
state.updateValidation((0, $Xt1Bd$reactstatelyform.mergeValidation)(startFieldValidation.current, e));
|
|
194
|
-
},
|
|
195
|
-
resetValidation: state.resetValidation,
|
|
196
|
-
commitValidation: state.commitValidation
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
descriptionProps: descriptionProps,
|
|
200
|
-
errorMessageProps: errorMessageProps,
|
|
201
|
-
calendarProps: {
|
|
202
|
-
autoFocus: true,
|
|
203
|
-
value: ((_state_dateRange = state.dateRange) === null || _state_dateRange === void 0 ? void 0 : _state_dateRange.start) && state.dateRange.end ? state.dateRange : null,
|
|
204
|
-
onChange: state.setDateRange,
|
|
205
|
-
minValue: props.minValue,
|
|
206
|
-
maxValue: props.maxValue,
|
|
207
|
-
isDisabled: props.isDisabled,
|
|
208
|
-
isReadOnly: props.isReadOnly,
|
|
209
|
-
isDateUnavailable: props.isDateUnavailable,
|
|
210
|
-
allowsNonContiguousRanges: props.allowsNonContiguousRanges,
|
|
211
|
-
defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
|
|
212
|
-
isInvalid: state.isInvalid,
|
|
213
|
-
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
|
|
214
|
-
firstDayOfWeek: props.firstDayOfWeek,
|
|
215
|
-
pageBehavior: props.pageBehavior
|
|
216
|
-
},
|
|
217
|
-
isInvalid: isInvalid,
|
|
218
|
-
validationErrors: validationErrors,
|
|
219
|
-
validationDetails: validationDetails
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
|
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AU,MAAM,QAAQ;YACxB,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU;YAC5B,mBAAmB,MAAM,iBAAiB;YAC1C,2BAA2B,MAAM,yBAAyB;YAC1D,qBAAqB,MAAM,SAAS,GAAG,YAAY,MAAM,gBAAgB;YACzE,WAAW,MAAM,SAAS;YAC1B,cAAc,OAAO,MAAM,YAAY,KAAK,aAAa,MAAM,YAAY,CAAC,MAAM,iBAAiB,IAAK,MAAM,YAAY,IAAI,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC;YAC5K,gBAAgB,MAAM,cAAc;YACpC,cAAc,MAAM,YAAY;QAClC;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/datepicker/src/useDateRangePicker.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\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaDatePickerProps, AriaDateRangePickerProps, DateValue} from '@react-types/datepicker';\nimport {AriaDialogProps} from '@react-types/dialog';\nimport {createFocusManager} from '@react-aria/focus';\nimport {DateRange, RangeCalendarProps} from '@react-types/calendar';\nimport {DateRangePickerState} from '@react-stately/datepicker';\nimport {DEFAULT_VALIDATION_RESULT, mergeValidation, privateValidationStateProp} from '@react-stately/form';\nimport {DOMAttributes, GroupDOMAttributes, KeyboardEvent, RefObject, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, nodeContains, useDescription, useId} from '@react-aria/utils';\nimport {focusManagerSymbol, roleSymbol} from './useDateField';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {useDatePickerGroup} from './useDatePickerGroup';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateRangePickerAria extends ValidationResult {\n /** Props for the date range picker's visible label element, if any. */\n labelProps: DOMAttributes,\n /** Props for the grouping element containing the date fields and button. */\n groupProps: GroupDOMAttributes,\n /** Props for the start date field. */\n startFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the end date field. */\n endFieldProps: AriaDatePickerProps<DateValue>,\n /** Props for the popover trigger button. */\n buttonProps: AriaButtonProps,\n /** Props for the description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the error message element, if any. */\n errorMessageProps: DOMAttributes,\n /** Props for the popover dialog. */\n dialogProps: AriaDialogProps,\n /** Props for the range calendar within the popover dialog. */\n calendarProps: RangeCalendarProps<DateValue>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a date picker component.\n * A date range picker combines two DateFields and a RangeCalendar popover to allow\n * users to enter or select a date and time range.\n */\nexport function useDateRangePicker<T extends DateValue>(props: AriaDateRangePickerProps<T>, state: DateRangePickerState, ref: RefObject<Element | null>): DateRangePickerAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/datepicker');\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;\n\n let {locale} = useLocale();\n let range = state.formatValue(locale, {month: 'long'});\n let description = range ? stringFormatter.format('selectedRangeDescription', {startDate: range.start, endDate: range.end}) : '';\n let descProps = useDescription(description);\n\n let startFieldProps = {\n 'aria-label': stringFormatter.format('startDate'),\n 'aria-labelledby': labelledBy\n };\n\n let endFieldProps = {\n 'aria-label': stringFormatter.format('endDate'),\n 'aria-labelledby': labelledBy\n };\n\n let buttonId = useId();\n let dialogId = useId();\n\n let groupProps = useDatePickerGroup(state, ref);\n\n let ariaDescribedBy = [descProps['aria-describedby'], fieldProps['aria-describedby']].filter(Boolean).join(' ') || undefined;\n let focusManager = useMemo(() => createFocusManager(ref, {\n // Exclude the button from the focus manager.\n accept: element => element.id !== buttonId\n }), [ref, buttonId]);\n\n let commonFieldProps = {\n [focusManagerSymbol]: focusManager,\n [roleSymbol]: 'presentation',\n 'aria-describedby': ariaDescribedBy,\n placeholderValue: props.placeholderValue,\n hideTimeZone: props.hideTimeZone,\n hourCycle: props.hourCycle,\n granularity: props.granularity,\n shouldForceLeadingZeros: props.shouldForceLeadingZeros,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isRequired: props.isRequired,\n validationBehavior: props.validationBehavior\n };\n\n let domProps = filterDOMProps(props);\n\n let isFocused = useRef(false);\n let {focusWithinProps} = useFocusWithin({\n ...props,\n isDisabled: state.isOpen,\n onBlurWithin: e => {\n // Ignore when focus moves into the popover.\n let dialog = document.getElementById(dialogId);\n if (!nodeContains(dialog, e.relatedTarget)) {\n isFocused.current = false;\n props.onBlur?.(e);\n props.onFocusChange?.(false);\n }\n },\n onFocusWithin: e => {\n if (!isFocused.current) {\n isFocused.current = true;\n props.onFocus?.(e);\n props.onFocusChange?.(true);\n }\n }\n });\n\n let startFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let endFieldValidation = useRef(DEFAULT_VALIDATION_RESULT);\n\n return {\n groupProps: mergeProps(domProps, groupProps, fieldProps, descProps, focusWithinProps, {\n role: 'group' as const,\n 'aria-disabled': props.isDisabled || null,\n 'aria-describedby': ariaDescribedBy,\n onKeyDown(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyDown) {\n props.onKeyDown(e);\n }\n },\n onKeyUp(e: KeyboardEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onKeyUp) {\n props.onKeyUp(e);\n }\n }\n }),\n labelProps: {\n ...labelProps,\n onClick: () => {\n focusManager.focusFirst();\n }\n },\n buttonProps: {\n ...descProps,\n id: buttonId,\n 'aria-haspopup': 'dialog',\n 'aria-label': stringFormatter.format('calendar'),\n 'aria-labelledby': `${buttonId} ${labelledBy}`,\n 'aria-describedby': ariaDescribedBy,\n 'aria-expanded': state.isOpen,\n isDisabled: props.isDisabled || props.isReadOnly,\n onPress: () => state.setOpen(true)\n },\n dialogProps: {\n id: dialogId,\n 'aria-labelledby': `${buttonId} ${labelledBy}`\n },\n startFieldProps: {\n ...startFieldProps,\n ...commonFieldProps,\n value: state.value?.start ?? null,\n defaultValue: state.defaultValue?.start,\n onChange: start => state.setDateTime('start', start),\n autoFocus: props.autoFocus,\n name: props.startName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n startFieldValidation.current = e;\n state.updateValidation(mergeValidation(e, endFieldValidation.current));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n endFieldProps: {\n ...endFieldProps,\n ...commonFieldProps,\n value: state.value?.end ?? null,\n defaultValue: state.defaultValue?.end,\n onChange: end => state.setDateTime('end', end),\n name: props.endName,\n form: props.form,\n [privateValidationStateProp]: {\n realtimeValidation: state.realtimeValidation,\n displayValidation: state.displayValidation,\n updateValidation(e) {\n endFieldValidation.current = e;\n state.updateValidation(mergeValidation(startFieldValidation.current, e));\n },\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation\n }\n },\n descriptionProps,\n errorMessageProps,\n calendarProps: {\n autoFocus: true,\n value: state.dateRange?.start && state.dateRange.end ? state.dateRange as DateRange : null,\n onChange: state.setDateRange,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDisabled: props.isDisabled,\n isReadOnly: props.isReadOnly,\n isDateUnavailable: props.isDateUnavailable,\n allowsNonContiguousRanges: props.allowsNonContiguousRanges,\n defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,\n isInvalid: state.isInvalid,\n errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : (props.errorMessage || state.displayValidation.validationErrors.join(' ')),\n firstDayOfWeek: props.firstDayOfWeek,\n pageBehavior: props.pageBehavior\n },\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useDateRangePicker.main.js.map"}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import {focusManagerSymbol as $16f0b7bb276bc17e$export$7b3062cd49e80452, roleSymbol as $16f0b7bb276bc17e$export$300019f83c56d282} from "./useDateField.mjs";
|
|
2
|
-
import $eIQ1H$intlStringsmodulejs from "./intlStrings.mjs";
|
|
3
|
-
import {useDatePickerGroup as $3dfb0f96be0d6a08$export$4a931266a3838b86} from "./useDatePickerGroup.mjs";
|
|
4
|
-
import {createFocusManager as $eIQ1H$createFocusManager} from "@react-aria/focus";
|
|
5
|
-
import {DEFAULT_VALIDATION_RESULT as $eIQ1H$DEFAULT_VALIDATION_RESULT, privateValidationStateProp as $eIQ1H$privateValidationStateProp, mergeValidation as $eIQ1H$mergeValidation} from "@react-stately/form";
|
|
6
|
-
import {useDescription as $eIQ1H$useDescription, useId as $eIQ1H$useId, filterDOMProps as $eIQ1H$filterDOMProps, nodeContains as $eIQ1H$nodeContains, mergeProps as $eIQ1H$mergeProps} from "@react-aria/utils";
|
|
7
|
-
import {useField as $eIQ1H$useField} from "@react-aria/label";
|
|
8
|
-
import {useFocusWithin as $eIQ1H$useFocusWithin} from "@react-aria/interactions";
|
|
9
|
-
import {useLocalizedStringFormatter as $eIQ1H$useLocalizedStringFormatter, useLocale as $eIQ1H$useLocale} from "@react-aria/i18n";
|
|
10
|
-
import {useMemo as $eIQ1H$useMemo, useRef as $eIQ1H$useRef} from "react";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function $parcel$interopDefault(a) {
|
|
14
|
-
return a && a.__esModule ? a.default : a;
|
|
15
|
-
}
|
|
16
|
-
/*
|
|
17
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
18
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
19
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
20
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
-
*
|
|
22
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
23
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
24
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
25
|
-
* governing permissions and limitations under the License.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function $887cac91b7cc8801$export$12fd5f0e9f4bb192(props, state, ref) {
|
|
37
|
-
var _state_value, _state_defaultValue, _state_value1, _state_defaultValue1, _state_dateRange;
|
|
38
|
-
let stringFormatter = (0, $eIQ1H$useLocalizedStringFormatter)((0, ($parcel$interopDefault($eIQ1H$intlStringsmodulejs))), '@react-aria/datepicker');
|
|
39
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
40
|
-
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $eIQ1H$useField)({
|
|
41
|
-
...props,
|
|
42
|
-
labelElementType: 'span',
|
|
43
|
-
isInvalid: isInvalid,
|
|
44
|
-
errorMessage: props.errorMessage || validationErrors
|
|
45
|
-
});
|
|
46
|
-
let labelledBy = fieldProps['aria-labelledby'] || fieldProps.id;
|
|
47
|
-
let { locale: locale } = (0, $eIQ1H$useLocale)();
|
|
48
|
-
let range = state.formatValue(locale, {
|
|
49
|
-
month: 'long'
|
|
50
|
-
});
|
|
51
|
-
let description = range ? stringFormatter.format('selectedRangeDescription', {
|
|
52
|
-
startDate: range.start,
|
|
53
|
-
endDate: range.end
|
|
54
|
-
}) : '';
|
|
55
|
-
let descProps = (0, $eIQ1H$useDescription)(description);
|
|
56
|
-
let startFieldProps = {
|
|
57
|
-
'aria-label': stringFormatter.format('startDate'),
|
|
58
|
-
'aria-labelledby': labelledBy
|
|
59
|
-
};
|
|
60
|
-
let endFieldProps = {
|
|
61
|
-
'aria-label': stringFormatter.format('endDate'),
|
|
62
|
-
'aria-labelledby': labelledBy
|
|
63
|
-
};
|
|
64
|
-
let buttonId = (0, $eIQ1H$useId)();
|
|
65
|
-
let dialogId = (0, $eIQ1H$useId)();
|
|
66
|
-
let groupProps = (0, $3dfb0f96be0d6a08$export$4a931266a3838b86)(state, ref);
|
|
67
|
-
let ariaDescribedBy = [
|
|
68
|
-
descProps['aria-describedby'],
|
|
69
|
-
fieldProps['aria-describedby']
|
|
70
|
-
].filter(Boolean).join(' ') || undefined;
|
|
71
|
-
let focusManager = (0, $eIQ1H$useMemo)(()=>(0, $eIQ1H$createFocusManager)(ref, {
|
|
72
|
-
// Exclude the button from the focus manager.
|
|
73
|
-
accept: (element)=>element.id !== buttonId
|
|
74
|
-
}), [
|
|
75
|
-
ref,
|
|
76
|
-
buttonId
|
|
77
|
-
]);
|
|
78
|
-
let commonFieldProps = {
|
|
79
|
-
[(0, $16f0b7bb276bc17e$export$7b3062cd49e80452)]: focusManager,
|
|
80
|
-
[(0, $16f0b7bb276bc17e$export$300019f83c56d282)]: 'presentation',
|
|
81
|
-
'aria-describedby': ariaDescribedBy,
|
|
82
|
-
placeholderValue: props.placeholderValue,
|
|
83
|
-
hideTimeZone: props.hideTimeZone,
|
|
84
|
-
hourCycle: props.hourCycle,
|
|
85
|
-
granularity: props.granularity,
|
|
86
|
-
shouldForceLeadingZeros: props.shouldForceLeadingZeros,
|
|
87
|
-
isDisabled: props.isDisabled,
|
|
88
|
-
isReadOnly: props.isReadOnly,
|
|
89
|
-
isRequired: props.isRequired,
|
|
90
|
-
validationBehavior: props.validationBehavior
|
|
91
|
-
};
|
|
92
|
-
let domProps = (0, $eIQ1H$filterDOMProps)(props);
|
|
93
|
-
let isFocused = (0, $eIQ1H$useRef)(false);
|
|
94
|
-
let { focusWithinProps: focusWithinProps } = (0, $eIQ1H$useFocusWithin)({
|
|
95
|
-
...props,
|
|
96
|
-
isDisabled: state.isOpen,
|
|
97
|
-
onBlurWithin: (e)=>{
|
|
98
|
-
// Ignore when focus moves into the popover.
|
|
99
|
-
let dialog = document.getElementById(dialogId);
|
|
100
|
-
if (!(0, $eIQ1H$nodeContains)(dialog, e.relatedTarget)) {
|
|
101
|
-
var _props_onBlur, _props_onFocusChange;
|
|
102
|
-
isFocused.current = false;
|
|
103
|
-
(_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
|
|
104
|
-
(_props_onFocusChange = props.onFocusChange) === null || _props_onFocusChange === void 0 ? void 0 : _props_onFocusChange.call(props, false);
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
onFocusWithin: (e)=>{
|
|
108
|
-
if (!isFocused.current) {
|
|
109
|
-
var _props_onFocus, _props_onFocusChange;
|
|
110
|
-
isFocused.current = true;
|
|
111
|
-
(_props_onFocus = props.onFocus) === null || _props_onFocus === void 0 ? void 0 : _props_onFocus.call(props, e);
|
|
112
|
-
(_props_onFocusChange = props.onFocusChange) === null || _props_onFocusChange === void 0 ? void 0 : _props_onFocusChange.call(props, true);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
let startFieldValidation = (0, $eIQ1H$useRef)((0, $eIQ1H$DEFAULT_VALIDATION_RESULT));
|
|
117
|
-
let endFieldValidation = (0, $eIQ1H$useRef)((0, $eIQ1H$DEFAULT_VALIDATION_RESULT));
|
|
118
|
-
var _state_value_start, _state_value_end;
|
|
119
|
-
return {
|
|
120
|
-
groupProps: (0, $eIQ1H$mergeProps)(domProps, groupProps, fieldProps, descProps, focusWithinProps, {
|
|
121
|
-
role: 'group',
|
|
122
|
-
'aria-disabled': props.isDisabled || null,
|
|
123
|
-
'aria-describedby': ariaDescribedBy,
|
|
124
|
-
onKeyDown (e) {
|
|
125
|
-
if (state.isOpen) return;
|
|
126
|
-
if (props.onKeyDown) props.onKeyDown(e);
|
|
127
|
-
},
|
|
128
|
-
onKeyUp (e) {
|
|
129
|
-
if (state.isOpen) return;
|
|
130
|
-
if (props.onKeyUp) props.onKeyUp(e);
|
|
131
|
-
}
|
|
132
|
-
}),
|
|
133
|
-
labelProps: {
|
|
134
|
-
...labelProps,
|
|
135
|
-
onClick: ()=>{
|
|
136
|
-
focusManager.focusFirst();
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
buttonProps: {
|
|
140
|
-
...descProps,
|
|
141
|
-
id: buttonId,
|
|
142
|
-
'aria-haspopup': 'dialog',
|
|
143
|
-
'aria-label': stringFormatter.format('calendar'),
|
|
144
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`,
|
|
145
|
-
'aria-describedby': ariaDescribedBy,
|
|
146
|
-
'aria-expanded': state.isOpen,
|
|
147
|
-
isDisabled: props.isDisabled || props.isReadOnly,
|
|
148
|
-
onPress: ()=>state.setOpen(true)
|
|
149
|
-
},
|
|
150
|
-
dialogProps: {
|
|
151
|
-
id: dialogId,
|
|
152
|
-
'aria-labelledby': `${buttonId} ${labelledBy}`
|
|
153
|
-
},
|
|
154
|
-
startFieldProps: {
|
|
155
|
-
...startFieldProps,
|
|
156
|
-
...commonFieldProps,
|
|
157
|
-
value: (_state_value_start = (_state_value = state.value) === null || _state_value === void 0 ? void 0 : _state_value.start) !== null && _state_value_start !== void 0 ? _state_value_start : null,
|
|
158
|
-
defaultValue: (_state_defaultValue = state.defaultValue) === null || _state_defaultValue === void 0 ? void 0 : _state_defaultValue.start,
|
|
159
|
-
onChange: (start)=>state.setDateTime('start', start),
|
|
160
|
-
autoFocus: props.autoFocus,
|
|
161
|
-
name: props.startName,
|
|
162
|
-
form: props.form,
|
|
163
|
-
[(0, $eIQ1H$privateValidationStateProp)]: {
|
|
164
|
-
realtimeValidation: state.realtimeValidation,
|
|
165
|
-
displayValidation: state.displayValidation,
|
|
166
|
-
updateValidation (e) {
|
|
167
|
-
startFieldValidation.current = e;
|
|
168
|
-
state.updateValidation((0, $eIQ1H$mergeValidation)(e, endFieldValidation.current));
|
|
169
|
-
},
|
|
170
|
-
resetValidation: state.resetValidation,
|
|
171
|
-
commitValidation: state.commitValidation
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
endFieldProps: {
|
|
175
|
-
...endFieldProps,
|
|
176
|
-
...commonFieldProps,
|
|
177
|
-
value: (_state_value_end = (_state_value1 = state.value) === null || _state_value1 === void 0 ? void 0 : _state_value1.end) !== null && _state_value_end !== void 0 ? _state_value_end : null,
|
|
178
|
-
defaultValue: (_state_defaultValue1 = state.defaultValue) === null || _state_defaultValue1 === void 0 ? void 0 : _state_defaultValue1.end,
|
|
179
|
-
onChange: (end)=>state.setDateTime('end', end),
|
|
180
|
-
name: props.endName,
|
|
181
|
-
form: props.form,
|
|
182
|
-
[(0, $eIQ1H$privateValidationStateProp)]: {
|
|
183
|
-
realtimeValidation: state.realtimeValidation,
|
|
184
|
-
displayValidation: state.displayValidation,
|
|
185
|
-
updateValidation (e) {
|
|
186
|
-
endFieldValidation.current = e;
|
|
187
|
-
state.updateValidation((0, $eIQ1H$mergeValidation)(startFieldValidation.current, e));
|
|
188
|
-
},
|
|
189
|
-
resetValidation: state.resetValidation,
|
|
190
|
-
commitValidation: state.commitValidation
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
descriptionProps: descriptionProps,
|
|
194
|
-
errorMessageProps: errorMessageProps,
|
|
195
|
-
calendarProps: {
|
|
196
|
-
autoFocus: true,
|
|
197
|
-
value: ((_state_dateRange = state.dateRange) === null || _state_dateRange === void 0 ? void 0 : _state_dateRange.start) && state.dateRange.end ? state.dateRange : null,
|
|
198
|
-
onChange: state.setDateRange,
|
|
199
|
-
minValue: props.minValue,
|
|
200
|
-
maxValue: props.maxValue,
|
|
201
|
-
isDisabled: props.isDisabled,
|
|
202
|
-
isReadOnly: props.isReadOnly,
|
|
203
|
-
isDateUnavailable: props.isDateUnavailable,
|
|
204
|
-
allowsNonContiguousRanges: props.allowsNonContiguousRanges,
|
|
205
|
-
defaultFocusedValue: state.dateRange ? undefined : props.placeholderValue,
|
|
206
|
-
isInvalid: state.isInvalid,
|
|
207
|
-
errorMessage: typeof props.errorMessage === 'function' ? props.errorMessage(state.displayValidation) : props.errorMessage || state.displayValidation.validationErrors.join(' '),
|
|
208
|
-
firstDayOfWeek: props.firstDayOfWeek,
|
|
209
|
-
pageBehavior: props.pageBehavior
|
|
210
|
-
},
|
|
211
|
-
isInvalid: isInvalid,
|
|
212
|
-
validationErrors: validationErrors,
|
|
213
|
-
validationDetails: validationDetails
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
export {$887cac91b7cc8801$export$12fd5f0e9f4bb192 as useDateRangePicker};
|
|
219
|
-
//# sourceMappingURL=useDateRangePicker.module.js.map
|