@instructure/ui-date-time-input 8.25.1-snapshot-10 → 8.25.1-snapshot-13

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [8.25.1-snapshot-10](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-10) (2022-06-20)
6
+ ## [8.25.1-snapshot-13](https://github.com/instructure/instructure-ui/compare/v8.25.0...v8.25.1-snapshot-13) (2022-06-22)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-date-time-input
9
9
 
@@ -1,4 +1,4 @@
1
- var _dec, _class, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
1
+ var _dec, _class, _class2, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
2
2
 
3
3
  /*
4
4
  * The MIT License (MIT)
@@ -42,33 +42,168 @@ category: components
42
42
  @tsProps
43
43
  **/
44
44
 
45
- let DateTimeInput = (_dec = testable(), _dec(_class = class DateTimeInput extends Component {
46
- static displayName = "DateTimeInput";
45
+ let DateTimeInput = (_dec = testable(), _dec(_class = (_class2 = class DateTimeInput extends Component {
47
46
  // extra verbose localized date and time
48
- static DEFAULT_MESSAGE_FORMAT = 'LLLL';
49
- static propTypes = propTypes;
50
- static allowedProps = allowedProps;
51
- static defaultProps = {
52
- layout: 'inline',
53
- colSpacing: 'medium',
54
- rowSpacing: 'small',
55
- timeStep: 30,
56
- messageFormat: DateTimeInput.DEFAULT_MESSAGE_FORMAT,
57
- isRequired: false,
58
- dateFormat: 'LL' // Localized date with full month, e.g. "August 6, 2014"
59
-
60
- };
61
- static contextType = ApplyLocaleContext;
62
- ref = null; // This is used by Tooltip for positioning
63
-
64
- handleRef = el => {
65
- this.ref = el;
66
- };
67
-
47
+ // This is used by Tooltip for positioning
68
48
  constructor(props) {
69
49
  super(props); // State needs to be calculated because render could be called before
70
50
  // componentDidMount()
71
51
 
52
+ this.ref = null;
53
+
54
+ this.handleRef = el => {
55
+ this.ref = el;
56
+ };
57
+
58
+ this.handleDateTextChange = (_event, date) => {
59
+ const dateParsed = this.tryParseDate(date.value);
60
+ this.setState({
61
+ dateInputText: date.value,
62
+ dateInputTextChanged: true,
63
+ calendarSelectedDate: dateParsed ? dateParsed : void 0,
64
+ renderedDate: dateParsed ? dateParsed.clone() : DateTime.now(this.locale(), this.timezone())
65
+ });
66
+ };
67
+
68
+ this.handleDayClick = (event, _ref) => {
69
+ let date = _ref.date;
70
+ const dateParsed = DateTime.parse(date, this.locale(), this.timezone());
71
+ this.updateStateBasedOnDateInput(dateParsed, event);
72
+ };
73
+
74
+ this.handleHideCalendar = event => {
75
+ // update state based on the DateInput's text value
76
+ if (this.state.dateInputTextChanged || event.key === 'Enter') {
77
+ const dateParsed = this.tryParseDate(this.state.dateInputText);
78
+ this.updateStateBasedOnDateInput(dateParsed, event);
79
+ } else {
80
+ // user clicked outside or tabbed away or pressed esc, reset text
81
+ this.setState({
82
+ dateInputText: this.state.iso ? this.state.iso.format(this.dateFormat) : '',
83
+ calendarSelectedDate: this.state.iso ? this.state.iso.clone() : void 0
84
+ });
85
+ }
86
+
87
+ this.setState({
88
+ isShowingCalendar: false,
89
+ dateInputTextChanged: false
90
+ });
91
+ };
92
+
93
+ this.handleTimeChange = (event, option) => {
94
+ let newValue;
95
+
96
+ if (this.state.iso) {
97
+ newValue = option.value;
98
+ } else {
99
+ // if no date is set just return the input text, it will error
100
+ newValue = option.inputText;
101
+ }
102
+
103
+ const newState = this.recalculateState(newValue, true, false);
104
+ this.changeStateIfNeeded(newState, event);
105
+ this.setState({
106
+ timeSelectValue: option.value
107
+ });
108
+ };
109
+
110
+ this.changeStateIfNeeded = (newState, e) => {
111
+ this.setState({
112
+ message: newState.message
113
+ });
114
+
115
+ if (!newState.iso && !this.state.iso) {
116
+ return;
117
+ }
118
+
119
+ if (!this.state.iso || !newState.iso || !this.state.iso.isSame(newState.iso)) {
120
+ this.setState(newState);
121
+
122
+ if (this.props.onChange) {
123
+ var _newState$iso;
124
+
125
+ this.props.onChange(e, (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString());
126
+ }
127
+ }
128
+ };
129
+
130
+ this.handleBlur = e => {
131
+ // when TABbing from the DateInput to TimeInput or visa-versa, the blur
132
+ // happens on the target before the relatedTarget gets focus.
133
+ // The timeout gives it a moment for that to happen
134
+ if (typeof this.props.onBlur === 'function') {
135
+ window.setTimeout(() => {
136
+ var _this$props$onBlur, _this$props;
137
+
138
+ (_this$props$onBlur = (_this$props = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props, e);
139
+ }, 0);
140
+ }
141
+ };
142
+
143
+ this.handleShowCalendar = _event => {
144
+ this.setState({
145
+ isShowingCalendar: true
146
+ });
147
+ };
148
+
149
+ this.handleSelectNextDay = _event => {
150
+ let toAlter;
151
+
152
+ if (this.state.calendarSelectedDate) {
153
+ toAlter = this.state.calendarSelectedDate.clone();
154
+ } else if (this.state.iso) {
155
+ toAlter = this.state.iso.clone();
156
+ } else {
157
+ toAlter = DateTime.now(this.locale(), this.timezone());
158
+ }
159
+
160
+ toAlter.add({
161
+ days: 1
162
+ });
163
+ this.setState({
164
+ calendarSelectedDate: toAlter,
165
+ renderedDate: toAlter.clone(),
166
+ dateInputText: toAlter.format(this.dateFormat)
167
+ });
168
+ };
169
+
170
+ this.handleSelectPrevDay = _event => {
171
+ let toAlter;
172
+
173
+ if (this.state.calendarSelectedDate) {
174
+ toAlter = this.state.calendarSelectedDate.clone();
175
+ } else if (this.state.iso) {
176
+ toAlter = this.state.iso.clone();
177
+ } else {
178
+ toAlter = DateTime.now(this.locale(), this.timezone());
179
+ }
180
+
181
+ toAlter.subtract({
182
+ days: 1
183
+ });
184
+ this.setState({
185
+ calendarSelectedDate: toAlter,
186
+ renderedDate: toAlter.clone(),
187
+ dateInputText: toAlter.format(this.dateFormat)
188
+ });
189
+ };
190
+
191
+ this.handleRenderNextMonth = _event => {
192
+ this.setState({
193
+ renderedDate: this.state.renderedDate.clone().add({
194
+ months: 1
195
+ })
196
+ });
197
+ };
198
+
199
+ this.handleRenderPrevMonth = _event => {
200
+ this.setState({
201
+ renderedDate: this.state.renderedDate.clone().subtract({
202
+ months: 1
203
+ })
204
+ });
205
+ };
206
+
72
207
  this.state = this.recalculateState(props.value || props.defaultValue);
73
208
  }
74
209
 
@@ -212,46 +347,12 @@ let DateTimeInput = (_dec = testable(), _dec(_class = class DateTimeInput extend
212
347
  } // Called when the user enters text into dateInput
213
348
 
214
349
 
215
- handleDateTextChange = (_event, date) => {
216
- const dateParsed = this.tryParseDate(date.value);
217
- this.setState({
218
- dateInputText: date.value,
219
- dateInputTextChanged: true,
220
- calendarSelectedDate: dateParsed ? dateParsed : void 0,
221
- renderedDate: dateParsed ? dateParsed.clone() : DateTime.now(this.locale(), this.timezone())
222
- });
223
- };
224
-
225
350
  tryParseDate(val) {
226
351
  const parsed = DateTime.parse(val, this.locale(), this.timezone());
227
352
  return parsed.isValid() ? parsed : null;
228
353
  } // date is returned es a ISO string, like 2021-09-14T22:00:00.000Z
229
354
 
230
355
 
231
- handleDayClick = (event, _ref) => {
232
- let date = _ref.date;
233
- const dateParsed = DateTime.parse(date, this.locale(), this.timezone());
234
- this.updateStateBasedOnDateInput(dateParsed, event);
235
- };
236
- handleHideCalendar = event => {
237
- // update state based on the DateInput's text value
238
- if (this.state.dateInputTextChanged || event.key === 'Enter') {
239
- const dateParsed = this.tryParseDate(this.state.dateInputText);
240
- this.updateStateBasedOnDateInput(dateParsed, event);
241
- } else {
242
- // user clicked outside or tabbed away or pressed esc, reset text
243
- this.setState({
244
- dateInputText: this.state.iso ? this.state.iso.format(this.dateFormat) : '',
245
- calendarSelectedDate: this.state.iso ? this.state.iso.clone() : void 0
246
- });
247
- }
248
-
249
- this.setState({
250
- isShowingCalendar: false,
251
- dateInputTextChanged: false
252
- });
253
- };
254
-
255
356
  updateStateBasedOnDateInput(dateParsed, event) {
256
357
  let newState;
257
358
 
@@ -273,113 +374,6 @@ let DateTimeInput = (_dec = testable(), _dec(_class = class DateTimeInput extend
273
374
  this.changeStateIfNeeded(newState, event);
274
375
  }
275
376
 
276
- handleTimeChange = (event, option) => {
277
- let newValue;
278
-
279
- if (this.state.iso) {
280
- newValue = option.value;
281
- } else {
282
- // if no date is set just return the input text, it will error
283
- newValue = option.inputText;
284
- }
285
-
286
- const newState = this.recalculateState(newValue, true, false);
287
- this.changeStateIfNeeded(newState, event);
288
- this.setState({
289
- timeSelectValue: option.value
290
- });
291
- };
292
- changeStateIfNeeded = (newState, e) => {
293
- this.setState({
294
- message: newState.message
295
- });
296
-
297
- if (!newState.iso && !this.state.iso) {
298
- return;
299
- }
300
-
301
- if (!this.state.iso || !newState.iso || !this.state.iso.isSame(newState.iso)) {
302
- this.setState(newState);
303
-
304
- if (this.props.onChange) {
305
- var _newState$iso;
306
-
307
- this.props.onChange(e, (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString());
308
- }
309
- }
310
- };
311
- handleBlur = e => {
312
- // when TABbing from the DateInput to TimeInput or visa-versa, the blur
313
- // happens on the target before the relatedTarget gets focus.
314
- // The timeout gives it a moment for that to happen
315
- if (typeof this.props.onBlur === 'function') {
316
- window.setTimeout(() => {
317
- var _this$props$onBlur, _this$props;
318
-
319
- (_this$props$onBlur = (_this$props = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props, e);
320
- }, 0);
321
- }
322
- };
323
- handleShowCalendar = _event => {
324
- this.setState({
325
- isShowingCalendar: true
326
- });
327
- };
328
- handleSelectNextDay = _event => {
329
- let toAlter;
330
-
331
- if (this.state.calendarSelectedDate) {
332
- toAlter = this.state.calendarSelectedDate.clone();
333
- } else if (this.state.iso) {
334
- toAlter = this.state.iso.clone();
335
- } else {
336
- toAlter = DateTime.now(this.locale(), this.timezone());
337
- }
338
-
339
- toAlter.add({
340
- days: 1
341
- });
342
- this.setState({
343
- calendarSelectedDate: toAlter,
344
- renderedDate: toAlter.clone(),
345
- dateInputText: toAlter.format(this.dateFormat)
346
- });
347
- };
348
- handleSelectPrevDay = _event => {
349
- let toAlter;
350
-
351
- if (this.state.calendarSelectedDate) {
352
- toAlter = this.state.calendarSelectedDate.clone();
353
- } else if (this.state.iso) {
354
- toAlter = this.state.iso.clone();
355
- } else {
356
- toAlter = DateTime.now(this.locale(), this.timezone());
357
- }
358
-
359
- toAlter.subtract({
360
- days: 1
361
- });
362
- this.setState({
363
- calendarSelectedDate: toAlter,
364
- renderedDate: toAlter.clone(),
365
- dateInputText: toAlter.format(this.dateFormat)
366
- });
367
- };
368
- handleRenderNextMonth = _event => {
369
- this.setState({
370
- renderedDate: this.state.renderedDate.clone().add({
371
- months: 1
372
- })
373
- });
374
- };
375
- handleRenderPrevMonth = _event => {
376
- this.setState({
377
- renderedDate: this.state.renderedDate.clone().subtract({
378
- months: 1
379
- })
380
- });
381
- };
382
-
383
377
  renderDays() {
384
378
  if (!this.state.isShowingCalendar) {
385
379
  // this is an expensive function, only execute if the calendar is open
@@ -531,6 +525,15 @@ let DateTimeInput = (_dec = testable(), _dec(_class = class DateTimeInput extend
531
525
  }));
532
526
  }
533
527
 
534
- }) || _class);
528
+ }, _class2.displayName = "DateTimeInput", _class2.DEFAULT_MESSAGE_FORMAT = 'LLLL', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
529
+ layout: 'inline',
530
+ colSpacing: 'medium',
531
+ rowSpacing: 'small',
532
+ timeStep: 30,
533
+ messageFormat: _class2.DEFAULT_MESSAGE_FORMAT,
534
+ isRequired: false,
535
+ dateFormat: 'LL' // Localized date with full month, e.g. "August 6, 2014"
536
+
537
+ }, _class2.contextType = ApplyLocaleContext, _class2)) || _class);
535
538
  export default DateTimeInput;
536
539
  export { DateTimeInput };
@@ -37,7 +37,7 @@ var _debounce = require("@instructure/debounce");
37
37
 
38
38
  var _props = require("./props");
39
39
 
40
- var _dec, _class, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
40
+ var _dec, _class, _class2, _IconArrowOpenStartSo, _IconArrowOpenEndSoli;
41
41
 
42
42
  /**
43
43
  ---
@@ -45,33 +45,170 @@ category: components
45
45
  ---
46
46
  @tsProps
47
47
  **/
48
- let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = class DateTimeInput extends _react.Component {
49
- static displayName = "DateTimeInput";
48
+ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 = class DateTimeInput extends _react.Component {
50
49
  // extra verbose localized date and time
51
- static DEFAULT_MESSAGE_FORMAT = 'LLLL';
52
- static propTypes = _props.propTypes;
53
- static allowedProps = _props.allowedProps;
54
- static defaultProps = {
55
- layout: 'inline',
56
- colSpacing: 'medium',
57
- rowSpacing: 'small',
58
- timeStep: 30,
59
- messageFormat: DateTimeInput.DEFAULT_MESSAGE_FORMAT,
60
- isRequired: false,
61
- dateFormat: 'LL' // Localized date with full month, e.g. "August 6, 2014"
62
-
63
- };
64
- static contextType = _ApplyLocaleContext.ApplyLocaleContext;
65
- ref = null; // This is used by Tooltip for positioning
66
-
67
- handleRef = el => {
68
- this.ref = el;
69
- };
70
-
50
+ // This is used by Tooltip for positioning
71
51
  constructor(props) {
72
52
  super(props); // State needs to be calculated because render could be called before
73
53
  // componentDidMount()
74
54
 
55
+ this.ref = null;
56
+
57
+ this.handleRef = el => {
58
+ this.ref = el;
59
+ };
60
+
61
+ this.handleDateTextChange = (_event, date) => {
62
+ const dateParsed = this.tryParseDate(date.value);
63
+ this.setState({
64
+ dateInputText: date.value,
65
+ dateInputTextChanged: true,
66
+ calendarSelectedDate: dateParsed ? dateParsed : void 0,
67
+ renderedDate: dateParsed ? dateParsed.clone() : _DateTime.DateTime.now(this.locale(), this.timezone())
68
+ });
69
+ };
70
+
71
+ this.handleDayClick = (event, _ref) => {
72
+ let date = _ref.date;
73
+
74
+ const dateParsed = _DateTime.DateTime.parse(date, this.locale(), this.timezone());
75
+
76
+ this.updateStateBasedOnDateInput(dateParsed, event);
77
+ };
78
+
79
+ this.handleHideCalendar = event => {
80
+ // update state based on the DateInput's text value
81
+ if (this.state.dateInputTextChanged || event.key === 'Enter') {
82
+ const dateParsed = this.tryParseDate(this.state.dateInputText);
83
+ this.updateStateBasedOnDateInput(dateParsed, event);
84
+ } else {
85
+ // user clicked outside or tabbed away or pressed esc, reset text
86
+ this.setState({
87
+ dateInputText: this.state.iso ? this.state.iso.format(this.dateFormat) : '',
88
+ calendarSelectedDate: this.state.iso ? this.state.iso.clone() : void 0
89
+ });
90
+ }
91
+
92
+ this.setState({
93
+ isShowingCalendar: false,
94
+ dateInputTextChanged: false
95
+ });
96
+ };
97
+
98
+ this.handleTimeChange = (event, option) => {
99
+ let newValue;
100
+
101
+ if (this.state.iso) {
102
+ newValue = option.value;
103
+ } else {
104
+ // if no date is set just return the input text, it will error
105
+ newValue = option.inputText;
106
+ }
107
+
108
+ const newState = this.recalculateState(newValue, true, false);
109
+ this.changeStateIfNeeded(newState, event);
110
+ this.setState({
111
+ timeSelectValue: option.value
112
+ });
113
+ };
114
+
115
+ this.changeStateIfNeeded = (newState, e) => {
116
+ this.setState({
117
+ message: newState.message
118
+ });
119
+
120
+ if (!newState.iso && !this.state.iso) {
121
+ return;
122
+ }
123
+
124
+ if (!this.state.iso || !newState.iso || !this.state.iso.isSame(newState.iso)) {
125
+ this.setState(newState);
126
+
127
+ if (this.props.onChange) {
128
+ var _newState$iso;
129
+
130
+ this.props.onChange(e, (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString());
131
+ }
132
+ }
133
+ };
134
+
135
+ this.handleBlur = e => {
136
+ // when TABbing from the DateInput to TimeInput or visa-versa, the blur
137
+ // happens on the target before the relatedTarget gets focus.
138
+ // The timeout gives it a moment for that to happen
139
+ if (typeof this.props.onBlur === 'function') {
140
+ window.setTimeout(() => {
141
+ var _this$props$onBlur, _this$props;
142
+
143
+ (_this$props$onBlur = (_this$props = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props, e);
144
+ }, 0);
145
+ }
146
+ };
147
+
148
+ this.handleShowCalendar = _event => {
149
+ this.setState({
150
+ isShowingCalendar: true
151
+ });
152
+ };
153
+
154
+ this.handleSelectNextDay = _event => {
155
+ let toAlter;
156
+
157
+ if (this.state.calendarSelectedDate) {
158
+ toAlter = this.state.calendarSelectedDate.clone();
159
+ } else if (this.state.iso) {
160
+ toAlter = this.state.iso.clone();
161
+ } else {
162
+ toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
163
+ }
164
+
165
+ toAlter.add({
166
+ days: 1
167
+ });
168
+ this.setState({
169
+ calendarSelectedDate: toAlter,
170
+ renderedDate: toAlter.clone(),
171
+ dateInputText: toAlter.format(this.dateFormat)
172
+ });
173
+ };
174
+
175
+ this.handleSelectPrevDay = _event => {
176
+ let toAlter;
177
+
178
+ if (this.state.calendarSelectedDate) {
179
+ toAlter = this.state.calendarSelectedDate.clone();
180
+ } else if (this.state.iso) {
181
+ toAlter = this.state.iso.clone();
182
+ } else {
183
+ toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
184
+ }
185
+
186
+ toAlter.subtract({
187
+ days: 1
188
+ });
189
+ this.setState({
190
+ calendarSelectedDate: toAlter,
191
+ renderedDate: toAlter.clone(),
192
+ dateInputText: toAlter.format(this.dateFormat)
193
+ });
194
+ };
195
+
196
+ this.handleRenderNextMonth = _event => {
197
+ this.setState({
198
+ renderedDate: this.state.renderedDate.clone().add({
199
+ months: 1
200
+ })
201
+ });
202
+ };
203
+
204
+ this.handleRenderPrevMonth = _event => {
205
+ this.setState({
206
+ renderedDate: this.state.renderedDate.clone().subtract({
207
+ months: 1
208
+ })
209
+ });
210
+ };
211
+
75
212
  this.state = this.recalculateState(props.value || props.defaultValue);
76
213
  }
77
214
 
@@ -216,16 +353,6 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = class DateT
216
353
  } // Called when the user enters text into dateInput
217
354
 
218
355
 
219
- handleDateTextChange = (_event, date) => {
220
- const dateParsed = this.tryParseDate(date.value);
221
- this.setState({
222
- dateInputText: date.value,
223
- dateInputTextChanged: true,
224
- calendarSelectedDate: dateParsed ? dateParsed : void 0,
225
- renderedDate: dateParsed ? dateParsed.clone() : _DateTime.DateTime.now(this.locale(), this.timezone())
226
- });
227
- };
228
-
229
356
  tryParseDate(val) {
230
357
  const parsed = _DateTime.DateTime.parse(val, this.locale(), this.timezone());
231
358
 
@@ -233,32 +360,6 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = class DateT
233
360
  } // date is returned es a ISO string, like 2021-09-14T22:00:00.000Z
234
361
 
235
362
 
236
- handleDayClick = (event, _ref) => {
237
- let date = _ref.date;
238
-
239
- const dateParsed = _DateTime.DateTime.parse(date, this.locale(), this.timezone());
240
-
241
- this.updateStateBasedOnDateInput(dateParsed, event);
242
- };
243
- handleHideCalendar = event => {
244
- // update state based on the DateInput's text value
245
- if (this.state.dateInputTextChanged || event.key === 'Enter') {
246
- const dateParsed = this.tryParseDate(this.state.dateInputText);
247
- this.updateStateBasedOnDateInput(dateParsed, event);
248
- } else {
249
- // user clicked outside or tabbed away or pressed esc, reset text
250
- this.setState({
251
- dateInputText: this.state.iso ? this.state.iso.format(this.dateFormat) : '',
252
- calendarSelectedDate: this.state.iso ? this.state.iso.clone() : void 0
253
- });
254
- }
255
-
256
- this.setState({
257
- isShowingCalendar: false,
258
- dateInputTextChanged: false
259
- });
260
- };
261
-
262
363
  updateStateBasedOnDateInput(dateParsed, event) {
263
364
  let newState;
264
365
 
@@ -281,113 +382,6 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = class DateT
281
382
  this.changeStateIfNeeded(newState, event);
282
383
  }
283
384
 
284
- handleTimeChange = (event, option) => {
285
- let newValue;
286
-
287
- if (this.state.iso) {
288
- newValue = option.value;
289
- } else {
290
- // if no date is set just return the input text, it will error
291
- newValue = option.inputText;
292
- }
293
-
294
- const newState = this.recalculateState(newValue, true, false);
295
- this.changeStateIfNeeded(newState, event);
296
- this.setState({
297
- timeSelectValue: option.value
298
- });
299
- };
300
- changeStateIfNeeded = (newState, e) => {
301
- this.setState({
302
- message: newState.message
303
- });
304
-
305
- if (!newState.iso && !this.state.iso) {
306
- return;
307
- }
308
-
309
- if (!this.state.iso || !newState.iso || !this.state.iso.isSame(newState.iso)) {
310
- this.setState(newState);
311
-
312
- if (this.props.onChange) {
313
- var _newState$iso;
314
-
315
- this.props.onChange(e, (_newState$iso = newState.iso) === null || _newState$iso === void 0 ? void 0 : _newState$iso.toISOString());
316
- }
317
- }
318
- };
319
- handleBlur = e => {
320
- // when TABbing from the DateInput to TimeInput or visa-versa, the blur
321
- // happens on the target before the relatedTarget gets focus.
322
- // The timeout gives it a moment for that to happen
323
- if (typeof this.props.onBlur === 'function') {
324
- window.setTimeout(() => {
325
- var _this$props$onBlur, _this$props;
326
-
327
- (_this$props$onBlur = (_this$props = this.props).onBlur) === null || _this$props$onBlur === void 0 ? void 0 : _this$props$onBlur.call(_this$props, e);
328
- }, 0);
329
- }
330
- };
331
- handleShowCalendar = _event => {
332
- this.setState({
333
- isShowingCalendar: true
334
- });
335
- };
336
- handleSelectNextDay = _event => {
337
- let toAlter;
338
-
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
-
347
- toAlter.add({
348
- days: 1
349
- });
350
- this.setState({
351
- calendarSelectedDate: toAlter,
352
- renderedDate: toAlter.clone(),
353
- dateInputText: toAlter.format(this.dateFormat)
354
- });
355
- };
356
- handleSelectPrevDay = _event => {
357
- let toAlter;
358
-
359
- if (this.state.calendarSelectedDate) {
360
- toAlter = this.state.calendarSelectedDate.clone();
361
- } else if (this.state.iso) {
362
- toAlter = this.state.iso.clone();
363
- } else {
364
- toAlter = _DateTime.DateTime.now(this.locale(), this.timezone());
365
- }
366
-
367
- toAlter.subtract({
368
- days: 1
369
- });
370
- this.setState({
371
- calendarSelectedDate: toAlter,
372
- renderedDate: toAlter.clone(),
373
- dateInputText: toAlter.format(this.dateFormat)
374
- });
375
- };
376
- handleRenderNextMonth = _event => {
377
- this.setState({
378
- renderedDate: this.state.renderedDate.clone().add({
379
- months: 1
380
- })
381
- });
382
- };
383
- handleRenderPrevMonth = _event => {
384
- this.setState({
385
- renderedDate: this.state.renderedDate.clone().subtract({
386
- months: 1
387
- })
388
- });
389
- };
390
-
391
385
  renderDays() {
392
386
  if (!this.state.isShowingCalendar) {
393
387
  // this is an expensive function, only execute if the calendar is open
@@ -542,7 +536,16 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = class DateT
542
536
  }));
543
537
  }
544
538
 
545
- }) || _class);
539
+ }, _class2.displayName = "DateTimeInput", _class2.DEFAULT_MESSAGE_FORMAT = 'LLLL', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
540
+ layout: 'inline',
541
+ colSpacing: 'medium',
542
+ rowSpacing: 'small',
543
+ timeStep: 30,
544
+ messageFormat: _class2.DEFAULT_MESSAGE_FORMAT,
545
+ isRequired: false,
546
+ dateFormat: 'LL' // Localized date with full month, e.g. "August 6, 2014"
547
+
548
+ }, _class2.contextType = _ApplyLocaleContext.ApplyLocaleContext, _class2)) || _class);
546
549
  exports.DateTimeInput = DateTimeInput;
