@instructure/quiz-core 20.35.3-rc.4 → 20.35.3-rc.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.
@@ -48,10 +48,11 @@ export function addInfo(message) {
48
48
  });
49
49
  }
50
50
  export function screenreaderNotification(message, politeness) {
51
+ var removeIn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 2000;
51
52
  return addAlert({
52
53
  message: message,
53
54
  variant: 'screenreader',
54
- removeIn: 2000,
55
+ removeIn: removeIn,
55
56
  politeness: politeness
56
57
  });
57
58
  }
@@ -8,10 +8,10 @@ import { FormFieldGroup } from '@instructure/ui-form-field';
8
8
  import { ScreenReaderContent } from '@instructure/ui-a11y-content';
9
9
  import { View } from '@instructure/ui-view';
10
10
  import Errors from "../../../../common/components/shared/errors/Errors.js";
11
- import NumberInput from '@instructure/quiz-number-input';
12
11
  import { List } from 'immutable';
13
12
  import { breakdownSeconds, DAY_IN_SECONDS, HOUR_IN_SECONDS, MINUTE_IN_SECONDS } from "../FormattedDuration/index.js";
14
13
  import t from '@instructure/quiz-i18n/es/format-message';
14
+ import { NumberInput } from '@instructure/quiz-number-input';
15
15
 
16
16
  // This component renders an input for multiple time units, and handles:
17
17
  // * converting smaller units to larger units when over the unit threshold (e.g. 95 minutes to 1h35m)
@@ -51,6 +51,7 @@ export var TimeUnitsInput = /*#__PURE__*/function (_Component) {
51
51
  var totalSeconds = minutes * MINUTE_IN_SECONDS + hours * HOUR_IN_SECONDS + days * DAY_IN_SECONDS;
52
52
  var hoursError = null;
53
53
  var daysError = null;
54
+ var shouldResetOnNormalize = false;
54
55
  var _breakdownSeconds = breakdownSeconds(totalSeconds, _this.props.includeDays),
55
56
  newDays = _breakdownSeconds.days,
56
57
  newHours = _breakdownSeconds.hours,
@@ -78,6 +79,7 @@ export var TimeUnitsInput = /*#__PURE__*/function (_Component) {
78
79
  });
79
80
  }
80
81
  totalSeconds = _this.props.maxTimeInSeconds;
82
+ shouldResetOnNormalize = true;
81
83
  } else if (totalSeconds < _this.props.minTimeInSeconds) {
82
84
  var _breakdownSeconds3 = breakdownSeconds(_this.props.minTimeInSeconds, _this.props.includeDays),
83
85
  minDays = _breakdownSeconds3.days,
@@ -101,6 +103,7 @@ export var TimeUnitsInput = /*#__PURE__*/function (_Component) {
101
103
  });
102
104
  }
103
105
  totalSeconds = _this.props.minTimeInSeconds;
106
+ shouldResetOnNormalize = true;
104
107
  }
105
108
  if (normalizeOnInput) {
106
109
  _this.setState({
@@ -110,7 +113,8 @@ export var TimeUnitsInput = /*#__PURE__*/function (_Component) {
110
113
  daysError: daysError,
111
114
  hoursError: hoursError,
112
115
  minutesError: null,
113
- totalSeconds: totalSeconds
116
+ totalSeconds: totalSeconds,
117
+ shouldResetOnNormalize: shouldResetOnNormalize
114
118
  }, _this.onNormalizeTime);
115
119
  } else {
116
120
  _this.setState({
@@ -123,7 +127,8 @@ export var TimeUnitsInput = /*#__PURE__*/function (_Component) {
123
127
  daysError: daysError,
124
128
  hoursError: hoursError,
125
129
  minutesError: null,
126
- totalSeconds: totalSeconds
130
+ totalSeconds: totalSeconds,
131
+ shouldResetOnNormalize: shouldResetOnNormalize
127
132
  });
128
133
  }
129
134
  };
@@ -132,13 +137,17 @@ export var TimeUnitsInput = /*#__PURE__*/function (_Component) {
132
137
  newDays = _breakdownSeconds4.days,
133
138
  newHours = _breakdownSeconds4.hours,
134
139
  newMinutes = _breakdownSeconds4.minutes;
140
+ if (_this.state.shouldResetOnNormalize) {
141
+ _this.props.onReset();
142
+ }
135
143
  _this.setState({
136
144
  days: newDays,
137
145
  rawDaysText: newDays,
138
146
  hours: newHours,
139
147
  rawHoursText: newHours,
140
148
  minutes: newMinutes,
141
- rawMinutesText: newMinutes
149
+ rawMinutesText: newMinutes,
150
+ shouldResetOnNormalize: false
142
151
  });
143
152
  _this.props.onChange(_this.state.totalSeconds);
144
153
  };
@@ -179,6 +188,7 @@ export var TimeUnitsInput = /*#__PURE__*/function (_Component) {
179
188
  rawHoursText: hours,
180
189
  rawMinutesText: minutes,
181
190
  totalSeconds: this.props.timeInSeconds,
191
+ shouldResetOnNormalize: false,
182
192
  errors: List()
183
193
  });
