@pie-element/fraction-model 4.3.4-next.0 → 5.0.0-beta.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.
@@ -1,107 +1,84 @@
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
- exports["default"] = exports.Main = 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
-
7
+ exports.default = exports.Main = void 0;
22
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
9
  var _react = _interopRequireDefault(require("react"));
25
-
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
26
11
  var _configUi = require("@pie-lib/config-ui");
27
-
28
12
  var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
29
-
30
- var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
- var _styles = require("@material-ui/core/styles");
33
-
13
+ var _fractionModel = require("@pie-element/fraction-model");
14
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
15
+ var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
16
+ var _styles = require("@mui/material/styles");
34
17
  var _cardBar = _interopRequireDefault(require("./card-bar"));
35
-
36
18
  var _modelOptions = _interopRequireDefault(require("./model-options"));
37
-
38
- var _fractionModel = require("@pie-element/fraction-model");
39
-
40
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
41
-
42
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
43
-
44
- 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; }
45
-
46
- 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; }
47
-
48
- 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); }; }
49
-
50
- 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; } }
51
-
52
- var styles = function styles(theme) {
53
- return {
54
- label: {
55
- marginBottom: theme.spacing.unit * 4
56
- },
57
- tooltip: {
58
- fontSize: theme.typography.fontSize - 2,
59
- whiteSpace: 'pre',
60
- maxWidth: '500px'
61
- },
62
- errorText: {
63
- fontSize: theme.typography.fontSize - 2,
64
- color: theme.palette.error.main,
65
- paddingTop: theme.spacing.unit
66
- },
67
- flexRow: {
68
- display: 'flex',
69
- alignItems: 'center',
70
- gap: '10px'
71
- },
72
- errorMessage: {
73
- fontSize: theme.typography.fontSize - 2,
74
- color: theme.palette.error.main,
75
- marginTop: theme.spacing.unit
76
- },
77
- modelError: {
78
- border: "2px solid ".concat(theme.palette.error.main)
79
- }
80
- };
81
- };
82
-
83
- var Main = /*#__PURE__*/function (_React$Component) {
84
- (0, _inherits2["default"])(Main, _React$Component);
85
-
86
- var _super = _createSuper(Main);
87
-
88
- function Main(props) {
89
- var _this;
90
-
91
- (0, _classCallCheck2["default"])(this, Main);
92
- _this = _super.call(this, props);
93
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onCorrectAnswerChange", function (correctResponse) {
94
- var _this$props = _this.props,
95
- model = _this$props.model,
96
- onChange = _this$props.onChange;
19
+ const StyledFormSection = (0, _styles.styled)(_configUi.FormSection)(({
20
+ theme
21
+ }) => ({
22
+ marginBottom: theme.spacing(4)
23
+ }));
24
+ const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
25
+ theme
26
+ }) => ({
27
+ '& .MuiTooltip-tooltip': {
28
+ fontSize: theme.typography.fontSize - 2,
29
+ whiteSpace: 'pre',
30
+ maxWidth: '500px'
31
+ }
32
+ }));
33
+ const ErrorMessage = (0, _styles.styled)('div')(({
34
+ theme
35
+ }) => ({
36
+ fontSize: theme.typography.fontSize - 2,
37
+ color: theme.palette.error.main,
38
+ marginTop: theme.spacing(1)
39
+ }));
40
+ const ModelErrorContainer = (0, _styles.styled)('div')(({
41
+ theme,
42
+ hasError
43
+ }) => ({
44
+ ...(hasError && {
45
+ border: `2px solid ${theme.palette.error.main}`
46
+ })
47
+ }));
48
+ const Label = (0, _styles.styled)('label')(({
49
+ theme
50
+ }) => ({
51
+ marginBottom: theme.spacing(4)
52
+ }));
53
+ class Main extends _react.default.Component {
54
+ constructor(props) {
55
+ super(props);
56
+ /*
57
+ * Method to handle correct answer change
58
+ * @param {array} correctResponse - correct response
59
+ * */
60
+ (0, _defineProperty2.default)(this, "onCorrectAnswerChange", correctResponse => {
61
+ const {
62
+ model,
63
+ onChange
64
+ } = this.props;
97
65
  model.correctResponse = correctResponse;
98
- onChange(_objectSpread({}, model));
66
+ onChange({
67
+ ...model
68
+ });
99
69
  });
100
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onModelOptionsChange", function (oldModel, newModel, showDiag) {
101
- var onChange = _this.props.onChange;
102
-
70
+ /*
71
+ * Method to handle model options change
72
+ * @param {object} oldModel - old model
73
+ * @param {object} newModel - new model
74
+ * @param {boolean} showDiag - show dialog or not
75
+ * */
76
+ (0, _defineProperty2.default)(this, "onModelOptionsChange", (oldModel, newModel, showDiag) => {
77
+ const {
78
+ onChange
79
+ } = this.props;
103
80
  if (showDiag && oldModel.correctResponse.length > 0) {
104
- _this.setState({
81
+ this.setState({
105
82
  correctAnswerChangeDialog: {
106
83
  open: true,
107
84
  oldModel: oldModel,
@@ -110,204 +87,167 @@ var Main = /*#__PURE__*/function (_React$Component) {
110
87
  }
111
88
  });
112
89
  } else {
113
- onChange(_objectSpread({}, newModel));
90
+ onChange({
91
+ ...newModel
92
+ });
114
93
  }
115
94
  });
116
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "generateRandomKey", function () {
95
+ /*
96
+ * Method to generate random key
97
+ * */
98
+ (0, _defineProperty2.default)(this, "generateRandomKey", () => {
117
99
  return Math.floor(Math.random() * 10000);
118
100
  });
119
- _this.state = {
101
+ this.state = {
120
102
  correctAnswerChangeDialog: {
121
103
  open: false,
122
104
  text: ''
123
105
  }
124
106
  };
125
- return _this;
126
107
  }
127
- /*
128
- * Method to handle correct answer change
129
- * @param {array} correctResponse - correct response
130
- * */
131
-
132
-
133
- (0, _createClass2["default"])(Main, [{
134
- key: "render",
135
- value: function render() {
136
- var _this2 = this;
137
-
138
- var _this$props2 = this.props,
139
- classes = _this$props2.classes,
140
- model = _this$props2.model,
141
- _onChange = _this$props2.onChange,
142
- configuration = _this$props2.configuration,
143
- imageSupport = _this$props2.imageSupport,
144
- uploadSoundSupport = _this$props2.uploadSoundSupport;
145
-
146
- var _ref = configuration || {},
147
- _ref$baseInputConfigu = _ref.baseInputConfiguration,
148
- baseInputConfiguration = _ref$baseInputConfigu === void 0 ? {} : _ref$baseInputConfigu,
149
- _ref$contentDimension = _ref.contentDimensions,
150
- contentDimensions = _ref$contentDimension === void 0 ? {} : _ref$contentDimension,
151
- _ref$title = _ref.title,
152
- title = _ref$title === void 0 ? {} : _ref$title,
153
- _ref$prompt = _ref.prompt,
154
- prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
155
- _ref$modelOptions = _ref.modelOptions,
156
- modelOptions = _ref$modelOptions === void 0 ? {} : _ref$modelOptions,
157
- _ref$mathMlOptions = _ref.mathMlOptions,
158
- mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions;
159
-
160
- var _ref2 = model || {},
161
- _ref2$errors = _ref2.errors,
162
- errors = _ref2$errors === void 0 ? {} : _ref2$errors,
163
- extraCSSRules = _ref2.extraCSSRules,
164
- spellCheckEnabled = _ref2.spellCheckEnabled,
165
- toolbarEditorPosition = _ref2.toolbarEditorPosition;
166
-
167
- var correctAnswerChangeDialog = this.state.correctAnswerChangeDialog;
168
- var toolbarOpts = {
169
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
170
- };
171
-
172
- var getPluginProps = function getPluginProps() {
173
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
174
- return _objectSpread(_objectSpread({}, baseInputConfiguration), props);
175
- };
176
-
177
- var fractionModelChartKey = this.generateRandomKey();
178
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
179
- extraCSSRules: extraCSSRules,
180
- dimensions: contentDimensions,
181
- hideSettings: true
182
- }, /*#__PURE__*/_react["default"].createElement(_cardBar["default"], {
183
- header: "Set Up"
184
- }), /*#__PURE__*/_react["default"].createElement(_configUi.FormSection, {
185
- label: (title === null || title === void 0 ? void 0 : title.label) || 'Title',
186
- className: classes.label
187
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
188
- className: classes.title,
189
- markup: model.title || '',
190
- onChange: function onChange(title) {
191
- return _onChange({
192
- title: title
193
- });
194
- },
195
- toolbarOpts: toolbarOpts,
196
- activePlugins: ['bold', 'html', 'italic', 'underline', 'strikethrough', 'image', 'math', 'languageCharacters', 'responseArea'],
197
- pluginProps: getPluginProps(title === null || title === void 0 ? void 0 : title.inputConfiguration),
198
- spellCheck: spellCheckEnabled,
199
- uploadSoundSupport: uploadSoundSupport,
200
- languageCharactersProps: [{
201
- language: 'spanish'
202
- }, {
203
- language: 'special'
204
- }],
205
- mathMlOptions: mathMlOptions
206
- })), /*#__PURE__*/_react["default"].createElement(_configUi.FormSection, {
207
- label: (prompt === null || prompt === void 0 ? void 0 : prompt.label) || 'Question',
208
- className: classes.label
209
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
210
- markup: model.prompt || '',
211
- minHeight: 60,
212
- onChange: function onChange(prompt) {
213
- return _onChange({
214
- prompt: prompt
215
- });
216
- },
217
- toolbarOpts: toolbarOpts,
218
- pluginProps: getPluginProps(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration),
219
- spellCheck: spellCheckEnabled,
220
- uploadSoundSupport: uploadSoundSupport,
221
- imageSupport: imageSupport,
222
- languageCharactersProps: [{
223
- language: 'spanish'
224
- }, {
225
- language: 'special'
226
- }],
227
- mathMlOptions: mathMlOptions
228
- })), /*#__PURE__*/_react["default"].createElement(_configUi.FormSection, null, /*#__PURE__*/_react["default"].createElement(_modelOptions["default"], {
229
- model: model,
230
- onChange: this.onModelOptionsChange,
231
- modelOptions: modelOptions
232
- })), /*#__PURE__*/_react["default"].createElement(_configUi.FormSection, null, /*#__PURE__*/_react["default"].createElement(_cardBar["default"], {
233
- header: "Correct Answer",
234
- info: /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
235
- classes: {
236
- tooltip: classes.tooltip
237
- },
238
- disableFocusListener: true,
239
- disableTouchListener: true,
240
- placement: 'right',
241
- title: 'The correct answer should include no more than one partially-filled model'
242
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
243
- fontSize: 'small',
244
- color: 'primary',
245
- style: {
246
- marginLeft: '8px'
108
+ render() {
109
+ const {
110
+ model,
111
+ onChange,
112
+ configuration,
113
+ imageSupport,
114
+ uploadSoundSupport
115
+ } = this.props;
116
+ const {
117
+ baseInputConfiguration = {},
118
+ contentDimensions = {},
119
+ title = {},
120
+ prompt = {},
121
+ modelOptions = {},
122
+ mathMlOptions = {}
123
+ } = configuration || {};
124
+ const {
125
+ errors = {},
126
+ extraCSSRules,
127
+ spellCheckEnabled,
128
+ toolbarEditorPosition
129
+ } = model || {};
130
+ const {
131
+ correctAnswerChangeDialog
132
+ } = this.state;
133
+ const toolbarOpts = {
134
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
135
+ };
136
+ const getPluginProps = (props = {}) => ({
137
+ ...baseInputConfiguration,
138
+ ...props
139
+ });
140
+ const fractionModelChartKey = this.generateRandomKey();
141
+ return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
142
+ extraCSSRules: extraCSSRules,
143
+ dimensions: contentDimensions,
144
+ hideSettings: true
145
+ }, /*#__PURE__*/_react.default.createElement(_cardBar.default, {
146
+ header: "Set Up"
147
+ }), /*#__PURE__*/_react.default.createElement(StyledFormSection, {
148
+ label: title?.label || 'Title'
149
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
150
+ markup: model.title || '',
151
+ onChange: title => onChange({
152
+ title
153
+ }),
154
+ toolbarOpts: toolbarOpts,
155
+ activePlugins: ['bold', 'html', 'italic', 'underline', 'strikethrough', 'image', 'math', 'languageCharacters', 'responseArea'],
156
+ pluginProps: getPluginProps(title?.inputConfiguration),
157
+ spellCheck: spellCheckEnabled,
158
+ uploadSoundSupport: uploadSoundSupport,
159
+ languageCharactersProps: [{
160
+ language: 'spanish'
161
+ }, {
162
+ language: 'special'
163
+ }],
164
+ mathMlOptions: mathMlOptions
165
+ })), /*#__PURE__*/_react.default.createElement(StyledFormSection, {
166
+ label: prompt?.label || 'Question'
167
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
168
+ markup: model.prompt || '',
169
+ minHeight: 60,
170
+ onChange: prompt => onChange({
171
+ prompt
172
+ }),
173
+ toolbarOpts: toolbarOpts,
174
+ pluginProps: getPluginProps(prompt?.inputConfiguration),
175
+ spellCheck: spellCheckEnabled,
176
+ uploadSoundSupport: uploadSoundSupport,
177
+ imageSupport: imageSupport,
178
+ languageCharactersProps: [{
179
+ language: 'spanish'
180
+ }, {
181
+ language: 'special'
182
+ }],
183
+ mathMlOptions: mathMlOptions
184
+ })), /*#__PURE__*/_react.default.createElement(_configUi.FormSection, null, /*#__PURE__*/_react.default.createElement(_modelOptions.default, {
185
+ model: model,
186
+ onChange: this.onModelOptionsChange,
187
+ modelOptions: modelOptions
188
+ })), /*#__PURE__*/_react.default.createElement(_configUi.FormSection, null, " ", /*#__PURE__*/_react.default.createElement(_cardBar.default, {
189
+ header: "Correct Answer",
190
+ info: /*#__PURE__*/_react.default.createElement(StyledTooltip, {
191
+ disableFocusListener: true,
192
+ disableTouchListener: true,
193
+ placement: 'right',
194
+ title: 'The correct answer should include no more than one partially-filled model'
195
+ }, /*#__PURE__*/_react.default.createElement(_Info.default, {
196
+ fontSize: 'small',
197
+ color: 'primary',
198
+ style: {
199
+ marginLeft: '8px'
200
+ }
201
+ }))
202
+ }), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(Label, null, "Click/touch the number of parts to represent the correct fraction model"), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(ModelErrorContainer, {
203
+ hasError: !!errors.correctResponse
204
+ }, /*#__PURE__*/_react.default.createElement(_fractionModel.FractionModelChart, {
205
+ key: fractionModelChartKey,
206
+ value: model.correctResponse,
207
+ modelType: model.modelTypeSelected,
208
+ noOfModels: model.maxModelSelected,
209
+ partsPerModel: model.partsPerModel,
210
+ showLabel: model.showGraphLabels,
211
+ onChange: this.onCorrectAnswerChange
212
+ })), errors.correctResponse && /*#__PURE__*/_react.default.createElement(ErrorMessage, null, errors.correctResponse)), /*#__PURE__*/_react.default.createElement(_configUi.AlertDialog, {
213
+ open: correctAnswerChangeDialog.open,
214
+ title: "Warning",
215
+ text: correctAnswerChangeDialog.text,
216
+ onConfirm: () => {
217
+ let newModel = this.state.correctAnswerChangeDialog.newModel;
218
+ newModel.correctResponse = [];
219
+ onChange({
220
+ ...newModel
221
+ });
222
+ this.setState({
223
+ correctAnswerChangeDialog: {
224
+ open: false
247
225
  }
248
- }))
249
- }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("label", {
250
- className: classes.label
251
- }, "Click/touch the number of parts to represent the correct fraction model"), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("div", {
252
- className: errors.correctResponse && classes.modelError
253
- }, /*#__PURE__*/_react["default"].createElement(_fractionModel.FractionModelChart, {
254
- key: fractionModelChartKey,
255
- value: model.correctResponse,
256
- modelType: model.modelTypeSelected,
257
- noOfModels: model.maxModelSelected,
258
- partsPerModel: model.partsPerModel,
259
- showLabel: model.showGraphLabels,
260
- onChange: this.onCorrectAnswerChange
261
- })), errors.correctResponse && /*#__PURE__*/_react["default"].createElement("div", {
262
- className: classes.errorMessage
263
- }, errors.correctResponse)), /*#__PURE__*/_react["default"].createElement(_configUi.AlertDialog, {
264
- open: correctAnswerChangeDialog.open,
265
- title: "Warning",
266
- text: correctAnswerChangeDialog.text,
267
- onConfirm: function onConfirm() {
268
- var newModel = _this2.state.correctAnswerChangeDialog.newModel;
269
- newModel.correctResponse = [];
270
-
271
- _onChange(_objectSpread({}, newModel));
272
-
273
- _this2.setState({
274
- correctAnswerChangeDialog: {
275
- open: false
276
- }
277
- });
278
- },
279
- onClose: function onClose() {
280
- var oldModel = _this2.state.correctAnswerChangeDialog.oldModel;
281
-
282
- _onChange(_objectSpread({}, oldModel));
283
-
284
- _this2.setState({
285
- correctAnswerChangeDialog: {
286
- open: false
287
- }
288
- });
289
- },
290
- onConfirmText: 'OK',
291
- onCloseText: 'Cancel'
292
- }));
293
- }
294
- }]);
295
- return Main;
296
- }(_react["default"].Component);
297
-
226
+ });
227
+ },
228
+ onClose: () => {
229
+ const oldModel = this.state.correctAnswerChangeDialog.oldModel;
230
+ onChange({
231
+ ...oldModel
232
+ });
233
+ this.setState({
234
+ correctAnswerChangeDialog: {
235
+ open: false
236
+ }
237
+ });
238
+ },
239
+ onConfirmText: 'OK',
240
+ onCloseText: 'Cancel'
241
+ }));
242
+ }
243
+ }
298
244
  exports.Main = Main;
