UNPKG

@instructure/quiz-interactions

Version:

A React UI component Library for quiz interaction types.

95 lines 3.97 kB
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/esm/inherits"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; var _dec, _class, _BlankAnswer; function _callSuper(_this, derived, args) { function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (e) { return false; } } derived = _getPrototypeOf(derived); return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args)); } /** @jsx jsx */ import { Component } from 'react'; import PropTypes from 'prop-types'; import { jsx } from '@instructure/emotion'; import { IconButton } from '@instructure/ui-buttons'; import { IconXLine } from '@instructure/ui-icons'; import DraggableBlankChoice from '../DraggableBlankChoice'; import generateStyle from './styles'; import generateComponentTheme from './theme'; import t from '@instructure/quiz-i18n/es/format-message'; import { withStyleOverrides } from '@instructure/quiz-common'; var BlankAnswer = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_BlankAnswer = /*#__PURE__*/function (_Component) { function BlankAnswer() { var _this2; _classCallCheck(this, BlankAnswer); for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) { _args[_key] = arguments[_key]; } _this2 = _callSuper(this, BlankAnswer, [].concat(_args)); _defineProperty(_this2, "button", null); _defineProperty(_this2, "handleClick", function (event) { var _this2$props; for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { args[_key2 - 1] = arguments[_key2]; } (_this2$props = _this2.props).onRemoveAnswer.apply(_this2$props, [event].concat(args)); }); _defineProperty(_this2, "handleRef", function (node) { _this2.button = node; }); return _this2; } _inherits(BlankAnswer, _Component); return _createClass(BlankAnswer, [{ key: "focus", value: function focus() { this.button.focus(); } }, { key: "render", value: function render() { var itemBody = this.props.itemBody; return jsx("div", { tabIndex: "-1", css: this.props.styles.answerOptionWrapper }, jsx(DraggableBlankChoice, { key: this.props.choiceId, id: this.props.choiceId, itemBody: itemBody, canDrag: false }), jsx(IconButton, { ref: this.handleRef, size: "small", renderIcon: IconXLine, withBackground: false, withBorder: false, onClick: this.handleClick, readOnly: this.props.readOnly, screenReaderLabel: t('Remove Choice {itemBody}', { itemBody: itemBody }) })); } }]); }(Component), _defineProperty(_BlankAnswer, "displayName", 'BlankAnswer'), _defineProperty(_BlankAnswer, "componentId", "Quizzes".concat(_BlankAnswer.displayName)), _defineProperty(_BlankAnswer, "propTypes", { choiceId: PropTypes.string.isRequired, itemBody: PropTypes.string.isRequired, onRemoveAnswer: PropTypes.func.isRequired, readOnly: PropTypes.bool, styles: PropTypes.object }), _defineProperty(_BlankAnswer, "defaultProps", { readOnly: false }), _BlankAnswer)) || _class); export { BlankAnswer as default };