@instructure/ui-date-time-input 11.7.3-snapshot-7 → 11.7.3-snapshot-26
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 +5 -2
- package/es/DateTimeInput/v1/index.js +197 -201
- package/lib/DateTimeInput/v1/index.js +199 -203
- package/package.json +15 -15
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -19,7 +19,6 @@ var _IconArrowOpenStartSolid = require("@instructure/ui-icons/lib/generated/Icon
|
|
|
19
19
|
var _props = require("./props");
|
|
20
20
|
var _console = require("@instructure/console");
|
|
21
21
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
22
|
-
var _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
23
22
|
/*
|
|
24
23
|
* The MIT License (MIT)
|
|
25
24
|
*
|
|
@@ -43,174 +42,46 @@ var _DateTimeInput, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
|
|
|
43
42
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
44
43
|
* SOFTWARE.
|
|
45
44
|
*/
|
|
45
|
+
|
|
46
46
|
/**
|
|
47
47
|
---
|
|
48
48
|
category: components
|
|
49
49
|
---
|
|
50
|
-
**/
|
|
51
|
-
|
|
50
|
+
**/class DateTimeInput extends _react.Component {
|
|
51
|
+
static displayName = "DateTimeInput";
|
|
52
|
+
// extra verbose localized date and time
|
|
53
|
+
static DEFAULT_MESSAGE_FORMAT = 'LLLL';
|
|
54
|
+
static allowedProps = _props.allowedProps;
|
|
55
|
+
static defaultProps = {
|
|
56
|
+
layout: 'inline',
|
|
57
|
+
colSpacing: 'medium',
|
|
58
|
+
rowSpacing: 'small',
|
|
59
|
+
timeStep: 30,
|
|
60
|
+
showMessages: true,
|
|
61
|
+
messageFormat: DateTimeInput.DEFAULT_MESSAGE_FORMAT,
|
|
62
|
+
isRequired: false,
|
|
63
|
+
dateFormat: 'LL',
|
|
64
|
+
// Localized date with full month, e.g. "August 6, 2014"
|
|
65
|
+
allowNonStepInput: false
|
|
66
|
+
};
|
|
67
|
+
static contextType = _ApplyLocaleContext.ApplyLocaleContext;
|
|
68
|
+
ref = null; // This is used by Tooltip for positioning
|
|
69
|
+
|
|
70
|
+
handleRef = el => {
|
|
71
|
+
this.ref = el;
|
|
72
|
+
};
|
|
52
73
|
constructor(props) {
|
|
53
74
|
super(props);
|
|
54
75
|
// State needs to be calculated because render could be called before
|
|
55
76
|
// componentDidMount()
|
|
56
|
-
this.ref = null;
|
|
57
|
-
// This is used by Tooltip for positioning
|
|
58
|
-
this.handleRef = el => {
|
|
59
|
-
this.ref = el;
|
|
60
|
-
};
|
|
61
|
-
this.reset = () => this.setState(this.recalculateState());
|
|
62
|
-
// Called when the user enters text into dateInput
|
|
63
|
-
this.handleDateTextChange = (_event, date) => {
|
|
64
|
-
const dateParsed = this.tryParseDate(date.value);
|
|
65
|
-
this.setState({
|
|
66
|
-
dateInputText: date.value,
|
|
67
|
-
dateInputTextChanged: true,
|
|
68
|
-
calendarSelectedDate: dateParsed ? dateParsed : void 0,
|
|
69
|
-
renderedDate: dateParsed ? dateParsed.clone() : _DateTime.DateTime.now(this.locale(), this.timezone())
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
// date is returned es a ISO string, like 2021-09-14T22:00:00.000Z
|
|
73
|
-
this.handleDayClick = (event, {
|
|
74
|
-
date
|
|
75
|
-
}) => {
|
|
76
|
-
const dateParsed = _DateTime.DateTime.parse(date, this.locale(), this.timezone());
|
|
77
|
-
this.updateStateBasedOnDateInput(dateParsed, event);
|
|
78
|
-
};
|
|
79
|
-
this.handleHideCalendar = event => {
|
|
80
|
-
// prevent event pooling https://reactjs.org/docs/legacy-event-pooling.html
|
|
81
|
-
// Remove if React 16 is no longer supported
|
|
82
|
-
event.persist();
|
|
83
|
-
// timeout is needed here because handleDayClick could be called in the same
|
|
84
|
-
// frame, and it updates calendarSelectedDate which is read in here.
|
|
85
|
-
setTimeout(() => {
|
|
86
|
-
if (event.key === 'Enter') {
|
|
87
|
-
// user pressed enter, use the selected value in the calendar
|
|
88
|
-
this.updateStateBasedOnDateInput(this.state.calendarSelectedDate, event);
|
|
89
|
-
} else {
|
|
90
|
-
// user clicked outside/tabbed away/pressed esc, try to use the value in dateInputText
|
|
91
|
-
const dateParsed = this.tryParseDate(this.state.dateInputText);
|
|
92
|
-
this.updateStateBasedOnDateInput(dateParsed, event);
|
|
93
|
-
}
|
|
94
|
-
this.setState({
|
|
95
|
-
isShowingCalendar: false,
|
|
96
|
-
dateInputTextChanged: false
|
|
97
|
-
});
|
|
98
|
-
}, 0);
|
|
99
|
-
};
|
|
100
|
-
this.updateStateBasedOnTimeSelect = (event, option) => {
|
|
101
|
-
// this.state.iso is undefined if date is invalid or not set.
|
|
102
|
-
// in this case recalculate with the dateInput's text which will result in
|
|
103
|
-
// an empty valid date (if isRequired is false) or an invalid date.
|
|
104
|
-
const newValue = this.state.iso ? option.value : this.state.dateInputText;
|
|
105
|
-
const newState = this.recalculateState(newValue, true, false);
|
|
106
|
-
this.changeStateIfNeeded(newState, event);
|
|
107
|
-
this.setState({
|
|
108
|
-
timeSelectValue: option.value
|
|
109
|
-
});
|
|
110
|
-
};
|
|
111
|
-
this.changeStateIfNeeded = (newState, e) => {
|
|
112
|
-
const dateStr = newState.dateInputText;
|
|
113
|
-
if (this.props.isRequired && !newState.iso || dateStr && dateStr.length > 0 && !newState.iso) {
|
|
114
|
-
const text = typeof this.props.invalidDateTimeMessage === 'function' ? this.props.invalidDateTimeMessage(dateStr ? dateStr : '') : this.props.invalidDateTimeMessage;
|
|
115
|
-
// eslint-disable-next-line no-param-reassign
|
|
116
|
-
newState.message = {
|
|
117
|
-
text: text,
|
|
118
|
-
type: 'error'
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
if (this.areDifferentDates(this.state.iso, newState.iso)) {
|
|
122
|
-
if (typeof this.props.onChange === 'function') {
|
|
123
|
-
var _newState$iso;
|
|
124
|
-
const newDate = (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString();
|
|
125
|
-
// Timeout is needed here because users might change value in the
|
|
126
|
-
// onChange event lister, which might not execute properly
|
|
127
|
-
setTimeout(() => {
|
|
128
|
-
var _this$props$onChange, _this$props;
|
|
129
|
-
(_this$props$onChange = (_this$props = this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props, e, newDate);
|
|
130
|
-
}, 0);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
this.setState(newState);
|
|
134
|
-
};
|
|
135
|
-
this.areDifferentDates = (d1, d2) => {
|
|
136
|
-
if (!d1 && !d2) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
return !d1 || !d2 || !d1.isSame(d2);
|
|
140
|
-
};
|
|
141
|
-
this.handleBlur = e => {
|
|
142
|
-
// when TABbing from the DateInput to TimeInput or visa-versa, the blur
|
|
143
|
-
// happens on the target before the relatedTarget gets focus.
|
|
144
|
-
// The timeout gives it a moment for that to happen
|
|
145
|
-
if (typeof this.props.onBlur === 'function') {
|
|
146
|
-
setTimeout(() => {
|
|
147
|
-
var _this$props$onBlur, _this$props2;
|
|
148
|
-
(_this$props$onBlur = (_this$props2 = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props2, e);
|
|
149
|
-
}, 0);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
this.handleShowCalendar = _event => {
|
|
153
|
-
this.setState({
|
|
154
|
-
isShowingCalendar: true
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
this.handleSelectNextDay = _event => {
|
|
158
|
-
let toAlter;
|
|
159
|
-
if (this.state.calendarSelectedDate) {
|
|
160
|
-
toAlter = this.state.calendarSelectedDate.clone();
|
|
161
|
-
} else if (this.state.iso) {
|
|
162
|
-
toAlter = this.state.iso.clone();
|
|
163
|
-
} else {
|
|
164
|
-
toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
|
|
165
|
-
}
|
|
166
|
-
toAlter.add({
|
|
167
|
-
days: 1
|
|
168
|
-
});
|
|
169
|
-
this.setState({
|
|
170
|
-
calendarSelectedDate: toAlter,
|
|
171
|
-
renderedDate: toAlter.clone()
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
this.handleSelectPrevDay = _event => {
|
|
175
|
-
let toAlter;
|
|
176
|
-
if (this.state.calendarSelectedDate) {
|
|
177
|
-
toAlter = this.state.calendarSelectedDate.clone();
|
|
178
|
-
} else if (this.state.iso) {
|
|
179
|
-
toAlter = this.state.iso.clone();
|
|
180
|
-
} else {
|
|
181
|
-
toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
|
|
182
|
-
}
|
|
183
|
-
toAlter.subtract({
|
|
184
|
-
days: 1
|
|
185
|
-
});
|
|
186
|
-
this.setState({
|
|
187
|
-
calendarSelectedDate: toAlter,
|
|
188
|
-
renderedDate: toAlter.clone()
|
|
189
|
-
});
|
|
190
|
-
};
|
|
191
|
-
this.handleRenderNextMonth = _event => {
|
|
192
|
-
this.setState({
|
|
193
|
-
renderedDate: this.state.renderedDate.clone().add({
|
|
194
|
-
months: 1
|
|
195
|
-
})
|
|
196
|
-
});
|
|
197
|
-
};
|
|
198
|
-
this.handleRenderPrevMonth = _event => {
|
|
199
|
-
this.setState({
|
|
200
|
-
renderedDate: this.state.renderedDate.clone().subtract({
|
|
201
|
-
months: 1
|
|
202
|
-
})
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
77
|
this.state = this.recalculateState(props.value || props.defaultValue);
|
|
206
78
|
}
|
|
207
79
|
componentDidMount() {
|
|
208
|
-
var _this$props$reset, _this$props3;
|
|
209
80
|
// we'll need to recalculate the state because the context value is
|
|
210
81
|
// set at this point (and it might change locale & timezone)
|
|
211
82
|
const initState = this.recalculateState(this.props.value || this.props.defaultValue);
|
|
212
83
|
this.setState(initState);
|
|
213
|
-
|
|
84
|
+
this.props.reset?.(this.reset);
|
|
214
85
|
}
|
|
215
86
|
componentDidUpdate(prevProps) {
|
|
216
87
|
const valueChanged = prevProps.value !== this.props.value || prevProps.defaultValue !== this.props.defaultValue;
|
|
@@ -228,7 +99,6 @@ class DateTimeInput extends _react.Component {
|
|
|
228
99
|
if (dateStr) {
|
|
229
100
|
const parsed = _DateTime.DateTime.parse(dateStr, this.locale(), this.timezone());
|
|
230
101
|
if (parsed.isValid()) {
|
|
231
|
-
var _this$state;
|
|
232
102
|
if (doNotChangeTime && this.state.timeSelectValue) {
|
|
233
103
|
// There is a selected time, adjust the parsed date to its value
|
|
234
104
|
const timeParsed = _DateTime.DateTime.parse(this.state.timeSelectValue, this.locale(), this.timezone());
|
|
@@ -237,7 +107,7 @@ class DateTimeInput extends _react.Component {
|
|
|
237
107
|
if (doNotChangeDate && this.state.iso) {
|
|
238
108
|
parsed.date(this.state.iso.date()).month(this.state.iso.month()).year(this.state.iso.year());
|
|
239
109
|
}
|
|
240
|
-
if (this.props.initialTimeForNewDate && !
|
|
110
|
+
if (this.props.initialTimeForNewDate && !this.state?.timeSelectValue) {
|
|
241
111
|
const hour = Number(this.props.initialTimeForNewDate.slice(0, 2));
|
|
242
112
|
const minute = Number(this.props.initialTimeForNewDate.slice(3, 5));
|
|
243
113
|
if (isNaN(hour) || isNaN(minute)) {
|
|
@@ -257,7 +127,7 @@ class DateTimeInput extends _react.Component {
|
|
|
257
127
|
errorMsg = text ? {
|
|
258
128
|
text,
|
|
259
129
|
type: 'error'
|
|
260
|
-
} :
|
|
130
|
+
} : undefined;
|
|
261
131
|
return {
|
|
262
132
|
iso: parsed.clone(),
|
|
263
133
|
calendarSelectedDate: parsed.clone(),
|
|
@@ -285,17 +155,18 @@ class DateTimeInput extends _react.Component {
|
|
|
285
155
|
// if there is no date string clear TimeSelect value
|
|
286
156
|
const clearTimeSelect = dateStr ? {} : {
|
|
287
157
|
timeSelectValue: '',
|
|
288
|
-
message:
|
|
158
|
+
message: undefined
|
|
289
159
|
};
|
|
290
160
|
return {
|
|
291
|
-
iso:
|
|
292
|
-
calendarSelectedDate:
|
|
161
|
+
iso: undefined,
|
|
162
|
+
calendarSelectedDate: undefined,
|
|
293
163
|
dateInputText: dateStr ? dateStr : '',
|
|
294
164
|
renderedDate: _DateTime.DateTime.now(this.locale(), this.timezone()),
|
|
295
165
|
dateInputTextChanged: false,
|
|
296
166
|
...clearTimeSelect
|
|
297
167
|
};
|
|
298
168
|
}
|
|
169
|
+
reset = () => this.setState(this.recalculateState());
|
|
299
170
|
locale() {
|
|
300
171
|
if (this.props.locale) {
|
|
301
172
|
return this.props.locale;
|
|
@@ -330,10 +201,50 @@ class DateTimeInput extends _react.Component {
|
|
|
330
201
|
}
|
|
331
202
|
return disabledDates(date.toISOString());
|
|
332
203
|
}
|
|
204
|
+
|
|
205
|
+
// Called when the user enters text into dateInput
|
|
206
|
+
handleDateTextChange = (_event, date) => {
|
|
207
|
+
const dateParsed = this.tryParseDate(date.value);
|
|
208
|
+
this.setState({
|
|
209
|
+
dateInputText: date.value,
|
|
210
|
+
dateInputTextChanged: true,
|
|
211
|
+
calendarSelectedDate: dateParsed ? dateParsed : undefined,
|
|
212
|
+
renderedDate: dateParsed ? dateParsed.clone() : _DateTime.DateTime.now(this.locale(), this.timezone())
|
|
213
|
+
});
|
|
214
|
+
};
|
|
333
215
|
tryParseDate(val) {
|
|
334
216
|
const parsed = _DateTime.DateTime.parse(val, this.locale(), this.timezone());
|
|
335
217
|
return parsed.isValid() ? parsed : null;
|
|
336
218
|
}
|
|
219
|
+
|
|
220
|
+
// date is returned es a ISO string, like 2021-09-14T22:00:00.000Z
|
|
221
|
+
handleDayClick = (event, {
|
|
222
|
+
date
|
|
223
|
+
}) => {
|
|
224
|
+
const dateParsed = _DateTime.DateTime.parse(date, this.locale(), this.timezone());
|
|
225
|
+
this.updateStateBasedOnDateInput(dateParsed, event);
|
|
226
|
+
};
|
|
227
|
+
handleHideCalendar = event => {
|
|
228
|
+
// prevent event pooling https://reactjs.org/docs/legacy-event-pooling.html
|
|
229
|
+
// Remove if React 16 is no longer supported
|
|
230
|
+
event.persist();
|
|
231
|
+
// timeout is needed here because handleDayClick could be called in the same
|
|
232
|
+
// frame, and it updates calendarSelectedDate which is read in here.
|
|
233
|
+
setTimeout(() => {
|
|
234
|
+
if (event.key === 'Enter') {
|
|
235
|
+
// user pressed enter, use the selected value in the calendar
|
|
236
|
+
this.updateStateBasedOnDateInput(this.state.calendarSelectedDate, event);
|
|
237
|
+
} else {
|
|
238
|
+
// user clicked outside/tabbed away/pressed esc, try to use the value in dateInputText
|
|
239
|
+
const dateParsed = this.tryParseDate(this.state.dateInputText);
|
|
240
|
+
this.updateStateBasedOnDateInput(dateParsed, event);
|
|
241
|
+
}
|
|
242
|
+
this.setState({
|
|
243
|
+
isShowingCalendar: false,
|
|
244
|
+
dateInputTextChanged: false
|
|
245
|
+
});
|
|
246
|
+
}, 0);
|
|
247
|
+
};
|
|
337
248
|
updateStateBasedOnDateInput(dateParsed, event) {
|
|
338
249
|
let newState;
|
|
339
250
|
if (dateParsed && this.state.timeSelectValue && (!this.state.dateInputText || this.state.dateInputText == '')) {
|
|
@@ -348,10 +259,112 @@ class DateTimeInput extends _react.Component {
|
|
|
348
259
|
// if the text in the dateInput is not readable display error
|
|
349
260
|
newState = this.recalculateState(this.state.dateInputText, false, true);
|
|
350
261
|
} else {
|
|
351
|
-
newState = this.recalculateState(dateParsed
|
|
262
|
+
newState = this.recalculateState(dateParsed?.toISOString(), false, true);
|
|
352
263
|
}
|
|
353
264
|
this.changeStateIfNeeded(newState, event);
|
|
354
265
|
}
|
|
266
|
+
updateStateBasedOnTimeSelect = (event, option) => {
|
|
267
|
+
// this.state.iso is undefined if date is invalid or not set.
|
|
268
|
+
// in this case recalculate with the dateInput's text which will result in
|
|
269
|
+
// an empty valid date (if isRequired is false) or an invalid date.
|
|
270
|
+
const newValue = this.state.iso ? option.value : this.state.dateInputText;
|
|
271
|
+
const newState = this.recalculateState(newValue, true, false);
|
|
272
|
+
this.changeStateIfNeeded(newState, event);
|
|
273
|
+
this.setState({
|
|
274
|
+
timeSelectValue: option.value
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
changeStateIfNeeded = (newState, e) => {
|
|
278
|
+
const dateStr = newState.dateInputText;
|
|
279
|
+
if (this.props.isRequired && !newState.iso || dateStr && dateStr.length > 0 && !newState.iso) {
|
|
280
|
+
const text = typeof this.props.invalidDateTimeMessage === 'function' ? this.props.invalidDateTimeMessage(dateStr ? dateStr : '') : this.props.invalidDateTimeMessage;
|
|
281
|
+
// eslint-disable-next-line no-param-reassign
|
|
282
|
+
newState.message = {
|
|
283
|
+
text: text,
|
|
284
|
+
type: 'error'
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
if (this.areDifferentDates(this.state.iso, newState.iso)) {
|
|
288
|
+
if (typeof this.props.onChange === 'function') {
|
|
289
|
+
const newDate = newState.iso?.toISOString();
|
|
290
|
+
// Timeout is needed here because users might change value in the
|
|
291
|
+
// onChange event lister, which might not execute properly
|
|
292
|
+
setTimeout(() => {
|
|
293
|
+
this.props.onChange?.(e, newDate);
|
|
294
|
+
}, 0);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
this.setState(newState);
|
|
298
|
+
};
|
|
299
|
+
areDifferentDates = (d1, d2) => {
|
|
300
|
+
if (!d1 && !d2) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
return !d1 || !d2 || !d1.isSame(d2);
|
|
304
|
+
};
|
|
305
|
+
handleBlur = e => {
|
|
306
|
+
// when TABbing from the DateInput to TimeInput or visa-versa, the blur
|
|
307
|
+
// happens on the target before the relatedTarget gets focus.
|
|
308
|
+
// The timeout gives it a moment for that to happen
|
|
309
|
+
if (typeof this.props.onBlur === 'function') {
|
|
310
|
+
setTimeout(() => {
|
|
311
|
+
this.props.onBlur?.(e);
|
|
312
|
+
}, 0);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
handleShowCalendar = _event => {
|
|
316
|
+
this.setState({
|
|
317
|
+
isShowingCalendar: true
|
|
318
|
+
});
|
|
319
|
+
};
|
|
320
|
+
handleSelectNextDay = _event => {
|
|
321
|
+
let toAlter;
|
|
322
|
+
if (this.state.calendarSelectedDate) {
|
|
323
|
+
toAlter = this.state.calendarSelectedDate.clone();
|
|
324
|
+
} else if (this.state.iso) {
|
|
325
|
+
toAlter = this.state.iso.clone();
|
|
326
|
+
} else {
|
|
327
|
+
toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
|
|
328
|
+
}
|
|
329
|
+
toAlter.add({
|
|
330
|
+
days: 1
|
|
331
|
+
});
|
|
332
|
+
this.setState({
|
|
333
|
+
calendarSelectedDate: toAlter,
|
|
334
|
+
renderedDate: toAlter.clone()
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
handleSelectPrevDay = _event => {
|
|
338
|
+
let toAlter;
|
|
339
|
+
if (this.state.calendarSelectedDate) {
|
|
340
|
+
toAlter = this.state.calendarSelectedDate.clone();
|
|
341
|
+
} else if (this.state.iso) {
|
|
342
|
+
toAlter = this.state.iso.clone();
|
|
343
|
+
} else {
|
|
344
|
+
toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
|
|
345
|
+
}
|
|
346
|
+
toAlter.subtract({
|
|
347
|
+
days: 1
|
|
348
|
+
});
|
|
349
|
+
this.setState({
|
|
350
|
+
calendarSelectedDate: toAlter,
|
|
351
|
+
renderedDate: toAlter.clone()
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
handleRenderNextMonth = _event => {
|
|
355
|
+
this.setState({
|
|
356
|
+
renderedDate: this.state.renderedDate.clone().add({
|
|
357
|
+
months: 1
|
|
358
|
+
})
|
|
359
|
+
});
|
|
360
|
+
};
|
|
361
|
+
handleRenderPrevMonth = _event => {
|
|
362
|
+
this.setState({
|
|
363
|
+
renderedDate: this.state.renderedDate.clone().subtract({
|
|
364
|
+
months: 1
|
|
365
|
+
})
|
|
366
|
+
});
|
|
367
|
+
};
|
|
355
368
|
renderDays() {
|
|
356
369
|
const renderedDate = this.state.renderedDate;
|
|
357
370
|
// Sets it to the first local day of the week counting back from the start of the month.
|
|
@@ -434,36 +447,37 @@ class DateTimeInput extends _react.Component {
|
|
|
434
447
|
size: "small",
|
|
435
448
|
withBackground: false,
|
|
436
449
|
withBorder: false,
|
|
437
|
-
renderIcon: type === 'prev' ?
|
|
450
|
+
renderIcon: type === 'prev' ? (0, _jsxRuntime.jsx)(_IconArrowOpenStartSolid.IconArrowOpenStartSolid, {
|
|
438
451
|
color: "primary"
|
|
439
|
-
})
|
|
452
|
+
}) : (0, _jsxRuntime.jsx)(_IconArrowOpenEndSolid.IconArrowOpenEndSolid, {
|
|
440
453
|
color: "primary"
|
|
441
|
-
})
|
|
454
|
+
}),
|
|
442
455
|
screenReaderLabel: type === 'prev' ? this.props.prevMonthLabel : this.props.nextMonthLabel
|
|
443
456
|
});
|
|
444
457
|
}
|
|
445
458
|
render() {
|
|
446
|
-
const
|
|
447
|
-
description
|
|
448
|
-
datePlaceholder
|
|
449
|
-
timePlaceholder
|
|
450
|
-
dateRenderLabel
|
|
451
|
-
dateInputRef
|
|
452
|
-
timeRenderLabel
|
|
453
|
-
timeFormat
|
|
454
|
-
timeStep
|
|
455
|
-
timeInputRef
|
|
456
|
-
locale
|
|
457
|
-
timezone
|
|
458
|
-
showMessages
|
|
459
|
-
messages
|
|
460
|
-
layout
|
|
461
|
-
rowSpacing
|
|
462
|
-
colSpacing
|
|
463
|
-
isRequired
|
|
464
|
-
interaction
|
|
465
|
-
renderWeekdayLabels
|
|
466
|
-
allowNonStepInput
|
|
459
|
+
const {
|
|
460
|
+
description,
|
|
461
|
+
datePlaceholder,
|
|
462
|
+
timePlaceholder,
|
|
463
|
+
dateRenderLabel,
|
|
464
|
+
dateInputRef,
|
|
465
|
+
timeRenderLabel,
|
|
466
|
+
timeFormat,
|
|
467
|
+
timeStep,
|
|
468
|
+
timeInputRef,
|
|
469
|
+
locale,
|
|
470
|
+
timezone,
|
|
471
|
+
showMessages,
|
|
472
|
+
messages,
|
|
473
|
+
layout,
|
|
474
|
+
rowSpacing,
|
|
475
|
+
colSpacing,
|
|
476
|
+
isRequired,
|
|
477
|
+
interaction,
|
|
478
|
+
renderWeekdayLabels,
|
|
479
|
+
allowNonStepInput
|
|
480
|
+
} = this.props;
|
|
467
481
|
const allMessages = [...(showMessages && this.state.message ? [this.state.message] : []), ...(messages || [])];
|
|
468
482
|
const hasError = allMessages.find(m => m.type === 'newError' || m.type === 'error');
|
|
469
483
|
// if the component is in error state, create an empty error message to pass down to the subcomponents (DateInput and TimeInput) so they get a red outline and red required asterisk
|
|
@@ -530,22 +544,4 @@ class DateTimeInput extends _react.Component {
|
|
|
530
544
|
}
|
|
531
545
|
}
|
|
532
546
|
exports.DateTimeInput = DateTimeInput;
|
|
533
|
-
_DateTimeInput = DateTimeInput;
|
|
534
|
-
DateTimeInput.displayName = "DateTimeInput";
|
|
535
|
-
// extra verbose localized date and time
|
|
536
|
-
DateTimeInput.DEFAULT_MESSAGE_FORMAT = 'LLLL';
|
|
537
|
-
DateTimeInput.allowedProps = _props.allowedProps;
|
|
538
|
-
DateTimeInput.defaultProps = {
|
|
539
|
-
layout: 'inline',
|
|
540
|
-
colSpacing: 'medium',
|
|
541
|
-
rowSpacing: 'small',
|
|
542
|
-
timeStep: 30,
|
|
543
|
-
showMessages: true,
|
|
544
|
-
messageFormat: _DateTimeInput.DEFAULT_MESSAGE_FORMAT,
|
|
545
|
-
isRequired: false,
|
|
546
|
-
dateFormat: 'LL',
|
|
547
|
-
// Localized date with full month, e.g. "August 6, 2014"
|
|
548
|
-
allowNonStepInput: false
|
|
549
|
-
};
|
|
550
|
-
DateTimeInput.contextType = _ApplyLocaleContext.ApplyLocaleContext;
|
|
551
547
|
var _default = exports.default = DateTimeInput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-date-time-input",
|
|
3
|
-
"version": "11.7.3-snapshot-
|
|
3
|
+
"version": "11.7.3-snapshot-26",
|
|
4
4
|
"description": "A UI component that allows to select date and time.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -14,26 +14,26 @@
|
|
|
14
14
|
"bugs": "https://github.com/instructure/instructure-ui/issues",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@babel/runtime": "^7.
|
|
18
|
-
"@instructure/
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/ui-a11y-content": "11.7.3-snapshot-
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/ui-date-input": "11.7.3-snapshot-
|
|
24
|
-
"@instructure/ui-form-field": "11.7.3-snapshot-
|
|
25
|
-
"@instructure/ui-i18n": "11.7.3-snapshot-
|
|
26
|
-
"@instructure/ui-icons": "11.7.3-snapshot-
|
|
27
|
-
"@instructure/ui-react-utils": "11.7.3-snapshot-
|
|
28
|
-
"@instructure/ui-time-select": "11.7.3-snapshot-
|
|
29
|
-
"@instructure/ui-utils": "11.7.3-snapshot-
|
|
17
|
+
"@babel/runtime": "^7.29.2",
|
|
18
|
+
"@instructure/console": "11.7.3-snapshot-26",
|
|
19
|
+
"@instructure/shared-types": "11.7.3-snapshot-26",
|
|
20
|
+
"@instructure/ui-a11y-content": "11.7.3-snapshot-26",
|
|
21
|
+
"@instructure/ui-buttons": "11.7.3-snapshot-26",
|
|
22
|
+
"@instructure/ui-calendar": "11.7.3-snapshot-26",
|
|
23
|
+
"@instructure/ui-date-input": "11.7.3-snapshot-26",
|
|
24
|
+
"@instructure/ui-form-field": "11.7.3-snapshot-26",
|
|
25
|
+
"@instructure/ui-i18n": "11.7.3-snapshot-26",
|
|
26
|
+
"@instructure/ui-icons": "11.7.3-snapshot-26",
|
|
27
|
+
"@instructure/ui-react-utils": "11.7.3-snapshot-26",
|
|
28
|
+
"@instructure/ui-time-select": "11.7.3-snapshot-26",
|
|
29
|
+
"@instructure/ui-utils": "11.7.3-snapshot-26"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@testing-library/jest-dom": "^6.6.3",
|
|
33
33
|
"@testing-library/react": "15.0.7",
|
|
34
34
|
"@testing-library/user-event": "^14.6.1",
|
|
35
35
|
"vitest": "^3.2.2",
|
|
36
|
-
"@instructure/ui-babel-preset": "11.7.3-snapshot-
|
|
36
|
+
"@instructure/ui-babel-preset": "11.7.3-snapshot-26"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": ">=18 <=19"
|