299
- (0, _defineProperty2["default"])(Main, "propTypes", {
300
- classes: _propTypes["default"].object.isRequired,
301
- model: _propTypes["default"].object.isRequired,
302
- configuration: _propTypes["default"].object.isRequired,
303
- onConfigurationChanged: _propTypes["default"].func.isRequired,
304
- onChange: _propTypes["default"].func.isRequired,
305
- uploadSoundSupport: _propTypes["default"].object.isRequired
245
+ (0, _defineProperty2.default)(Main, "propTypes", {
246
+ model: _propTypes.default.object.isRequired,
247
+ configuration: _propTypes.default.object.isRequired,
248
+ onConfigurationChanged: _propTypes.default.func.isRequired,
249
+ onChange: _propTypes.default.func.isRequired,
250
+ uploadSoundSupport: _propTypes.default.object.isRequired
306
251
  });
307
-
308
- var _default = (0, _styles.withStyles)(styles, {
309
- name: 'Main'
310
- })(Main);
311
-
312
- exports["default"] = _default;
252
+ var _default = exports.default = Main;
313
253
  //# sourceMappingURL=main.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["styles","theme","label","marginBottom","spacing","unit","tooltip","fontSize","typography","whiteSpace","maxWidth","errorText","color","palette","error","main","paddingTop","flexRow","display","alignItems","gap","errorMessage","marginTop","modelError","border","Main","props","correctResponse","model","onChange","oldModel","newModel","showDiag","length","setState","correctAnswerChangeDialog","open","text","Math","floor","random","state","classes","configuration","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","title","prompt","modelOptions","mathMlOptions","errors","extraCSSRules","spellCheckEnabled","toolbarEditorPosition","toolbarOpts","position","getPluginProps","fractionModelChartKey","generateRandomKey","inputConfiguration","language","onModelOptionsChange","marginLeft","modelTypeSelected","maxModelSelected","partsPerModel","showGraphLabels","onCorrectAnswerChange","React","Component","PropTypes","object","isRequired","onConfigurationChanged","func","name"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,KAAK,EAAE;AACLC,MAAAA,YAAY,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB;AAD9B,KADkB;AAIzBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,QAAQ,EAAEN,KAAK,CAACO,UAAN,CAAiBD,QAAjB,GAA4B,CAD/B;AAEPE,MAAAA,UAAU,EAAE,KAFL;AAGPC,MAAAA,QAAQ,EAAE;AAHH,KAJgB;AASzBC,IAAAA,SAAS,EAAE;AACTJ,MAAAA,QAAQ,EAAEN,KAAK,CAACO,UAAN,CAAiBD,QAAjB,GAA4B,CAD7B;AAETK,MAAAA,KAAK,EAAEX,KAAK,CAACY,OAAN,CAAcC,KAAd,CAAoBC,IAFlB;AAGTC,MAAAA,UAAU,EAAEf,KAAK,CAACG,OAAN,CAAcC;AAHjB,KATc;AAczBY,IAAAA,OAAO,EAAE;AACPC,MAAAA,OAAO,EAAE,MADF;AAEPC,MAAAA,UAAU,EAAE,QAFL;AAGPC,MAAAA,GAAG,EAAE;AAHE,KAdgB;AAmBzBC,IAAAA,YAAY,EAAE;AACZd,MAAAA,QAAQ,EAAEN,KAAK,CAACO,UAAN,CAAiBD,QAAjB,GAA4B,CAD1B;A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Ad;AAGD,SAXH;AAYE,QAAA,OAAO,EAAE,mBAAM;AACb,cAAMN,QAAQ,GAAG,MAAI,CAACW,KAAL,CAAWN,yBAAX,CAAqCL,QAAtD;;AACAD,UAAAA,SAAQ,mBAAMC,QAAN,EAAR;;AACA,UAAA,MAAI,CAACI,QAAL,CAAc;AAAEC,YAAAA,yBAAyB,EAAE;AAAEC,cAAAA,IAAI,EAAE;AAAR;AAA7B,WAAd;AACD,SAhBH;AAiBE,QAAA,aAAa,EAAE,IAjBjB;AAkBE,QAAA,WAAW,EAAE;AAlBf,QApFF,CADF;AA2GD;;;EAjMuBkC,kBAAMC,S;;;iCAAnB9C,I,eACQ;AACjBiB,EAAAA,OAAO,EAAE8B,sBAAUC,MAAV,CAAiBC,UADT;AAEjB9C,EAAAA,KAAK,EAAE4C,sBAAUC,MAAV,CAAiBC,UAFP;AAGjB/B,EAAAA,aAAa,EAAE6B,sBAAUC,MAAV,CAAiBC,UAHf;AAIjBC,EAAAA,sBAAsB,EAAEH,sBAAUI,IAAV,CAAeF,UAJtB;AAKjB7C,EAAAA,QAAQ,EAAE2C,sBAAUI,IAAV,CAAeF,UALR;AAMjB7B,EAAAA,kBAAkB,EAAE2B,sBAAUC,MAAV,CAAiBC;AANpB,C;;eAmMN,wBAAW1E,MAAX,EAAmB;AAAE6E,EAAAA,IAAI,EAAE;AAAR,CAAnB,EAAqCpD,IAArC,C","sourcesContent":["import React from 'react';\nimport { FormSection, layout, AlertDialog } from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport CardBar from './card-bar';\nimport ModelOptions from './model-options';\nimport { FractionModelChart } from '@pie-element/fraction-model';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport Info from '@material-ui/icons/Info';\n\nconst styles = (theme) => ({\n label: {\n marginBottom: theme.spacing.unit * 4,\n },\n tooltip: {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing.unit,\n },\n flexRow: {\n display: 'flex',\n alignItems: 'center',\n gap: '10px',\n },\n errorMessage: {\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n marginTop: theme.spacing.unit,\n },\n modelError: {\n border: `2px solid ${theme.palette.error.main}`,\n },\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n uploadSoundSupport: PropTypes.object.isRequired,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n correctAnswerChangeDialog: {\n open: false,\n text: '',\n },\n };\n }\n\n /*\n * Method to handle correct answer change\n * @param {array} correctResponse - correct response\n * */\n onCorrectAnswerChange = (correctResponse) => {\n const { model, onChange } = this.props;\n model.correctResponse = correctResponse;\n onChange({ ...model });\n };\n\n /*\n * Method to handle model options change\n * @param {object} oldModel - old model\n * @param {object} newModel - new model\n * @param {boolean} showDiag - show dialog or not\n * */\n onModelOptionsChange = (oldModel, newModel, showDiag) => {\n const { onChange } = this.props;\n if (showDiag && oldModel.correctResponse.length > 0) {\n this.setState({\n correctAnswerChangeDialog: {\n open: true,\n oldModel: oldModel,\n newModel: newModel,\n text: 'Changing either the Number of Models or Parts per Model will remove added correct answer. Are you sure you want to continue?',\n },\n });\n } else {\n onChange({ ...newModel });\n }\n };\n\n /*\n * Method to generate random key\n * */\n generateRandomKey = () => {\n return Math.floor(Math.random() * 10000);\n };\n\n render() {\n const { classes, model, onChange, configuration, imageSupport, uploadSoundSupport } = this.props;\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n title = {},\n prompt = {},\n modelOptions = {},\n mathMlOptions = {},\n } = configuration || {};\n\n const { errors = {}, extraCSSRules, spellCheckEnabled, toolbarEditorPosition } = model || {};\n\n const { correctAnswerChangeDialog } = this.state;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n\n const fractionModelChartKey = this.generateRandomKey();\n\n return (\n <layout.ConfigLayout extraCSSRules={extraCSSRules} dimensions={contentDimensions} hideSettings={true}>\n <CardBar header=\"Set Up\"></CardBar>\n\n <FormSection label={title?.label || 'Title'} className={classes.label}>\n <EditableHtml\n className={classes.title}\n markup={model.title || ''}\n onChange={(title) => onChange({ title })}\n toolbarOpts={toolbarOpts}\n activePlugins={[\n 'bold',\n 'html',\n 'italic',\n 'underline',\n 'strikethrough',\n 'image',\n 'math',\n 'languageCharacters',\n 'responseArea',\n ]}\n pluginProps={getPluginProps(title?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </FormSection>\n\n <FormSection label={prompt?.label || 'Question'} className={classes.label}>\n <EditableHtml\n markup={model.prompt || ''}\n minHeight={60}\n onChange={(prompt) => onChange({ prompt })}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n imageSupport={imageSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </FormSection>\n\n <FormSection>\n <ModelOptions model={model} onChange={this.onModelOptionsChange} modelOptions={modelOptions} />\n </FormSection>\n\n <FormSection>\n <CardBar\n header=\"Correct Answer\"\n info={\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={'The correct answer should include no more than one partially-filled model'}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />\n </Tooltip>\n }\n ></CardBar>\n\n <br />\n <label className={classes.label}>\n Click/touch the number of parts to represent the correct fraction model\n </label>\n <br />\n\n <div className={errors.correctResponse && classes.modelError}>\n <FractionModelChart\n key={fractionModelChartKey}\n value={model.correctResponse}\n modelType={model.modelTypeSelected}\n noOfModels={model.maxModelSelected}\n partsPerModel={model.partsPerModel}\n showLabel={model.showGraphLabels}\n onChange={this.onCorrectAnswerChange}\n ></FractionModelChart>\n </div>\n\n {errors.correctResponse && <div className={classes.errorMessage}>{errors.correctResponse}</div>}\n </FormSection>\n\n <AlertDialog\n open={correctAnswerChangeDialog.open}\n title=\"Warning\"\n text={correctAnswerChangeDialog.text}\n onConfirm={() => {\n let newModel = this.state.correctAnswerChangeDialog.newModel;\n newModel.correctResponse = [];\n onChange({ ...newModel });\n this.setState({\n correctAnswerChangeDialog: { open: false },\n });\n }}\n onClose={() => {\n const oldModel = this.state.correctAnswerChangeDialog.oldModel;\n onChange({ ...oldModel });\n this.setState({ correctAnswerChangeDialog: { open: false } });\n }}\n onConfirmText={'OK'}\n onCloseText={'Cancel'}\n />\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default withStyles(styles, { name: 'Main' })(Main);\n"],"file":"main.js"}
1
+ {"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_configUi","_editableHtml","_fractionModel","_Tooltip","_Info","_styles","_cardBar","_modelOptions","StyledFormSection","styled","FormSection","theme","marginBottom","spacing","StyledTooltip","Tooltip","fontSize","typography","whiteSpace","maxWidth","ErrorMessage","color","palette","error","main","marginTop","ModelErrorContainer","hasError","border","Label","Main","React","Component","constructor","props","_defineProperty2","default","correctResponse","model","onChange","oldModel","newModel","showDiag","length","setState","correctAnswerChangeDialog","open","text","Math","floor","random","state","render","configuration","imageSupport","uploadSoundSupport","baseInputConfiguration","contentDimensions","title","prompt","modelOptions","mathMlOptions","errors","extraCSSRules","spellCheckEnabled","toolbarEditorPosition","toolbarOpts","position","getPluginProps","fractionModelChartKey","generateRandomKey","createElement","layout","ConfigLayout","dimensions","hideSettings","header","label","markup","activePlugins","pluginProps","inputConfiguration","spellCheck","languageCharactersProps","language","minHeight","onModelOptionsChange","info","disableFocusListener","disableTouchListener","placement","style","marginLeft","FractionModelChart","key","value","modelType","modelTypeSelected","noOfModels","maxModelSelected","partsPerModel","showLabel","showGraphLabels","onCorrectAnswerChange","AlertDialog","onConfirm","onClose","onConfirmText","onCloseText","exports","PropTypes","object","isRequired","onConfigurationChanged","func","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { FormSection, layout, AlertDialog } from '@pie-lib/config-ui';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { FractionModelChart } from '@pie-element/fraction-model';\nimport Tooltip from '@mui/material/Tooltip';\nimport Info from '@mui/icons-material/Info';\nimport { styled } from '@mui/material/styles';\n\nimport CardBar from './card-bar';\nimport ModelOptions from './model-options';\n\nconst StyledFormSection = styled(FormSection)(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nconst StyledTooltip = styled(Tooltip)(({ theme }) => ({\n '& .MuiTooltip-tooltip': {\n fontSize: theme.typography.fontSize - 2,\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n}));\n\nconst ErrorMessage = styled('div')(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n marginTop: theme.spacing(1),\n}));\n\nconst ModelErrorContainer = styled('div')(({ theme, hasError }) => ({\n ...(hasError && {\n border: `2px solid ${theme.palette.error.main}`,\n }),\n}));\n\nconst Label = styled('label')(({ theme }) => ({\n marginBottom: theme.spacing(4),\n}));\n\nexport class Main extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n onChange: PropTypes.func.isRequired,\n uploadSoundSupport: PropTypes.object.isRequired,\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n correctAnswerChangeDialog: {\n open: false,\n text: '',\n },\n };\n }\n\n /*\n * Method to handle correct answer change\n * @param {array} correctResponse - correct response\n * */\n onCorrectAnswerChange = (correctResponse) => {\n const { model, onChange } = this.props;\n model.correctResponse = correctResponse;\n onChange({ ...model });\n };\n\n /*\n * Method to handle model options change\n * @param {object} oldModel - old model\n * @param {object} newModel - new model\n * @param {boolean} showDiag - show dialog or not\n * */\n onModelOptionsChange = (oldModel, newModel, showDiag) => {\n const { onChange } = this.props;\n if (showDiag && oldModel.correctResponse.length > 0) {\n this.setState({\n correctAnswerChangeDialog: {\n open: true,\n oldModel: oldModel,\n newModel: newModel,\n text: 'Changing either the Number of Models or Parts per Model will remove added correct answer. Are you sure you want to continue?',\n },\n });\n } else {\n onChange({ ...newModel });\n }\n };\n\n /*\n * Method to generate random key\n * */\n generateRandomKey = () => {\n return Math.floor(Math.random() * 10000);\n };\n\n render() {\n const { model, onChange, configuration, imageSupport, uploadSoundSupport } = this.props;\n const {\n baseInputConfiguration = {},\n contentDimensions = {},\n title = {},\n prompt = {},\n modelOptions = {},\n mathMlOptions = {},\n } = configuration || {};\n\n const { errors = {}, extraCSSRules, spellCheckEnabled, toolbarEditorPosition } = model || {};\n\n const { correctAnswerChangeDialog } = this.state;\n\n const toolbarOpts = {\n position: toolbarEditorPosition === 'top' ? 'top' : 'bottom',\n };\n\n const getPluginProps = (props = {}) => ({\n ...baseInputConfiguration,\n ...props,\n });\n\n const fractionModelChartKey = this.generateRandomKey();\n\n return (\n <layout.ConfigLayout extraCSSRules={extraCSSRules} dimensions={contentDimensions} hideSettings={true}>\n <CardBar header=\"Set Up\"></CardBar>\n\n <StyledFormSection label={title?.label || 'Title'}>\n <EditableHtml\n markup={model.title || ''}\n onChange={(title) => onChange({ title })}\n toolbarOpts={toolbarOpts}\n activePlugins={[\n 'bold',\n 'html',\n 'italic',\n 'underline',\n 'strikethrough',\n 'image',\n 'math',\n 'languageCharacters',\n 'responseArea',\n ]}\n pluginProps={getPluginProps(title?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </StyledFormSection>\n\n <StyledFormSection label={prompt?.label || 'Question'}>\n <EditableHtml\n markup={model.prompt || ''}\n minHeight={60}\n onChange={(prompt) => onChange({ prompt })}\n toolbarOpts={toolbarOpts}\n pluginProps={getPluginProps(prompt?.inputConfiguration)}\n spellCheck={spellCheckEnabled}\n uploadSoundSupport={uploadSoundSupport}\n imageSupport={imageSupport}\n languageCharactersProps={[{ language: 'spanish' }, { language: 'special' }]}\n mathMlOptions={mathMlOptions}\n />\n </StyledFormSection>\n\n <FormSection>\n <ModelOptions model={model} onChange={this.onModelOptionsChange} modelOptions={modelOptions} />\n </FormSection>\n\n <FormSection> <CardBar\n header=\"Correct Answer\"\n info={\n <StyledTooltip\n disableFocusListener\n disableTouchListener\n placement={'right'}\n title={'The correct answer should include no more than one partially-filled model'}\n >\n <Info fontSize={'small'} color={'primary'} style={{ marginLeft: '8px' }} />\n </StyledTooltip>\n }\n ></CardBar>\n\n <br />\n <Label>\n Click/touch the number of parts to represent the correct fraction model\n </Label>\n <br />\n\n <ModelErrorContainer hasError={!!errors.correctResponse}>\n <FractionModelChart\n key={fractionModelChartKey}\n value={model.correctResponse}\n modelType={model.modelTypeSelected}\n noOfModels={model.maxModelSelected}\n partsPerModel={model.partsPerModel}\n showLabel={model.showGraphLabels}\n onChange={this.onCorrectAnswerChange}\n ></FractionModelChart>\n </ModelErrorContainer>\n\n {errors.correctResponse && <ErrorMessage>{errors.correctResponse}</ErrorMessage>}\n </FormSection>\n\n <AlertDialog\n open={correctAnswerChangeDialog.open}\n title=\"Warning\"\n text={correctAnswerChangeDialog.text}\n onConfirm={() => {\n let newModel = this.state.correctAnswerChangeDialog.newModel;\n newModel.correctResponse = [];\n onChange({ ...newModel });\n this.setState({\n correctAnswerChangeDialog: { open: false },\n });\n }}\n onClose={() => {\n const oldModel = this.state.correctAnswerChangeDialog.oldModel;\n onChange({ ...oldModel });\n this.setState({ correctAnswerChangeDialog: { open: false } });\n }}\n onConfirmText={'OK'}\n onCloseText={'Cancel'}\n />\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,KAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAEA,IAAAQ,QAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,aAAA,GAAAV,sBAAA,CAAAC,OAAA;AAEA,MAAMU,iBAAiB,GAAG,IAAAC,cAAM,EAACC,qBAAW,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EAC5DC,YAAY,EAAED,KAAK,CAACE,OAAO,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,MAAMC,aAAa,GAAG,IAAAL,cAAM,EAACM,gBAAO,CAAC,CAAC,CAAC;EAAEJ;AAAM,CAAC,MAAM;EACpD,uBAAuB,EAAE;IACvBK,QAAQ,EAAEL,KAAK,CAACM,UAAU,CAACD,QAAQ,GAAG,CAAC;IACvCE,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC,CAAC;AAEH,MAAMC,YAAY,GAAG,IAAAX,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEE;AAAM,CAAC,MAAM;EACjDK,QAAQ,EAAEL,KAAK,CAACM,UAAU,CAACD,QAAQ,GAAG,CAAC;EACvCK,KAAK,EAAEV,KAAK,CAACW,OAAO,CAACC,KAAK,CAACC,IAAI;EAC/BC,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