@instructure/quiz-core 22.0.0 → 22.2.0
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/es/banks/components/AddBankEntryModal/presenter.js +4 -1
- package/es/banks/components/BankEntry/presenter.js +110 -12
- package/es/banks/components/BankEntryRow/presenter.js +52 -8
- package/es/banks/components/CopyMoveBankEntryModal/presenter.js +84 -15
- package/es/building/components/resources/DeleteStimulusModal/presenter.js +13 -7
- package/es/common/components/layout/sidebar/Stimulus/Collection/presenter.js +6 -3
- package/es/common/components/layout/sidebar/Stimulus/presenter.js +103 -40
- package/es/common/components/layout/sidebar/Stimulus/styles.js +2 -26
- package/es/common/components/layout/sidebar/Stimulus/theme.js +1 -10
- package/es/common/components/resources/BankSelection/presenter.js +31 -8
- package/es/common/components/resources/sessionItemResult/SessionItemResult/presenter.js +20 -20
- package/es/common/components/resources/stimulus/Stimulus/presenter.js +2 -2
- package/es/common/components/resources/stimulus/StimulusEdit/presenter.js +40 -37
- package/es/common/components/resources/stimulus/StimulusEditInfo/presenter.js +6 -5
- package/es/common/components/resources/stimulus/StimulusShow/index.js +1 -1
- package/es/common/components/resources/stimulus/StimulusShowInfo/index.js +1 -1
- package/es/common/components/shared/GenericAsyncSearch/GenericAsyncSearch.js +10 -3
- package/es/common/components/shared/InteractionTypes/presenter.js +3 -2
- package/es/common/components/shared/drag_and_drop/dragAndDropUtils.js +7 -0
- package/es/common/records/BankEntry.js +9 -1
- package/es/common/records/QuizEntry.js +29 -17
- package/es/common/records/SessionItem.js +6 -0
- package/es/common/reducers/modifications.js +21 -12
- package/es/common/util/warningHelpers.js +13 -3
- package/es/moderating/components/sidebar/ModerateTray/presenter.js +5 -5
- package/es/taking/api/taking.js +1 -1
- package/lib/banks/components/AddBankEntryModal/presenter.js +4 -1
- package/lib/banks/components/BankEntry/presenter.js +110 -12
- package/lib/banks/components/BankEntryRow/presenter.js +52 -8
- package/lib/banks/components/CopyMoveBankEntryModal/presenter.js +84 -15
- package/lib/building/components/resources/DeleteStimulusModal/presenter.js +13 -7
- package/lib/common/components/layout/sidebar/Stimulus/Collection/presenter.js +6 -3
- package/lib/common/components/layout/sidebar/Stimulus/presenter.js +103 -40
- package/lib/common/components/layout/sidebar/Stimulus/styles.js +2 -26
- package/lib/common/components/layout/sidebar/Stimulus/theme.js +1 -10
- package/lib/common/components/resources/BankSelection/presenter.js +31 -8
- package/lib/common/components/resources/sessionItemResult/SessionItemResult/presenter.js +20 -20
- package/lib/common/components/resources/stimulus/Stimulus/presenter.js +2 -2
- package/lib/common/components/resources/stimulus/StimulusEdit/presenter.js +40 -37
- package/lib/common/components/resources/stimulus/StimulusEditInfo/presenter.js +6 -5
- package/lib/common/components/resources/stimulus/StimulusShow/index.js +1 -1
- package/lib/common/components/resources/stimulus/StimulusShowInfo/index.js +1 -1
- package/lib/common/components/shared/GenericAsyncSearch/GenericAsyncSearch.js +10 -3
- package/lib/common/components/shared/InteractionTypes/presenter.js +3 -2
- package/lib/common/components/shared/drag_and_drop/dragAndDropUtils.js +7 -0
- package/lib/common/records/BankEntry.js +9 -1
- package/lib/common/records/QuizEntry.js +29 -17
- package/lib/common/records/SessionItem.js +6 -0
- package/lib/common/reducers/modifications.js +21 -12
- package/lib/common/util/warningHelpers.js +13 -3
- package/lib/moderating/components/sidebar/ModerateTray/presenter.js +5 -5
- package/lib/taking/api/taking.js +1 -1
- package/package.json +8 -8
|
@@ -40,17 +40,27 @@ function _callSuper(_this, derived, args) {
|
|
|
40
40
|
return (0, _possibleConstructorReturn2["default"])(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], (0, _getPrototypeOf2["default"])(_this).constructor) : derived.apply(_this, args));
|
|
41
41
|
}
|
|
42
42
|
var CopyMoveBankEntryModal = exports.CopyMoveBankEntryModal = /*#__PURE__*/function (_Component) {
|
|
43
|
-
function CopyMoveBankEntryModal() {
|
|
43
|
+
function CopyMoveBankEntryModal(props) {
|
|
44
44
|
var _this2;
|
|
45
45
|
(0, _classCallCheck2["default"])(this, CopyMoveBankEntryModal);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
_this2 = _callSuper(this, CopyMoveBankEntryModal, [props]);
|
|
47
|
+
/**
|
|
48
|
+
* @type {React.RefObject<RadioInput> | null}
|
|
49
|
+
*/
|
|
50
|
+
(0, _defineProperty2["default"])(_this2, "radioInputRef", null);
|
|
51
|
+
/**
|
|
52
|
+
* @type {React.RefObject<TextInput> | null}
|
|
53
|
+
*/
|
|
54
|
+
(0, _defineProperty2["default"])(_this2, "textInputRef", null);
|
|
50
55
|
(0, _defineProperty2["default"])(_this2, "state", {
|
|
51
56
|
bankType: 'existing',
|
|
52
57
|
newBankTitle: '',
|
|
53
|
-
selectedBank: null
|
|
58
|
+
selectedBank: null,
|
|
59
|
+
radioValidationError: null,
|
|
60
|
+
selectValidationError: null
|
|
61
|
+
});
|
|
62
|
+
(0, _defineProperty2["default"])(_this2, "setBankInputRef", function (ref) {
|
|
63
|
+
_this2.bankSelectionInputRef = ref;
|
|
54
64
|
});
|
|
55
65
|
(0, _defineProperty2["default"])(_this2, "copyOrMove", function (newBankId) {
|
|
56
66
|
if (_this2.props.keepCopy) {
|
|
@@ -60,7 +70,55 @@ var CopyMoveBankEntryModal = exports.CopyMoveBankEntryModal = /*#__PURE__*/funct
|
|
|
60
70
|
}
|
|
61
71
|
_this2.closeAction();
|
|
62
72
|
});
|
|
73
|
+
(0, _defineProperty2["default"])(_this2, "clearValidationErrors", function () {
|
|
74
|
+
_this2.setState({
|
|
75
|
+
radioValidationError: null,
|
|
76
|
+
selectValidationError: null
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
(0, _defineProperty2["default"])(_this2, "validateAction", function () {
|
|
80
|
+
var _this2$state = _this2.state,
|
|
81
|
+
bankType = _this2$state.bankType,
|
|
82
|
+
newBankTitle = _this2$state.newBankTitle,
|
|
83
|
+
selectedBank = _this2$state.selectedBank;
|
|
84
|
+
if (!bankType) {
|
|
85
|
+
var _this2$radioInputRef;
|
|
86
|
+
(_this2$radioInputRef = _this2.radioInputRef) === null || _this2$radioInputRef === void 0 || (_this2$radioInputRef = _this2$radioInputRef.current) === null || _this2$radioInputRef === void 0 || _this2$radioInputRef.focus();
|
|
87
|
+
_this2.setState({
|
|
88
|
+
radioValidationError: [{
|
|
89
|
+
text: (0, _formatMessage["default"])('Please choose a Copy/Move option'),
|
|
90
|
+
type: 'newError'
|
|
91
|
+
}]
|
|
92
|
+
});
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (bankType === 'existing' && !selectedBank) {
|
|
96
|
+
_this2.bankSelectionInputRef.focus();
|
|
97
|
+
_this2.setState({
|
|
98
|
+
selectValidationError: [{
|
|
99
|
+
text: (0, _formatMessage["default"])('Please select a bank'),
|
|
100
|
+
type: 'newError'
|
|
101
|
+
}]
|
|
102
|
+
});
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (bankType === 'new' && (!newBankTitle || !newBankTitle.trim())) {
|
|
106
|
+
var _this2$textInputRef;
|
|
107
|
+
(_this2$textInputRef = _this2.textInputRef) === null || _this2$textInputRef === void 0 || (_this2$textInputRef = _this2$textInputRef.current) === null || _this2$textInputRef === void 0 || _this2$textInputRef.focus();
|
|
108
|
+
_this2.setState({
|
|
109
|
+
selectValidationError: [{
|
|
110
|
+
text: (0, _formatMessage["default"])('Please enter a new bank title'),
|
|
111
|
+
type: 'newError'
|
|
112
|
+
}]
|
|
113
|
+
});
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
});
|
|
63
118
|
(0, _defineProperty2["default"])(_this2, "continueAction", function () {
|
|
119
|
+
if (!_this2.validateAction()) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
64
122
|
if (_this2.state.bankType === 'new') {
|
|
65
123
|
var newBank = _Bank["default"].create({
|
|
66
124
|
title: _this2.state.newBankTitle,
|
|
@@ -101,12 +159,14 @@ var CopyMoveBankEntryModal = exports.CopyMoveBankEntryModal = /*#__PURE__*/funct
|
|
|
101
159
|
return _this2.initiateCopy(newBankId).then(_this2.props.onAdd);
|
|
102
160
|
});
|
|
103
161
|
(0, _defineProperty2["default"])(_this2, "closeAction", function () {
|
|
162
|
+
_this2.clearValidationErrors();
|
|
104
163
|
if (_this2.props.modalTrigger) {
|
|
105
164
|
_this2.props.modalTrigger.focus();
|
|
106
165
|
}
|
|
107
166
|
_this2.props.closeModal();
|
|
108
167
|
});
|
|
109
168
|
(0, _defineProperty2["default"])(_this2, "onBankSelection", function (e, option) {
|
|
169
|
+
_this2.clearValidationErrors();
|
|
110
170
|
_this2.setState({
|
|
111
171
|
selectedBank: new _Bank["default"](option)
|
|
112
172
|
});
|
|
@@ -115,15 +175,20 @@ var CopyMoveBankEntryModal = exports.CopyMoveBankEntryModal = /*#__PURE__*/funct
|
|
|
115
175
|
_this2.props.uiSet(_quizCommon.COPY_MOVE_BANK_ENTRY_MODAL_KEEP_COPY, e.target.checked);
|
|
116
176
|
});
|
|
117
177
|
(0, _defineProperty2["default"])(_this2, "handleRadioChange", function (event, value) {
|
|
178
|
+
_this2.clearValidationErrors();
|
|
118
179
|
_this2.setState({
|
|
119
180
|
bankType: value
|
|
120
181
|
});
|
|
121
182
|
});
|
|
122
183
|
(0, _defineProperty2["default"])(_this2, "onTitleChange", function (e) {
|
|
184
|
+
_this2.clearValidationErrors();
|
|
123
185
|
_this2.setState({
|
|
124
186
|
newBankTitle: e.target.value
|
|
125
187
|
});
|
|
126
188
|
});
|
|
189
|
+
_this2.radioInputRef = _react["default"].createRef();
|
|
190
|
+
_this2.textInputRef = _react["default"].createRef();
|
|
191
|
+
_this2.bankSelectionInputRef = _react["default"].createRef();
|
|
127
192
|
return _this2;
|
|
128
193
|
}
|
|
129
194
|
(0, _inherits2["default"])(CopyMoveBankEntryModal, _Component);
|
|
@@ -138,14 +203,9 @@ var CopyMoveBankEntryModal = exports.CopyMoveBankEntryModal = /*#__PURE__*/funct
|
|
|
138
203
|
}, {
|
|
139
204
|
key: "addToBankButton",
|
|
140
205
|
value: function addToBankButton() {
|
|
141
|
-
var _this$state = this.state,
|
|
142
|
-
bankType = _this$state.bankType,
|
|
143
|
-
newBankTitle = _this$state.newBankTitle;
|
|
144
|
-
var disabled = bankType === 'existing' && !this.state.selectedBank || bankType === 'new' && (!newBankTitle || !newBankTitle.trim());
|
|
145
206
|
return /*#__PURE__*/_react["default"].createElement(_uiButtons.Button, {
|
|
146
207
|
color: "primary",
|
|
147
208
|
onClick: this.continueAction,
|
|
148
|
-
disabled: disabled,
|
|
149
209
|
margin: _quizCommon.XSMALL_SIDE_MARGIN,
|
|
150
210
|
"data-automation": "sdk-add-to-bank-button"
|
|
151
211
|
}, (0, _formatMessage["default"])('Add'));
|
|
@@ -155,16 +215,22 @@ var CopyMoveBankEntryModal = exports.CopyMoveBankEntryModal = /*#__PURE__*/funct
|
|
|
155
215
|
value: function renderBankTypeContent() {
|
|
156
216
|
if (this.state.bankType === 'existing') {
|
|
157
217
|
return /*#__PURE__*/_react["default"].createElement(_presenter["default"], {
|
|
218
|
+
inputRef: this.setBankInputRef,
|
|
158
219
|
onBankSelection: this.onBankSelection,
|
|
159
220
|
selectedBank: this.state.selectedBank,
|
|
160
|
-
"data-automation": "sdk-bank-selection"
|
|
221
|
+
"data-automation": "sdk-bank-selection",
|
|
222
|
+
externalError: this.state.selectValidationError,
|
|
223
|
+
isRequired: true
|
|
161
224
|
});
|
|
162
225
|
}
|
|
163
226
|
return /*#__PURE__*/_react["default"].createElement(_quizCommon.TextInput, {
|
|
164
227
|
onChange: this.onTitleChange,
|
|
165
228
|
value: this.state.newBankTitle,
|
|
166
229
|
renderLabel: (0, _formatMessage["default"])('New Bank Title'),
|
|
167
|
-
type: "text"
|
|
230
|
+
type: "text",
|
|
231
|
+
messages: this.state.selectValidationError,
|
|
232
|
+
ref: this.textInputRef,
|
|
233
|
+
isRequired: true
|
|
168
234
|
});
|
|
169
235
|
}
|
|
170
236
|
}, {
|
|
@@ -174,10 +240,13 @@ var CopyMoveBankEntryModal = exports.CopyMoveBankEntryModal = /*#__PURE__*/funct
|
|
|
174
240
|
onChange: this.handleRadioChange,
|
|
175
241
|
name: (0, _formatMessage["default"])('Bank Type'),
|
|
176
242
|
defaultValue: this.state.bankType,
|
|
177
|
-
description: /*#__PURE__*/_react["default"].createElement(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage["default"])('Bank Type'))
|
|
243
|
+
description: /*#__PURE__*/_react["default"].createElement(_uiA11yContent.ScreenReaderContent, null, (0, _formatMessage["default"])('Bank Type')),
|
|
244
|
+
messages: this.state.radioValidationError,
|
|
245
|
+
isRequired: true
|
|
178
246
|
}, /*#__PURE__*/_react["default"].createElement(_uiRadioInput.RadioInput, {
|
|
179
247
|
value: "existing",
|
|
180
|
-
label: (0, _formatMessage["default"])('Existing item bank')
|
|
248
|
+
label: (0, _formatMessage["default"])('Existing item bank'),
|
|
249
|
+
ref: this.radioInputRef
|
|
181
250
|
}), /*#__PURE__*/_react["default"].createElement(_uiRadioInput.RadioInput, {
|
|
182
251
|
value: "new",
|
|
183
252
|
label: (0, _formatMessage["default"])('New item bank')
|
|
@@ -165,8 +165,14 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
|
|
|
165
165
|
}, {
|
|
166
166
|
key: "isPassage",
|
|
167
167
|
value: function isPassage() {
|
|
168
|
-
var _this$props$stimulusE;
|
|
169
|
-
|
|
168
|
+
var _this$props$stimulusE, _this$props$stimulusE3;
|
|
169
|
+
if (((_this$props$stimulusE = this.props.stimulusEntry) === null || _this$props$stimulusE === void 0 ? void 0 : _this$props$stimulusE.entryType) === 'BankEntry') {
|
|
170
|
+
var _this$props$stimulusE2;
|
|
171
|
+
var bankEntry = (_this$props$stimulusE2 = this.props.stimulusEntry) === null || _this$props$stimulusE2 === void 0 ? void 0 : _this$props$stimulusE2.getEntry();
|
|
172
|
+
var stimulusEntry = bankEntry === null || bankEntry === void 0 ? void 0 : bankEntry.getEntry();
|
|
173
|
+
return stimulusEntry === null || stimulusEntry === void 0 ? void 0 : stimulusEntry.isPassage;
|
|
174
|
+
}
|
|
175
|
+
return (_this$props$stimulusE3 = this.props.stimulusEntry) === null || _this$props$stimulusE3 === void 0 ? void 0 : _this$props$stimulusE3.getEntry().passage;
|
|
170
176
|
}
|
|
171
177
|
}, {
|
|
172
178
|
key: "anyImmutableKeepers",
|
|
@@ -197,7 +203,7 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
|
|
|
197
203
|
onClick: this.closeAction,
|
|
198
204
|
margin: _quizCommon.XSMALL_SIDE_MARGIN,
|
|
199
205
|
"data-automation": "sdk-keep-".concat(this.isPassage() ? 'passage' : 'stimulus', "-button")
|
|
200
|
-
}, this.isPassage() ? (0, _formatMessage["default"])('Keep
|
|
206
|
+
}, this.isPassage() ? (0, _formatMessage["default"])('Keep Text Block') : (0, _formatMessage["default"])('Keep Stimulus'));
|
|
201
207
|
}
|
|
202
208
|
}, {
|
|
203
209
|
key: "doneButton",
|
|
@@ -207,7 +213,7 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
|
|
|
207
213
|
onClick: this.handleSubmit,
|
|
208
214
|
margin: _quizCommon.XSMALL_SIDE_MARGIN,
|
|
209
215
|
"data-automation": "sdk-remove-".concat(this.isPassage() ? 'passage' : 'stimulus', "-button")
|
|
210
|
-
}, this.isPassage() ? (0, _formatMessage["default"])('Remove
|
|
216
|
+
}, this.isPassage() ? (0, _formatMessage["default"])('Remove Text Block') : (0, _formatMessage["default"])('Remove Stimulus'));
|
|
211
217
|
}
|
|
212
218
|
}, {
|
|
213
219
|
key: "renderChooseWhich",
|
|
@@ -250,7 +256,7 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
|
|
|
250
256
|
}, {
|
|
251
257
|
key: "renderContent",
|
|
252
258
|
value: function renderContent() {
|
|
253
|
-
var message = this.isPassage() ? (0, _formatMessage["default"])('Are you sure you want to remove this
|
|
259
|
+
var message = this.isPassage() ? (0, _formatMessage["default"])('Are you sure you want to remove this text block?') : (0, _formatMessage["default"])('Are you sure you want to remove this stimulus?');
|
|
254
260
|
var content = this.props.childEntries.size === 0 ? (0, _emotion.jsx)("span", null, message) : this.renderMainMenu();
|
|
255
261
|
var stimulusTitle = this.props.stimulusEntry && this.props.stimulusEntry.getEntry().title;
|
|
256
262
|
return (0, _emotion.jsx)("div", {
|
|
@@ -267,11 +273,11 @@ var DeleteStimulusModal = exports.DeleteStimulusModal = (_dec = (0, _quizCommon.
|
|
|
267
273
|
open: this.props.modalOpen,
|
|
268
274
|
onDismiss: this.closeAction,
|
|
269
275
|
size: "small",
|
|
270
|
-
label: this.isPassage() ? (0, _formatMessage["default"])('Confirm
|
|
276
|
+
label: this.isPassage() ? (0, _formatMessage["default"])('Confirm Text Block Removal') : (0, _formatMessage["default"])('Confirm Stimulus Removal')
|
|
271
277
|
}, (0, _emotion.jsx)(_quizCommon.ModalHeader, null, (0, _emotion.jsx)(_uiHeading.Heading, {
|
|
272
278
|
level: "reset",
|
|
273
279
|
as: "h2"
|
|
274
|
-
}, this.isPassage() ? (0, _formatMessage["default"])('Confirm
|
|
280
|
+
}, this.isPassage() ? (0, _formatMessage["default"])('Confirm Text Block Removal') : (0, _formatMessage["default"])('Confirm Stimulus Removal')), (0, _emotion.jsx)(_uiButtons.CloseButton, {
|
|
275
281
|
onClick: this.closeAction,
|
|
276
282
|
placement: "end",
|
|
277
283
|
offset: "medium",
|
|
@@ -96,6 +96,7 @@ var Collection = exports.Collection = (_dec = (0, _quizCommon.withStyleOverrides
|
|
|
96
96
|
}, _this3.props.renderSidebarItem(item, displayPosition, sidebarOpen));
|
|
97
97
|
});
|
|
98
98
|
var transitionType = isShowingItems ? 'slide-down' : 'slide-up';
|
|
99
|
+
var screenReaderText = this.props.isPassage ? (0, _formatMessage["default"])('Collapse text block questions') : (0, _formatMessage["default"])('Collapse stimulus questions');
|
|
99
100
|
return (0, _emotion.jsx)(_uiMotion.Transition, {
|
|
100
101
|
"in": isShowingItems || this.shouldDisplayAllItems(),
|
|
101
102
|
type: transitionType
|
|
@@ -107,7 +108,7 @@ var Collection = exports.Collection = (_dec = (0, _quizCommon.withStyleOverrides
|
|
|
107
108
|
withBackground: false,
|
|
108
109
|
withBorder: false,
|
|
109
110
|
renderIcon: _uiIcons.IconArrowOpenUpLine,
|
|
110
|
-
screenReaderLabel:
|
|
111
|
+
screenReaderLabel: screenReaderText
|
|
111
112
|
})), (0, _emotion.jsx)("div", null, itemComponents)));
|
|
112
113
|
}
|
|
113
114
|
}, {
|
|
@@ -118,6 +119,7 @@ var Collection = exports.Collection = (_dec = (0, _quizCommon.withStyleOverrides
|
|
|
118
119
|
itemCollection = _this$props2.itemCollection,
|
|
119
120
|
isShowingItems = _this$props2.isShowingItems;
|
|
120
121
|
var transitionType = !isShowingItems ? 'slide-up' : 'slide-down';
|
|
122
|
+
var screenReaderText = this.props.isPassage ? (0, _formatMessage["default"])('Expand text block questions') : (0, _formatMessage["default"])('Expand stimulus questions');
|
|
121
123
|
return (0, _emotion.jsx)(_uiMotion.Transition, {
|
|
122
124
|
"in": !isShowingItems,
|
|
123
125
|
type: transitionType
|
|
@@ -131,7 +133,7 @@ var Collection = exports.Collection = (_dec = (0, _quizCommon.withStyleOverrides
|
|
|
131
133
|
withBackground: false,
|
|
132
134
|
withBorder: false,
|
|
133
135
|
renderIcon: _uiIcons.IconArrowOpenDownLine,
|
|
134
|
-
screenReaderLabel:
|
|
136
|
+
screenReaderLabel: screenReaderText
|
|
135
137
|
})));
|
|
136
138
|
}
|
|
137
139
|
}, {
|
|
@@ -162,7 +164,8 @@ var Collection = exports.Collection = (_dec = (0, _quizCommon.withStyleOverrides
|
|
|
162
164
|
// set in connect
|
|
163
165
|
setSidebarStimulusIsShowing: _propTypes["default"].func.isRequired,
|
|
164
166
|
styles: _propTypes["default"].object,
|
|
165
|
-
makeStyles: _propTypes["default"].func
|
|
167
|
+
makeStyles: _propTypes["default"].func,
|
|
168
|
+
isPassage: _propTypes["default"].bool
|
|
166
169
|
}), (0, _defineProperty2["default"])(_Collection, "defaultProps", {
|
|
167
170
|
isShowingItems: false
|
|
168
171
|
}), _Collection)) || _class);
|
|
@@ -26,6 +26,8 @@ var _formatMessage = _interopRequireDefault(require("@instructure/quiz-i18n/es/f
|
|
|
26
26
|
var _quizCommon = require("@instructure/quiz-common");
|
|
27
27
|
var _uiTooltip = require("@instructure/ui-tooltip");
|
|
28
28
|
var _uiA11yContent = require("@instructure/ui-a11y-content");
|
|
29
|
+
var _uiView = require("@instructure/ui-view");
|
|
30
|
+
var _uiText = require("@instructure/ui-text");
|
|
29
31
|
var _dec, _class, _SidebarStimulus;
|
|
30
32
|
/** @jsx jsx */
|
|
31
33
|
function _callSuper(_this, derived, args) {
|
|
@@ -71,18 +73,26 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
|
|
|
71
73
|
value: function componentDidUpdate() {
|
|
72
74
|
this.props.makeStyles();
|
|
73
75
|
}
|
|
76
|
+
}, {
|
|
77
|
+
key: "stimulusIsPassage",
|
|
78
|
+
value: function stimulusIsPassage() {
|
|
79
|
+
var _this$props$stimulus;
|
|
80
|
+
return (_this$props$stimulus = this.props.stimulus) === null || _this$props$stimulus === void 0 ? void 0 : _this$props$stimulus.isPassage;
|
|
81
|
+
}
|
|
74
82
|
}, {
|
|
75
83
|
key: "renderCollection",
|
|
76
84
|
value: function renderCollection() {
|
|
77
|
-
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
85
|
+
var _this$props$stimulus2;
|
|
80
86
|
var _this$props = this.props,
|
|
81
87
|
displayPosition = _this$props.displayPosition,
|
|
82
88
|
isOver = _this$props.isOver,
|
|
83
89
|
isShowingItems = _this$props.isShowingItems,
|
|
84
90
|
renderSidebarItem = _this$props.renderSidebarItem,
|
|
85
|
-
sidebarOpen = _this$props.sidebarOpen
|
|
91
|
+
sidebarOpen = _this$props.sidebarOpen,
|
|
92
|
+
isDragging = _this$props.isDragging;
|
|
93
|
+
if (this.stimulusIsPassage() || isDragging) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
86
96
|
return (0, _emotion.jsx)(_Collection["default"], {
|
|
87
97
|
firstPosition: displayPosition,
|
|
88
98
|
isOver: isOver,
|
|
@@ -90,22 +100,33 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
|
|
|
90
100
|
itemCollection: this.props.childEntries,
|
|
91
101
|
renderSidebarItem: renderSidebarItem,
|
|
92
102
|
sidebarOpen: sidebarOpen,
|
|
93
|
-
stimulusId: this.props.stimulus.id
|
|
103
|
+
stimulusId: this.props.stimulus.id,
|
|
104
|
+
isPassage: (_this$props$stimulus2 = this.props.stimulus) === null || _this$props$stimulus2 === void 0 ? void 0 : _this$props$stimulus2.isPassage
|
|
94
105
|
});
|
|
95
106
|
}
|
|
96
107
|
}, {
|
|
97
108
|
key: "renderButton",
|
|
98
109
|
value: function renderButton() {
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
var _this$props2 = this.props,
|
|
111
|
+
displayPosition = _this$props2.displayPosition,
|
|
112
|
+
sidebarOpen = _this$props2.sidebarOpen;
|
|
113
|
+
var textForNavigation;
|
|
114
|
+
if (this.stimulusIsPassage()) {
|
|
115
|
+
textForNavigation = (0, _formatMessage["default"])('Navigate to text block');
|
|
116
|
+
} else {
|
|
117
|
+
textForNavigation = (0, _formatMessage["default"])('Navigate to stimulus at position {displayPosition}', {
|
|
118
|
+
displayPosition: displayPosition
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
var content = sidebarOpen ? '' : textForNavigation;
|
|
122
|
+
var tip = (0, _emotion.jsx)(_uiText.Text, {
|
|
123
|
+
"aria-hidden": !sidebarOpen,
|
|
124
|
+
"aria-label": content
|
|
125
|
+
}, content);
|
|
103
126
|
return (0, _emotion.jsx)(_uiTooltip.Tooltip, {
|
|
104
|
-
renderTip:
|
|
105
|
-
"aria-hidden": "true"
|
|
106
|
-
}, textForNavigation),
|
|
127
|
+
renderTip: tip,
|
|
107
128
|
placement: "start",
|
|
108
|
-
on:
|
|
129
|
+
on: sidebarOpen ? [] : ['hover', 'focus']
|
|
109
130
|
}, (0, _emotion.jsx)(_uiLink.Link, {
|
|
110
131
|
href: "#",
|
|
111
132
|
margin: "small",
|
|
@@ -117,33 +138,82 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
|
|
|
117
138
|
className: _quizCommon.END_EDITING_TRIGGER_CLASSNAME
|
|
118
139
|
}, (0, _emotion.jsx)(_uiA11yContent.ScreenReaderContent, null, textForNavigation)));
|
|
119
140
|
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "infoHeaderLabel",
|
|
143
|
+
value: function infoHeaderLabel() {
|
|
144
|
+
return this.stimulusIsPassage() ? (0, _formatMessage["default"])('Text Block') : (0, _formatMessage["default"])('Stimulus');
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "renderSummary",
|
|
148
|
+
value: function renderSummary() {
|
|
149
|
+
var _this$props3 = this.props,
|
|
150
|
+
displayPosition = _this$props3.displayPosition,
|
|
151
|
+
isDragging = _this$props3.isDragging,
|
|
152
|
+
isShowingItems = _this$props3.isShowingItems,
|
|
153
|
+
sidebarOpen = _this$props3.sidebarOpen,
|
|
154
|
+
stimulus = _this$props3.stimulus;
|
|
155
|
+
if (this.stimulusIsPassage()) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
return (0, _emotion.jsx)(_Summary["default"], {
|
|
159
|
+
startPosition: displayPosition,
|
|
160
|
+
isDragging: isDragging,
|
|
161
|
+
isShowingItems: isShowingItems,
|
|
162
|
+
stimulusId: stimulus.id,
|
|
163
|
+
sidebarOpen: sidebarOpen,
|
|
164
|
+
numberOfItems: this.props.childEntries.size
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "stimulusHoverCss",
|
|
169
|
+
value: function stimulusHoverCss() {
|
|
170
|
+
return {
|
|
171
|
+
// TODO: figure out how to get rid of the last of these styles.
|
|
172
|
+
':hover': this.props.styles.onHover
|
|
173
|
+
};
|
|
174
|
+
}
|
|
120
175
|
}, {
|
|
121
176
|
key: "renderClosed",
|
|
122
177
|
value: function renderClosed() {
|
|
123
|
-
return (0, _emotion.jsx)(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
178
|
+
return (0, _emotion.jsx)(_uiView.View, {
|
|
179
|
+
borderWidth: "0 0 small 0",
|
|
180
|
+
borderColor: "primary",
|
|
181
|
+
as: "div"
|
|
182
|
+
}, (0, _emotion.jsx)(_uiView.View, {
|
|
183
|
+
textAlign: "center",
|
|
184
|
+
padding: "xx-small 0",
|
|
185
|
+
borderWidth: "none large none none",
|
|
186
|
+
borderColor: "transparent",
|
|
187
|
+
css: this.stimulusHoverCss(),
|
|
188
|
+
as: "div"
|
|
127
189
|
}, this.renderButton()), this.renderCollection());
|
|
128
190
|
}
|
|
129
191
|
}, {
|
|
130
192
|
key: "renderOpen",
|
|
131
193
|
value: function renderOpen() {
|
|
132
|
-
var _this$
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}, (0,
|
|
146
|
-
|
|
194
|
+
var _this$props4 = this.props,
|
|
195
|
+
stimulus = _this$props4.stimulus,
|
|
196
|
+
children = _this$props4.children;
|
|
197
|
+
return (0, _emotion.jsx)(_uiView.View, {
|
|
198
|
+
borderWidth: "0 0 small 0",
|
|
199
|
+
borderColor: "primary",
|
|
200
|
+
as: "div"
|
|
201
|
+
}, (0, _emotion.jsx)(_uiView.View, {
|
|
202
|
+
padding: "small 0",
|
|
203
|
+
borderWidth: "none large none none",
|
|
204
|
+
borderColor: "transparent",
|
|
205
|
+
css: this.stimulusHoverCss(),
|
|
206
|
+
as: "div"
|
|
207
|
+
}, (0, _emotion.jsx)(_uiView.View, {
|
|
208
|
+
margin: "auto auto x-small x-small",
|
|
209
|
+
padding: "auto auto auto x-small",
|
|
210
|
+
as: "div"
|
|
211
|
+
}, (0, _emotion.jsx)(_uiText.Text, {
|
|
212
|
+
size: "x-small",
|
|
213
|
+
color: "secondary"
|
|
214
|
+
}, this.infoHeaderLabel())), (0, _emotion.jsx)(_uiView.View, {
|
|
215
|
+
margin: "auto auto auto small",
|
|
216
|
+
as: "div"
|
|
147
217
|
}, (0, _emotion.jsx)(_quizCommon.Flex, {
|
|
148
218
|
justifyItems: "space-between"
|
|
149
219
|
}, (0, _emotion.jsx)(_quizCommon.Flex.Item, null, this.renderButton()), (0, _emotion.jsx)(_quizCommon.Flex.Item, {
|
|
@@ -153,14 +223,7 @@ var SidebarStimulus = exports.SidebarStimulus = (_dec = (0, _quizCommon.withStyl
|
|
|
153
223
|
tabIndex: "-1"
|
|
154
224
|
}, (0, _emotion.jsx)(_Title["default"], {
|
|
155
225
|
title: stimulus.title
|
|
156
|
-
})), (0, _emotion.jsx)(_quizCommon.Flex.Item, null, children)), (
|
|
157
|
-
startPosition: displayPosition,
|
|
158
|
-
isDragging: isDragging,
|
|
159
|
-
isShowingItems: isShowingItems,
|
|
160
|
-
sidebarOpen: sidebarOpen,
|
|
161
|
-
stimulusId: stimulus.id,
|
|
162
|
-
numberOfItems: this.props.childEntries.size
|
|
163
|
-
}))), this.renderCollection());
|
|
226
|
+
})), (0, _emotion.jsx)(_quizCommon.Flex.Item, null, children)), this.renderSummary())), this.renderCollection());
|
|
164
227
|
}
|
|
165
228
|
}, {
|
|
166
229
|
key: "render",
|
|
@@ -6,32 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var generateStyle = function generateStyle(componentTheme) {
|
|
8
8
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
sidebarItemClosedButton: {
|
|
13
|
-
borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.borderColor),
|
|
14
|
-
padding: componentTheme.sidebarClosedButtonPadding,
|
|
15
|
-
textAlign: 'center',
|
|
16
|
-
'&:hover': {
|
|
17
|
-
borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.hoverBorderColor)
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
stimulusHeader: {
|
|
21
|
-
padding: "".concat(componentTheme.sidebarHeaderPadding, " 0"),
|
|
22
|
-
borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.borderColor),
|
|
23
|
-
'&:hover:': {
|
|
24
|
-
borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.hoverBorderColor)
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
stimulusBody: {
|
|
28
|
-
marginLeft: '5%'
|
|
29
|
-
},
|
|
30
|
-
infoHeader: {
|
|
31
|
-
fontSize: componentTheme.sidebarIsOpenInfoHeaderFontSize,
|
|
32
|
-
color: componentTheme.sidebarIsOpenInfoHeaderColor,
|
|
33
|
-
marginBottom: componentTheme.sidebarIsOpenInfoHeaderMargin,
|
|
34
|
-
paddingLeft: componentTheme.sidebarIsOpenInfoHeaderPadding
|
|
9
|
+
onHover: {
|
|
10
|
+
borderRight: "".concat(componentTheme.hoverBorderWidth, " solid ").concat(componentTheme.hoverBorderColor)
|
|
35
11
|
}
|
|
36
12
|
};
|
|
37
13
|
};
|
|
@@ -11,16 +11,7 @@ var generateComponentTheme = function generateComponentTheme(_ref) {
|
|
|
11
11
|
typography = _ref.typography;
|
|
12
12
|
return {
|
|
13
13
|
borderColor: colors.contrasts.white1010,
|
|
14
|
-
hoverBorderColor: colors.contrasts.blue4570
|
|
15
|
-
hoverBorderWidth: borders.widthLarge,
|
|
16
|
-
sidebarClosedButtonPadding: "".concat(spacing.xxSmall, " 0"),
|
|
17
|
-
sidebarHeaderPadding: spacing.small,
|
|
18
|
-
sidebarItemBorderWidth: borders.widthSmall,
|
|
19
|
-
sidebarItemBorderColor: colors.contrasts.grey1214,
|
|
20
|
-
sidebarIsOpenInfoHeaderFontSize: typography.fontSizeXSmall,
|
|
21
|
-
sidebarIsOpenInfoHeaderPadding: spacing.xSmall,
|
|
22
|
-
sidebarIsOpenInfoHeaderMargin: spacing.xSmall,
|
|
23
|
-
sidebarIsOpenInfoHeaderColor: colors.contrasts.grey4570
|
|
14
|
+
hoverBorderColor: colors.contrasts.blue4570
|
|
24
15
|
};
|
|
25
16
|
};
|
|
26
17
|
var _default = exports["default"] = generateComponentTheme;
|
|
@@ -36,13 +36,15 @@ function _callSuper(_this, derived, args) {
|
|
|
36
36
|
return (0, _possibleConstructorReturn2["default"])(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], (0, _getPrototypeOf2["default"])(_this).constructor) : derived.apply(_this, args));
|
|
37
37
|
}
|
|
38
38
|
var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
|
|
39
|
-
function BankSelection() {
|
|
39
|
+
function BankSelection(props) {
|
|
40
40
|
var _this2;
|
|
41
41
|
(0, _classCallCheck2["default"])(this, BankSelection);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
_this2 = _callSuper(this, BankSelection, [props]);
|
|
43
|
+
(0, _defineProperty2["default"])(_this2, "setInputRef", function (ref) {
|
|
44
|
+
var _this2$props$inputRef, _this2$props;
|
|
45
|
+
_this2.inputRef = ref;
|
|
46
|
+
(_this2$props$inputRef = (_this2$props = _this2.props).inputRef) === null || _this2$props$inputRef === void 0 || _this2$props$inputRef.call(_this2$props, ref);
|
|
47
|
+
});
|
|
46
48
|
(0, _defineProperty2["default"])(_this2, "searchBanks", function (search) {
|
|
47
49
|
return _this2.props.simpleFetchBanks({
|
|
48
50
|
search: search
|
|
@@ -65,18 +67,31 @@ var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
|
|
|
65
67
|
archived: bankOption.archived
|
|
66
68
|
});
|
|
67
69
|
});
|
|
70
|
+
_this2.inputRef = null;
|
|
68
71
|
return _this2;
|
|
69
72
|
}
|
|
70
73
|
(0, _inherits2["default"])(BankSelection, _Component);
|
|
71
74
|
return (0, _createClass2["default"])(BankSelection, [{
|
|
75
|
+
key: "focusSelectField",
|
|
76
|
+
value: function focusSelectField() {
|
|
77
|
+
if (this.inputRef) {
|
|
78
|
+
this.inputRef.focus();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
72
82
|
key: "getErrors",
|
|
73
83
|
value: function getErrors() {
|
|
74
84
|
var selectedBank = this.props.selectedBank;
|
|
75
85
|
if (selectedBank && selectedBank.archived) {
|
|
86
|
+
this.focusSelectField();
|
|
76
87
|
return (0, _instUIMessages.toErrors)([(0, _formatMessage["default"])('The item bank "{ bankTitle }" no longer exists. Please select a valid bank.', {
|
|
77
88
|
bankTitle: selectedBank.title
|
|
78
89
|
})]);
|
|
79
90
|
}
|
|
91
|
+
if (this.props.externalError) {
|
|
92
|
+
this.focusSelectField();
|
|
93
|
+
return this.props.externalError;
|
|
94
|
+
}
|
|
80
95
|
}
|
|
81
96
|
}, {
|
|
82
97
|
key: "selectedOption",
|
|
@@ -92,13 +107,15 @@ var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
|
|
|
92
107
|
key: "render",
|
|
93
108
|
value: function render() {
|
|
94
109
|
return /*#__PURE__*/_react["default"].createElement(_GenericAsyncSearch.GenericAsyncSearch, {
|
|
110
|
+
inputRef: this.setInputRef,
|
|
95
111
|
onSelectionChange: this.onSelect,
|
|
96
112
|
label: this.props.label || (0, _formatMessage["default"])('Select the destination bank'),
|
|
97
113
|
placeholder: (0, _formatMessage["default"])('Search for a bank'),
|
|
98
114
|
selectedOption: this.selectedOption(),
|
|
99
115
|
getOptions: this.searchBanks,
|
|
100
116
|
messages: this.getErrors(),
|
|
101
|
-
selectAutomation: 'sdk-item-bank-modal'
|
|
117
|
+
selectAutomation: 'sdk-item-bank-modal',
|
|
118
|
+
isRequired: this.props.isRequired
|
|
102
119
|
});
|
|
103
120
|
}
|
|
104
121
|
}]);
|
|
@@ -107,12 +124,18 @@ var BankSelection = exports.BankSelection = /*#__PURE__*/function (_Component) {
|
|
|
107
124
|
label: _propTypes["default"].string,
|
|
108
125
|
onBankSelection: _propTypes["default"].func,
|
|
109
126
|
selectedBank: _reactImmutableProptypes["default"].record,
|
|
110
|
-
simpleFetchBanks: _propTypes["default"].func
|
|
127
|
+
simpleFetchBanks: _propTypes["default"].func,
|
|
128
|
+
externalError: _reactImmutableProptypes["default"].record,
|
|
129
|
+
inputRef: _propTypes["default"].func,
|
|
130
|
+
isRequired: _propTypes["default"].bool
|
|
111
131
|
});
|
|
112
132
|
(0, _defineProperty2["default"])(BankSelection, "defaultProps", {
|
|
113
133
|
label: null,
|
|
114
134
|
onBankSelection: function onBankSelection() {},
|
|
115
135
|
selectedBank: null,
|
|
116
|
-
simpleFetchBanks: _banks.simpleFetchBanks
|
|
136
|
+
simpleFetchBanks: _banks.simpleFetchBanks,
|
|
137
|
+
externalError: null,
|
|
138
|
+
inputRef: function inputRef() {},
|
|
139
|
+
isRequired: false
|
|
117
140
|
});
|
|
118
141
|
var _default = exports["default"] = BankSelection;
|