184
194
  }
@@ -288,7 +298,8 @@ TimeUnitsInput.propTypes = {
288
298
  minutesDataAutomation: PropTypes.string,
289
299
  maxTimeInSeconds: PropTypes.number.isRequired,
290
300
  minTimeInSeconds: PropTypes.number,
291
- normalizeOnInput: PropTypes.bool
301
+ normalizeOnInput: PropTypes.bool,
302
+ onReset: PropTypes.func
292
303
  // Should the number inputs normalize on every input event, instead of waiting for blur event?
293
304
  // Note: increment actions (e.g. arrow up) will always normalize immediately
294
305
  // Note: onChange will only ever be called after normalization
@@ -305,6 +316,7 @@ TimeUnitsInput.defaultProps = {
305
316
  daysDataAutomation: '',
306
317
  hoursDataAutomation: '',
307
318
  minutesDataAutomation: '',
308
- inputWidth: null
319
+ inputWidth: null,
320
+ onReset: void 0
309
321
  };
310
322
  export default TimeUnitsInput;
@@ -60,10 +60,11 @@ function addInfo(message) {
60
60
  });
61
61
  }
62
62
  function screenreaderNotification(message, politeness) {
63
+ var removeIn = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 2000;
63
64
  return addAlert({
64
65
  message: message,
65
66
  variant: 'screenreader',
66
- removeIn: 2000,
67
+ removeIn: removeIn,
67
68
  politeness: politeness
68
69
  });
69
70
  }
@@ -16,10 +16,10 @@ var _uiFormField = require("@instructure/ui-form-field");
16
16
  var _uiA11yContent = require("@instructure/ui-a11y-content");
17
17
  var _uiView = require("@instructure/ui-view");
18
18
  var _Errors = _interopRequireDefault(require("../../../../common/components/shared/errors/Errors.js"));
19
- var _quizNumberInput = _interopRequireDefault(require("@instructure/quiz-number-input"));
20
19
  var _immutable = require("immutable");
21
20
  var _index = require("../FormattedDuration/index.js");
22
21
  var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/format-message"));
22
+ var _quizNumberInput = require("@instructure/quiz-number-input");
23
23
  // This component renders an input for multiple time units, and handles:
24
24
  // * converting smaller units to larger units when over the unit threshold (e.g. 95 minutes to 1h35m)
25
25
  // * displaying feedback messages when unit values are over a unit threshold
@@ -57,6 +57,7 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
57
57
  var totalSeconds = minutes * _index.MINUTE_IN_SECONDS + hours * _index.HOUR_IN_SECONDS + days * _index.DAY_IN_SECONDS;
58
58
  var hoursError = null;
59
59
  var daysError = null;
60
+ var shouldResetOnNormalize = false;
60
61
  var _breakdownSeconds = (0, _index.breakdownSeconds)(totalSeconds, _this.props.includeDays),
61
62
  newDays = _breakdownSeconds.days,
62
63
  newHours = _breakdownSeconds.hours,
@@ -84,6 +85,7 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
84
85
  });
85
86
  }
86
87
  totalSeconds = _this.props.maxTimeInSeconds;
