@pie-element/graphing 8.3.4-next.3 → 9.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,164 +1,132 @@
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 _graphing = require("@pie-lib/graphing");
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), "changeBackgroundMarks", function (backgroundMarks) {
104
- var model = _objectSpread(_objectSpread({}, _this.props.model), {}, {
105
- backgroundMarks: backgroundMarks
106
- });
107
-
108
- _this.props.onChange(model);
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
+ (0, _defineProperty2.default)(this, "changeBackgroundMarks", backgroundMarks => {
64
+ const model = {
65
+ ...this.props.model,
66
+ backgroundMarks
67
+ };
68
+ this.props.onChange(model);
109
69
  });
110
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeLabels", function (labels) {
111
- var _this$props = _this.props,
112
- model = _this$props.model,
113
- onChange = _this$props.onChange;
114
- onChange(_objectSpread(_objectSpread({}, model), {}, {
115
- labels: labels
116
- }));
70
+ (0, _defineProperty2.default)(this, "changeLabels", labels => {
71
+ const {
72
+ model,
73
+ onChange
74
+ } = this.props;
75
+ onChange({
76
+ ...model,
77
+ labels
78
+ });
117
79
  });
118
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeTitle", function (title) {
119
- var _this$props2 = _this.props,
120
- model = _this$props2.model,
121
- onChange = _this$props2.onChange;
122
- onChange(_objectSpread(_objectSpread({}, model), {}, {
123
- title: title
124
- }));
80
+ (0, _defineProperty2.default)(this, "changeTitle", title => {
81
+ const {
82
+ model,
83
+ onChange
84
+ } = this.props;
85
+ onChange({
86
+ ...model,
87
+ title
88
+ });
125
89
  });
126
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onConfigChange", function (config, newSelectedGrid) {
127
- var _this$props3 = _this.props,
128
- model = _this$props3.model,
129
- onChange = _this$props3.onChange;
130
- var _model$defaultGridCon = model.defaultGridConfiguration,
131
- oldSelectedGrid = _model$defaultGridCon === void 0 ? 0 : _model$defaultGridCon;
132
- var _this$state = _this.state,
133
- oldGridValues = _this$state.gridValues,
134
- oldLabelValues = _this$state.labelValues,
135
- oldDomain = _this$state.domain,
136
- oldRange = _this$state.range;
137
-
138
- var updatedModel = _objectSpread(_objectSpread({}, model), config);
139
-
140
- var answers = updatedModel.answers,
141
- domain = updatedModel.domain,
142
- includeAxes = updatedModel.includeAxes,
143
- graph = updatedModel.graph,
144
- range = updatedModel.range,
145
- standardGrid = updatedModel.standardGrid;
146
- var gridValues = {
90
+ (0, _defineProperty2.default)(this, "onConfigChange", (config, newSelectedGrid) => {
91
+ const {
92
+ model,
93
+ onChange
94
+ } = this.props;
95
+ const {
96
+ defaultGridConfiguration: oldSelectedGrid = 0
97
+ } = model;
98
+ const {
99
+ gridValues: oldGridValues,
100
+ labelValues: oldLabelValues,
101
+ domain: oldDomain,
102
+ range: oldRange
103
+ } = this.state;
104
+ const updatedModel = {
105
+ ...model,
106
+ ...config
107
+ };
108
+ const {
109
+ answers,
110
+ domain,
111
+ includeAxes,
112
+ graph,
113
+ range,
114
+ standardGrid
115
+ } = updatedModel;
116
+ const gridValues = {
147
117
  domain: [],
148
118
  range: []
149
119
  };
150
- var labelValues = {
120
+ const labelValues = {
151
121
  domain: [],
152
122
  range: []
153
123
  };
154
- var selectedGrid = newSelectedGrid >= 0 ? newSelectedGrid : oldSelectedGrid;
155
-
124
+ const selectedGrid = newSelectedGrid >= 0 ? newSelectedGrid : oldSelectedGrid;
156
125
  if (includeAxes) {
157
- var domainConstraints = (0, _utils.applyConstraints)(domain, graph.width, oldGridValues.domain, oldLabelValues.domain);
126
+ const domainConstraints = (0, _utils.applyConstraints)(domain, graph.width, oldGridValues.domain, oldLabelValues.domain);
158
127
  gridValues.domain = domainConstraints.gridValues || [];
159
128
  labelValues.domain = domainConstraints.labelValues || [];
160
129
  }
161
-
162
130
  if (standardGrid) {
163
131
  gridValues.range = gridValues.domain;
164
132
  labelValues.range = labelValues.domain;
@@ -166,270 +134,255 @@ var GraphingConfig = /*#__PURE__*/function (_React$Component) {
166
134
  range.labelStep = domain.labelStep;
167
135
  } else {
168
136
  if (includeAxes) {
169
- var rangeConstraints = (0, _utils.applyConstraints)(range, graph.height, oldGridValues.range, oldLabelValues.range);
137
+ const rangeConstraints = (0, _utils.applyConstraints)(range, graph.height, oldGridValues.range, oldLabelValues.range);
170
138
  gridValues.range = rangeConstraints.gridValues || [];
171
139
  labelValues.range = rangeConstraints.labelValues || [];
172
140
  }
173
141
  }
174
-
175
- var plotableAnswers = (0, _utils.filterPlotableMarks)(domain, range, answers);
176
-
142
+ const plotableAnswers = (0, _utils.filterPlotableMarks)(domain, range, answers);
177
143
  if (!(0, _lodash.isEqual)(answers, plotableAnswers)) {
178
- _this.setState({
144
+ this.setState({
179
145
  dialog: {
180
146
  isOpened: true,
181
- onClose: function onClose() {
182
- return _this.setState({
183
- dialog: {
184
- isOpened: false
185
- }
186
- }, onChange(_objectSpread(_objectSpread({}, model), {}, {
187
- domain: oldDomain,
188
- range: oldRange
189
- })));
190
- },
191
- onConfirm: function onConfirm() {
192
- _this.setState({
193
- gridValues: gridValues,
194
- labelValues: labelValues,
147
+ onClose: () => this.setState({
148
+ dialog: {
149
+ isOpened: false
150
+ }
151
+ }, onChange({
152
+ ...model,
153
+ domain: oldDomain,
154
+ range: oldRange
155
+ })),
156
+ onConfirm: () => {
157
+ this.setState({
158
+ gridValues,
159
+ labelValues,
195
160
  dialog: {
196
161
  isOpened: false
197
162
  },
198
- domain: _objectSpread({}, domain),
199
- range: _objectSpread({}, range)
200
- }, onChange(_objectSpread(_objectSpread({}, updatedModel), {}, {
163
+ domain: {
164
+ ...domain
165
+ },
166
+ range: {
167
+ ...range
168
+ }
169
+ }, onChange({
170
+ ...updatedModel,
201
171
  answers: plotableAnswers,
202
172
  defaultGridConfiguration: selectedGrid
203
- })));
173
+ }));
204
174
  }
205
175
  }
206
176
  });
207
-
208
177
  return;
209
178
  }
210
-
211
- _this.setState({
212
- gridValues: gridValues,
213
- labelValues: labelValues,
214
- domain: _objectSpread({}, domain),
215
- range: _objectSpread({}, range)
179
+ this.setState({
180
+ gridValues,
181
+ labelValues,
182
+ domain: {
183
+ ...domain
184
+ },
185
+ range: {
186
+ ...range
187
+ }
216
188
  });
217
-
218
- onChange(_objectSpread(_objectSpread({}, updatedModel), {}, {
189
+ onChange({
190
+ ...updatedModel,
219
191
  defaultGridConfiguration: selectedGrid
220
- }));
192
+ });
221
193
  });
222
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeView", function (event, expanded) {
223
- var _this$props$graphDime = _this.props.graphDimensions;
224
- _this$props$graphDime = _this$props$graphDime === void 0 ? {} : _this$props$graphDime;
225
- var enabled = _this$props$graphDime.enabled;
226
-
194
+ (0, _defineProperty2.default)(this, "onChangeView", (event, expanded) => {
195
+ const {
196
+ graphDimensions: {
197
+ enabled
198
+ } = {}
199
+ } = this.props;
227
200
  if (enabled) {
228
- _this.setState({
201
+ this.setState({
229
202
  showPixelGuides: expanded
230
203
  });
231
204
  }
232
205
  });
233
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeGridConfiguration", function (event) {
234
- var gridConfigurations = _this.props.gridConfigurations;
235
- var value = event.target.value;
236
-
237
- _this.onConfigChange((gridConfigurations === null || gridConfigurations === void 0 ? void 0 : gridConfigurations[value]) || {}, value);
206
+ (0, _defineProperty2.default)(this, "changeGridConfiguration", event => {
207
+ const {
208
+ gridConfigurations
209
+ } = this.props;
210
+ const {
211
+ value
212
+ } = event.target;
213
+ this.onConfigChange(gridConfigurations?.[value] || {}, value);
238
214
  });
239
-
240
- var _ref = props.model || {},
241
- _domain = _ref.domain,
242
- _range = _ref.range,
243
- _graph = _ref.graph;
244
-
245
- var _gridValues = {
215
+ const {
216
+ domain: _domain,
217
+ range: _range,
218
+ graph: _graph
219
+ } = props.model || {};
220
+ const _gridValues = {
246
221
  domain: (0, _utils.getGridValues)(_domain, _graph.width, true),
247
222
  range: (0, _utils.getGridValues)(_range, _graph.height, true)
248
223
  };
249
- var _labelValues = {
224
+ const _labelValues = {
250
225
  domain: (0, _utils.getLabelValues)(_domain.step),
251
226
  range: (0, _utils.getLabelValues)(_range.step)
252
227
  };
253
- _this.state = {
228
+ this.state = {
254
229
  gridValues: _gridValues,
255
230
  labelValues: _labelValues,
256
231
  showPixelGuides: false,
257
232
  dialog: {
258
233
  isOpened: false
259
234
  },
260
- domain: _objectSpread({}, _domain),
261
- range: _objectSpread({}, _range)
235
+ domain: {
236
+ ..._domain
237
+ },
238
+ range: {
239
+ ..._range
240
+ }
262
241
  };
263
- return _this;
264
242
  }
265
-
266
- (0, _createClass2["default"])(GraphingConfig, [{
267
- key: "render",
268
- value: function render() {
269
- var _this$props4 = this.props,
270
- _this$props4$authorin = _this$props4.authoring,
271
- authoring = _this$props4$authorin === void 0 ? {} : _this$props4$authorin,
272
- _this$props4$availabl = _this$props4.availableTools,
273
- availableTools = _this$props4$availabl === void 0 ? [] : _this$props4$availabl,
274
- classes = _this$props4.classes,
275
- _this$props4$gridConf = _this$props4.gridConfigurations,
276
- gridConfigurations = _this$props4$gridConf === void 0 ? [] : _this$props4$gridConf,
277
- _this$props4$graphDim = _this$props4.graphDimensions,
278
- graphDimensions = _this$props4$graphDim === void 0 ? {} : _this$props4$graphDim,
279
- labelsPlaceholders = _this$props4.labelsPlaceholders,
280
- model = _this$props4.model,
281
- showLabels = _this$props4.showLabels,
282
- dimensionsEnabled = _this$props4.dimensionsEnabled,
283
- showTitle = _this$props4.showTitle,
284
- titlePlaceholder = _this$props4.titlePlaceholder,
285
- _this$props4$mathMlOp = _this$props4.mathMlOptions,
286
- mathMlOptions = _this$props4$mathMlOp === void 0 ? {} : _this$props4$mathMlOp,
287
- removeIncompleteTool = _this$props4.removeIncompleteTool;
288
-
289
- var _ref2 = model || {},
290
- arrows = _ref2.arrows,
291
- backgroundMarks = _ref2.backgroundMarks,
292
- coordinatesOnHover = _ref2.coordinatesOnHover,
293
- defaultGridConfiguration = _ref2.defaultGridConfiguration,
294
- domain = _ref2.domain,
295
- includeAxes = _ref2.includeAxes,
296
- labels = _ref2.labels,
297
- range = _ref2.range,
298
- standardGrid = _ref2.standardGrid,
299
- title = _ref2.title;
300
-
301
- var graph = (model || {}).graph || {};
302
-
303
- var _ref3 = graphDimensions || {},
304
- min = _ref3.min,
305
- max = _ref3.max,
306
- step = _ref3.step;
307
-
308
- var _this$state2 = this.state,
309
- _this$state2$dialog = _this$state2.dialog,
310
- dialog = _this$state2$dialog === void 0 ? {} : _this$state2$dialog,
311
- gridValues = _this$state2.gridValues,
312
- labelValues = _this$state2.labelValues,
313
- showPixelGuides = _this$state2.showPixelGuides;
314
- var sizeConstraints = {
315
- min: Math.max(150, min),
316
- max: Math.min(800, max),
317
- step: step >= 1 ? Math.min(200, step) : 20
318
- };
319
- var displayedFields = {
320
- axisLabel: authoring.axisLabel,
321
- dimensionsEnabled: dimensionsEnabled,
322
- includeAxesEnabled: authoring.includeAxesEnabled,
323
- labelStep: authoring.labelStep,
324
- min: authoring.min,
325
- max: authoring.max,
326
- standardGridEnabled: authoring.standardGridEnabled,
327
- step: authoring.step
328
- };
329
- var displayGridSetup = authoring.enabled && Object.values(displayedFields).some(function (field) {
330
- return (0, _typeof2["default"])(field) === 'object' ? field.enabled : field;
331
- });
332
- return /*#__PURE__*/React.createElement("div", {
333
- className: classes.container
334
- }, /*#__PURE__*/React.createElement("div", {
335
- className: classes.gridConfigWrapper
336
- }, gridConfigurations && gridConfigurations.length ? /*#__PURE__*/React.createElement("div", {
337
- className: classes.gridConfig
338
- }, /*#__PURE__*/React.createElement(_core.Typography, {
339
- component: "div",
340
- variant: "subheading",
341
- className: classes.gridConfigLabel
342
- }, "Grid Configuration"), /*#__PURE__*/React.createElement(_core.Select, {
343
- input: /*#__PURE__*/React.createElement(_core.OutlinedInput, null),
344
- className: classes.gridConfigSelect,
345
- displayEmpty: true,
346
- onChange: this.changeGridConfiguration,
347
- value: defaultGridConfiguration
348
- }, (gridConfigurations || []).map(function (config, index) {
349
- return /*#__PURE__*/React.createElement(_core.MenuItem, {
350
- key: index,
351
- value: index
352
- }, config.label);
353
- }))) : null, displayGridSetup && /*#__PURE__*/React.createElement(_graphing.GridSetup, {
354
- displayedFields: displayedFields,
355
- domain: domain,
356
- gridValues: gridValues,
357
- includeAxes: includeAxes,
358
- labelValues: labelValues,
359
- range: range,
360
- size: graph,
361
- sizeConstraints: sizeConstraints,
362
- standardGrid: standardGrid,
363
- onChange: this.onConfigChange,
364
- onChangeView: this.onChangeView
365
- })), /*#__PURE__*/React.createElement("div", {
366
- className: classes.graphConfig,
367
- key: "graph"
368
- }, /*#__PURE__*/React.createElement(_core.Typography, {
369
- component: "div",
370
- variant: "subheading"
371
- }, "Define Graph Attributes"), /*#__PURE__*/React.createElement(_core.Typography, {
372
- component: "div",
373
- variant: "body1",
374
- className: classes.subtitleText
375
- }, "Use this interface to add/edit a title and/or labels, and to set background shapes"), /*#__PURE__*/React.createElement(_graphing.GraphContainer, {
376
- axesSettings: {
377
- includeArrows: arrows
378
- },
379
- backgroundMarks: [],
380
- coordinatesOnHover: coordinatesOnHover,
381
- collapsibleToolbar: true,
382
- collapsibleToolbarTitle: 'Add Background Shapes to Graph',
383
- domain: domain,
384
- key: "graphing-config",
385
- labels: labels,
386
- labelsPlaceholders: labelsPlaceholders,
387
- marks: backgroundMarks,
388
- onChangeLabels: this.changeLabels,
389
- onChangeMarks: this.changeBackgroundMarks,
390
- onChangeTitle: this.changeTitle,
391
- range: range,
392
- showLabels: showLabels,
393
- showPixelGuides: showPixelGuides,
394
- showTitle: showTitle,
395
- size: {
396
- width: graph.width,
397
- height: graph.height
398
- },
399
- title: title,
400
- titlePlaceholder: titlePlaceholder,
401
- toolbarTools: availableTools,
402
- mathMlOptions: mathMlOptions,
403
- removeIncompleteTool: removeIncompleteTool
404
- })), /*#__PURE__*/React.createElement(_configUi.AlertDialog, {
405
- open: dialog.isOpened,
406
- title: "Warning",
407
- 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.",
408
- onClose: dialog.onClose,
409
- onConfirm: dialog.onConfirm
410
- }));
411
- }
412
- }]);
413
- return GraphingConfig;
414
- }(React.Component);
415
-
243
+ render() {
244
+ const {
245
+ authoring = {},
246
+ availableTools = [],
247
+ gridConfigurations = [],
248
+ graphDimensions = {},
249
+ labelsPlaceholders,
250
+ model,
251
+ showLabels,
252
+ dimensionsEnabled,
253
+ showTitle,
254
+ titlePlaceholder,
255
+ mathMlOptions = {},
256
+ removeIncompleteTool
257
+ } = this.props;
258
+ const {
259
+ arrows,
260
+ backgroundMarks,
261
+ coordinatesOnHover,
262
+ defaultGridConfiguration,
263
+ domain,
264
+ includeAxes,
265
+ labels,
266
+ range,
267
+ standardGrid,
268
+ title
269
+ } = model || {};
270
+ const graph = (model || {}).graph || {};
271
+ const {
272
+ min,
273
+ max,
274
+ step
275
+ } = graphDimensions || {};
276
+ const {
277
+ dialog = {},
278
+ gridValues,
279
+ labelValues,
280
+ showPixelGuides
281
+ } = this.state;
282
+ const sizeConstraints = {
283
+ min: Math.max(150, min),
284
+ max: Math.min(800, max),
285
+ step: step >= 1 ? Math.min(200, step) : 20
286
+ };
287
+ const displayedFields = {
288
+ axisLabel: authoring.axisLabel,
289
+ dimensionsEnabled,
290
+ includeAxesEnabled: authoring.includeAxesEnabled,
291
+ labelStep: authoring.labelStep,
292
+ min: authoring.min,
293
+ max: authoring.max,
294
+ standardGridEnabled: authoring.standardGridEnabled,
295
+ step: authoring.step
296
+ };
297
+ const displayGridSetup = authoring.enabled && Object.values(displayedFields).some(field => typeof field === 'object' ? field.enabled : field);
298
+ return /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(GridConfigWrapper, null, gridConfigurations && gridConfigurations.length ? /*#__PURE__*/React.createElement(GridConfig, null, /*#__PURE__*/React.createElement(GridConfigLabel, {
299
+ component: "div",
300
+ variant: "h6"
301
+ }, "Grid Configuration"), /*#__PURE__*/React.createElement(GridConfigSelect, {
302
+ input: /*#__PURE__*/React.createElement(_material.OutlinedInput, null),
303
+ displayEmpty: true,
304
+ onChange: this.changeGridConfiguration,
305
+ value: defaultGridConfiguration,
306
+ MenuProps: {
307
+ transitionDuration: {
308
+ enter: 225,
309
+ exit: 195
310
+ }
311
+ }
312
+ }, (gridConfigurations || []).map((config, index) => /*#__PURE__*/React.createElement(_material.MenuItem, {
313
+ key: index,
314
+ value: index
315
+ }, config.label)))) : null, displayGridSetup && /*#__PURE__*/React.createElement(_graphing.GridSetup, {
316
+ displayedFields: displayedFields,
317
+ domain: domain,
318
+ gridValues: gridValues,
319
+ includeAxes: includeAxes,
320
+ labelValues: labelValues,
321
+ range: range,
322
+ size: graph,
323
+ sizeConstraints: sizeConstraints,
324
+ standardGrid: standardGrid,
325
+ onChange: this.onConfigChange,
326
+ onChangeView: this.onChangeView
327
+ })), /*#__PURE__*/React.createElement(GraphConfig, {
328
+ key: "graph"
329
+ }, /*#__PURE__*/React.createElement(_material.Typography, {
330
+ component: "div",
331
+ variant: "h6"
332
+ }, "Define Graph Attributes"), /*#__PURE__*/React.createElement(SubtitleText, {
333
+ component: "div",
334
+ variant: "body1"
335
+ }, "Use this interface to add/edit a title and/or labels, and to set background shapes"), /*#__PURE__*/React.createElement(_graphing.GraphContainer, {
336
+ axesSettings: {
337
+ includeArrows: arrows
338
+ },
339
+ backgroundMarks: [],
340
+ coordinatesOnHover: coordinatesOnHover,
341
+ collapsibleToolbar: true,
342
+ collapsibleToolbarTitle: 'Add Background Shapes to Graph',
343
+ domain: domain,
344
+ key: "graphing-config",
345
+ labels: labels,
346
+ labelsPlaceholders: labelsPlaceholders,
347
+ marks: backgroundMarks,
348
+ onChangeLabels: this.changeLabels,
349
+ onChangeMarks: this.changeBackgroundMarks,
350
+ onChangeTitle: this.changeTitle,
351
+ range: range,
352
+ showLabels: showLabels,
353
+ showPixelGuides: showPixelGuides,
354
+ showTitle: showTitle,
355
+ size: {
356
+ width: graph.width,
357
+ height: graph.height
358
+ },
359
+ title: title,
360
+ titlePlaceholder: titlePlaceholder,
361
+ toolbarTools: availableTools,
362
+ mathMlOptions: mathMlOptions,
363
+ removeIncompleteTool: removeIncompleteTool
364
+ })), /*#__PURE__*/React.createElement(_configUi.AlertDialog, {
365
+ open: dialog.isOpened,
366
+ title: "Warning",
367
+ 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.",
368
+ onClose: dialog.onClose,
369
+ onConfirm: dialog.onConfirm
370
+ }));
371
+ }
372
+ }
416
373
  exports.GraphingConfig = GraphingConfig;
417
- (0, _defineProperty2["default"])(GraphingConfig, "propTypes", {
418
- availableTools: _propTypes["default"].array,
419
- classes: _propTypes["default"].object.isRequired,
420
- authoring: _propTypes["default"].object,
421
- dimensionsEnabled: _propTypes["default"].bool,
422
- graphDimensions: _propTypes["default"].object,
423
- gridConfigurations: _propTypes["default"].array,
424
- labelsPlaceholders: _propTypes["default"].object,
425
- model: _propTypes["default"].object.isRequired,
426
- onChange: _propTypes["default"].func.isRequired,
427
- showLabels: _propTypes["default"].bool,
428
- showTitle: _propTypes["default"].bool,
429
- titlePlaceholder: _propTypes["default"].string
374
+ (0, _defineProperty2.default)(GraphingConfig, "propTypes", {
375
+ availableTools: _propTypes.default.array,
376
+ authoring: _propTypes.default.object,
377
+ dimensionsEnabled: _propTypes.default.bool,
378
+ graphDimensions: _propTypes.default.object,
379
+ gridConfigurations: _propTypes.default.array,
380
+ labelsPlaceholders: _propTypes.default.object,
381
+ model: _propTypes.default.object.isRequired,
382
+ onChange: _propTypes.default.func.isRequired,
383
+ showLabels: _propTypes.default.bool,
384
+ showTitle: _propTypes.default.bool,
385
+ titlePlaceholder: _propTypes.default.string
430
386
  });
431
-
432
- var _default = (0, _styles.withStyles)(styles)(GraphingConfig);
433
-
434
- exports["default"] = _default;
387
+ var _default = exports.default = GraphingConfig;
435
388
  //# sourceMappingURL=graphing-config.js.map