@pie-element/math-inline 5.6.4-next.974 → 5.6.4-next.984
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.
|
@@ -44,39 +44,47 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
|
|
|
44
44
|
|
|
45
45
|
var _super = _createSuper(SimpleQuestionBlockRaw);
|
|
46
46
|
|
|
47
|
-
function SimpleQuestionBlockRaw() {
|
|
47
|
+
function SimpleQuestionBlockRaw(props) {
|
|
48
48
|
var _this;
|
|
49
49
|
|
|
50
50
|
(0, _classCallCheck2["default"])(this, SimpleQuestionBlockRaw);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
_this = _super.call(this, props);
|
|
52
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "mathToolBarContainsTarget", function (e) {
|
|
53
|
+
return document.getElementById(_this.mathToolBarId).contains(e.target);
|
|
54
|
+
});
|
|
55
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClick", function (e) {
|
|
56
|
+
try {
|
|
57
|
+
if (!_this.mathToolBarContainsTarget(e)) {
|
|
58
|
+
_this.setState({
|
|
59
|
+
showKeypad: false
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
} catch (e) {// console.log(e.toString());
|
|
63
|
+
}
|
|
59
64
|
});
|
|
60
65
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
|
|
61
66
|
return _this.setState({
|
|
62
67
|
showKeypad: true
|
|
63
68
|
});
|
|
64
69
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!relatedTarget || !currentTarget || relatedTarget.offsetParent !== currentTarget.offsetParent) {
|
|
71
|
-
_this.setState({
|
|
72
|
-
showKeypad: false
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
});
|
|
70
|
+
_this.state = {
|
|
71
|
+
showKeypad: true
|
|
72
|
+
};
|
|
73
|
+
_this.mathToolBarId = "math-toolbar-".concat(new Date().getTime());
|
|
76
74
|
return _this;
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
(0, _createClass2["default"])(SimpleQuestionBlockRaw, [{
|
|
78
|
+
key: "componentDidMount",
|
|
79
|
+
value: function componentDidMount() {
|
|
80
|
+
window.addEventListener('click', this.handleClick);
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "componentWillUnmount",
|
|
84
|
+
value: function componentWillUnmount() {
|
|
85
|
+
window.removeEventListener('click', this.handleClick);
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
80
88
|
key: "render",
|
|
81
89
|
value: function render() {
|
|
82
90
|
var _cx;
|
|
@@ -89,19 +97,16 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
|
|
|
89
97
|
emptyResponse = _this$props.emptyResponse,
|
|
90
98
|
onSimpleResponseChange = _this$props.onSimpleResponseChange;
|
|
91
99
|
|
|
92
|
-
var
|
|
93
|
-
config =
|
|
94
|
-
disabled =
|
|
95
|
-
correctness =
|
|
96
|
-
view = _ref2.view;
|
|
100
|
+
var _ref = model || {},
|
|
101
|
+
config = _ref.config,
|
|
102
|
+
disabled = _ref.disabled,
|
|
103
|
+
correctness = _ref.correctness;
|
|
97
104
|
|
|
98
105
|
if (!config) {
|
|
99
106
|
return;
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
var correct = correctness && correctness.correct;
|
|
103
|
-
var showAsCorrect = !emptyResponse && (showCorrect || correct);
|
|
104
|
-
var showAsIncorrect = !emptyResponse && !correct && !showCorrect && !view;
|
|
105
110
|
var responses = config.responses,
|
|
106
111
|
equationEditor = config.equationEditor;
|
|
107
112
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -110,7 +115,9 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
|
|
|
110
115
|
className: (0, _classnames["default"])(classes["static"], (_cx = {}, (0, _defineProperty2["default"])(_cx, classes.incorrect, !emptyResponse && !correct && !showCorrect), (0, _defineProperty2["default"])(_cx, classes.correct, !emptyResponse && (correct || showCorrect)), _cx))
|
|
111
116
|
}, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
|
|
112
117
|
latex: showCorrect ? responses && responses.length && responses[0].answer : session.response || ''
|
|
113
|
-
})) : /*#__PURE__*/_react["default"].createElement(
|
|
118
|
+
})) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
119
|
+
id: this.mathToolBarId
|
|
120
|
+
}, /*#__PURE__*/_react["default"].createElement(_mathToolbar.MathToolbar, {
|
|
114
121
|
classNames: {
|
|
115
122
|
editor: classes.responseEditor
|
|
116
123
|
},
|
|
@@ -119,11 +126,10 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
|
|
|
119
126
|
onChange: onSimpleResponseChange,
|
|
120
127
|
onDone: function onDone() {},
|
|
121
128
|
onFocus: this.onFocus,
|
|
122
|
-
onBlur: this.onBlur,
|
|
123
129
|
controlledKeypad: true,
|
|
124
130
|
showKeypad: this.state.showKeypad,
|
|
125
131
|
hideDoneButton: true
|
|
126
|
-
}));
|
|
132
|
+
})));
|
|
127
133
|
}
|
|
128
134
|
}]);
|
|
129
135
|
return SimpleQuestionBlockRaw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/simple-question-block.jsx"],"names":["SimpleQuestionBlockRaw","
|
|
1
|
+
{"version":3,"sources":["../src/simple-question-block.jsx"],"names":["SimpleQuestionBlockRaw","props","e","document","getElementById","mathToolBarId","contains","target","mathToolBarContainsTarget","setState","showKeypad","state","Date","getTime","window","addEventListener","handleClick","removeEventListener","classes","model","showCorrect","session","emptyResponse","onSimpleResponseChange","config","disabled","correctness","correct","responses","equationEditor","expression","incorrect","length","answer","response","editor","responseEditor","onFocus","React","Component","PropTypes","object","func","isRequired","bool","SimpleQuestionBlock","theme","display","justifyContent","width","maxWidth","height","textAlign","padding","spacing","unit","border","color","primaryLight","marginTop","marginBottom","text","background","fontSize","letterSpacing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,sB;;;;;AAUX,kCAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,kHAiBS,UAAAC,CAAC;AAAA,aAAIC,QAAQ,CAACC,cAAT,CAAwB,MAAKC,aAA7B,EAA4CC,QAA5C,CAAqDJ,CAAC,CAACK,MAAvD,CAAJ;AAAA,KAjBV;AAAA,oGAmBL,UAACL,CAAD,EAAO;AACnB,UAAI;AACF,YAAI,CAAC,MAAKM,yBAAL,CAA+BN,CAA/B,CAAL,EAAwC;AACtC,gBAAKO,QAAL,CAAc;AAAEC,YAAAA,UAAU,EAAE;AAAd,WAAd;AACD;AACF,OAJD,CAIE,OAAOR,CAAP,EAAU,CACV;AACD;AACF,KA3BkB;AAAA,gGA6BT;AAAA,aAAM,MAAKO,QAAL,CAAc;AAAEC,QAAAA,UAAU,EAAE;AAAd,OAAd,CAAN;AAAA,KA7BS;AAGjB,UAAKC,KAAL,GAAa;AACXD,MAAAA,UAAU,EAAE;AADD,KAAb;AAGA,UAAKL,aAAL,0BAAqC,IAAIO,IAAJ,GAAWC,OAAX,EAArC;AANiB;AAOlB;;;;WAED,6BAAoB;AAClBC,MAAAA,MAAM,CAACC,gBAAP,CAAwB,OAAxB,EAAiC,KAAKC,WAAtC;AACD;;;WAED,gCAAuB;AACrBF,MAAAA,MAAM,CAACG,mBAAP,CAA2B,OAA3B,EAAoC,KAAKD,WAAzC;AACD;;;WAgBD,kBAAS;AAAA;;AACP,wBAOI,KAAKf,KAPT;AAAA,UACEiB,OADF,eACEA,OADF;AAAA,UAEEC,KAFF,eAEEA,KAFF;AAAA,UAGEC,W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B/C,cAAQ;AACNE,MAAAA,KAAK,EAAEA,gBAAMI,IAAN,EADD;AAENC,MAAAA,UAAU,EAAEL,gBAAMK,UAAN,EAFN;AAGNN,MAAAA,MAAM,sBAAeC,gBAAMC,YAAN,EAAf,CAHA;AAINT,MAAAA,KAAK,EAAE,aAJD;AAKNc,MAAAA,QAAQ,EAAE,MALJ;AAMNV,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAAd,GAAqB,CANxB;AAON,2BAAqB;AACnB,6BAAqB;AACnB,4BAAkB;AAChBR,YAAAA,OAAO,EAAE;AADO;AADC;AADF;AAPf,KAlBuC;AAiC/CpB,IAAAA,OAAO,EAAE;AACP6B,MAAAA,MAAM,sBAAeC,gBAAM9B,OAAN,EAAf,gBADC;AAEP0B,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAFhB;AAGPS,MAAAA,aAAa,EAAE;AAHR,KAjCsC;AAsC/CjC,IAAAA,SAAS,EAAE;AACTyB,MAAAA,MAAM,sBAAeC,gBAAM1B,SAAN,EAAf,gBADG;AAETsB,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAFd;AAGTS,MAAAA,aAAa,EAAE;AAHN;AAtCoC,GAAL;AAAA,CAAhB,EA2CxBhE,sBA3CwB,CAA5B;eA6Ce6C,mB","sourcesContent":["import React from 'react';\nimport { MathToolbar } from '@pie-lib/math-toolbar';\nimport { mq } from '@pie-lib/math-input';\nimport cx from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport { color } from '@pie-lib/render-ui';\n\nexport class SimpleQuestionBlockRaw extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n onSimpleResponseChange: PropTypes.func,\n model: PropTypes.object.isRequired,\n emptyResponse: PropTypes.bool,\n session: PropTypes.object.isRequired,\n showCorrect: PropTypes.bool\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showKeypad: true\n };\n this.mathToolBarId = `math-toolbar-${new Date().getTime()}`;\n }\n\n componentDidMount() {\n window.addEventListener('click', this.handleClick);\n }\n\n componentWillUnmount() {\n window.removeEventListener('click', this.handleClick);\n }\n\n mathToolBarContainsTarget = e => document.getElementById(this.mathToolBarId).contains(e.target);\n\n handleClick = (e) => {\n try {\n if (!this.mathToolBarContainsTarget(e)) {\n this.setState({ showKeypad: false });\n }\n } catch (e) {\n // console.log(e.toString());\n }\n }\n\n onFocus = () => this.setState({ showKeypad: true })\n\n render() {\n const {\n classes,\n model,\n showCorrect,\n session,\n emptyResponse,\n onSimpleResponseChange\n } = this.props;\n const { config, disabled, correctness } = model || {};\n\n if (!config) {\n return;\n }\n\n const correct = correctness && correctness.correct;\n const { responses, equationEditor } = config;\n\n return (\n <div className={classes.expression}>\n {showCorrect || disabled ? (\n <div\n className={cx(classes.static, {\n [classes.incorrect]: !emptyResponse && !correct && !showCorrect,\n [classes.correct]: !emptyResponse && (correct || showCorrect)\n })}\n >\n <mq.Static\n latex={\n showCorrect ? (responses && responses.length && responses[0].answer) : (session.response || '')\n }\n />\n </div>\n ) : (\n <div id={this.mathToolBarId}>\n <MathToolbar\n classNames={{ editor: classes.responseEditor }}\n latex={session.response || ''}\n keypadMode={equationEditor}\n onChange={onSimpleResponseChange}\n onDone={() => {\n }}\n onFocus={this.onFocus}\n controlledKeypad={true}\n showKeypad={this.state.showKeypad}\n hideDoneButton={true}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nconst SimpleQuestionBlock = withStyles(theme => ({\n responseEditor: {\n display: 'flex',\n justifyContent: 'center',\n width: 'auto',\n maxWidth: 'fit-content',\n height: 'auto',\n textAlign: 'left',\n padding: theme.spacing.unit,\n '&.mq-math-mode': {\n border: `1px solid ${color.primaryLight()}`\n }\n },\n expression: {\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n padding: theme.spacing.unit\n },\n static: {\n color: color.text(),\n background: color.background(),\n border: `1px solid ${color.primaryLight()}`,\n width: 'fit-content',\n fontSize: '1rem',\n padding: theme.spacing.unit / 2,\n '& > .mq-math-mode': {\n '& > .mq-hasCursor': {\n '& > .mq-cursor': {\n display: 'none'\n }\n }\n }\n },\n correct: {\n border: `2px solid ${color.correct()} !important`,\n padding: theme.spacing.unit,\n letterSpacing: '0.5px',\n },\n incorrect: {\n border: `2px solid ${color.incorrect()} !important`,\n padding: theme.spacing.unit,\n letterSpacing: '0.5px',\n }\n}))(SimpleQuestionBlockRaw);\n\nexport default SimpleQuestionBlock;\n"],"file":"simple-question-block.js"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"repository": "pie-framework/pie-elements",
|
|
7
|
-
"version": "5.6.4-next.
|
|
7
|
+
"version": "5.6.4-next.984+344a7c065",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"description": "",
|
|
10
10
|
"scripts": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"author": "",
|
|
30
30
|
"license": "ISC",
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "344a7c065d38b9669d064219d54a5ce66f5690b2",
|
|
32
32
|
"module": "src/index.js",
|
|
33
33
|
"exports": {
|
|
34
34
|
".": "./src/index.js",
|