@instructure/quiz-interactions
Version:
A React UI component Library for quiz interaction types.
108 lines • 4.32 kB
JavaScript
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, _ChoicesList;
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 { Text } from '@instructure/ui-text';
import DropTargetContainer from '../DropTargetContainer';
import Pill from '../Pill';
import generateStyle from './styles';
import generateComponentTheme from './theme';
import t from '@instructure/quiz-i18n/es/format-message';
import { withStyleOverrides } from '@instructure/quiz-common';
var ChoicesList = (_dec = withStyleOverrides(generateStyle, generateComponentTheme), _dec(_class = (_ChoicesList = /*#__PURE__*/function (_Component) {
function ChoicesList() {
var _this2;
_classCallCheck(this, ChoicesList);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this2 = _callSuper(this, ChoicesList, [].concat(args));
_defineProperty(_this2, "renderChoices", function () {
return jsx("div", {
className: "choicesBackground",
css: _this2.props.styles.choicesBackground
}, _this2.props.distractors.map(function (item) {
var id = "".concat(item.id, "_").concat(_this2.props.takeId);
return jsx(Pill, {
key: item.id,
id: id,
itemBody: item.itemBody,
isDraggable: _this2.props.isDraggable,
actionsContent: _this2.props.actionsContent
});
}));
});
return _this2;
}
_inherits(ChoicesList, _Component);
return _createClass(ChoicesList, [{
key: "renderChoicesContainer",
value: function renderChoicesContainer() {
if (!this.props.distractors.length) {
return jsx("div", {
className: "fs-mask",
css: this.props.styles.emptyContainer
}, jsx(Text, {
color: "secondary"
}, t('Drag Uncategorized Answers Here')));
}
if (this.props.isDraggable) {
return jsx(DropTargetContainer, {
onDrop: this.props.onDrop,
className: "fs-mask",
css: this.props.styles.choicesContainer
}, this.renderChoices());
}
return jsx("div", {
className: "fs-mask",
css: this.props.styles.choicesContainer
}, this.renderChoices());
}
}, {
key: "render",
value: function render() {
return jsx("div", {
css: this.props.styles.mainContainer
}, jsx(Text, {
color: "primary"
}, t('Possible answers')), this.renderChoicesContainer());
}
}]);
}(Component), _defineProperty(_ChoicesList, "displayName", 'ChoicesList'), _defineProperty(_ChoicesList, "componentId", "Quizzes".concat(_ChoicesList.displayName)), _defineProperty(_ChoicesList, "propTypes", {
actionsContent: PropTypes.func,
distractors: PropTypes.arrayOf(PropTypes.shape({
id: PropTypes.string.isRequired,
itemBody: PropTypes.string.isRequired
})).isRequired,
isDraggable: PropTypes.bool,
onDrop: PropTypes.func,
takeId: PropTypes.string,
styles: PropTypes.object
}), _defineProperty(_ChoicesList, "defaultProps", {
actionsContent: void 0,
isDraggable: void 0,
onDrop: void 0,
takeId: ''
}), _ChoicesList)) || _class);
export { ChoicesList as default };