@instructure/ui-date-input 11.7.8 → 11.7.9-pr-snapshot-1792147648392
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/CHANGELOG.md +13 -0
- package/es/DateInput/v1/index.js +295 -389
- package/es/DateInput/v1/props.js +40 -26
- package/es/DateInput/v1/styles.js +12 -45
- package/es/DateInput/v2/index.js +192 -275
- package/es/DateInput/v2/props.js +1 -1
- package/es/DateInput2/v1/index.js +188 -267
- package/es/DateInput2/v1/props.js +1 -1
- package/es/exports/a.js +1 -25
- package/es/exports/b.js +1 -25
- package/package.json +18 -24
- package/tsconfig.build.json +0 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/lib/DateInput/v1/index.js +0 -426
- package/lib/DateInput/v1/props.js +0 -31
- package/lib/DateInput/v1/styles.js +0 -52
- package/lib/DateInput/v2/index.js +0 -299
- package/lib/DateInput/v2/props.js +0 -5
- package/lib/DateInput2/v1/index.js +0 -290
- package/lib/DateInput2/v1/props.js +0 -5
- package/lib/exports/a.js +0 -19
- package/lib/exports/b.js +0 -19
- package/lib/package.json +0 -1
package/es/DateInput/v1/props.js
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
const allowedProps = [
|
|
2
|
+
'renderLabel',
|
|
3
|
+
'value',
|
|
4
|
+
'size',
|
|
5
|
+
'placeholder',
|
|
6
|
+
'onChange',
|
|
7
|
+
'onBlur',
|
|
8
|
+
'interaction',
|
|
9
|
+
'isRequired',
|
|
10
|
+
'isInline',
|
|
11
|
+
'assistiveText',
|
|
12
|
+
'layout',
|
|
13
|
+
'width',
|
|
14
|
+
'display',
|
|
15
|
+
'inputRef',
|
|
16
|
+
'messages',
|
|
17
|
+
'placement',
|
|
18
|
+
'isShowingCalendar',
|
|
19
|
+
'onRequestValidateDate',
|
|
20
|
+
'onRequestShowCalendar',
|
|
21
|
+
'onRequestHideCalendar',
|
|
22
|
+
'onRequestSelectNextDay',
|
|
23
|
+
'onRequestSelectPrevDay',
|
|
24
|
+
'onRequestRenderNextMonth',
|
|
25
|
+
'onRequestRenderPrevMonth',
|
|
26
|
+
'renderNavigationLabel',
|
|
27
|
+
'renderWeekdayLabels',
|
|
28
|
+
'renderNextMonthButton',
|
|
29
|
+
'renderPrevMonthButton',
|
|
30
|
+
'children',
|
|
31
|
+
'disabledDates',
|
|
32
|
+
'currentDate',
|
|
33
|
+
'disabledDateErrorMessage',
|
|
34
|
+
'invalidDateErrorMessage',
|
|
35
|
+
'locale',
|
|
36
|
+
'timezone',
|
|
37
|
+
'withYearPicker',
|
|
38
|
+
'selectedLabel'
|
|
39
|
+
];
|
|
40
|
+
export { allowedProps };
|
|
@@ -1,46 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* ---
|
|
27
|
-
* private: true
|
|
28
|
-
* ---
|
|
29
|
-
* Generates the style object from the theme and provided additional information
|
|
30
|
-
* @param _componentTheme The theme variable object.
|
|
31
|
-
* @param props the props of the component, the style is applied to
|
|
32
|
-
* @return The final style object, which will be used in the component
|
|
33
|
-
*/
|
|
34
|
-
const generateStyle = (_componentTheme, props) => {
|
|
35
|
-
return {
|
|
36
|
-
dateInput: {
|
|
37
|
-
label: 'dateInput',
|
|
38
|
-
display: props.display
|
|
39
|
-
},
|
|
40
|
-
assistiveText: {
|
|
41
|
-
label: 'dateInput__assistiveText',
|
|
42
|
-
display: 'none'
|
|
43
|
-
}
|
|
44
|
-
};
|
|
1
|
+
const generateStyle = (_componentTheme, props)=>{
|
|
2
|
+
return {
|
|
3
|
+
dateInput: {
|
|
4
|
+
label: 'dateInput',
|
|
5
|
+
display: props.display
|
|
6
|
+
},
|
|
7
|
+
assistiveText: {
|
|
8
|
+
label: 'dateInput__assistiveText',
|
|
9
|
+
display: 'none'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
45
12
|
};
|
|
46
|
-
export default generateStyle;
|
|
13
|
+
export default generateStyle;
|
package/es/DateInput/v2/index.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
25
2
|
import { useState, useEffect, forwardRef } from 'react';
|
|
26
3
|
import { Calendar } from '@instructure/ui-calendar/latest';
|
|
27
4
|
import { IconButton } from '@instructure/ui-buttons/latest';
|
|
@@ -30,262 +7,202 @@ import { Popover } from '@instructure/ui-popover/latest';
|
|
|
30
7
|
import { TextInput } from '@instructure/ui-text-input/latest';
|
|
31
8
|
import { callRenderProp, passthroughProps, useDeterministicId } from '@instructure/ui-react-utils';
|
|
32
9
|
import { getLocale, getTimezone } from '@instructure/ui-i18n';
|
|
33
|
-
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
34
10
|
function parseLocaleDate(dateString = '', locale, timeZone) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
let index = 0;
|
|
51
|
-
let day, month, year;
|
|
52
|
-
localeDate.forEach(part => {
|
|
53
|
-
if (part.type === 'month') {
|
|
54
|
-
month = parseInt(splitDate[index], 10);
|
|
55
|
-
index++;
|
|
56
|
-
} else if (part.type === 'day') {
|
|
57
|
-
day = parseInt(splitDate[index], 10);
|
|
58
|
-
index++;
|
|
59
|
-
} else if (part.type === 'year') {
|
|
60
|
-
year = parseInt(splitDate[index], 10);
|
|
61
|
-
index++;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// sensible limitations
|
|
66
|
-
if (!year || !month || !day || year < 1000 || year > 9999) return null;
|
|
67
|
-
|
|
68
|
-
// create utc date from year, month (zero indexed) and day
|
|
69
|
-
const date = new Date(Date.UTC(year, month - 1, day));
|
|
70
|
-
|
|
71
|
-
// Format date string in the provided timezone. The locale here is irrelevant, we only care about how to time is adjusted for the timezone.
|
|
72
|
-
const parts = new Intl.DateTimeFormat('en-US', {
|
|
73
|
-
timeZone,
|
|
74
|
-
year: 'numeric',
|
|
75
|
-
month: '2-digit',
|
|
76
|
-
day: '2-digit',
|
|
77
|
-
hour: '2-digit',
|
|
78
|
-
minute: '2-digit',
|
|
79
|
-
second: '2-digit',
|
|
80
|
-
hour12: false
|
|
81
|
-
}).formatToParts(date);
|
|
82
|
-
|
|
83
|
-
// Extract the date and time parts from the formatted string
|
|
84
|
-
const dateStringInTimezone = parts.reduce((acc, part) => {
|
|
85
|
-
return part.type === 'literal' ? acc : {
|
|
86
|
-
...acc,
|
|
87
|
-
[part.type]: part.value
|
|
88
|
-
};
|
|
89
|
-
}, {});
|
|
90
|
-
|
|
91
|
-
// Create a date string in the format 'YYYY-MM-DDTHH:mm:ss'
|
|
92
|
-
const dateInTimezone = `${dateStringInTimezone.year}-${dateStringInTimezone.month}-${dateStringInTimezone.day}T${dateStringInTimezone.hour}:${dateStringInTimezone.minute}:${dateStringInTimezone.second}`;
|
|
93
|
-
|
|
94
|
-
// Calculate time difference for timezone offset
|
|
95
|
-
const timeDiff = new Date(dateInTimezone + 'Z').getTime() - date.getTime();
|
|
96
|
-
const utcTime = new Date(date.getTime() - timeDiff);
|
|
97
|
-
// Return the UTC Date corresponding to the time in the specified timezone
|
|
98
|
-
return utcTime;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
---
|
|
103
|
-
category: components
|
|
104
|
-
---
|
|
105
|
-
**/
|
|
106
|
-
const DateInput = /*#__PURE__*/forwardRef(({
|
|
107
|
-
renderLabel,
|
|
108
|
-
screenReaderLabels,
|
|
109
|
-
isRequired = false,
|
|
110
|
-
interaction = 'enabled',
|
|
111
|
-
isInline = false,
|
|
112
|
-
value,
|
|
113
|
-
messages,
|
|
114
|
-
width,
|
|
115
|
-
onChange,
|
|
116
|
-
onBlur,
|
|
117
|
-
withYearPicker,
|
|
118
|
-
invalidDateErrorMessage,
|
|
119
|
-
locale,
|
|
120
|
-
timezone,
|
|
121
|
-
placeholder,
|
|
122
|
-
dateFormat,
|
|
123
|
-
onRequestValidateDate,
|
|
124
|
-
disabledDates,
|
|
125
|
-
renderCalendarIcon,
|
|
126
|
-
margin,
|
|
127
|
-
inputRef,
|
|
128
|
-
...rest
|
|
129
|
-
}, ref) => {
|
|
130
|
-
const userLocale = locale || getLocale();
|
|
131
|
-
const userTimezone = timezone || getTimezone();
|
|
132
|
-
const [inputMessages, setInputMessages] = useState(messages || []);
|
|
133
|
-
const [showPopover, setShowPopover] = useState(false);
|
|
134
|
-
useEffect(() => {
|
|
135
|
-
// don't set input messages if there is an internal error set already
|
|
136
|
-
if (inputMessages.find(m => m.text === invalidDateErrorMessage)) return;
|
|
137
|
-
setInputMessages(messages || []);
|
|
138
|
-
}, [messages]);
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
const [, utcIsoDate] = parseDate(value);
|
|
141
|
-
// clear error messages if date becomes valid
|
|
142
|
-
if (utcIsoDate || !value) {
|
|
143
|
-
setInputMessages(messages || []);
|
|
144
|
-
}
|
|
145
|
-
}, [value]);
|
|
146
|
-
const parseDate = (dateString = '') => {
|
|
147
|
-
let date = null;
|
|
148
|
-
if (dateFormat) {
|
|
149
|
-
if (typeof dateFormat === 'string') {
|
|
150
|
-
// use dateFormat instead of the user locale
|
|
151
|
-
date = parseLocaleDate(dateString, dateFormat, userTimezone);
|
|
152
|
-
} else if (dateFormat.parser) {
|
|
153
|
-
date = dateFormat.parser(dateString);
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
// no dateFormat prop passed, use locale for formatting
|
|
157
|
-
date = parseLocaleDate(dateString, userLocale, userTimezone);
|
|
158
|
-
}
|
|
159
|
-
return date ? [formatDate(date), date.toISOString()] : ['', ''];
|
|
160
|
-
};
|
|
161
|
-
const formatDate = (date, timeZone = userTimezone) => {
|
|
162
|
-
// use formatter function if provided
|
|
163
|
-
if (typeof dateFormat !== 'string' && dateFormat?.formatter) {
|
|
164
|
-
return dateFormat.formatter(date);
|
|
165
|
-
}
|
|
166
|
-
// if dateFormat set to a locale, use that, otherwise default to the user's locale
|
|
167
|
-
return date.toLocaleDateString(typeof dateFormat === 'string' ? dateFormat : userLocale, {
|
|
168
|
-
timeZone,
|
|
169
|
-
calendar: 'gregory',
|
|
170
|
-
numberingSystem: 'latn'
|
|
11
|
+
const splitDate = dateString.split(/[,.\s/.-]+/).filter(Boolean);
|
|
12
|
+
const localeDate = new Intl.DateTimeFormat(locale).formatToParts(new Date());
|
|
13
|
+
let index = 0;
|
|
14
|
+
let day, month, year;
|
|
15
|
+
localeDate.forEach((part)=>{
|
|
16
|
+
if (part.type === 'month') {
|
|
17
|
+
month = parseInt(splitDate[index], 10);
|
|
18
|
+
index++;
|
|
19
|
+
} else if (part.type === 'day') {
|
|
20
|
+
day = parseInt(splitDate[index], 10);
|
|
21
|
+
index++;
|
|
22
|
+
} else if (part.type === 'year') {
|
|
23
|
+
year = parseInt(splitDate[index], 10);
|
|
24
|
+
index++;
|
|
25
|
+
}
|
|
171
26
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
27
|
+
if (!year || !month || !day || year < 1000 || year > 9999) return null;
|
|
28
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
29
|
+
const parts = new Intl.DateTimeFormat('en-US', {
|
|
30
|
+
timeZone,
|
|
31
|
+
year: 'numeric',
|
|
32
|
+
month: '2-digit',
|
|
33
|
+
day: '2-digit',
|
|
34
|
+
hour: '2-digit',
|
|
35
|
+
minute: '2-digit',
|
|
36
|
+
second: '2-digit',
|
|
37
|
+
hour12: false
|
|
38
|
+
}).formatToParts(date);
|
|
39
|
+
const dateStringInTimezone = parts.reduce((acc, part)=>{
|
|
40
|
+
return part.type === 'literal' ? acc : {
|
|
41
|
+
...acc,
|
|
42
|
+
[part.type]: part.value
|
|
43
|
+
};
|
|
44
|
+
}, {});
|
|
45
|
+
const dateInTimezone = `${dateStringInTimezone.year}-${dateStringInTimezone.month}-${dateStringInTimezone.day}T${dateStringInTimezone.hour}:${dateStringInTimezone.minute}:${dateStringInTimezone.second}`;
|
|
46
|
+
const timeDiff = new Date(dateInTimezone + 'Z').getTime() - date.getTime();
|
|
47
|
+
const utcTime = new Date(date.getTime() - timeDiff);
|
|
48
|
+
return utcTime;
|
|
49
|
+
}
|
|
50
|
+
const DateInput = /*#__PURE__*/ forwardRef(({ renderLabel, screenReaderLabels, isRequired = false, interaction = 'enabled', isInline = false, value, messages, width, onChange, onBlur, withYearPicker, invalidDateErrorMessage, locale, timezone, placeholder, dateFormat, onRequestValidateDate, disabledDates, renderCalendarIcon, margin, inputRef, ...rest }, ref)=>{
|
|
51
|
+
const userLocale = locale || getLocale();
|
|
52
|
+
const userTimezone = timezone || getTimezone();
|
|
53
|
+
const [inputMessages, setInputMessages] = useState(messages || []);
|
|
54
|
+
const [showPopover, setShowPopover] = useState(false);
|
|
55
|
+
useEffect(()=>{
|
|
56
|
+
if (inputMessages.find((m)=>m.text === invalidDateErrorMessage)) return;
|
|
57
|
+
setInputMessages(messages || []);
|
|
58
|
+
}, [
|
|
59
|
+
messages
|
|
60
|
+
]);
|
|
61
|
+
useEffect(()=>{
|
|
62
|
+
const [, utcIsoDate] = parseDate(value);
|
|
63
|
+
if (utcIsoDate || !value) {
|
|
64
|
+
setInputMessages(messages || []);
|
|
65
|
+
}
|
|
66
|
+
}, [
|
|
67
|
+
value
|
|
68
|
+
]);
|
|
69
|
+
const parseDate = (dateString = '')=>{
|
|
70
|
+
let date = null;
|
|
71
|
+
if (dateFormat) {
|
|
72
|
+
if (typeof dateFormat === 'string') {
|
|
73
|
+
date = parseLocaleDate(dateString, dateFormat, userTimezone);
|
|
74
|
+
} else if (dateFormat.parser) {
|
|
75
|
+
date = dateFormat.parser(dateString);
|
|
76
|
+
}
|
|
77
|
+
} else {
|
|
78
|
+
date = parseLocaleDate(dateString, userLocale, userTimezone);
|
|
79
|
+
}
|
|
80
|
+
return date ? [
|
|
81
|
+
formatDate(date),
|
|
82
|
+
date.toISOString()
|
|
83
|
+
] : [
|
|
84
|
+
'',
|
|
85
|
+
''
|
|
86
|
+
];
|
|
87
|
+
};
|
|
88
|
+
const formatDate = (date, timeZone = userTimezone)=>{
|
|
89
|
+
if (typeof dateFormat !== 'string' && dateFormat?.formatter) {
|
|
90
|
+
return dateFormat.formatter(date);
|
|
91
|
+
}
|
|
92
|
+
return date.toLocaleDateString(typeof dateFormat === 'string' ? dateFormat : userLocale, {
|
|
93
|
+
timeZone,
|
|
94
|
+
calendar: 'gregory',
|
|
95
|
+
numberingSystem: 'latn'
|
|
96
|
+
});
|
|
180
97
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
labelId
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
withBorder: false,
|
|
237
|
-
screenReaderLabel: screenReaderLabels.calendarIcon,
|
|
98
|
+
const getDateFormatHint = ()=>{
|
|
99
|
+
const exampleDate = new Date('2024-09-01');
|
|
100
|
+
const formattedDate = formatDate(exampleDate, 'UTC');
|
|
101
|
+
const regex = (n)=>{
|
|
102
|
+
return new RegExp(`(?<!\\d)0*${n}(?!\\d)`, 'g');
|
|
103
|
+
};
|
|
104
|
+
const year = '2024';
|
|
105
|
+
const month = '9';
|
|
106
|
+
const day = '1';
|
|
107
|
+
return formattedDate.replace(regex(year), (match)=>'Y'.repeat(match.length)).replace(regex(month), (match)=>'M'.repeat(match.length)).replace(regex(day), (match)=>'D'.repeat(match.length));
|
|
108
|
+
};
|
|
109
|
+
const handleInputChange = (e, newValue)=>{
|
|
110
|
+
const [, utcIsoDate] = parseDate(newValue);
|
|
111
|
+
onChange?.(e, newValue, utcIsoDate);
|
|
112
|
+
};
|
|
113
|
+
const handleDateSelected = (dateString, _momentDate, e)=>{
|
|
114
|
+
setShowPopover(false);
|
|
115
|
+
const newValue = formatDate(new Date(dateString));
|
|
116
|
+
onChange?.(e, newValue, dateString);
|
|
117
|
+
onRequestValidateDate?.(e, newValue, dateString);
|
|
118
|
+
};
|
|
119
|
+
const handleBlur = (e)=>{
|
|
120
|
+
const [localeDate, utcIsoDate] = parseDate(value);
|
|
121
|
+
if (localeDate) {
|
|
122
|
+
if (localeDate !== value) {
|
|
123
|
+
onChange?.(e, localeDate, utcIsoDate);
|
|
124
|
+
}
|
|
125
|
+
} else if (value && invalidDateErrorMessage) {
|
|
126
|
+
setInputMessages([
|
|
127
|
+
{
|
|
128
|
+
type: 'error',
|
|
129
|
+
text: invalidDateErrorMessage
|
|
130
|
+
}
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
onRequestValidateDate?.(e, value || '', utcIsoDate);
|
|
134
|
+
onBlur?.(e, value || '', utcIsoDate);
|
|
135
|
+
};
|
|
136
|
+
const selectedDate = parseDate(value)[1];
|
|
137
|
+
const labelId = useDeterministicId('TextInput-label')();
|
|
138
|
+
return /*#__PURE__*/ _jsx(TextInput, {
|
|
139
|
+
...passthroughProps(rest),
|
|
140
|
+
ref: ref,
|
|
141
|
+
inputRef: inputRef,
|
|
142
|
+
renderLabel: renderLabel,
|
|
143
|
+
labelId: labelId,
|
|
144
|
+
"aria-labelledby": labelId,
|
|
145
|
+
onChange: handleInputChange,
|
|
146
|
+
onBlur: handleBlur,
|
|
147
|
+
isRequired: isRequired,
|
|
148
|
+
value: value,
|
|
149
|
+
placeholder: placeholder ?? getDateFormatHint(),
|
|
150
|
+
width: width,
|
|
151
|
+
display: isInline ? 'inline-block' : 'block',
|
|
152
|
+
messages: inputMessages,
|
|
238
153
|
interaction: interaction,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
154
|
+
margin: margin,
|
|
155
|
+
renderAfterInput: /*#__PURE__*/ _jsx(Popover, {
|
|
156
|
+
renderTrigger: /*#__PURE__*/ _jsx(IconButton, {
|
|
157
|
+
size: "condensedMedium",
|
|
158
|
+
withBackground: false,
|
|
159
|
+
withBorder: false,
|
|
160
|
+
screenReaderLabel: screenReaderLabels.calendarIcon,
|
|
161
|
+
interaction: interaction,
|
|
162
|
+
children: renderCalendarIcon ? callRenderProp(renderCalendarIcon) : /*#__PURE__*/ _jsx(CalendarInstUIIcon, {
|
|
163
|
+
color: "baseColor"
|
|
164
|
+
})
|
|
165
|
+
}),
|
|
166
|
+
isShowingContent: showPopover,
|
|
167
|
+
onShowContent: ()=>setShowPopover(true),
|
|
168
|
+
onHideContent: ()=>setShowPopover(false),
|
|
169
|
+
on: "click",
|
|
170
|
+
shouldContainFocus: true,
|
|
171
|
+
shouldReturnFocus: true,
|
|
172
|
+
shouldCloseOnDocumentClick: true,
|
|
173
|
+
shouldScrollContent: true,
|
|
174
|
+
screenReaderLabel: screenReaderLabels.datePickerDialog,
|
|
175
|
+
children: /*#__PURE__*/ _jsx(Calendar, {
|
|
176
|
+
withYearPicker: withYearPicker,
|
|
177
|
+
onDateSelected: handleDateSelected,
|
|
178
|
+
selectedDate: selectedDate,
|
|
179
|
+
selectedLabel: screenReaderLabels.selectedLabel,
|
|
180
|
+
disabledDates: disabledDates,
|
|
181
|
+
visibleMonth: selectedDate,
|
|
182
|
+
locale: userLocale,
|
|
183
|
+
timezone: userTimezone,
|
|
184
|
+
renderNextMonthButton: ({ targetMonthSrLabel })=>/*#__PURE__*/ _jsx(IconButton, {
|
|
185
|
+
size: "small",
|
|
186
|
+
withBackground: false,
|
|
187
|
+
withBorder: false,
|
|
188
|
+
renderIcon: /*#__PURE__*/ _jsx(ChevronRightInstUIIcon, {
|
|
189
|
+
color: "baseColor"
|
|
190
|
+
}),
|
|
191
|
+
screenReaderLabel: `${screenReaderLabels.nextMonthButton}, ${targetMonthSrLabel}`
|
|
192
|
+
}),
|
|
193
|
+
renderPrevMonthButton: ({ targetMonthSrLabel })=>/*#__PURE__*/ _jsx(IconButton, {
|
|
194
|
+
size: "small",
|
|
195
|
+
withBackground: false,
|
|
196
|
+
withBorder: false,
|
|
197
|
+
renderIcon: /*#__PURE__*/ _jsx(ChevronLeftInstUIIcon, {
|
|
198
|
+
color: "baseColor"
|
|
199
|
+
}),
|
|
200
|
+
screenReaderLabel: `${screenReaderLabels.prevMonthButton}, ${targetMonthSrLabel}`
|
|
201
|
+
})
|
|
202
|
+
})
|
|
282
203
|
})
|
|
283
|
-
|
|
284
|
-
})
|
|
285
|
-
});
|
|
204
|
+
});
|
|
286
205
|
});
|
|
287
|
-
|
|
288
|
-
// TODO this is probably needed?
|
|
289
206
|
DateInput.displayName = 'DateInput';
|
|
290
207
|
export default DateInput;
|
|
291
|
-
export { DateInput };
|
|
208
|
+
export { DateInput };
|
package/es/DateInput/v2/props.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { };
|