@pie-lib/mask-markup 1.33.2-next.0 → 1.34.0-mui-update.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/CHANGELOG.md +7 -11
- package/lib/choices/choice.js +74 -203
- package/lib/choices/choice.js.map +1 -1
- package/lib/choices/index.js +19 -52
- package/lib/choices/index.js.map +1 -1
- package/lib/componentize.js +1 -5
- package/lib/componentize.js.map +1 -1
- package/lib/components/blank.js +292 -357
- package/lib/components/blank.js.map +1 -1
- package/lib/components/correct-input.js +41 -65
- package/lib/components/correct-input.js.map +1 -1
- package/lib/components/dropdown.js +203 -248
- package/lib/components/dropdown.js.map +1 -1
- package/lib/components/input.js +10 -17
- package/lib/components/input.js.map +1 -1
- package/lib/constructed-response.js +38 -52
- package/lib/constructed-response.js.map +1 -1
- package/lib/customizable.js +5 -9
- package/lib/customizable.js.map +1 -1
- package/lib/drag-in-the-blank.js +117 -96
- package/lib/drag-in-the-blank.js.map +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +1 -1
- package/lib/inline-dropdown.js +4 -12
- package/lib/inline-dropdown.js.map +1 -1
- package/lib/mask.js +40 -112
- package/lib/mask.js.map +1 -1
- package/lib/serialization.js +8 -48
- package/lib/serialization.js.map +1 -1
- package/lib/with-mask.js +26 -55
- package/lib/with-mask.js.map +1 -1
- package/package.json +12 -10
- package/src/choices/choice.jsx +58 -154
- package/src/choices/index.jsx +8 -2
- package/src/components/blank.jsx +272 -262
- package/src/components/correct-input.jsx +33 -39
- package/src/components/dropdown.jsx +165 -156
- package/src/constructed-response.jsx +22 -18
- package/src/drag-in-the-blank.jsx +97 -39
- package/src/mask.jsx +18 -27
|
@@ -1,117 +1,221 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
10
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
11
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
22
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
14
|
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
15
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
var _ArrowDropDown = _interopRequireDefault(require("@material-ui/icons/ArrowDropDown"));
|
|
37
|
-
|
|
38
|
-
var _ArrowDropUp = _interopRequireDefault(require("@material-ui/icons/ArrowDropUp"));
|
|
39
|
-
|
|
40
|
-
var _Close = _interopRequireDefault(require("@material-ui/icons/Close"));
|
|
41
|
-
|
|
42
|
-
var _Check = _interopRequireDefault(require("@material-ui/icons/Check"));
|
|
43
|
-
|
|
44
|
-
var _styles = require("@material-ui/core/styles");
|
|
45
|
-
|
|
46
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
47
|
-
|
|
16
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
17
|
+
var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
|
|
18
|
+
var _Menu = _interopRequireDefault(require("@mui/material/Menu"));
|
|
19
|
+
var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
|
|
20
|
+
var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
|
|
21
|
+
var _ArrowDropUp = _interopRequireDefault(require("@mui/icons-material/ArrowDropUp"));
|
|
22
|
+
var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
|
|
23
|
+
var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
|
|
24
|
+
var _styles = require("@mui/material/styles");
|
|
48
25
|
var _renderUi = require("@pie-lib/render-ui");
|
|
49
|
-
|
|
50
26
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
27
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
29
|
+
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)); }
|
|
30
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
31
|
+
var StyledButton = (0, _styles.styled)(_Button["default"])(function () {
|
|
32
|
+
return {
|
|
33
|
+
color: _renderUi.color.text(),
|
|
34
|
+
border: "1px solid ".concat(_renderUi.color.borderGray()),
|
|
35
|
+
borderRadius: '4px',
|
|
36
|
+
justifyContent: 'space-between',
|
|
37
|
+
backgroundColor: _renderUi.color.background(),
|
|
38
|
+
position: 'relative',
|
|
39
|
+
height: '45px',
|
|
40
|
+
width: 'fit-content',
|
|
41
|
+
margin: '2px',
|
|
42
|
+
textTransform: 'none',
|
|
43
|
+
'& span': {
|
|
44
|
+
paddingRight: '5px'
|
|
45
|
+
},
|
|
46
|
+
'& svg': {
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
right: 0,
|
|
49
|
+
top: 'calc(50% - 12px)',
|
|
50
|
+
pointerEvents: 'none',
|
|
51
|
+
color: _renderUi.color.text(),
|
|
52
|
+
marginLeft: '5px'
|
|
53
|
+
},
|
|
54
|
+
'&.Mui-focused': {
|
|
55
|
+
outline: "3px solid ".concat(_renderUi.color.tertiary()),
|
|
56
|
+
outlineOffset: '2px',
|
|
57
|
+
borderWidth: '3px'
|
|
58
|
+
},
|
|
59
|
+
'&.disabledCorrect': {
|
|
60
|
+
borderWidth: '2px',
|
|
61
|
+
borderColor: _renderUi.color.correct(),
|
|
62
|
+
color: "".concat(_renderUi.color.text(), " !important")
|
|
63
|
+
},
|
|
64
|
+
'&.disabledIncorrect': {
|
|
65
|
+
borderWidth: '2px',
|
|
66
|
+
borderColor: _renderUi.color.incorrectWithIcon(),
|
|
67
|
+
color: "".concat(_renderUi.color.text(), " !important")
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
var StyledMenu = (0, _styles.styled)(_Menu["default"])(function () {
|
|
72
|
+
return {
|
|
73
|
+
backgroundColor: _renderUi.color.background(),
|
|
74
|
+
border: "1px solid ".concat(_renderUi.color.correct(), " !important"),
|
|
75
|
+
'&:hover': {
|
|
76
|
+
border: "1px solid ".concat(_renderUi.color.text(), " "),
|
|
77
|
+
borderColor: 'initial'
|
|
78
|
+
},
|
|
79
|
+
'&:focus': {
|
|
80
|
+
border: "1px solid ".concat(_renderUi.color.text()),
|
|
81
|
+
borderColor: 'initial'
|
|
82
|
+
},
|
|
83
|
+
// remove default padding on the inner list
|
|
84
|
+
'& .MuiList-root': {
|
|
85
|
+
padding: 0
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
var StyledMenuItem = (0, _styles.styled)(_MenuItem["default"])(function () {
|
|
90
|
+
return {
|
|
91
|
+
color: _renderUi.color.text(),
|
|
92
|
+
backgroundColor: _renderUi.color.background(),
|
|
93
|
+
'&.Mui-focused': {
|
|
94
|
+
outline: "3px solid ".concat(_renderUi.color.tertiary()),
|
|
95
|
+
outlineOffset: '-1px',
|
|
96
|
+
// keeps it inside the item
|
|
97
|
+
color: _renderUi.color.text(),
|
|
98
|
+
backgroundColor: _renderUi.color.background()
|
|
99
|
+
},
|
|
100
|
+
'&:hover': {
|
|
101
|
+
color: _renderUi.color.text(),
|
|
102
|
+
backgroundColor: _renderUi.color.dropdownBackground()
|
|
103
|
+
},
|
|
104
|
+
boxSizing: 'border-box',
|
|
105
|
+
padding: '25px',
|
|
106
|
+
borderRadius: '4px',
|
|
107
|
+
'&.selected': {
|
|
108
|
+
color: "".concat(_renderUi.color.text(), " !important"),
|
|
109
|
+
backgroundColor: "".concat(_renderUi.color.background(), " !important"),
|
|
110
|
+
'&:hover': {
|
|
111
|
+
color: _renderUi.color.text(),
|
|
112
|
+
backgroundColor: "".concat(_renderUi.color.dropdownBackground(), " !important")
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
var StyledLabel = (0, _styles.styled)('span')(function () {
|
|
118
|
+
return {
|
|
119
|
+
fontSize: 'max(1rem, 14px)'
|
|
120
|
+
};
|
|
121
|
+
});
|
|
122
|
+
var StyledSelectedIndicator = (0, _styles.styled)('span')(function () {
|
|
123
|
+
return {
|
|
124
|
+
fontSize: 'max(1rem, 14px)',
|
|
125
|
+
position: 'absolute',
|
|
126
|
+
right: '10px'
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
var StyledInputLabel = (0, _styles.styled)(_InputLabel["default"])(function () {
|
|
130
|
+
return {
|
|
131
|
+
position: 'absolute',
|
|
132
|
+
left: '-10000px',
|
|
133
|
+
top: 'auto',
|
|
134
|
+
width: '1px',
|
|
135
|
+
height: '1px',
|
|
136
|
+
overflow: 'hidden'
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
var StyledCorrectnessIcon = (0, _styles.styled)(_Check["default"])(function () {
|
|
140
|
+
return {
|
|
141
|
+
color: "".concat(_renderUi.color.white(), " !important"),
|
|
142
|
+
position: 'absolute',
|
|
143
|
+
top: '-8px !important',
|
|
144
|
+
left: '-8px',
|
|
145
|
+
marginLeft: '0 !important',
|
|
146
|
+
borderRadius: '50%',
|
|
147
|
+
fontSize: '16px',
|
|
148
|
+
padding: '2px',
|
|
149
|
+
'&.correct': {
|
|
150
|
+
backgroundColor: _renderUi.color.correct()
|
|
151
|
+
},
|
|
152
|
+
'&.incorrect': {
|
|
153
|
+
backgroundColor: _renderUi.color.incorrectWithIcon()
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
var StyledIncorrectnessIcon = (0, _styles.styled)(_Close["default"])(function () {
|
|
158
|
+
return {
|
|
159
|
+
color: "".concat(_renderUi.color.white(), " !important"),
|
|
160
|
+
position: 'absolute',
|
|
161
|
+
top: '-8px !important',
|
|
162
|
+
left: '-8px',
|
|
163
|
+
marginLeft: '0 !important',
|
|
164
|
+
borderRadius: '50%',
|
|
165
|
+
fontSize: '16px',
|
|
166
|
+
padding: '2px',
|
|
167
|
+
'&.correct': {
|
|
168
|
+
backgroundColor: _renderUi.color.correct()
|
|
169
|
+
},
|
|
170
|
+
'&.incorrect': {
|
|
171
|
+
backgroundColor: _renderUi.color.incorrectWithIcon()
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
});
|
|
60
175
|
var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
61
|
-
(0, _inherits2["default"])(Dropdown, _React$Component);
|
|
62
|
-
|
|
63
|
-
var _super = _createSuper(Dropdown);
|
|
64
|
-
|
|
65
176
|
function Dropdown(props) {
|
|
66
177
|
var _this;
|
|
67
|
-
|
|
68
178
|
(0, _classCallCheck2["default"])(this, Dropdown);
|
|
69
|
-
_this =
|
|
70
|
-
(0, _defineProperty2["default"])(
|
|
179
|
+
_this = _callSuper(this, Dropdown, [props]);
|
|
180
|
+
(0, _defineProperty2["default"])(_this, "handleClick", function (event) {
|
|
71
181
|
return _this.setState({
|
|
72
182
|
anchorEl: event.currentTarget
|
|
73
183
|
});
|
|
74
184
|
});
|
|
75
|
-
(0, _defineProperty2["default"])(
|
|
185
|
+
(0, _defineProperty2["default"])(_this, "handleClose", function () {
|
|
76
186
|
var value = _this.props.value;
|
|
77
|
-
|
|
78
187
|
_this.setState({
|
|
79
188
|
anchorEl: null,
|
|
80
189
|
previewValue: null,
|
|
81
190
|
highlightedOptionId: null
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
|
|
191
|
+
});
|
|
192
|
+
// clear displayed preview if no selection
|
|
85
193
|
if (!value && _this.previewRef.current) {
|
|
86
194
|
_this.previewRef.current.innerHTML = '';
|
|
87
195
|
}
|
|
88
196
|
});
|
|
89
|
-
(0, _defineProperty2["default"])(
|
|
90
|
-
var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index);
|
|
197
|
+
(0, _defineProperty2["default"])(_this, "handleHighlight", function (index) {
|
|
198
|
+
var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index);
|
|
91
199
|
|
|
200
|
+
// preview on hover if nothing selected
|
|
92
201
|
var stateUpdate = {
|
|
93
202
|
highlightedOptionId: highlightedOptionId
|
|
94
203
|
};
|
|
95
|
-
|
|
96
204
|
if (!_this.props.value) {
|
|
97
205
|
stateUpdate.previewValue = _this.props.choices[index].value;
|
|
98
206
|
}
|
|
99
|
-
|
|
100
207
|
_this.setState(stateUpdate);
|
|
101
208
|
});
|
|
102
|
-
(0, _defineProperty2["default"])(
|
|
209
|
+
(0, _defineProperty2["default"])(_this, "handleSelect", function (value, index) {
|
|
103
210
|
_this.props.onChange(_this.props.id, value);
|
|
104
|
-
|
|
105
211
|
_this.handleHighlight(index);
|
|
106
|
-
|
|
107
212
|
_this.handleClose();
|
|
108
213
|
});
|
|
109
|
-
(0, _defineProperty2["default"])(
|
|
214
|
+
(0, _defineProperty2["default"])(_this, "handleHover", function (index) {
|
|
110
215
|
var selectedValue = _this.props.value;
|
|
111
216
|
if (selectedValue) return;
|
|
112
217
|
var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index);
|
|
113
218
|
var previewValue = _this.state.previewValue;
|
|
114
|
-
|
|
115
219
|
_this.setState({
|
|
116
220
|
highlightedOptionId: highlightedOptionId,
|
|
117
221
|
previewValue: previewValue
|
|
@@ -119,7 +223,6 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
119
223
|
// On hover, preview the math-rendered content inside the button if no value is selected.
|
|
120
224
|
var ref = _this.elementRefs[index];
|
|
121
225
|
var preview = _this.previewRef.current;
|
|
122
|
-
|
|
123
226
|
if (ref && preview) {
|
|
124
227
|
preview.innerHTML = ref.innerHTML;
|
|
125
228
|
}
|
|
@@ -137,8 +240,8 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
137
240
|
_this.elementRefs = [];
|
|
138
241
|
return _this;
|
|
139
242
|
}
|
|
140
|
-
|
|
141
|
-
(0, _createClass2["default"])(Dropdown, [{
|
|
243
|
+
(0, _inherits2["default"])(Dropdown, _React$Component);
|
|
244
|
+
return (0, _createClass2["default"])(Dropdown, [{
|
|
142
245
|
key: "componentDidMount",
|
|
143
246
|
value: function componentDidMount() {
|
|
144
247
|
// measure hidden menu width once
|
|
@@ -153,23 +256,19 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
153
256
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
154
257
|
var hiddenEl = this.hiddenRef.current;
|
|
155
258
|
var dropdownJustOpened = !prevState.anchorEl && this.state.anchorEl;
|
|
156
|
-
|
|
157
259
|
if (dropdownJustOpened) {
|
|
158
260
|
this.elementRefs.forEach(function (ref) {
|
|
159
261
|
if (!ref) return;
|
|
160
262
|
var containsLatex = ref.querySelector('[data-latex], [data-raw]');
|
|
161
263
|
var hasMathJax = ref.querySelector('mjx-container');
|
|
162
264
|
var mathHandled = ref.querySelector('[data-math-handled="true"]');
|
|
163
|
-
|
|
164
265
|
if (containsLatex && (!mathHandled || !hasMathJax)) {
|
|
165
266
|
(0, _mathRendering.renderMath)(ref);
|
|
166
267
|
}
|
|
167
268
|
});
|
|
168
269
|
}
|
|
169
|
-
|
|
170
270
|
if (hiddenEl) {
|
|
171
271
|
var newWidth = hiddenEl.clientWidth;
|
|
172
|
-
|
|
173
272
|
if (newWidth !== this.state.menuWidth) {
|
|
174
273
|
this.elementRefs.forEach(function (ref) {
|
|
175
274
|
if (ref) (0, _mathRendering.renderMath)(ref);
|
|
@@ -193,46 +292,43 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
193
292
|
key: "render",
|
|
194
293
|
value: function render() {
|
|
195
294
|
var _this2 = this;
|
|
196
|
-
|
|
197
295
|
var _this$props = this.props,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
correctValue = _this$props.correctValue;
|
|
296
|
+
id = _this$props.id,
|
|
297
|
+
correct = _this$props.correct,
|
|
298
|
+
disabled = _this$props.disabled,
|
|
299
|
+
value = _this$props.value,
|
|
300
|
+
choices = _this$props.choices,
|
|
301
|
+
showCorrectAnswer = _this$props.showCorrectAnswer,
|
|
302
|
+
singleQuery = _this$props.singleQuery,
|
|
303
|
+
correctValue = _this$props.correctValue;
|
|
207
304
|
var anchorEl = this.state.anchorEl;
|
|
208
305
|
var open = Boolean(anchorEl);
|
|
209
306
|
var buttonId = "dropdown-button-".concat(id);
|
|
210
307
|
var menuId = "dropdown-menu-".concat(id);
|
|
211
|
-
var valueDisplayId = "dropdown-value-".concat(id);
|
|
212
|
-
|
|
213
|
-
var disabledClass; // Reset elementRefs before each render to avoid stale references
|
|
308
|
+
var valueDisplayId = "dropdown-value-".concat(id);
|
|
214
309
|
|
|
310
|
+
// Determine the class for disabled state, view mode and evaluate mode
|
|
311
|
+
var disabledClass;
|
|
312
|
+
// Reset elementRefs before each render to avoid stale references
|
|
215
313
|
this.elementRefs = [];
|
|
216
|
-
|
|
217
314
|
if (disabled && correct !== undefined) {
|
|
218
|
-
disabledClass = correct || showCorrectAnswer ?
|
|
219
|
-
}
|
|
220
|
-
|
|
315
|
+
disabledClass = correct || showCorrectAnswer ? 'disabledCorrect' : 'disabledIncorrect';
|
|
316
|
+
}
|
|
221
317
|
|
|
318
|
+
// Create distinct, visually hidden labels for each dropdown
|
|
222
319
|
var incrementedId = parseInt(id, 10) + 1;
|
|
223
320
|
var labelId = singleQuery ? 'Query-label' : "Query-label-".concat(incrementedId);
|
|
224
|
-
var labelText = singleQuery ? 'Query' : "Query ".concat(incrementedId);
|
|
321
|
+
var labelText = singleQuery ? 'Query' : "Query ".concat(incrementedId);
|
|
225
322
|
|
|
323
|
+
// Changed from Select to Button for dropdown to enhance accessibility. This modification offers explicit control over aria attributes and focuses management, ensuring the dropdown is compliant with accessibility standards. The use of Button and Menu components allows for better handling of keyboard interactions and provides accessible labels and menus, aligning with WCAG guidelines and improving usability for assistive technology users.
|
|
226
324
|
var correctnessIcon = null;
|
|
227
|
-
|
|
228
325
|
if (disabled && correct !== undefined) {
|
|
229
|
-
correctnessIcon = correct || showCorrectAnswer ? /*#__PURE__*/_react["default"].createElement(
|
|
230
|
-
className:
|
|
231
|
-
}) : /*#__PURE__*/_react["default"].createElement(
|
|
232
|
-
className:
|
|
326
|
+
correctnessIcon = correct || showCorrectAnswer ? /*#__PURE__*/_react["default"].createElement(StyledCorrectnessIcon, {
|
|
327
|
+
className: "correct"
|
|
328
|
+
}) : /*#__PURE__*/_react["default"].createElement(StyledIncorrectnessIcon, {
|
|
329
|
+
className: "incorrect"
|
|
233
330
|
});
|
|
234
331
|
}
|
|
235
|
-
|
|
236
332
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
237
333
|
ref: this.hiddenRef,
|
|
238
334
|
style: {
|
|
@@ -244,26 +340,20 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
244
340
|
tabIndex: -1,
|
|
245
341
|
"aria-hidden": "true"
|
|
246
342
|
}, (choices || []).map(function (c, index) {
|
|
247
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
343
|
+
return /*#__PURE__*/_react["default"].createElement(StyledMenuItem, {
|
|
248
344
|
key: index,
|
|
249
|
-
classes: {
|
|
250
|
-
root: classes.menuRoot,
|
|
251
|
-
selected: classes.selected
|
|
252
|
-
},
|
|
253
345
|
tabIndex: -1,
|
|
254
346
|
"aria-hidden": "true"
|
|
255
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
256
|
-
className: classes.label,
|
|
347
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
|
|
257
348
|
dangerouslySetInnerHTML: {
|
|
258
349
|
__html: c.label
|
|
259
350
|
}
|
|
260
351
|
}));
|
|
261
|
-
})), /*#__PURE__*/_react["default"].createElement(
|
|
262
|
-
className: classes.srOnly,
|
|
352
|
+
})), /*#__PURE__*/_react["default"].createElement(StyledInputLabel, {
|
|
263
353
|
id: labelId,
|
|
264
354
|
tabIndex: -1,
|
|
265
355
|
"aria-hidden": "true"
|
|
266
|
-
}, labelText), /*#__PURE__*/_react["default"].createElement(
|
|
356
|
+
}, labelText), /*#__PURE__*/_react["default"].createElement(StyledButton, {
|
|
267
357
|
ref: this.buttonRef,
|
|
268
358
|
style: _objectSpread(_objectSpread({}, this.state.menuWidth && {
|
|
269
359
|
minWidth: "calc(".concat(this.state.menuWidth, "px + 8px)")
|
|
@@ -276,26 +366,21 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
276
366
|
"aria-expanded": open ? 'true' : undefined,
|
|
277
367
|
"aria-activedescendant": this.state.highlightedOptionId,
|
|
278
368
|
onClick: this.handleClick,
|
|
279
|
-
|
|
280
|
-
root: classes.root,
|
|
281
|
-
disabled: disabledClass
|
|
282
|
-
},
|
|
369
|
+
className: disabledClass,
|
|
283
370
|
disabled: disabled,
|
|
284
371
|
id: buttonId,
|
|
285
372
|
role: "combobox",
|
|
286
373
|
"aria-label": "Select an option for ".concat(labelText),
|
|
287
374
|
"aria-labelledby": valueDisplayId
|
|
288
|
-
}, correctnessIcon, /*#__PURE__*/_react["default"].createElement(
|
|
375
|
+
}, correctnessIcon, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
|
|
289
376
|
id: valueDisplayId,
|
|
290
377
|
ref: this.previewRef,
|
|
291
|
-
className: classes.label,
|
|
292
378
|
dangerouslySetInnerHTML: {
|
|
293
379
|
__html: correctValue ? correctValue : open && this.state.previewValue ? this.getLabel(choices, this.state.previewValue) : this.getLabel(choices, value) || ''
|
|
294
380
|
}
|
|
295
|
-
}), open ? /*#__PURE__*/_react["default"].createElement(_ArrowDropUp["default"], null) : /*#__PURE__*/_react["default"].createElement(_ArrowDropDown["default"], null)), /*#__PURE__*/_react["default"].createElement(
|
|
381
|
+
}), open ? /*#__PURE__*/_react["default"].createElement(_ArrowDropUp["default"], null) : /*#__PURE__*/_react["default"].createElement(_ArrowDropDown["default"], null)), /*#__PURE__*/_react["default"].createElement(StyledMenu, {
|
|
296
382
|
id: menuId,
|
|
297
383
|
anchorEl: anchorEl,
|
|
298
|
-
className: classes.selectMenu,
|
|
299
384
|
keepMounted: true,
|
|
300
385
|
open: open,
|
|
301
386
|
onClose: this.handleClose,
|
|
@@ -321,12 +406,9 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
321
406
|
}
|
|
322
407
|
}, (choices || []).map(function (c, index) {
|
|
323
408
|
var optionId = "dropdown-option-".concat(id, "-").concat(index);
|
|
324
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
409
|
+
return /*#__PURE__*/_react["default"].createElement(StyledMenuItem, {
|
|
325
410
|
id: optionId,
|
|
326
|
-
|
|
327
|
-
root: classes.menuRoot,
|
|
328
|
-
selected: classes.selected
|
|
329
|
-
},
|
|
411
|
+
className: c.value === value ? 'selected' : '',
|
|
330
412
|
key: "".concat(c.label, "-").concat(index),
|
|
331
413
|
value: c.value,
|
|
332
414
|
onClick: function onClick() {
|
|
@@ -337,16 +419,14 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
337
419
|
onMouseOver: function onMouseOver() {
|
|
338
420
|
return _this2.handleHover(index);
|
|
339
421
|
}
|
|
340
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
422
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
|
|
341
423
|
ref: function ref(_ref) {
|
|
342
424
|
return _this2.elementRefs[index] = _ref;
|
|
343
425
|
},
|
|
344
|
-
className: classes.label,
|
|
345
426
|
dangerouslySetInnerHTML: {
|
|
346
427
|
__html: c.label
|
|
347
428
|
}
|
|
348
|
-
}), /*#__PURE__*/_react["default"].createElement(
|
|
349
|
-
className: classes.selectedIndicator,
|
|
429
|
+
}), /*#__PURE__*/_react["default"].createElement(StyledSelectedIndicator, {
|
|
350
430
|
dangerouslySetInnerHTML: {
|
|
351
431
|
__html: c.value === value ? ' ✓' : ''
|
|
352
432
|
}
|
|
@@ -354,15 +434,12 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
354
434
|
})));
|
|
355
435
|
}
|
|
356
436
|
}]);
|
|
357
|
-
return Dropdown;
|
|
358
437
|
}(_react["default"].Component);
|
|
359
|
-
|
|
360
438
|
(0, _defineProperty2["default"])(Dropdown, "propTypes", {
|
|
361
439
|
id: _propTypes["default"].string,
|
|
362
440
|
value: _propTypes["default"].string,
|
|
363
441
|
disabled: _propTypes["default"].bool,
|
|
364
442
|
onChange: _propTypes["default"].func,
|
|
365
|
-
classes: _propTypes["default"].object,
|
|
366
443
|
correct: _propTypes["default"].bool,
|
|
367
444
|
choices: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|
|
368
445
|
value: _propTypes["default"].string,
|
|
@@ -372,127 +449,5 @@ var Dropdown = /*#__PURE__*/function (_React$Component) {
|
|
|
372
449
|
singleQuery: _propTypes["default"].bool,
|
|
373
450
|
correctValue: _propTypes["default"].string
|
|
374
451
|
});
|
|
375
|
-
|
|
376
|
-
var styles = function styles() {
|
|
377
|
-
return {
|
|
378
|
-
root: {
|
|
379
|
-
color: _renderUi.color.text(),
|
|
380
|
-
border: "1px solid ".concat(_renderUi.color.borderGray()),
|
|
381
|
-
borderRadius: '4px',
|
|
382
|
-
justifyContent: 'space-between',
|
|
383
|
-
backgroundColor: _renderUi.color.background(),
|
|
384
|
-
position: 'relative',
|
|
385
|
-
height: '45px',
|
|
386
|
-
width: 'fit-content',
|
|
387
|
-
margin: '2px',
|
|
388
|
-
textTransform: 'none',
|
|
389
|
-
'& span': {
|
|
390
|
-
paddingRight: '5px'
|
|
391
|
-
},
|
|
392
|
-
'& svg': {
|
|
393
|
-
position: 'absolute',
|
|
394
|
-
right: 0,
|
|
395
|
-
top: 'calc(50% - 12px)',
|
|
396
|
-
pointerEvents: 'none',
|
|
397
|
-
color: _renderUi.color.text(),
|
|
398
|
-
marginLeft: '5px'
|
|
399
|
-
},
|
|
400
|
-
'&:focus, &:focus-visible': {
|
|
401
|
-
outline: "3px solid ".concat(_renderUi.color.tertiary()),
|
|
402
|
-
outlineOffset: '2px',
|
|
403
|
-
borderWidth: '3px'
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
disabledCorrect: {
|
|
407
|
-
borderWidth: '2px',
|
|
408
|
-
borderColor: _renderUi.color.correct(),
|
|
409
|
-
color: "".concat(_renderUi.color.text(), " !important")
|
|
410
|
-
},
|
|
411
|
-
disabledIncorrect: {
|
|
412
|
-
borderWidth: '2px',
|
|
413
|
-
borderColor: _renderUi.color.incorrectWithIcon(),
|
|
414
|
-
color: "".concat(_renderUi.color.text(), " !important")
|
|
415
|
-
},
|
|
416
|
-
selectMenu: {
|
|
417
|
-
backgroundColor: _renderUi.color.background(),
|
|
418
|
-
border: "1px solid ".concat(_renderUi.color.correct(), " !important"),
|
|
419
|
-
'&:hover': {
|
|
420
|
-
border: "1px solid ".concat(_renderUi.color.text(), " "),
|
|
421
|
-
borderColor: 'initial'
|
|
422
|
-
},
|
|
423
|
-
'&:focus': {
|
|
424
|
-
border: "1px solid ".concat(_renderUi.color.text()),
|
|
425
|
-
borderColor: 'initial'
|
|
426
|
-
},
|
|
427
|
-
// remove default padding on the inner list
|
|
428
|
-
'& .MuiList-root': {
|
|
429
|
-
padding: 0
|
|
430
|
-
}
|
|
431
|
-
},
|
|
432
|
-
selected: {
|
|
433
|
-
color: "".concat(_renderUi.color.text(), " !important"),
|
|
434
|
-
backgroundColor: "".concat(_renderUi.color.background(), " !important"),
|
|
435
|
-
'&:hover': {
|
|
436
|
-
color: _renderUi.color.text(),
|
|
437
|
-
backgroundColor: "".concat(_renderUi.color.dropdownBackground(), " !important")
|
|
438
|
-
}
|
|
439
|
-
},
|
|
440
|
-
menuRoot: {
|
|
441
|
-
color: _renderUi.color.text(),
|
|
442
|
-
backgroundColor: _renderUi.color.background(),
|
|
443
|
-
'&:focus, &:focus-visible': {
|
|
444
|
-
outline: "3px solid ".concat(_renderUi.color.tertiary()),
|
|
445
|
-
outlineOffset: '-1px' // keeps it inside the item
|
|
446
|
-
|
|
447
|
-
},
|
|
448
|
-
'&:focus': {
|
|
449
|
-
color: _renderUi.color.text(),
|
|
450
|
-
backgroundColor: _renderUi.color.background()
|
|
451
|
-
},
|
|
452
|
-
'&:hover': {
|
|
453
|
-
color: _renderUi.color.text(),
|
|
454
|
-
backgroundColor: _renderUi.color.dropdownBackground()
|
|
455
|
-
},
|
|
456
|
-
boxSizing: 'border-box',
|
|
457
|
-
padding: '25px',
|
|
458
|
-
borderRadius: '4px'
|
|
459
|
-
},
|
|
460
|
-
label: {
|
|
461
|
-
fontSize: 'max(1rem, 14px)'
|
|
462
|
-
},
|
|
463
|
-
selectedIndicator: {
|
|
464
|
-
fontSize: 'max(1rem, 14px)',
|
|
465
|
-
position: 'absolute',
|
|
466
|
-
right: '10px'
|
|
467
|
-
},
|
|
468
|
-
srOnly: {
|
|
469
|
-
position: 'absolute',
|
|
470
|
-
left: '-10000px',
|
|
471
|
-
top: 'auto',
|
|
472
|
-
width: '1px',
|
|
473
|
-
height: '1px',
|
|
474
|
-
overflow: 'hidden'
|
|
475
|
-
},
|
|
476
|
-
correctnessIndicatorIcon: {
|
|
477
|
-
color: "".concat(_renderUi.color.white(), " !important"),
|
|
478
|
-
position: 'absolute',
|
|
479
|
-
top: '-8px !important',
|
|
480
|
-
left: '-8px',
|
|
481
|
-
marginLeft: '0 !important',
|
|
482
|
-
borderRadius: '50%',
|
|
483
|
-
fontSize: '16px',
|
|
484
|
-
padding: '2px'
|
|
485
|
-
},
|
|
486
|
-
correctIcon: {
|
|
487
|
-
backgroundColor: _renderUi.color.correct()
|
|
488
|
-
},
|
|
489
|
-
incorrectIcon: {
|
|
490
|
-
backgroundColor: _renderUi.color.incorrectWithIcon()
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
var _default = (0, _styles.withStyles)(styles)(Dropdown);
|
|
496
|
-
|
|
497
|
-
exports["default"] = _default;
|
|
452
|
+
var _default = exports["default"] = Dropdown;
|
|
498
453
|
//# sourceMappingURL=dropdown.js.map
|