@instructure/ui-date-time-input 8.46.2-snapshot-2 → 8.46.2-snapshot-5
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/index.js +12 -3
- package/lib/DateTimeInput/index.js +12 -3
- package/package.json +18 -18
- package/src/DateTimeInput/README.md +1 -1
- package/src/DateTimeInput/index.tsx +14 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateTimeInput/index.d.ts +1 -1
- package/types/DateTimeInput/index.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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.46.2-snapshot-
|
|
6
|
+
## [8.46.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.46.1...v8.46.2-snapshot-5) (2023-10-19)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-date-time-input:** clear TimeSelect value when DateInput value is cleared ([b1a58e5](https://github.com/instructure/instructure-ui/commit/b1a58e5c04822da491966bc0a79403b30749ff7e))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
|
@@ -89,7 +89,7 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_class2 = class DateTimeI
|
|
|
89
89
|
});
|
|
90
90
|
}, 0);
|
|
91
91
|
};
|
|
92
|
-
this.
|
|
92
|
+
this.updateStateBasedOnTimeSelect = (event, option) => {
|
|
93
93
|
// this.state.iso is undefined if date is invalid or not set.
|
|
94
94
|
// in this case recalculate with the dateInput's text which will result in
|
|
95
95
|
// an empty valid date (if isRequired is false) or an invalid date.
|
|
@@ -252,12 +252,21 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_class2 = class DateTimeI
|
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
+
// if there is no date string clear TimeSelect value
|
|
256
|
+
const clearTimeSelect = dateStr ? {} : {
|
|
257
|
+
timeSelectValue: '',
|
|
258
|
+
message: {
|
|
259
|
+
type: 'success',
|
|
260
|
+
text: ''
|
|
261
|
+
}
|
|
262
|
+
};
|
|
255
263
|
return {
|
|
256
264
|
iso: void 0,
|
|
257
265
|
calendarSelectedDate: void 0,
|
|
258
266
|
dateInputText: dateStr ? dateStr : '',
|
|
259
267
|
renderedDate: DateTime.now(this.locale(), this.timezone()),
|
|
260
|
-
dateInputTextChanged: false
|
|
268
|
+
dateInputTextChanged: false,
|
|
269
|
+
...clearTimeSelect
|
|
261
270
|
};
|
|
262
271
|
}
|
|
263
272
|
locale() {
|
|
@@ -447,7 +456,7 @@ let DateTimeInput = (_dec = testable(), _dec(_class = (_class2 = class DateTimeI
|
|
|
447
456
|
renderNavigationLabel: /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement("div", null, this.state.renderedDate.format('MMMM')), /*#__PURE__*/React.createElement("div", null, this.state.renderedDate.format('y')))
|
|
448
457
|
}, this.renderDays()), /*#__PURE__*/React.createElement(TimeSelect, {
|
|
449
458
|
value: this.state.timeSelectValue,
|
|
450
|
-
onChange: this.
|
|
459
|
+
onChange: this.updateStateBasedOnTimeSelect,
|
|
451
460
|
onBlur: this.handleBlur,
|
|
452
461
|
renderLabel: timeRenderLabel,
|
|
453
462
|
locale: locale,
|
|
@@ -97,7 +97,7 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 =
|
|
|
97
97
|
});
|
|
98
98
|
}, 0);
|
|
99
99
|
};
|
|
100
|
-
this.
|
|
100
|
+
this.updateStateBasedOnTimeSelect = (event, option) => {
|
|
101
101
|
// this.state.iso is undefined if date is invalid or not set.
|
|
102
102
|
// in this case recalculate with the dateInput's text which will result in
|
|
103
103
|
// an empty valid date (if isRequired is false) or an invalid date.
|
|
@@ -260,12 +260,21 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 =
|
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
+
// if there is no date string clear TimeSelect value
|
|
264
|
+
const clearTimeSelect = dateStr ? {} : {
|
|
265
|
+
timeSelectValue: '',
|
|
266
|
+
message: {
|
|
267
|
+
type: 'success',
|
|
268
|
+
text: ''
|
|
269
|
+
}
|
|
270
|
+
};
|
|
263
271
|
return {
|
|
264
272
|
iso: void 0,
|
|
265
273
|
calendarSelectedDate: void 0,
|
|
266
274
|
dateInputText: dateStr ? dateStr : '',
|
|
267
275
|
renderedDate: _DateTime.DateTime.now(this.locale(), this.timezone()),
|
|
268
|
-
dateInputTextChanged: false
|
|
276
|
+
dateInputTextChanged: false,
|
|
277
|
+
...clearTimeSelect
|
|
269
278
|
};
|
|
270
279
|
}
|
|
271
280
|
locale() {
|
|
@@ -455,7 +464,7 @@ let DateTimeInput = (_dec = (0, _testable.testable)(), _dec(_class = (_class2 =
|
|
|
455
464
|
renderNavigationLabel: /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement("div", null, this.state.renderedDate.format('MMMM')), /*#__PURE__*/_react.default.createElement("div", null, this.state.renderedDate.format('y')))
|
|
456
465
|
}, this.renderDays()), /*#__PURE__*/_react.default.createElement(_TimeSelect.TimeSelect, {
|
|
457
466
|
value: this.state.timeSelectValue,
|
|
458
|
-
onChange: this.
|
|
467
|
+
onChange: this.updateStateBasedOnTimeSelect,
|
|
459
468
|
onBlur: this.handleBlur,
|
|
460
469
|
renderLabel: timeRenderLabel,
|
|
461
470
|
locale: locale,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-date-time-input",
|
|
3
|
-
"version": "8.46.2-snapshot-
|
|
3
|
+
"version": "8.46.2-snapshot-5",
|
|
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.46.2-snapshot-
|
|
27
|
-
"@instructure/ui-test-locator": "8.46.2-snapshot-
|
|
28
|
-
"@instructure/ui-test-utils": "8.46.2-snapshot-
|
|
26
|
+
"@instructure/ui-babel-preset": "8.46.2-snapshot-5",
|
|
27
|
+
"@instructure/ui-test-locator": "8.46.2-snapshot-5",
|
|
28
|
+
"@instructure/ui-test-utils": "8.46.2-snapshot-5"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.22.15",
|
|
32
|
-
"@instructure/debounce": "8.46.2-snapshot-
|
|
33
|
-
"@instructure/emotion": "8.46.2-snapshot-
|
|
34
|
-
"@instructure/ui-a11y-content": "8.46.2-snapshot-
|
|
35
|
-
"@instructure/ui-buttons": "8.46.2-snapshot-
|
|
36
|
-
"@instructure/ui-calendar": "8.46.2-snapshot-
|
|
37
|
-
"@instructure/ui-date-input": "8.46.2-snapshot-
|
|
38
|
-
"@instructure/ui-form-field": "8.46.2-snapshot-
|
|
39
|
-
"@instructure/ui-i18n": "8.46.2-snapshot-
|
|
40
|
-
"@instructure/ui-icons": "8.46.2-snapshot-
|
|
41
|
-
"@instructure/ui-prop-types": "8.46.2-snapshot-
|
|
42
|
-
"@instructure/ui-react-utils": "8.46.2-snapshot-
|
|
43
|
-
"@instructure/ui-testable": "8.46.2-snapshot-
|
|
44
|
-
"@instructure/ui-time-select": "8.46.2-snapshot-
|
|
45
|
-
"@instructure/ui-utils": "8.46.2-snapshot-
|
|
32
|
+
"@instructure/debounce": "8.46.2-snapshot-5",
|
|
33
|
+
"@instructure/emotion": "8.46.2-snapshot-5",
|
|
34
|
+
"@instructure/ui-a11y-content": "8.46.2-snapshot-5",
|
|
35
|
+
"@instructure/ui-buttons": "8.46.2-snapshot-5",
|
|
36
|
+
"@instructure/ui-calendar": "8.46.2-snapshot-5",
|
|
37
|
+
"@instructure/ui-date-input": "8.46.2-snapshot-5",
|
|
38
|
+
"@instructure/ui-form-field": "8.46.2-snapshot-5",
|
|
39
|
+
"@instructure/ui-i18n": "8.46.2-snapshot-5",
|
|
40
|
+
"@instructure/ui-icons": "8.46.2-snapshot-5",
|
|
41
|
+
"@instructure/ui-prop-types": "8.46.2-snapshot-5",
|
|
42
|
+
"@instructure/ui-react-utils": "8.46.2-snapshot-5",
|
|
43
|
+
"@instructure/ui-testable": "8.46.2-snapshot-5",
|
|
44
|
+
"@instructure/ui-time-select": "8.46.2-snapshot-5",
|
|
45
|
+
"@instructure/ui-utils": "8.46.2-snapshot-5",
|
|
46
46
|
"prop-types": "^15.8.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -171,12 +171,23 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
+
// if there is no date string clear TimeSelect value
|
|
175
|
+
const clearTimeSelect: Partial<DateTimeInputState> = dateStr
|
|
176
|
+
? {}
|
|
177
|
+
: {
|
|
178
|
+
timeSelectValue: '',
|
|
179
|
+
message: {
|
|
180
|
+
type: 'success',
|
|
181
|
+
text: ''
|
|
182
|
+
}
|
|
183
|
+
}
|
|
174
184
|
return {
|
|
175
185
|
iso: undefined,
|
|
176
186
|
calendarSelectedDate: undefined,
|
|
177
187
|
dateInputText: dateStr ? dateStr : '',
|
|
178
188
|
renderedDate: DateTime.now(this.locale(), this.timezone()),
|
|
179
|
-
dateInputTextChanged: false
|
|
189
|
+
dateInputTextChanged: false,
|
|
190
|
+
...clearTimeSelect
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
193
|
|
|
@@ -295,7 +306,7 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
|
|
|
295
306
|
this.changeStateIfNeeded(newState, event)
|
|
296
307
|
}
|
|
297
308
|
|
|
298
|
-
|
|
309
|
+
updateStateBasedOnTimeSelect = (
|
|
299
310
|
event: SyntheticEvent,
|
|
300
311
|
option: { value?: string; inputText: string }
|
|
301
312
|
) => {
|
|
@@ -566,7 +577,7 @@ class DateTimeInput extends Component<DateTimeInputProps, DateTimeInputState> {
|
|
|
566
577
|
</DateInput>
|
|
567
578
|
<TimeSelect
|
|
568
579
|
value={this.state.timeSelectValue}
|
|
569
|
-
onChange={this.
|
|
580
|
+
onChange={this.updateStateBasedOnTimeSelect}
|
|
570
581
|
onBlur={this.handleBlur}
|
|
571
582
|
renderLabel={timeRenderLabel}
|
|
572
583
|
locale={locale}
|