@instructure/quiz-core 21.0.1-rc.13 → 21.0.1-rc.15

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.
@@ -9,7 +9,7 @@ var _dec, _class, _DeleteStimulusModal;
9
9
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
10
10
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
11
  /** @jsx jsx */
12
- import { Component } from 'react';
12
+ import React, { Component } from 'react';
13
13
  import PropTypes from 'prop-types';
14
14
  import ImmutablePropTypes from 'react-immutable-proptypes';
15
15
  import partial from 'lodash/partial';
@@ -26,19 +26,31 @@ import { Modal, ModalHeader, ModalBody, ModalFooter, DELETE_STIMULUS_MODAL_SELEC
26
26
  import generateStyle from './styles';
27
27
  import generateComponentTheme from './theme';
28
28
  export var DeleteStimulusModal = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_DeleteStimulusModal = /*#__PURE__*/function (_Component) {
29
- function DeleteStimulusModal() {
29
+ function DeleteStimulusModal(props) {
30
30
  var _this;
31
31
  _classCallCheck(this, DeleteStimulusModal);
32
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
- args[_key] = arguments[_key];
34
- }
35
- _this = _callSuper(this, DeleteStimulusModal, [].concat(args));
32
+ _this = _callSuper(this, DeleteStimulusModal, [props]);
33
+ /**
34
+ * @type {React.RefObject<RadioInput> | null}
35
+ */
36
+ _defineProperty(_this, "radioInputRef", null);
36
37
  _defineProperty(_this, "handleSubmit", function (e) {
37
- _this.closeAction();
38
38
  var _this$props = _this.props,
39
39
  quizId = _this$props.quizId,
40
40
  stimulusEntry = _this$props.stimulusEntry,
41
41
  childEntries = _this$props.childEntries;
42
+ if (!_this.props.deletionMode && childEntries.size > 0) {
43
+ var _this$radioInputRef;
44
+ (_this$radioInputRef = _this.radioInputRef) === null || _this$radioInputRef === void 0 || (_this$radioInputRef = _this$radioInputRef.current) === null || _this$radioInputRef === void 0 || _this$radioInputRef.focus();
45
+ _this.setState({
46
+ validationError: [{
47
+ text: t('Please choose a deletion mode.'),
48
+ type: 'newError'
49
+ }]
50
+ });
51
+ return;
52
+ }
53
+ _this.closeAction();
42
54
  if (_this.props.deletionMode === 'chooseWhich') {
43
55
  _this.removeStimulus(_this.props.selectedChildren.toArray());
44
56
  } else if (_this.props.deletionMode === 'deleteAll') {
@@ -51,8 +63,17 @@ export var DeleteStimulusModal = (_dec = withStyleOverrides(generateStyle, gener
51
63
  _this.props.closeModal();
52
64
  _this.props.setUi(DELETE_STIMULUS_MODAL_DELETION_MODE, null);
53
65
  _this.props.setUi(DELETE_STIMULUS_MODAL_SELECTED_CHILDREN, Set.of());
66
+ _this.clearValidationError();
67
+ });
68
+ _defineProperty(_this, "clearValidationError", function () {
69
+ if (_this.state.validationError) {
70
+ _this.setState({
71
+ validationError: null
72
+ });
73
+ }
54
74
  });
55
75
  _defineProperty(_this, "setDeletionMode", function (event, value) {
76
+ _this.clearValidationError();
56
77
  _this.props.setUi(DELETE_STIMULUS_MODAL_DELETION_MODE, value);
57
78
  });
58
79
  _defineProperty(_this, "toggleChildSelected", function (childEntry) {
@@ -96,6 +117,10 @@ export var DeleteStimulusModal = (_dec = withStyleOverrides(generateStyle, gener
96
117
  css: _this.props.styles.checkboxesWrapper
97
118
  }, jsx(PresentationContent, null, jsx("hr", null)), checkboxes, jsx(PresentationContent, null, jsx("hr", null)));
98
119
  });
120
+ _this.state = {
121
+ validationError: null
122
+ };
123
+ _this.radioInputRef = React.createRef();
99
124
  return _this;
100
125
  }
101
126
  _inherits(DeleteStimulusModal, _Component);
@@ -156,12 +181,7 @@ export var DeleteStimulusModal = (_dec = withStyleOverrides(generateStyle, gener
156
181
  }, {
157
182
  key: "doneButton",
158
183
  value: function doneButton() {
159
- var _this$props3 = this.props,
160
- deletionMode = _this$props3.deletionMode,
161
- childEntries = _this$props3.childEntries;
162
- var disabled = !deletionMode && childEntries.size > 0;
163
184
  return jsx(Button, {
164
- disabled: disabled,
165
185
  color: "primary",
166
186
  onClick: this.handleSubmit,
167
187
  margin: XSMALL_SIDE_MARGIN,
@@ -189,8 +209,10 @@ export var DeleteStimulusModal = (_dec = withStyleOverrides(generateStyle, gener
189
209
  name: "deletionMode",
190
210
  defaultValue: this.props.deletionMode,
191
211
  onChange: this.setDeletionMode,
192
- description: jsx(ScreenReaderContent, null, t('Stimulus Removal Mode'))
212
+ description: jsx(ScreenReaderContent, null, t('Stimulus Removal Mode')),
213
+ messages: this.state.validationError
193
214
  }, jsx(RadioInput, {
215
+ ref: this.radioInputRef,
194
216
  key: "deleteAll",
195
217
  value: "deleteAll",
196
218
  label: jsx("div", {
@@ -12,7 +12,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
12
12
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
13
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
- var _react = require("react");
15
+ var _react = _interopRequireWildcard(require("react"));
16
16
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
  var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));
18
18
  var _partial = _interopRequireDefault(require("lodash/partial"));
@@ -30,22 +30,36 @@ var _styles = _interopRequireDefault(require("./styles"));
30
30
  var _theme = _interopRequireDefault(require("./theme"));
31
31
  var _dec, _class, _DeleteStimulusModal;
32
32
  /** @jsx jsx */
33
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
34
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
33
35
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
34
36
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
35
37
  var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.withStyleOverrides)(_styles["default"], _theme["default"]), _dec(_class = (_DeleteStimulusModal = /*#__PURE__*/function (_Component) {
36
- function DeleteStimulusModal() {
38
+ function DeleteStimulusModal(props) {
37
39
  var _this;
38
40
  (0, _classCallCheck2["default"])(this, DeleteStimulusModal);
39
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
- args[_key] = arguments[_key];
41
- }
42
- _this = _callSuper(this, DeleteStimulusModal, [].concat(args));
41
+ _this = _callSuper(this, DeleteStimulusModal, [props]);
42
+ /**
43
+ * @type {React.RefObject<RadioInput> | null}
44
+ */
45
+ (0, _defineProperty2["default"])(_this, "radioInputRef", null);
43
46
  (0, _defineProperty2["default"])(_this, "handleSubmit", function (e) {
44
- _this.closeAction();
45
47
  var _this$props = _this.props,
46
48
  quizId = _this$props.quizId,
47
49
  stimulusEntry = _this$props.stimulusEntry,
48
50
  childEntries = _this$props.childEntries;
51
+ if (!_this.props.deletionMode && childEntries.size > 0) {
52
+ var _this$radioInputRef;
53
+ (_this$radioInputRef = _this.radioInputRef) === null || _this$radioInputRef === void 0 || (_this$radioInputRef = _this$radioInputRef.current) === null || _this$radioInputRef === void 0 || _this$radioInputRef.focus();
54
+ _this.setState({
55
+ validationError: [{
56
+ text: (0, _formatMessage["default"])('Please choose a deletion mode.'),
57
+ type: 'newError'
58
+ }]
59
+ });
60
+ return;
61
+ }
62
+ _this.closeAction();
49
63
  if (_this.props.deletionMode === 'chooseWhich') {
50
64
  _this.removeStimulus(_this.props.selectedChildren.toArray());
51
65
  } else if (_this.props.deletionMode === 'deleteAll') {
@@ -58,8 +72,17 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
58
72
  _this.props.closeModal();
59
73
  _this.props.setUi(_quizCommon.DELETE_STIMULUS_MODAL_DELETION_MODE, null);
60
74
  _this.props.setUi(_quizCommon.DELETE_STIMULUS_MODAL_SELECTED_CHILDREN, _immutable.Set.of());
75
+ _this.clearValidationError();
76
+ });
77
+ (0, _defineProperty2["default"])(_this, "clearValidationError", function () {
78
+ if (_this.state.validationError) {
79
+ _this.setState({
80
+ validationError: null
81
+ });
82
+ }
61
83
  });
62
84
  (0, _defineProperty2["default"])(_this, "setDeletionMode", function (event, value) {
85
+ _this.clearValidationError();
63
86
  _this.props.setUi(_quizCommon.DELETE_STIMULUS_MODAL_DELETION_MODE, value);
64
87
  });
65
88
  (0, _defineProperty2["default"])(_this, "toggleChildSelected", function (childEntry) {
@@ -103,6 +126,10 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
103
126
  css: _this.props.styles.checkboxesWrapper
104
127
  }, (0, _emotion.jsx)(_uiA11yContent.PresentationContent, null, (0, _emotion.jsx)("hr", null)), checkboxes, (0, _emotion.jsx)(_uiA11yContent.PresentationContent, null, (0, _emotion.jsx)("hr", null)));
105
128
  });
129
+ _this.state = {
130
+ validationError: null
131
+ };
132
+ _this.radioInputRef = _react["default"].createRef();
106
133
  return _this;
107
134
  }
108
135
  (0, _inherits2["default"])(DeleteStimulusModal, _Component);
@@ -163,12 +190,7 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
163
190
  }, {
164
191
  key: "doneButton",
165
192
  value: function doneButton() {
166
- var _this$props3 = this.props,
167
- deletionMode = _this$props3.deletionMode,
168
- childEntries = _this$props3.childEntries;
169
- var disabled = !deletionMode && childEntries.size > 0;
170
193
  return (0, _emotion.jsx)(_uiButtons.Button, {
171
- disabled: disabled,
172
194
  color: "primary",
173
195
  onClick: this.handleSubmit,
174
196
  margin: _quizCommon.XSMALL_SIDE_MARGIN,
@@ -196,8 +218,10 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
196
218
  name: "deletionMode",
197
219
  defaultValue: this.props.deletionMode,
198
220
  onChange: this.setDeletionMode,
199
- description: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage["default"])('Stimulus Removal Mode'))
221
+ description: (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage["default"])('Stimulus Removal Mode')),
222
+ messages: this.state.validationError
200
223
  }, (0, _emotion.jsx)(_uiRadioInput.RadioInput, {
224
+ ref: this.radioInputRef,
201
225
  key: "deleteAll",
202
226
  value: "deleteAll",
203
227
  label: (0, _emotion.jsx)("div", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/quiz-core",
3
- "version": "21.0.1-rc.13+17470e761",
3
+ "version": "21.0.1-rc.15+2eb659881",
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": "^9.11.1",
47
47
  "@instructure/grading-utils": "^1.0.0",
48
48
  "@instructure/outcomes-ui": "^3.2.2",
49
- "@instructure/quiz-common": "21.0.1-rc.13+17470e761",
50
- "@instructure/quiz-i18n": "21.0.1-rc.13+17470e761",
51
- "@instructure/quiz-interactions": "21.0.1-rc.13+17470e761",
52
- "@instructure/quiz-number-input": "21.0.1-rc.13+17470e761",
53
- "@instructure/quiz-rce": "21.0.1-rc.13+17470e761",
49
+ "@instructure/quiz-common": "21.0.1-rc.15+2eb659881",
50
+ "@instructure/quiz-i18n": "21.0.1-rc.15+2eb659881",
51
+ "@instructure/quiz-interactions": "21.0.1-rc.15+2eb659881",
52
+ "@instructure/quiz-number-input": "21.0.1-rc.15+2eb659881",
53
+ "@instructure/quiz-rce": "21.0.1-rc.15+2eb659881",
54
54
  "@instructure/ui-a11y-content": "^9.11.1",
55
55
  "@instructure/ui-alerts": "^9.11.1",
56
56
  "@instructure/ui-avatar": "^9.11.1",
@@ -109,7 +109,7 @@
109
109
  "file-saver": "~2.0.5",
110
110
  "humps": "^2.0.0",
111
111
  "immutable": "^3.8.1",
112
- "instructure-validations": "21.0.1-rc.13+17470e761",
112
+ "instructure-validations": "21.0.1-rc.15+2eb659881",
113
113
  "ipaddr.js": "^1.5.4",
114
114
  "isomorphic-fetch": "^2.2.0",
115
115
  "isuuid": "^0.1.0",
@@ -158,7 +158,7 @@
158
158
  "jquery": "^2.2.3",
159
159
  "karma-junit-reporter": "^2.0.1",
160
160
  "most-subject": "^5.3.0",
161
- "quiz-presets": "21.0.1-rc.13+17470e761",
161
+ "quiz-presets": "21.0.1-rc.15+2eb659881",
162
162
  "react": "^16.8.6",
163
163
  "react-addons-test-utils": "^15.6.2",
164
164
  "react-dom": "^16.8.6",
@@ -174,5 +174,5 @@
174
174
  "publishConfig": {
175
175
  "access": "public"
176
176
  },
177
- "gitHead": "17470e7616cdb6731bf58c3560f4ea714990c58f"
177
+ "gitHead": "2eb6598816fde1560fa50fe1f5bc3a718819a36a"
178
178
  }