88
+ shouldResetOnNormalize = true;
87
89
  } else if (totalSeconds < _this.props.minTimeInSeconds) {
88
90
  var _breakdownSeconds3 = (0, _index.breakdownSeconds)(_this.props.minTimeInSeconds, _this.props.includeDays),
89
91
  minDays = _breakdownSeconds3.days,
@@ -107,6 +109,7 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
107
109
  });
108
110
  }
109
111
  totalSeconds = _this.props.minTimeInSeconds;
112
+ shouldResetOnNormalize = true;
110
113
  }
111
114
  if (normalizeOnInput) {
112
115
  _this.setState({
@@ -116,7 +119,8 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
116
119
  daysError: daysError,
117
120
  hoursError: hoursError,
118
121
  minutesError: null,
119
- totalSeconds: totalSeconds
122
+ totalSeconds: totalSeconds,
123
+ shouldResetOnNormalize: shouldResetOnNormalize
120
124
  }, _this.onNormalizeTime);
121
125
  } else {
122
126
  _this.setState({
@@ -129,7 +133,8 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
129
133
  daysError: daysError,
130
134
  hoursError: hoursError,
131
135
  minutesError: null,
132
- totalSeconds: totalSeconds
136
+ totalSeconds: totalSeconds,
137
+ shouldResetOnNormalize: shouldResetOnNormalize
133
138
  });
134
139
  }
135
140
  };
@@ -138,13 +143,17 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
138
143
  newDays = _breakdownSeconds4.days,
139
144
  newHours = _breakdownSeconds4.hours,
140
145
  newMinutes = _breakdownSeconds4.minutes;
146
+ if (_this.state.shouldResetOnNormalize) {
147
+ _this.props.onReset();
148
+ }
141
149
  _this.setState({
142
150
  days: newDays,
143
151
  rawDaysText: newDays,
144
152
  hours: newHours,
145
153
  rawHoursText: newHours,
146
154
  minutes: newMinutes,
147
- rawMinutesText: newMinutes
155
+ rawMinutesText: newMinutes,
156
+ shouldResetOnNormalize: false
148
157
  });
149
158
  _this.props.onChange(_this.state.totalSeconds);
150
159
  };
@@ -185,6 +194,7 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
185
194
  rawHoursText: hours,
186
195
  rawMinutesText: minutes,
187
196
  totalSeconds: this.props.timeInSeconds,
197
+ shouldResetOnNormalize: false,
188
198
  errors: (0, _immutable.List)()
189
199
  });
190
200
  }
@@ -237,7 +247,7 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
237
247
  layout: "columns",
238
248
  vAlign: "top",
239
249
  startAt: "small"
