@pie-lib/mask-markup 1.20.0 → 1.22.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.
@@ -0,0 +1,484 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ 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
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
+
24
+ var _react = _interopRequireDefault(require("react"));
25
+
26
+ var _propTypes = _interopRequireDefault(require("prop-types"));
27
+
28
+ var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
29
+
30
+ var _InputLabel = _interopRequireDefault(require("@material-ui/core/InputLabel"));
31
+
32
+ var _Menu = _interopRequireDefault(require("@material-ui/core/Menu"));
33
+
34
+ var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
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
+
48
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
49
+
50
+ var _renderUi = require("@pie-lib/render-ui");
51
+
52
+ var _mathRendering = require("@pie-lib/math-rendering");
53
+
54
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
55
+
56
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
57
+
58
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
59
+
60
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
61
+
62
+ var Dropdown = /*#__PURE__*/function (_React$Component) {
63
+ (0, _inherits2["default"])(Dropdown, _React$Component);
64
+
65
+ var _super = _createSuper(Dropdown);
66
+
67
+ function Dropdown(props) {
68
+ var _this;
69
+
70
+ (0, _classCallCheck2["default"])(this, Dropdown);
71
+ _this = _super.call(this, props);
72
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClick", function (event) {
73
+ return _this.setState({
74
+ anchorEl: event.currentTarget
75
+ });
76
+ });
77
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClose", function () {
78
+ var value = _this.props.value;
79
+
80
+ _this.setState({
81
+ anchorEl: null,
82
+ previewValue: null,
83
+ highlightedOptionId: null
84
+ }); // clear displayed preview if no selection
85
+
86
+
87
+ if (!value && _this.previewRef.current) {
88
+ _this.previewRef.current.innerHTML = '';
89
+ }
90
+ });
91
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleHighlight", function (index) {
92
+ var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index); // preview on hover if nothing selected
93
+
94
+ var stateUpdate = {
95
+ highlightedOptionId: highlightedOptionId
96
+ };
97
+
98
+ if (!_this.props.value) {
99
+ stateUpdate.previewValue = _this.props.choices[index].value;
100
+ }
101
+
102
+ _this.setState(stateUpdate);
103
+ });
104
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleSelect", function (value, index) {
105
+ _this.props.onChange(_this.props.id, value);
106
+
107
+ _this.handleHighlight(index);
108
+
109
+ _this.handleClose();
110
+ });
111
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleHover", function (index) {
112
+ var selectedValue = _this.props.value;
113
+ if (selectedValue) return;
114
+ var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index);
115
+ var previewValue = _this.state.previewValue;
116
+
117
+ _this.setState({
118
+ highlightedOptionId: highlightedOptionId,
119
+ previewValue: previewValue
120
+ }, function () {
121
+ // On hover, preview the math-rendered content inside the button if no value is selected.
122
+ var ref = _this.elementRefs[index];
123
+ var preview = _this.previewRef.current;
124
+
125
+ if (ref && preview) {
126
+ preview.innerHTML = ref.innerHTML;
127
+ }
128
+ });
129
+ });
130
+ _this.state = {
131
+ anchorEl: null,
132
+ highlightedOptionId: null,
133
+ menuWidth: null,
134
+ previewValue: null
135
+ };
136
+ _this.hiddenRef = /*#__PURE__*/_react["default"].createRef();
137
+ _this.buttonRef = /*#__PURE__*/_react["default"].createRef();
138
+ _this.previewRef = /*#__PURE__*/_react["default"].createRef();
139
+ _this.elementRefs = [];
140
+ return _this;
141
+ }
142
+
143
+ (0, _createClass2["default"])(Dropdown, [{
144
+ key: "componentDidMount",
145
+ value: function componentDidMount() {
146
+ // measure hidden menu width once
147
+ if (this.hiddenRef.current && this.state.menuWidth === null) {
148
+ this.setState({
149
+ menuWidth: this.hiddenRef.current.clientWidth
150
+ });
151
+ }
152
+ }
153
+ }, {
154
+ key: "componentDidUpdate",
155
+ value: function componentDidUpdate(prevProps, prevState) {
156
+ var hiddenEl = this.hiddenRef.current;
157
+ var dropdownJustOpened = !prevState.anchorEl && this.state.anchorEl;
158
+
159
+ if (dropdownJustOpened) {
160
+ this.elementRefs.forEach(function (ref) {
161
+ if (!ref) return;
162
+ var containsLatex = ref.querySelector('[data-latex], [data-raw]');
163
+ var hasMathJax = ref.querySelector('mjx-container');
164
+ var mathHandled = ref.querySelector('[data-math-handled="true"]');
165
+
166
+ if (containsLatex && (!mathHandled || !hasMathJax)) {
167
+ (0, _mathRendering.renderMath)(ref);
168
+ }
169
+ });
170
+ }
171
+
172
+ if (hiddenEl) {
173
+ var newWidth = hiddenEl.clientWidth;
174
+
175
+ if (newWidth !== this.state.menuWidth) {
176
+ this.elementRefs.forEach(function (ref) {
177
+ if (ref) (0, _mathRendering.renderMath)(ref);
178
+ });
179
+ (0, _mathRendering.renderMath)(hiddenEl);
180
+ this.setState({
181
+ menuWidth: newWidth
182
+ });
183
+ }
184
+ }
185
+ }
186
+ }, {
187
+ key: "getLabel",
188
+ value: function getLabel(choices, value) {
189
+ var found = (choices || []).find(function (choice) {
190
+ return choice.value === value;
191
+ });
192
+ return found ? found.label.trim() : undefined;
193
+ }
194
+ }, {
195
+ key: "render",
196
+ value: function render() {
197
+ var _this2 = this;
198
+
199
+ var _this$props = this.props,
200
+ classes = _this$props.classes,
201
+ id = _this$props.id,
202
+ correct = _this$props.correct,
203
+ disabled = _this$props.disabled,
204
+ value = _this$props.value,
205
+ choices = _this$props.choices,
206
+ showCorrectAnswer = _this$props.showCorrectAnswer,
207
+ singleQuery = _this$props.singleQuery,
208
+ correctValue = _this$props.correctValue;
209
+ var anchorEl = this.state.anchorEl;
210
+ var open = Boolean(anchorEl);
211
+ var buttonId = "dropdown-button-".concat(id);
212
+ var menuId = "dropdown-menu-".concat(id);
213
+ var valueDisplayId = "dropdown-value-".concat(id); // Determine the class for disabled state, view mode and evaluate mode
214
+
215
+ var disabledClass; // Reset elementRefs before each render to avoid stale references
216
+
217
+ this.elementRefs = [];
218
+
219
+ if (disabled && correct !== undefined) {
220
+ disabledClass = correct || showCorrectAnswer ? classes.disabledCorrect : classes.disabledIncorrect;
221
+ } // Create distinct, visually hidden labels for each dropdown
222
+
223
+
224
+ var incrementedId = parseInt(id, 10) + 1;
225
+ var labelId = singleQuery ? 'Query-label' : "Query-label-".concat(incrementedId);
226
+ var labelText = singleQuery ? 'Query' : "Query ".concat(incrementedId); // 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.
227
+
228
+ var correctnessIcon = null;
229
+
230
+ if (disabled && correct !== undefined) {
231
+ correctnessIcon = correct || showCorrectAnswer ? /*#__PURE__*/_react["default"].createElement(_Check["default"], {
232
+ className: (0, _classnames["default"])(classes.correctnessIndicatorIcon, classes.correctIcon)
233
+ }) : /*#__PURE__*/_react["default"].createElement(_Close["default"], {
234
+ className: (0, _classnames["default"])(classes.correctnessIndicatorIcon, classes.incorrectIcon)
235
+ });
236
+ }
237
+
238
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
239
+ ref: this.hiddenRef,
240
+ style: {
241
+ position: 'absolute',
242
+ visibility: 'hidden',
243
+ top: 0,
244
+ left: 0
245
+ }
246
+ }, (choices || []).map(function (c, index) {
247
+ return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
248
+ key: index,
249
+ classes: {
250
+ root: classes.menuRoot,
251
+ selected: classes.selected
252
+ }
253
+ }, /*#__PURE__*/_react["default"].createElement("span", {
254
+ className: classes.label,
255
+ dangerouslySetInnerHTML: {
256
+ __html: c.label
257
+ }
258
+ }));
259
+ })), /*#__PURE__*/_react["default"].createElement(_InputLabel["default"], {
260
+ className: classes.srOnly,
261
+ id: labelId
262
+ }, labelText), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
263
+ ref: this.buttonRef,
264
+ style: _objectSpread(_objectSpread({}, this.state.menuWidth && {
265
+ minWidth: "calc(".concat(this.state.menuWidth, "px + 8px)")
266
+ }), {}, {
267
+ borderWidth: open ? '2px' : '1px',
268
+ transition: 'border-width 0.2s ease-in-out'
269
+ }),
270
+ "aria-controls": open ? menuId : undefined,
271
+ "aria-haspopup": "listbox",
272
+ "aria-expanded": open ? 'true' : undefined,
273
+ "aria-activedescendant": this.state.highlightedOptionId,
274
+ onClick: this.handleClick,
275
+ classes: {
276
+ root: classes.root,
277
+ disabled: disabledClass
278
+ },
279
+ disabled: disabled,
280
+ id: buttonId,
281
+ role: "combobox",
282
+ "aria-label": "Select answer",
283
+ "aria-labelledby": valueDisplayId
284
+ }, correctnessIcon, /*#__PURE__*/_react["default"].createElement("span", {
285
+ id: valueDisplayId,
286
+ ref: this.previewRef,
287
+ className: classes.label,
288
+ dangerouslySetInnerHTML: {
289
+ __html: correctValue ? correctValue : open && this.state.previewValue ? this.getLabel(choices, this.state.previewValue) : this.getLabel(choices, value) || ''
290
+ }
291
+ }), open ? /*#__PURE__*/_react["default"].createElement(_ArrowDropUp["default"], null) : /*#__PURE__*/_react["default"].createElement(_ArrowDropDown["default"], null)), /*#__PURE__*/_react["default"].createElement(_Menu["default"], {
292
+ id: menuId,
293
+ anchorEl: anchorEl,
294
+ className: classes.selectMenu,
295
+ keepMounted: true,
296
+ open: open,
297
+ onClose: this.handleClose,
298
+ getContentAnchorEl: null,
299
+ anchorOrigin: {
300
+ vertical: 'bottom',
301
+ horizontal: 'left'
302
+ },
303
+ transformOrigin: {
304
+ vertical: 'top',
305
+ horizontal: 'left'
306
+ },
307
+ PaperProps: this.state.menuWidth ? {
308
+ style: {
309
+ minWidth: this.state.menuWidth,
310
+ padding: '4px'
311
+ }
312
+ } : undefined,
313
+ MenuListProps: {
314
+ 'aria-labelledby': buttonId,
315
+ role: 'listbox',
316
+ disablePadding: true
317
+ }
318
+ }, (choices || []).map(function (c, index) {
319
+ var optionId = "dropdown-option-".concat(id, "-").concat(index);
320
+ return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
321
+ id: optionId,
322
+ classes: {
323
+ root: classes.menuRoot,
324
+ selected: classes.selected
325
+ },
326
+ key: "".concat(c.label, "-").concat(index),
327
+ value: c.value,
328
+ onClick: function onClick() {
329
+ return _this2.handleSelect(c.value, index);
330
+ },
331
+ role: "option",
332
+ "aria-selected": _this2.state.highlightedOptionId === optionId ? 'true' : undefined,
333
+ onMouseOver: function onMouseOver() {
334
+ return _this2.handleHover(index);
335
+ }
336
+ }, /*#__PURE__*/_react["default"].createElement("span", {
337
+ ref: function ref(_ref) {
338
+ return _this2.elementRefs[index] = _ref;
339
+ },
340
+ className: classes.label,
341
+ dangerouslySetInnerHTML: {
342
+ __html: c.label
343
+ }
344
+ }), /*#__PURE__*/_react["default"].createElement("span", {
345
+ className: classes.selectedIndicator,
346
+ dangerouslySetInnerHTML: {
347
+ __html: c.value === value ? ' &check;' : ''
348
+ }
349
+ }));
350
+ })));
351
+ }
352
+ }]);
353
+ return Dropdown;
354
+ }(_react["default"].Component);
355
+
356
+ (0, _defineProperty2["default"])(Dropdown, "propTypes", {
357
+ id: _propTypes["default"].string,
358
+ value: _propTypes["default"].string,
359
+ disabled: _propTypes["default"].bool,
360
+ onChange: _propTypes["default"].func,
361
+ classes: _propTypes["default"].object,
362
+ correct: _propTypes["default"].bool,
363
+ choices: _propTypes["default"].arrayOf(_propTypes["default"].shape({
364
+ value: _propTypes["default"].string,
365
+ label: _propTypes["default"].string
366
+ })),
367
+ showCorrectAnswer: _propTypes["default"].bool,
368
+ singleQuery: _propTypes["default"].bool,
369
+ correctValue: _propTypes["default"].string
370
+ });
371
+
372
+ var styles = function styles() {
373
+ return {
374
+ root: {
375
+ color: _renderUi.color.text(),
376
+ border: "1px solid ".concat(_renderUi.color.borderGray()),
377
+ borderRadius: '4px',
378
+ justifyContent: 'space-between',
379
+ backgroundColor: _renderUi.color.background(),
380
+ position: 'relative',
381
+ height: '45px',
382
+ width: 'fit-content',
383
+ margin: '2px',
384
+ textTransform: 'none',
385
+ '& span': {
386
+ paddingRight: '5px'
387
+ },
388
+ '& svg': {
389
+ position: 'absolute',
390
+ right: 0,
391
+ top: 'calc(50% - 12px)',
392
+ pointerEvents: 'none',
393
+ color: _renderUi.color.text(),
394
+ marginLeft: '5px'
395
+ }
396
+ },
397
+ disabledCorrect: {
398
+ borderWidth: '2px',
399
+ borderColor: _renderUi.color.correct(),
400
+ color: "".concat(_renderUi.color.text(), " !important")
401
+ },
402
+ disabledIncorrect: {
403
+ borderWidth: '2px',
404
+ borderColor: _renderUi.color.incorrectWithIcon(),
405
+ color: "".concat(_renderUi.color.text(), " !important")
406
+ },
407
+ selectMenu: {
408
+ backgroundColor: _renderUi.color.background(),
409
+ border: "1px solid ".concat(_renderUi.color.correct(), " !important"),
410
+ '&:hover': {
411
+ border: "1px solid ".concat(_renderUi.color.text(), " "),
412
+ borderColor: 'initial'
413
+ },
414
+ '&:focus': {
415
+ border: "1px solid ".concat(_renderUi.color.text()),
416
+ borderColor: 'initial'
417
+ },
418
+ // remove default padding on the inner list
419
+ '& .MuiList-root': {
420
+ padding: 0
421
+ }
422
+ },
423
+ selected: {
424
+ color: "".concat(_renderUi.color.text(), " !important"),
425
+ backgroundColor: "".concat(_renderUi.color.background(), " !important"),
426
+ '&:hover': {
427
+ color: _renderUi.color.text(),
428
+ backgroundColor: "".concat(_renderUi.color.dropdownBackground(), " !important")
429
+ }
430
+ },
431
+ menuRoot: {
432
+ color: _renderUi.color.text(),
433
+ backgroundColor: _renderUi.color.background(),
434
+ '&:focus': {
435
+ color: _renderUi.color.text(),
436
+ backgroundColor: _renderUi.color.background()
437
+ },
438
+ '&:hover': {
439
+ color: _renderUi.color.text(),
440
+ backgroundColor: _renderUi.color.dropdownBackground()
441
+ },
442
+ boxSizing: 'border-box',
443
+ padding: '25px',
444
+ borderRadius: '4px'
445
+ },
446
+ label: {
447
+ fontSize: 'max(1rem, 14px)'
448
+ },
449
+ selectedIndicator: {
450
+ fontSize: 'max(1rem, 14px)',
451
+ position: 'absolute',
452
+ right: '10px'
453
+ },
454
+ srOnly: {
455
+ position: 'absolute',
456
+ left: '-10000px',
457
+ top: 'auto',
458
+ width: '1px',
459
+ height: '1px',
460
+ overflow: 'hidden'
461
+ },
462
+ correctnessIndicatorIcon: {
463
+ color: "".concat(_renderUi.color.white(), " !important"),
464
+ position: 'absolute',
465
+ top: '-8px !important',
466
+ left: '-8px',
467
+ marginLeft: '0 !important',
468
+ borderRadius: '50%',
469
+ fontSize: '16px',
470
+ padding: '2px'
471
+ },
472
+ correctIcon: {
473
+ backgroundColor: _renderUi.color.correct()
474
+ },
475
+ incorrectIcon: {
476
+ backgroundColor: _renderUi.color.incorrectWithIcon()
477
+ }
478
+ };
479
+ };
480
+
481
+ var _default = (0, _styles.withStyles)(styles)(Dropdown);
482
+
483
+ exports["default"] = _default;
484
+ //# sourceMappingURL=dropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/dropdown.jsx"],"names":["Dropdown","props","event","setState","anchorEl","currentTarget","value","previewValue","highlightedOptionId","previewRef","current","innerHTML","index","id","stateUpdate","choices","onChange","handleHighlight","handleClose","selectedValue","state","ref","elementRefs","preview","menuWidth","hiddenRef","React","createRef","buttonRef","clientWidth","prevProps","prevState","hiddenEl","dropdownJustOpened","forEach","containsLatex","querySelector","hasMathJax","mathHandled","newWidth","found","find","choice","label","trim","undefined","classes","correct","disabled","showCorrectAnswer","singleQuery","correctValue","open","Boolean","buttonId","menuId","valueDisplayId","disabledClass","disabledCorrect","disabledIncorrect","incrementedId","parseInt","labelId","labelText","correctnessIcon","correctnessIndicatorIcon","correctIcon","incorrectIcon","position","visibility","top","left","map","c","root","menuRoot","selected","__html","srOnly","minWidth","borderWidth","transition","handleClick","getLabel","selectMenu","vertical","horizontal","style","padding","role","disablePadding","optionId","handleSelect","handleHover","selectedIndicator","Component","PropTypes","string","bool","func","object","arrayOf","shape","styles","color","text","border","borderGray","borderRadius","justifyContent","backgroundColor","background","height","width","margin","textTransform","paddingRight","right","pointerEvents","marginLeft","borderColor","incorrectWithIcon","dropdownBackground","boxSizing","fontSize","overflow","white"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;IAEMA,Q;;;;;AAcJ,oBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,oGAqDL,UAACC,KAAD;AAAA,aAAW,MAAKC,QAAL,CAAc;AAAEC,QAAAA,QAAQ,EAAEF,KAAK,CAACG;AAAlB,OAAd,CAAX;AAAA,KArDK;AAAA,oGAuDL,YAAM;AAClB,UAAQC,KAAR,GAAkB,MAAKL,KAAvB,CAAQK,KAAR;;AACA,YAAKH,QAAL,CAAc;AAAEC,QAAAA,QAAQ,EAAE,IAAZ;AAAkBG,QAAAA,YAAY,EAAE,IAAhC;AAAsCC,QAAAA,mBAAmB,EAAE;AAA3D,OAAd,EAFkB,CAGlB;;;AACA,UAAI,CAACF,KAAD,IAAU,MAAKG,UAAL,CAAgBC,OAA9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,MAAAA,YAAY,EAAE,KANU;AAOxBgB,MAAAA,QAAQ,EAAE,MAPc;AAQxBpC,MAAAA,OAAO,EAAE;AARe,KAzFN;AAmGpBtB,IAAAA,WAAW,EAAE;AACX4C,MAAAA,eAAe,EAAEN,gBAAMzD,OAAN;AADN,KAnGO;AAsGpBoB,IAAAA,aAAa,EAAE;AACb2C,MAAAA,eAAe,EAAEN,gBAAMiB,iBAAN;AADJ;AAtGK,GAAP;AAAA,CAAf;;eA2Ge,wBAAWlB,MAAX,EAAmBvG,QAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Button from '@material-ui/core/Button';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport Menu from '@material-ui/core/Menu';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';\nimport ArrowDropUpIcon from '@material-ui/icons/ArrowDropUp';\nimport Close from '@material-ui/icons/Close';\nimport Check from '@material-ui/icons/Check';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport isEqual from 'lodash/isEqual';\n\nimport { color } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nclass Dropdown extends React.Component {\n static propTypes = {\n id: PropTypes.string,\n value: PropTypes.string,\n disabled: PropTypes.bool,\n onChange: PropTypes.func,\n classes: PropTypes.object,\n correct: PropTypes.bool,\n choices: PropTypes.arrayOf(PropTypes.shape({ value: PropTypes.string, label: PropTypes.string })),\n showCorrectAnswer: PropTypes.bool,\n singleQuery: PropTypes.bool,\n correctValue: PropTypes.string,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n anchorEl: null,\n highlightedOptionId: null,\n menuWidth: null,\n previewValue: null,\n };\n this.hiddenRef = React.createRef();\n this.buttonRef = React.createRef();\n this.previewRef = React.createRef();\n this.elementRefs = [];\n }\n\n componentDidMount() {\n // measure hidden menu width once\n if (this.hiddenRef.current && this.state.menuWidth === null) {\n this.setState({ menuWidth: this.hiddenRef.current.clientWidth });\n }\n }\n\n componentDidUpdate(prevProps, prevState) {\n const hiddenEl = this.hiddenRef.current;\n\n const dropdownJustOpened = !prevState.anchorEl && this.state.anchorEl;\n if (dropdownJustOpened) {\n this.elementRefs.forEach((ref) => {\n if (!ref) return;\n\n const containsLatex = ref.querySelector('[data-latex], [data-raw]');\n const hasMathJax = ref.querySelector('mjx-container');\n const mathHandled = ref.querySelector('[data-math-handled=\"true\"]');\n\n if (containsLatex && (!mathHandled || !hasMathJax)) {\n renderMath(ref);\n }\n });\n }\n\n if (hiddenEl) {\n const newWidth = hiddenEl.clientWidth;\n if (newWidth !== this.state.menuWidth) {\n this.elementRefs.forEach((ref) => {\n if (ref) renderMath(ref);\n });\n\n renderMath(hiddenEl);\n this.setState({ menuWidth: newWidth });\n }\n }\n }\n\n handleClick = (event) => this.setState({ anchorEl: event.currentTarget });\n\n handleClose = () => {\n const { value } = this.props;\n this.setState({ anchorEl: null, previewValue: null, highlightedOptionId: null });\n // clear displayed preview if no selection\n if (!value && this.previewRef.current) {\n this.previewRef.current.innerHTML = '';\n }\n };\n\n handleHighlight = (index) => {\n const highlightedOptionId = `dropdown-option-${this.props.id}-${index}`;\n\n // preview on hover if nothing selected\n const stateUpdate = { highlightedOptionId };\n if (!this.props.value) {\n stateUpdate.previewValue = this.props.choices[index].value;\n }\n this.setState(stateUpdate);\n };\n\n handleSelect = (value, index) => {\n this.props.onChange(this.props.id, value);\n this.handleHighlight(index);\n this.handleClose();\n };\n\n handleHover = (index) => {\n const selectedValue = this.props.value;\n\n if (selectedValue) return;\n\n const highlightedOptionId = `dropdown-option-${this.props.id}-${index}`;\n const previewValue = this.state.previewValue;\n\n this.setState({ highlightedOptionId, previewValue }, () => {\n // On hover, preview the math-rendered content inside the button if no value is selected.\n const ref = this.elementRefs[index];\n const preview = this.previewRef.current;\n\n if (ref && preview) {\n preview.innerHTML = ref.innerHTML;\n }\n });\n };\n\n getLabel(choices, value) {\n const found = (choices || []).find((choice) => choice.value === value);\n\n return found ? found.label.trim() : undefined;\n }\n\n render() {\n const { classes, id, correct, disabled, value, choices, showCorrectAnswer, singleQuery, correctValue } = this.props;\n const { anchorEl } = this.state;\n const open = Boolean(anchorEl);\n const buttonId = `dropdown-button-${id}`;\n const menuId = `dropdown-menu-${id}`;\n const valueDisplayId = `dropdown-value-${id}`;\n\n // Determine the class for disabled state, view mode and evaluate mode\n let disabledClass;\n // Reset elementRefs before each render to avoid stale references\n this.elementRefs = [];\n\n if (disabled && correct !== undefined) {\n disabledClass = correct || showCorrectAnswer ? classes.disabledCorrect : classes.disabledIncorrect;\n }\n\n // Create distinct, visually hidden labels for each dropdown\n const incrementedId = parseInt(id, 10) + 1;\n const labelId = singleQuery ? 'Query-label' : `Query-label-${incrementedId}`;\n const labelText = singleQuery ? 'Query' : `Query ${incrementedId}`;\n\n // 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.\n let correctnessIcon = null;\n if (disabled && correct !== undefined) {\n correctnessIcon =\n correct || showCorrectAnswer ? (\n <Check className={classNames(classes.correctnessIndicatorIcon, classes.correctIcon)} />\n ) : (\n <Close className={classNames(classes.correctnessIndicatorIcon, classes.incorrectIcon)} />\n );\n }\n\n return (\n <>\n <div ref={this.hiddenRef} style={{ position: 'absolute', visibility: 'hidden', top: 0, left: 0 }}>\n {(choices || []).map((c, index) => (\n <MenuItem key={index} classes={{ root: classes.menuRoot, selected: classes.selected }}>\n <span className={classes.label} dangerouslySetInnerHTML={{ __html: c.label }} />\n </MenuItem>\n ))}\n </div>\n <InputLabel className={classes.srOnly} id={labelId}>\n {labelText}\n </InputLabel>\n <Button\n ref={this.buttonRef}\n style={{\n ...(this.state.menuWidth && { minWidth: `calc(${this.state.menuWidth}px + 8px)` }),\n borderWidth: open ? '2px' : '1px',\n transition: 'border-width 0.2s ease-in-out',\n }}\n aria-controls={open ? menuId : undefined}\n aria-haspopup=\"listbox\"\n aria-expanded={open ? 'true' : undefined}\n aria-activedescendant={this.state.highlightedOptionId}\n onClick={this.handleClick}\n classes={{\n root: classes.root,\n disabled: disabledClass,\n }}\n disabled={disabled}\n id={buttonId}\n role=\"combobox\"\n aria-label=\"Select answer\"\n aria-labelledby={valueDisplayId}\n >\n {correctnessIcon}\n <span\n id={valueDisplayId}\n ref={this.previewRef}\n className={classes.label}\n dangerouslySetInnerHTML={{\n __html: correctValue\n ? correctValue\n : open && this.state.previewValue\n ? this.getLabel(choices, this.state.previewValue)\n : this.getLabel(choices, value) || '',\n }}\n />\n {open ? <ArrowDropUpIcon /> : <ArrowDropDownIcon />}\n </Button>\n <Menu\n id={menuId}\n anchorEl={anchorEl}\n className={classes.selectMenu}\n keepMounted\n open={open}\n onClose={this.handleClose}\n getContentAnchorEl={null}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }}\n transformOrigin={{ vertical: 'top', horizontal: 'left' }}\n PaperProps={this.state.menuWidth ? { style: { minWidth: this.state.menuWidth, padding: '4px' } } : undefined}\n MenuListProps={{\n 'aria-labelledby': buttonId,\n role: 'listbox',\n disablePadding: true,\n }}\n >\n {(choices || []).map((c, index) => {\n const optionId = `dropdown-option-${id}-${index}`;\n\n return (\n <MenuItem\n id={optionId}\n classes={{ root: classes.menuRoot, selected: classes.selected }}\n key={`${c.label}-${index}`}\n value={c.value}\n onClick={() => this.handleSelect(c.value, index)}\n role=\"option\"\n aria-selected={this.state.highlightedOptionId === optionId ? 'true' : undefined}\n onMouseOver={() => this.handleHover(index)}\n >\n <span\n ref={(ref) => (this.elementRefs[index] = ref)}\n className={classes.label}\n dangerouslySetInnerHTML={{ __html: c.label }}\n />\n <span\n className={classes.selectedIndicator}\n dangerouslySetInnerHTML={{ __html: c.value === value ? ' &check;' : '' }}\n />\n </MenuItem>\n );\n })}\n </Menu>\n </>\n );\n }\n}\n\nconst styles = () => ({\n root: {\n color: color.text(),\n border: `1px solid ${color.borderGray()}`,\n borderRadius: '4px',\n justifyContent: 'space-between',\n backgroundColor: color.background(),\n position: 'relative',\n height: '45px',\n width: 'fit-content',\n margin: '2px',\n textTransform: 'none',\n '& span': {\n paddingRight: '5px',\n },\n '& svg': {\n position: 'absolute',\n right: 0,\n top: 'calc(50% - 12px)',\n pointerEvents: 'none',\n color: color.text(),\n marginLeft: '5px',\n },\n },\n disabledCorrect: {\n borderWidth: '2px',\n borderColor: color.correct(),\n color: `${color.text()} !important`,\n },\n disabledIncorrect: {\n borderWidth: '2px',\n borderColor: color.incorrectWithIcon(),\n color: `${color.text()} !important`,\n },\n selectMenu: {\n backgroundColor: color.background(),\n border: `1px solid ${color.correct()} !important`,\n '&:hover': {\n border: `1px solid ${color.text()} `,\n borderColor: 'initial',\n },\n '&:focus': {\n border: `1px solid ${color.text()}`,\n borderColor: 'initial',\n },\n // remove default padding on the inner list\n '& .MuiList-root': {\n padding: 0,\n },\n },\n selected: {\n color: `${color.text()} !important`,\n backgroundColor: `${color.background()} !important`,\n '&:hover': {\n color: color.text(),\n backgroundColor: `${color.dropdownBackground()} !important`,\n },\n },\n menuRoot: {\n color: color.text(),\n backgroundColor: color.background(),\n '&:focus': {\n color: color.text(),\n backgroundColor: color.background(),\n },\n '&:hover': {\n color: color.text(),\n backgroundColor: color.dropdownBackground(),\n },\n boxSizing: 'border-box',\n padding: '25px',\n borderRadius: '4px',\n },\n label: {\n fontSize: 'max(1rem, 14px)',\n },\n selectedIndicator: {\n fontSize: 'max(1rem, 14px)',\n position: 'absolute',\n right: '10px',\n },\n srOnly: {\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n },\n correctnessIndicatorIcon: {\n color: `${color.white()} !important`,\n position: 'absolute',\n top: '-8px !important',\n left: '-8px',\n marginLeft: '0 !important',\n borderRadius: '50%',\n fontSize: '16px',\n padding: '2px',\n },\n correctIcon: {\n backgroundColor: color.correct(),\n },\n incorrectIcon: {\n backgroundColor: color.incorrectWithIcon(),\n },\n});\n\nexport default withStyles(styles)(Dropdown);\n"],"file":"dropdown.js"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _react = _interopRequireDefault(require("react"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var _correctInput = _interopRequireDefault(require("./correct-input"));
15
+
16
+ var Input = function Input(_ref) {
17
+ var disabled = _ref.disabled,
18
+ correct = _ref.correct,
19
+ charactersLimit = _ref.charactersLimit,
20
+ id = _ref.id,
21
+ isConstructedResponse = _ref.isConstructedResponse,
22
+ value = _ref.value,
23
+ _onChange = _ref.onChange,
24
+ showCorrectAnswer = _ref.showCorrectAnswer,
25
+ spellCheck = _ref.spellCheck,
26
+ width = _ref.width;
27
+ return /*#__PURE__*/_react["default"].createElement(_correctInput["default"], {
28
+ disabled: disabled,
29
+ correct: showCorrectAnswer || correct,
30
+ charactersLimit: charactersLimit,
31
+ variant: "outlined",
32
+ value: value,
33
+ isConstructedResponse: isConstructedResponse,
34
+ spellCheck: spellCheck,
35
+ isBox: true,
36
+ width: width,
37
+ onChange: function onChange(e) {
38
+ _onChange(id, e.target.value);
39
+ }
40
+ });
41
+ };
42
+
43
+ Input.propTypes = {
44
+ id: _propTypes["default"].string,
45
+ value: _propTypes["default"].string,
46
+ onChange: _propTypes["default"].func,
47
+ disabled: _propTypes["default"].bool,
48
+ spellCheck: _propTypes["default"].bool,
49
+ correct: _propTypes["default"].bool,
50
+ showCorrectAnswer: _propTypes["default"].bool,
51
+ charactersLimit: _propTypes["default"].number,
52
+ width: _propTypes["default"].number,
53
+ isConstructedResponse: _propTypes["default"].bool
54
+ };
55
+ var _default = Input;
56
+ exports["default"] = _default;
57
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/input.jsx"],"names":["Input","disabled","correct","charactersLimit","id","isConstructedResponse","value","onChange","showCorrectAnswer","spellCheck","width","e","target","propTypes","PropTypes","string","func","bool","number"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,KAAK,GAAG,SAARA,KAAQ,OAWR;AAAA,MAVJC,QAUI,QAVJA,QAUI;AAAA,MATJC,OASI,QATJA,OASI;AAAA,MARJC,eAQI,QARJA,eAQI;AAAA,MAPJC,EAOI,QAPJA,EAOI;AAAA,MANJC,qBAMI,QANJA,qBAMI;AAAA,MALJC,KAKI,QALJA,KAKI;AAAA,MAJJC,SAII,QAJJA,QAII;AAAA,MAHJC,iBAGI,QAHJA,iBAGI;AAAA,MAFJC,UAEI,QAFJA,UAEI;AAAA,MADJC,KACI,QADJA,KACI;AACJ,sBACE,gCAAC,wBAAD;AACE,IAAA,QAAQ,EAAET,QADZ;AAEE,IAAA,OAAO,EAAEO,iBAAiB,IAAIN,OAFhC;AAGE,IAAA,eAAe,EAAEC,eAHnB;AAIE,IAAA,OAAO,EAAC,UAJV;AAKE,IAAA,KAAK,EAAEG,KALT;AAME,IAAA,qBAAqB,EAAED,qBANzB;AAOE,IAAA,UAAU,EAAEI,UAPd;AAQE,IAAA,KAAK,EAAE,IART;AASE,IAAA,KAAK,EAAEC,KATT;AAUE,IAAA,QAAQ,EAAE,kBAACC,CAAD,EAAO;AACfJ,MAAAA,SAAQ,CAACH,EAAD,EAAKO,CAAC,CAACC,MAAF,CAASN,KAAd,CAAR;AACD;AAZH,IADF;AAgBD,CA5BD;;AA8BAN,KAAK,CAACa,SAAN,GAAkB;AAChBT,EAAAA,EAAE,EAAEU,sBAAUC,MADE;AAEhBT,EAAAA,KAAK,EAAEQ,sBAAUC,MAFD;AAGhBR,EAAAA,QAAQ,EAAEO,sBAAUE,IAHJ;AAIhBf,EAAAA,QAAQ,EAAEa,sBAAUG,IAJJ;AAKhBR,EAAAA,UAAU,EAAEK,sBAAUG,IALN;AAMhBf,EAAAA,OAAO,EAAEY,sBAAUG,IANH;AAOhBT,EAAAA,iBAAiB,EAAEM,sBAAUG,IAPb;AAQhBd,EAAAA,eAAe,EAAEW,sBAAUI,MARX;AAShBR,EAAAA,KAAK,EAAEI,sBAAUI,MATD;AAUhBb,EAAAA,qBAAqB,EAAES,sBAAUG;AAVjB,CAAlB;eAaejB,K","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport CorrectInput from './correct-input';\n\nconst Input = ({\n disabled,\n correct,\n charactersLimit,\n id,\n isConstructedResponse,\n value,\n onChange,\n showCorrectAnswer,\n spellCheck,\n width,\n}) => {\n return (\n <CorrectInput\n disabled={disabled}\n correct={showCorrectAnswer || correct}\n charactersLimit={charactersLimit}\n variant=\"outlined\"\n value={value}\n isConstructedResponse={isConstructedResponse}\n spellCheck={spellCheck}\n isBox={true}\n width={width}\n onChange={(e) => {\n onChange(id, e.target.value);\n }}\n />\n );\n};\n\nInput.propTypes = {\n id: PropTypes.string,\n value: PropTypes.string,\n onChange: PropTypes.func,\n disabled: PropTypes.bool,\n spellCheck: PropTypes.bool,\n correct: PropTypes.bool,\n showCorrectAnswer: PropTypes.bool,\n charactersLimit: PropTypes.number,\n width: PropTypes.number,\n isConstructedResponse: PropTypes.bool,\n};\n\nexport default Input;\n"],"file":"input.js"}