547
550
  var _default = DateTimeInput;
548
551
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-date-time-input",
3
- "version": "8.25.1-snapshot-10",
3
+ "version": "8.25.1-snapshot-13",
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",
@@ -23,26 +23,26 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.25.1-snapshot-10",
27
- "@instructure/ui-test-locator": "8.25.1-snapshot-10",
28
- "@instructure/ui-test-utils": "8.25.1-snapshot-10"
26
+ "@instructure/ui-babel-preset": "8.25.1-snapshot-13",
27
+ "@instructure/ui-test-locator": "8.25.1-snapshot-13",
28
+ "@instructure/ui-test-utils": "8.25.1-snapshot-13"
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.13.10",
32
- "@instructure/debounce": "8.25.1-snapshot-10",
33
- "@instructure/emotion": "8.25.1-snapshot-10",
34
- "@instructure/ui-a11y-content": "8.25.1-snapshot-10",
35
- "@instructure/ui-buttons": "8.25.1-snapshot-10",
36
- "@instructure/ui-calendar": "8.25.1-snapshot-10",
37
- "@instructure/ui-date-input": "8.25.1-snapshot-10",
38
- "@instructure/ui-form-field": "8.25.1-snapshot-10",
39
- "@instructure/ui-i18n": "8.25.1-snapshot-10",
40
- "@instructure/ui-icons": "8.25.1-snapshot-10",
41
- "@instructure/ui-prop-types": "8.25.1-snapshot-10",
42
- "@instructure/ui-react-utils": "8.25.1-snapshot-10",
43
- "@instructure/ui-testable": "8.25.1-snapshot-10",
44
- "@instructure/ui-time-select": "8.25.1-snapshot-10",
45
- "@instructure/ui-utils": "8.25.1-snapshot-10",
32
+ "@instructure/debounce": "8.25.1-snapshot-13",
33
+ "@instructure/emotion": "8.25.1-snapshot-13",
34
+ "@instructure/ui-a11y-content": "8.25.1-snapshot-13",
35
+ "@instructure/ui-buttons": "8.25.1-snapshot-13",
36
+ "@instructure/ui-calendar": "8.25.1-snapshot-13",
37
+ "@instructure/ui-date-input": "8.25.1-snapshot-13",
38
+ "@instructure/ui-form-field": "8.25.1-snapshot-13",
39
+ "@instructure/ui-i18n": "8.25.1-snapshot-13",
40
+ "@instructure/ui-icons": "8.25.1-snapshot-13",
41
+ "@instructure/ui-prop-types": "8.25.1-snapshot-13",
42
+ "@instructure/ui-react-utils": "8.25.1-snapshot-13",
43
+ "@instructure/ui-testable": "8.25.1-snapshot-13",
44
+ "@instructure/ui-time-select": "8.25.1-snapshot-13",
45
+ "@instructure/ui-utils": "8.25.1-snapshot-13",
46
46
  "prop-types": "^15"
47
47
  },
48
48
  "peerDependencies": {