240
- }, this.props.includeDays && /*#__PURE__*/_react.default.createElement(_quizNumberInput.default, {
250
+ }, this.props.includeDays && /*#__PURE__*/_react.default.createElement(_quizNumberInput.NumberInput, {
241
251
  renderLabel: this.props.daysLabel,
242
252
  min: 0,
243
253
  value: this.state.rawDaysText,
@@ -248,7 +258,7 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
248
258
  }] : null,
249
259
  "data-automation": this.props.daysDataAutomation,
250
260
  width: this.props.inputWidth
251
- }), /*#__PURE__*/_react.default.createElement(_quizNumberInput.default, {
261
+ }), /*#__PURE__*/_react.default.createElement(_quizNumberInput.NumberInput, {
252
262
  renderLabel: this.props.hoursLabel,
253
263
  min: this.props.includeDays ? void 0 : 0,
254
264
  value: this.state.rawHoursText,
@@ -259,7 +269,7 @@ var TimeUnitsInput = /*#__PURE__*/function (_Component) {
259
269
  }] : null,
260
270
  "data-automation": this.props.hoursDataAutomation,
261
271
  width: this.props.inputWidth
262
- }), /*#__PURE__*/_react.default.createElement(_quizNumberInput.default, {
272
+ }), /*#__PURE__*/_react.default.createElement(_quizNumberInput.NumberInput, {
263
273
  renderLabel: this.props.minutesLabel,
264
274
  value: this.state.rawMinutesText,
265
275
  onChange: this.onChangeExtraMinutes,
@@ -295,7 +305,8 @@ TimeUnitsInput.propTypes = {
295
305
  minutesDataAutomation: _propTypes.default.string,
296
306
  maxTimeInSeconds: _propTypes.default.number.isRequired,
297
307
  minTimeInSeconds: _propTypes.default.number,
298
- normalizeOnInput: _propTypes.default.bool
308
+ normalizeOnInput: _propTypes.default.bool,
309
+ onReset: _propTypes.default.func
299
310
  // Should the number inputs normalize on every input event, instead of waiting for blur event?
300
311
  // Note: increment actions (e.g. arrow up) will always normalize immediately
301
312
  // Note: onChange will only ever be called after normalization
@@ -312,7 +323,8 @@ TimeUnitsInput.defaultProps = {
312
323
  daysDataAutomation: '',
313
324
  hoursDataAutomation: '',
314
325
  minutesDataAutomation: '',
315
- inputWidth: null
326
+ inputWidth: null,
327
+ onReset: void 0
316
328
  };
317
329
  var _default = TimeUnitsInput;
318
330
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "20.35.3-rc.4+03bf2e57f",
3
+ "version": "20.35.3-rc.5+69d5bb5ff",
4
4
  "license": "MIT",
5
5
  "description": "The Quiz React SDK by Instructure Inc.",
6
6
  "author": "Instructure, Inc. Engineering and Product Design",
@@ -46,11 +46,11 @@
46
46
  "@instructure/emotion": "^8.56.3",
47
47
  "@instructure/grading-utils": "^1.0.0",
48
48
  "@instructure/outcomes-ui": "^3.2.2",
49
- "@instructure/quiz-common": "^20.35.3-rc.4+03bf2e57f",
50
- "@instructure/quiz-i18n": "^20.35.3-rc.4+03bf2e57f",
51
- "@instructure/quiz-interactions": "^20.35.3-rc.4+03bf2e57f",
52
- "@instructure/quiz-number-input": "^20.35.3-rc.4+03bf2e57f",
53
- "@instructure/quiz-rce": "^20.35.3-rc.4+03bf2e57f",
49
+ "@instructure/quiz-common": "^20.35.3-rc.5+69d5bb5ff",
50
+ "@instructure/quiz-i18n": "^20.35.3-rc.5+69d5bb5ff",
51
+ "@instructure/quiz-interactions": "^20.35.3-rc.5+69d5bb5ff",
52
+ "@instructure/quiz-number-input": "^20.35.3-rc.5+69d5bb5ff",
53
+ "@instructure/quiz-rce": "^20.35.3-rc.5+69d5bb5ff",
54
54
  "@instructure/ui-a11y-content": "^8.56.3",
55
55
  "@instructure/ui-alerts": "^8.56.3",
56
56
  "@instructure/ui-avatar": "^8.56.3",
@@ -114,7 +114,7 @@
114
114
  "file-saver": "~2.0.5",
115
115
  "humps": "^2.0.0",
116
116
  "immutable": "^3.8.1",
117
- "instructure-validations": "^20.35.3-rc.4+03bf2e57f",
117
+ "instructure-validations": "^20.35.3-rc.5+69d5bb5ff",
118
118
  "ipaddr.js": "^1.5.4",
119
119
  "isomorphic-fetch": "^2.2.0",
120
120
  "isuuid": "^0.1.0",
@@ -163,7 +163,7 @@
163
163
  "jquery": "^2.2.3",
164
164
  "karma-junit-reporter": "^2.0.1",
165
165
  "most-subject": "^5.3.0",
166
- "quiz-presets": "^20.35.3-rc.4+03bf2e57f",
166
+ "quiz-presets": "^20.35.3-rc.5+69d5bb5ff",
167
167
  "react": "^16.8.6",
168
168
  "react-addons-test-utils": "^15.6.2",
169
169
  "react-dom": "^16.8.6",
@@ -179,5 +179,5 @@
179
179
  "publishConfig": {
180
180
  "access": "public"
181
181
  },
182
- "gitHead": "03bf2e57fdc3379d33a09042beba6167e6eb896e"
182
+ "gitHead": "69d5bb5ffcf37feb54044541884cb1709b170389"
183
183
  }