@pie-element/graphing-solution-set 4.3.4-next.3 → 5.0.0-beta.1

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,158 +1,138 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof3 = require("@babel/runtime/helpers/typeof");
6
-
7
4
  Object.defineProperty(exports, "__esModule", {
8
5
  value: true
9
6
  });
10
- exports["default"] = exports.GraphingConfig = void 0;
11
-
12
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
21
-
22
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
23
-
24
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
25
-
7
+ exports.default = exports.GraphingConfig = void 0;
26
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
27
-
28
9
  var React = _interopRequireWildcard(require("react"));
29
-
30
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
31
-
32
11
  var _graphingSolutionSet = require("@pie-lib/graphing-solution-set");
33
-
34
12
  var _configUi = require("@pie-lib/config-ui");
35
-
36
- var _core = require("@material-ui/core");
37
-
38
- var _styles = require("@material-ui/core/styles");
39
-
13
+ var _material = require("@mui/material");
14
+ var _styles = require("@mui/material/styles");
40
15
  var _utils = require("./utils");
41
-
42
16
  var _lodash = require("lodash");
43
-
44
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
-
46
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
-
48
- 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; }
49
-
50
- 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; }
51
-
52
- 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); }; }
53
-
54
- 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; } }
55
-
56
- var styles = function styles(theme) {
57
- return {
58
- container: {
59
- display: 'flex',
60
- flexWrap: 'wrap',
61
- marginBottom: theme.spacing.unit * 2.5
62
- },
63
- gridConfigWrapper: {
64
- display: 'flex',
65
- flexDirection: 'column',
66
- marginRight: theme.spacing.unit * 3,
67
- marginBottom: theme.spacing.unit * 2.5
68
- },
69
- graphConfig: {
70
- display: 'flex',
71
- flexDirection: 'column'
72
- },
73
- subtitleText: {
74
- marginTop: theme.spacing.unit * 1.5,
75
- marginBottom: theme.spacing.unit
76
- },
77
- gridConfig: {
78
- display: 'flex',
79
- flexWrap: 'wrap',
80
- alignItems: 'center',
81
- width: '100%',
82
- marginBottom: theme.spacing.unit * 2.5
83
- },
84
- gridConfigLabel: {
85
- padding: "0 ".concat(theme.spacing.unit, "px")
86
- },
87
- gridConfigSelect: {
88
- flex: '1'
89
- }
90
- };
91
- };
92
-
93
- var GraphingConfig = /*#__PURE__*/function (_React$Component) {
94
- (0, _inherits2["default"])(GraphingConfig, _React$Component);
95
-
96
- var _super = _createSuper(GraphingConfig);
97
-
98
- function GraphingConfig(props) {
99
- var _this;
100
-
101
- (0, _classCallCheck2["default"])(this, GraphingConfig);
102
- _this = _super.call(this, props);
103
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeLabels", function (labels) {
104
- var _this$props = _this.props,
105
- model = _this$props.model,
106
- onChange = _this$props.onChange;
107
- onChange(_objectSpread(_objectSpread({}, model), {}, {
108
- labels: labels
109
- }));
17
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
18
+ const Container = (0, _styles.styled)('div')(({
19
+ theme
20
+ }) => ({
21
+ display: 'flex',
22
+ flexWrap: 'wrap',
23
+ marginBottom: theme.spacing(2.5)
24
+ }));
25
+ const GridConfigWrapper = (0, _styles.styled)('div')(({
26
+ theme
27
+ }) => ({
28
+ display: 'flex',
29
+ flexDirection: 'column',
30
+ marginRight: theme.spacing(3),
31
+ marginBottom: theme.spacing(2.5)
32
+ }));
33
+ const GraphConfig = (0, _styles.styled)('div')({
34
+ display: 'flex',
35
+ flexDirection: 'column'
36
+ });
37
+ const SubtitleText = (0, _styles.styled)(_material.Typography)(({
38
+ theme
39
+ }) => ({
40
+ marginTop: theme.spacing(1.5),
41
+ marginBottom: theme.spacing(1)
42
+ }));
43
+ const GridConfig = (0, _styles.styled)('div')(({
44
+ theme
45
+ }) => ({
46
+ display: 'flex',
47
+ flexWrap: 'wrap',
48
+ alignItems: 'center',
49
+ width: '100%',
50
+ marginBottom: theme.spacing(2.5)
51
+ }));
52
+ const GridConfigLabel = (0, _styles.styled)(_material.Typography)(({
53
+ theme
54
+ }) => ({
55
+ padding: `0 ${theme.spacing(1)}`
56
+ }));
57
+ const GridConfigSelect = (0, _styles.styled)(_material.Select)({
58
+ flex: '1'
59
+ });
60
+ class GraphingConfig extends React.Component {
61
+ constructor(props) {
62
+ super(props);
63
+ /*
64
+ * Function to change labels
65
+ * @param {object} labels - labels object
66
+ * */
67
+ (0, _defineProperty2.default)(this, "changeLabels", labels => {
68
+ const {
69
+ model,
70
+ onChange
71
+ } = this.props;
72
+ onChange({
73
+ ...model,
74
+ labels
75
+ });
110
76
  });
111
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeTitle", function (title) {
112
- var _this$props2 = _this.props,
113
- model = _this$props2.model,
114
- onChange = _this$props2.onChange;
115
- onChange(_objectSpread(_objectSpread({}, model), {}, {
116
- title: title
117
- }));
77
+ /*
78
+ * Function to change title
79
+ * @param {string} title - title string
80
+ * */
81
+ (0, _defineProperty2.default)(this, "changeTitle", title => {
82
+ const {
83
+ model,
84
+ onChange
85
+ } = this.props;
86
+ onChange({
87
+ ...model,
88
+ title
89
+ });
118
90
  });
119
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onConfigChange", function (config, newSelectedGrid) {
120
- var _this$props3 = _this.props,
121
- model = _this$props3.model,
122
- onChange = _this$props3.onChange;
123
- var _model$defaultGridCon = model.defaultGridConfiguration,
124
- oldSelectedGrid = _model$defaultGridCon === void 0 ? 0 : _model$defaultGridCon;
125
- var _this$state = _this.state,
126
- oldGridValues = _this$state.gridValues,
127
- oldLabelValues = _this$state.labelValues,
128
- oldDomain = _this$state.domain,
129
- oldRange = _this$state.range;
130
-
131
- var updatedModel = _objectSpread(_objectSpread({}, model), config);
132
-
133
- var answers = updatedModel.answers,
134
- domain = updatedModel.domain,
135
- _updatedModel$include = updatedModel.includeAxes,
136
- includeAxes = _updatedModel$include === void 0 ? true : _updatedModel$include,
137
- graph = updatedModel.graph,
138
- range = updatedModel.range,
139
- standardGrid = updatedModel.standardGrid;
140
- var gridValues = {
91
+ /*
92
+ * Function to change grid configuration
93
+ * @param {object} config - grid configuration object
94
+ * @param {number} newSelectedGrid - new selected grid
95
+ * */
96
+ (0, _defineProperty2.default)(this, "onConfigChange", (config, newSelectedGrid) => {
97
+ const {
98
+ model,
99
+ onChange
100
+ } = this.props;
101
+ const {
102
+ defaultGridConfiguration: oldSelectedGrid = 0
103
+ } = model;
104
+ const {
105
+ gridValues: oldGridValues,
106
+ labelValues: oldLabelValues,
107
+ domain: oldDomain,
108
+ range: oldRange
109
+ } = this.state;
110
+ const updatedModel = {
111
+ ...model,
112
+ ...config
113
+ };
114
+ const {
115
+ answers,
116
+ domain,
117
+ includeAxes = true,
118
+ graph,
119
+ range,
120
+ standardGrid
121
+ } = updatedModel;
122
+ const gridValues = {
141
123
  domain: [],
142
124
  range: []
143
125
  };
144
- var labelValues = {
126
+ const labelValues = {
145
127
  domain: [],
146
128
  range: []
147
129
  };
148
- var selectedGrid = newSelectedGrid >= 0 ? newSelectedGrid : oldSelectedGrid;
149
-
130
+ const selectedGrid = newSelectedGrid >= 0 ? newSelectedGrid : oldSelectedGrid;
150
131
  if (includeAxes) {
151
- var domainConstraints = (0, _utils.applyConstraints)(domain, graph.width, oldGridValues.domain, oldLabelValues.domain);
132
+ const domainConstraints = (0, _utils.applyConstraints)(domain, graph.width, oldGridValues.domain, oldLabelValues.domain);
152
133
  gridValues.domain = domainConstraints.gridValues || [];
153
134
  labelValues.domain = domainConstraints.labelValues || [];
154
135
  }
155
-
156
136
  if (standardGrid) {
157
137
  gridValues.range = gridValues.domain;
158
138
  labelValues.range = labelValues.domain;
@@ -160,283 +140,269 @@ var GraphingConfig = /*#__PURE__*/function (_React$Component) {
160
140
  range.labelStep = domain.labelStep;
161
141
  } else {
162
142
  if (includeAxes) {
163
- var rangeConstraints = (0, _utils.applyConstraints)(range, graph.height, oldGridValues.range, oldLabelValues.range);
143
+ const rangeConstraints = (0, _utils.applyConstraints)(range, graph.height, oldGridValues.range, oldLabelValues.range);
164
144
  gridValues.range = rangeConstraints.gridValues || [];
165
145
  labelValues.range = rangeConstraints.labelValues || [];
166
146
  }
167
147
  }
168
-
169
- var filteredAnswers = (0, _lodash.cloneDeep)(answers);
170
- filteredAnswers.correctAnswer.marks = answers.correctAnswer.marks.filter(function (mark) {
171
- return mark.type !== 'polygon';
172
- });
173
- var plotableAnswers = (0, _utils.filterPlotableMarks)(domain, range, filteredAnswers);
174
-
148
+ const filteredAnswers = (0, _lodash.cloneDeep)(answers);
149
+ filteredAnswers.correctAnswer.marks = answers.correctAnswer.marks.filter(mark => mark.type !== 'polygon');
150
+ const plotableAnswers = (0, _utils.filterPlotableMarks)(domain, range, filteredAnswers);
175
151
  if (!(0, _lodash.isEqual)(filteredAnswers, plotableAnswers)) {
176
- _this.setState({
152
+ this.setState({
177
153
  dialog: {
178
154
  isOpened: true,
179
- onClose: function onClose() {
180
- return _this.setState({
181
- dialog: {
182
- isOpened: false
183
- }
184
- }, onChange(_objectSpread(_objectSpread({}, model), {}, {
185
- domain: oldDomain,
186
- range: oldRange
187
- })));
188
- },
189
- onConfirm: function onConfirm() {
155
+ onClose: () => this.setState({
156
+ dialog: {
157
+ isOpened: false
158
+ }
159
+ }, onChange({
160
+ ...model,
161
+ domain: oldDomain,
162
+ range: oldRange
163
+ })),
164
+ onConfirm: () => {
190
165
  updatedModel.gssLineData.sections = [];
191
166
  updatedModel.gssLineData.selectedTool = 'lineA';
192
-
193
- _this.setState({
194
- gridValues: gridValues,
195
- labelValues: labelValues,
167
+ this.setState({
168
+ gridValues,
169
+ labelValues,
196
170
  dialog: {
197
171
  isOpened: false
198
172
  },
199
- domain: _objectSpread({}, domain),
200
- range: _objectSpread({}, range)
201
- }, onChange(_objectSpread(_objectSpread({}, updatedModel), {}, {
173
+ domain: {
174
+ ...domain
175
+ },
176
+ range: {
177
+ ...range
178
+ }
179
+ }, onChange({
180
+ ...updatedModel,
202
181
  answers: plotableAnswers,
203
182
  defaultGridConfiguration: selectedGrid
204
- })));
183
+ }));
205
184
  }
206
185
  }
207
186
  });
208
-
209
187
  return;
210
188
  }
211
-
212
- _this.setState({
213
- gridValues: gridValues,
214
- labelValues: labelValues,
215
- domain: _objectSpread({}, domain),
216
- range: _objectSpread({}, range)
189
+ this.setState({
190
+ gridValues,
191
+ labelValues,
192
+ domain: {
193
+ ...domain
194
+ },
195
+ range: {
196
+ ...range
197
+ }
217
198
  });
218
-
219
- onChange(_objectSpread(_objectSpread({}, updatedModel), {}, {
199
+ onChange({
200
+ ...updatedModel,
220
201
  defaultGridConfiguration: selectedGrid
221
- }));
202
+ });
222
203
  });
223
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeView", function (event, expanded) {
224
- var _this$props$graphDime = _this.props.graphDimensions;
225
- _this$props$graphDime = _this$props$graphDime === void 0 ? {} : _this$props$graphDime;
226
- var enabled = _this$props$graphDime.enabled;
227
-
204
+ /*
205
+ * Function to change view
206
+ * @param {object} event - event object
207
+ * @param {boolean} expanded - expanded boolean
208
+ * */
209
+ (0, _defineProperty2.default)(this, "onChangeView", (event, expanded) => {
210
+ const {
211
+ graphDimensions: {
212
+ enabled
213
+ } = {}
214
+ } = this.props;
228
215
  if (enabled) {
229
- _this.setState({
216
+ this.setState({
230
217
  showPixelGuides: expanded
231
218
  });
232
219
  }
233
220
  });
234
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeGridConfiguration", function (event) {
235
- var gridConfigurations = _this.props.gridConfigurations;
236
- var value = event.target.value;
237
-
238
- _this.onConfigChange((gridConfigurations === null || gridConfigurations === void 0 ? void 0 : gridConfigurations[value]) || {}, value);
221
+ /*
222
+ * Function to change grid configuration
223
+ * @param {object} event - event object
224
+ * */
225
+ (0, _defineProperty2.default)(this, "changeGridConfiguration", event => {
226
+ const {
227
+ gridConfigurations
228
+ } = this.props;
229
+ const {
230
+ value
231
+ } = event.target;
232
+ this.onConfigChange(gridConfigurations?.[value] || {}, value);
239
233
  });
240
-
241
- var _ref = props.model || {},
242
- _domain = _ref.domain,
243
- _range = _ref.range,
244
- _graph = _ref.graph;
245
-
246
- var _gridValues = {
234
+ const {
235
+ domain: _domain,
236
+ range: _range,
237
+ graph: _graph
238
+ } = props.model || {};
239
+ const _gridValues = {
247
240
  domain: (0, _utils.getGridValues)(_domain, _graph.width, true),
248
241
  range: (0, _utils.getGridValues)(_range, _graph.height, true)
249
242
  };
250
- var _labelValues = {
243
+ const _labelValues = {
251
244
  domain: (0, _utils.getLabelValues)(_domain.step),
252
245
  range: (0, _utils.getLabelValues)(_range.step)
253
246
  };
254
- _this.state = {
247
+ this.state = {
255
248
  gridValues: _gridValues,
256
249
  labelValues: _labelValues,
257
250
  showPixelGuides: false,
258
251
  dialog: {
259
252
  isOpened: false
260
253
  },
261
- domain: _objectSpread({}, _domain),
262
- range: _objectSpread({}, _range)
254
+ domain: {
255
+ ..._domain
256
+ },
257
+ range: {
258
+ ..._range
259
+ }
263
260
  };
264
- return _this;
265
261
  }
266
262
  /*
267
- * Function to change labels
268
- * @param {object} labels - labels object
263
+ * Render the component
269
264
  * */
270
-
271
-
272
- (0, _createClass2["default"])(GraphingConfig, [{
273
- key: "render",
274
- value:
275
- /*
276
- * Render the component
277
- * */
278
- function render() {
279
- var _this$props4 = this.props,
280
- _this$props4$authorin = _this$props4.authoring,
281
- authoring = _this$props4$authorin === void 0 ? {} : _this$props4$authorin,
282
- classes = _this$props4.classes,
283
- _this$props4$gridConf = _this$props4.gridConfigurations,
284
- gridConfigurations = _this$props4$gridConf === void 0 ? [] : _this$props4$gridConf,
285
- _this$props4$graphDim = _this$props4.graphDimensions,
286
- graphDimensions = _this$props4$graphDim === void 0 ? {} : _this$props4$graphDim,
287
- labelsPlaceholders = _this$props4.labelsPlaceholders,
288
- model = _this$props4.model,
289
- showLabels = _this$props4.showLabels,
290
- dimensionsEnabled = _this$props4.dimensionsEnabled,
291
- showTitle = _this$props4.showTitle,
292
- titlePlaceholder = _this$props4.titlePlaceholder,
293
- _this$props4$mathMlOp = _this$props4.mathMlOptions,
294
- mathMlOptions = _this$props4$mathMlOp === void 0 ? {} : _this$props4$mathMlOp;
295
-
296
- var _ref2 = model || {},
297
- arrows = _ref2.arrows,
298
- coordinatesOnHover = _ref2.coordinatesOnHover,
299
- defaultGridConfiguration = _ref2.defaultGridConfiguration,
300
- domain = _ref2.domain,
301
- labels = _ref2.labels,
302
- range = _ref2.range,
303
- standardGrid = _ref2.standardGrid,
304
- title = _ref2.title;
305
-
306
- var graph = (model || {}).graph || {};
307
-
308
- var _ref3 = graphDimensions || {},
309
- min = _ref3.min,
310
- max = _ref3.max,
311
- step = _ref3.step;
312
-
313
- var _this$state2 = this.state,
314
- _this$state2$dialog = _this$state2.dialog,
315
- dialog = _this$state2$dialog === void 0 ? {} : _this$state2$dialog,
316
- gridValues = _this$state2.gridValues,
317
- labelValues = _this$state2.labelValues,
318
- showPixelGuides = _this$state2.showPixelGuides;
319
- var sizeConstraints = {
320
- min: Math.max(150, min),
321
- max: Math.min(800, max),
322
- step: step >= 1 ? Math.min(200, step) : 20
323
- };
324
- var displayedFields = {
325
- axisLabel: authoring.axisLabel,
326
- dimensionsEnabled: dimensionsEnabled,
327
- includeAxesEnabled: false,
328
- //Setting false by default as per requirement
329
- labelStep: authoring.labelStep,
330
- min: authoring.min,
331
- max: authoring.max,
332
- standardGridEnabled: authoring.standardGridEnabled,
333
- step: authoring.step
334
- };
335
- var displayGridSetup = authoring.enabled && Object.values(displayedFields).some(function (field) {
336
- return (0, _typeof2["default"])(field) === 'object' ? field.enabled : field;
337
- });
338
- return /*#__PURE__*/React.createElement("div", {
339
- className: classes.container
340
- }, /*#__PURE__*/React.createElement("div", {
341
- className: classes.gridConfigWrapper
342
- }, gridConfigurations && gridConfigurations.length ? /*#__PURE__*/React.createElement("div", {
343
- className: classes.gridConfig
344
- }, /*#__PURE__*/React.createElement(_core.Typography, {
345
- component: "div",
346
- variant: "subheading",
347
- className: classes.gridConfigLabel
348
- }, "Grid Configuration"), /*#__PURE__*/React.createElement(_core.Select, {
349
- input: /*#__PURE__*/React.createElement(_core.OutlinedInput, {
350
- labelWidth: 10
351
- }),
352
- className: classes.gridConfigSelect,
353
- displayEmpty: true,
354
- onChange: this.changeGridConfiguration,
355
- value: defaultGridConfiguration
356
- }, (gridConfigurations || []).map(function (config, index) {
357
- return /*#__PURE__*/React.createElement(_core.MenuItem, {
358
- key: index,
359
- value: index
360
- }, config.label);
361
- }))) : null, displayGridSetup && /*#__PURE__*/React.createElement(_graphingSolutionSet.GridSetup, {
362
- displayedFields: displayedFields,
363
- domain: domain,
364
- gridValues: gridValues,
365
- includeAxes: true //Setting true by default as per requirement
366
- ,
367
- labelValues: labelValues,
368
- range: range,
369
- size: graph,
370
- sizeConstraints: sizeConstraints,
371
- standardGrid: standardGrid,
372
- onChange: this.onConfigChange,
373
- onChangeView: this.onChangeView
374
- })), /*#__PURE__*/React.createElement("div", {
375
- className: classes.graphConfig,
376
- key: "graph"
377
- }, /*#__PURE__*/React.createElement(_core.Typography, {
378
- component: "div",
379
- variant: "subheading"
380
- }, "Define Graph Attributes"), /*#__PURE__*/React.createElement(_core.Typography, {
381
- component: "div",
382
- variant: "body1",
383
- className: classes.subtitleText
384
- }, "Use this interface to add/edit a title and/or labels"), /*#__PURE__*/React.createElement(_graphingSolutionSet.GraphContainer, {
385
- axesSettings: {
386
- includeArrows: arrows
387
- },
388
- backgroundMarks: [],
389
- coordinatesOnHover: coordinatesOnHover,
390
- collapsibleToolbar: true,
391
- collapsibleToolbarTitle: 'Add Background Shapes to Graph',
392
- domain: domain,
393
- key: "graphing-config",
394
- labels: labels,
395
- labelsPlaceholders: labelsPlaceholders,
396
- marks: [],
397
- onChangeLabels: this.changeLabels,
398
- onChangeTitle: this.changeTitle,
399
- range: range,
400
- showLabels: showLabels,
401
- showPixelGuides: showPixelGuides,
402
- showTitle: showTitle,
403
- size: {
404
- width: graph.width,
405
- height: graph.height
406
- },
407
- title: title,
408
- titlePlaceholder: titlePlaceholder,
409
- disableToolbar: true,
410
- mathMlOptions: mathMlOptions
411
- })), /*#__PURE__*/React.createElement(_configUi.AlertDialog, {
412
- open: dialog.isOpened,
413
- title: "Warning",
414
- text: "This change would make it impossible for students to plot one or more graph objects in the current correct answers. If you proceed, all such graph objects will be removed from the correct answers.",
415
- onClose: dialog.onClose,
416
- onConfirm: dialog.onConfirm
417
- }));
418
- }
419
- }]);
420
- return GraphingConfig;
421
- }(React.Component);
422
-
265
+ render() {
266
+ const {
267
+ authoring = {},
268
+ gridConfigurations = [],
269
+ graphDimensions = {},
270
+ labelsPlaceholders,
271
+ model,
272
+ showLabels,
273
+ dimensionsEnabled,
274
+ showTitle,
275
+ titlePlaceholder,
276
+ mathMlOptions = {}
277
+ } = this.props;
278
+ const {
279
+ arrows,
280
+ coordinatesOnHover,
281
+ defaultGridConfiguration,
282
+ domain,
283
+ labels,
284
+ range,
285
+ standardGrid,
286
+ title
287
+ } = model || {};
288
+ const graph = (model || {}).graph || {};
289
+ const {
290
+ min,
291
+ max,
292
+ step
293
+ } = graphDimensions || {};
294
+ const {
295
+ dialog = {},
296
+ gridValues,
297
+ labelValues,
298
+ showPixelGuides
299
+ } = this.state;
300
+ const sizeConstraints = {
301
+ min: Math.max(150, min),
302
+ max: Math.min(800, max),
303
+ step: step >= 1 ? Math.min(200, step) : 20
304
+ };
305
+ const displayedFields = {
306
+ axisLabel: authoring.axisLabel,
307
+ dimensionsEnabled,
308
+ includeAxesEnabled: false,
309
+ //Setting false by default as per requirement
310
+ labelStep: authoring.labelStep,
311
+ min: authoring.min,
312
+ max: authoring.max,
313
+ standardGridEnabled: authoring.standardGridEnabled,
314
+ step: authoring.step
315
+ };
316
+ const displayGridSetup = authoring.enabled && Object.values(displayedFields).some(field => typeof field === 'object' ? field.enabled : field);
317
+ return /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(GridConfigWrapper, null, gridConfigurations && gridConfigurations.length ? /*#__PURE__*/React.createElement(GridConfig, null, /*#__PURE__*/React.createElement(GridConfigLabel, {
318
+ component: "div",
319
+ variant: "h6"
320
+ }, "Grid Configuration"), /*#__PURE__*/React.createElement(GridConfigSelect, {
321
+ input: /*#__PURE__*/React.createElement(_material.OutlinedInput, {
322
+ labelWidth: 10
323
+ }),
324
+ displayEmpty: true,
325
+ onChange: this.changeGridConfiguration,
326
+ value: defaultGridConfiguration,
327
+ MenuProps: {
328
+ transitionDuration: {
329
+ enter: 225,
330
+ exit: 195
331
+ }
332
+ }
333
+ }, (gridConfigurations || []).map((config, index) => /*#__PURE__*/React.createElement(_material.MenuItem, {
334
+ key: index,
335
+ value: index
336
+ }, config.label)))) : null, displayGridSetup && /*#__PURE__*/React.createElement(_graphingSolutionSet.GridSetup, {
337
+ displayedFields: displayedFields,
338
+ domain: domain,
339
+ gridValues: gridValues,
340
+ includeAxes: true //Setting true by default as per requirement
341
+ ,
342
+ labelValues: labelValues,
343
+ range: range,
344
+ size: graph,
345
+ sizeConstraints: sizeConstraints,
346
+ standardGrid: standardGrid,
347
+ onChange: this.onConfigChange,
348
+ onChangeView: this.onChangeView
349
+ })), /*#__PURE__*/React.createElement(GraphConfig, {
350
+ key: "graph"
351
+ }, /*#__PURE__*/React.createElement(_material.Typography, {
352
+ component: "div",
353
+ variant: "h6"
354
+ }, "Define Graph Attributes"), /*#__PURE__*/React.createElement(SubtitleText, {
355
+ component: "div",
356
+ variant: "body1"
357
+ }, "Use this interface to add/edit a title and/or labels"), /*#__PURE__*/React.createElement(_graphingSolutionSet.GraphContainer, {
358
+ axesSettings: {
359
+ includeArrows: arrows
360
+ },
361
+ backgroundMarks: [],
362
+ coordinatesOnHover: coordinatesOnHover,
363
+ collapsibleToolbar: true,
364
+ collapsibleToolbarTitle: 'Add Background Shapes to Graph',
365
+ domain: domain,
366
+ key: "graphing-config",
367
+ labels: labels,
368
+ labelsPlaceholders: labelsPlaceholders,
369
+ marks: [],
370
+ onChangeLabels: this.changeLabels,
371
+ onChangeTitle: this.changeTitle,
372
+ range: range,
373
+ showLabels: showLabels,
374
+ showPixelGuides: showPixelGuides,
375
+ showTitle: showTitle,
376
+ size: {
377
+ width: graph.width,
378
+ height: graph.height
379
+ },
380
+ title: title,
381
+ titlePlaceholder: titlePlaceholder,
382
+ disableToolbar: true,
383
+ mathMlOptions: mathMlOptions
384
+ })), /*#__PURE__*/React.createElement(_configUi.AlertDialog, {
385
+ open: dialog.isOpened,
386
+ title: "Warning",
387
+ text: "This change would make it impossible for students to plot one or more graph objects in the current correct answers. If you proceed, all such graph objects will be removed from the correct answers.",
388
+ onClose: dialog.onClose,
389
+ onConfirm: dialog.onConfirm
390
+ }));
391
+ }
392
+ }
423
393
  exports.GraphingConfig = GraphingConfig;
424
- (0, _defineProperty2["default"])(GraphingConfig, "propTypes", {
425
- availableTools: _propTypes["default"].array,
426
- classes: _propTypes["default"].object.isRequired,
427
- authoring: _propTypes["default"].object,
428
- dimensionsEnabled: _propTypes["default"].bool,
429
- graphDimensions: _propTypes["default"].object,
430
- gridConfigurations: _propTypes["default"].array,
431
- labelsPlaceholders: _propTypes["default"].object,
432
- model: _propTypes["default"].object.isRequired,
433
- onChange: _propTypes["default"].func.isRequired,
434
- showLabels: _propTypes["default"].bool,
435
- showTitle: _propTypes["default"].bool,
436
- titlePlaceholder: _propTypes["default"].string
394
+ (0, _defineProperty2.default)(GraphingConfig, "propTypes", {
395
+ availableTools: _propTypes.default.array,
396
+ authoring: _propTypes.default.object,
397
+ dimensionsEnabled: _propTypes.default.bool,
398
+ graphDimensions: _propTypes.default.object,
399
+ gridConfigurations: _propTypes.default.array,
400
+ labelsPlaceholders: _propTypes.default.object,
401
+ model: _propTypes.default.object.isRequired,
402
+ onChange: _propTypes.default.func.isRequired,
403
+ showLabels: _propTypes.default.bool,
404
+ showTitle: _propTypes.default.bool,
405
+ titlePlaceholder: _propTypes.default.string
437
406
  });
438
-
439
- var _default = (0, _styles.withStyles)(styles)(GraphingConfig);
440
-
441
- exports["default"] = _default;
407
+ var _default = exports.default = GraphingConfig;
442
408
  //# sourceMappingURL=graphing-config.js.map