@pie-element/charting 3.0.0 → 5.0.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,62 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting@5.0.0...@pie-element/charting@5.0.1) (2022-07-19)
7
+
8
+ **Note:** Version bump only for package @pie-element/charting
9
+
10
+
11
+
12
+
13
+
14
+ # [5.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting@4.0.0...@pie-element/charting@5.0.0) (2022-06-28)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * updated pie-lib since the previous version was a breaking change that was not released properly ([e51250d](https://github.com/pie-framework/pie-elements/commit/e51250dfe5b2d6593e186c685b6f75167479ff39))
20
+ * **charting:** keep chart interactive in IBX preview mode PD-1365 ([f92515a](https://github.com/pie-framework/pie-elements/commit/f92515a7071c72cfcc07a830095cd70cc4740e58))
21
+
22
+
23
+ ### Features
24
+
25
+ * **charting:** add maxImageWidth and maxImageHeight props PD-1801 ([0bff787](https://github.com/pie-framework/pie-elements/commit/0bff787ff2c9301138346f02e04646ee55f659fc))
26
+ * **charting:** remove editCategoryEnabled property ([0ea2a3c](https://github.com/pie-framework/pie-elements/commit/0ea2a3cf9c4ebf09c493ad6aee02ee1cc1987b36))
27
+ * **charting:** remove editCategoryEnabled property checkbox and usage. ([b844871](https://github.com/pie-framework/pie-elements/commit/b84487145c2d92edaaed2427070e4294b0681803))
28
+
29
+
30
+ ### Reverts
31
+
32
+ * Revert "try to add student can add categories checkbox in pie-lib" ([0ba8f3f](https://github.com/pie-framework/pie-elements/commit/0ba8f3f80ea98eee535b0c2da1da92b4899ada83))
33
+
34
+
35
+ ### BREAKING CHANGES
36
+
37
+ * **charting:** The editCategoryEnabled checkbox and property was removed.
38
+ Enabled property will be used for each category.
39
+ * **charting:** The editCategoryEnabled propery has been removed
40
+
41
+
42
+
43
+
44
+
45
+ # [4.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting@3.0.0...@pie-element/charting@4.0.0) (2022-06-28)
46
+
47
+
48
+ ### chore
49
+
50
+ * Merge master with develop. ([cdca48a](https://github.com/pie-framework/pie-elements/commit/cdca48abaa1d4179e4a961e13d171e14b7ed2444))
51
+
52
+
53
+ ### BREAKING CHANGES
54
+
55
+ * Image percent buttons were removed from toolbar.
56
+ New properties maxImageWidth and maxImageHeight were added.
57
+
58
+
59
+
60
+
61
+
6
62
  # [3.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting@2.7.30...@pie-element/charting@3.0.0) (2022-06-13)
7
63
 
8
64
 
@@ -3,6 +3,61 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.0...@pie-element/charting-configure@5.0.1) (2022-07-19)
7
+
8
+ **Note:** Version bump only for package @pie-element/charting-configure
9
+
10
+
11
+
12
+
13
+
14
+ # [5.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@4.0.0...@pie-element/charting-configure@5.0.0) (2022-06-28)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * updated pie-lib since the previous version was a breaking change that was not released properly ([e51250d](https://github.com/pie-framework/pie-elements/commit/e51250dfe5b2d6593e186c685b6f75167479ff39))
20
+
21
+
22
+ ### Features
23
+
24
+ * **charting:** add maxImageWidth and maxImageHeight props PD-1801 ([0bff787](https://github.com/pie-framework/pie-elements/commit/0bff787ff2c9301138346f02e04646ee55f659fc))
25
+ * **charting:** remove editCategoryEnabled property ([0ea2a3c](https://github.com/pie-framework/pie-elements/commit/0ea2a3cf9c4ebf09c493ad6aee02ee1cc1987b36))
26
+ * **charting:** remove editCategoryEnabled property checkbox and usage. ([b844871](https://github.com/pie-framework/pie-elements/commit/b84487145c2d92edaaed2427070e4294b0681803))
27
+
28
+
29
+ ### Reverts
30
+
31
+ * Revert "try to add student can add categories checkbox in pie-lib" ([0ba8f3f](https://github.com/pie-framework/pie-elements/commit/0ba8f3f80ea98eee535b0c2da1da92b4899ada83))
32
+
33
+
34
+ ### BREAKING CHANGES
35
+
36
+ * **charting:** The editCategoryEnabled checkbox and property was removed.
37
+ Enabled property will be used for each category.
38
+ * **charting:** The editCategoryEnabled propery has been removed
39
+
40
+
41
+
42
+
43
+
44
+ # [4.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@3.0.0...@pie-element/charting-configure@4.0.0) (2022-06-28)
45
+
46
+
47
+ ### chore
48
+
49
+ * Merge master with develop. ([cdca48a](https://github.com/pie-framework/pie-elements/commit/cdca48abaa1d4179e4a961e13d171e14b7ed2444))
50
+
51
+
52
+ ### BREAKING CHANGES
53
+
54
+ * Image percent buttons were removed from toolbar.
55
+ New properties maxImageWidth and maxImageHeight were added.
56
+
57
+
58
+
59
+
60
+
6
61
  # [3.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.49...@pie-element/charting-configure@3.0.0) (2022-06-13)
7
62
 
8
63
 
@@ -112,8 +112,13 @@ var ChartingConfig = /*#__PURE__*/function (_React$Component) {
112
112
  size: model.graph,
113
113
  domain: model.domain,
114
114
  range: model.range,
115
- charts: charts,
116
- data: model.data,
115
+ charts: charts // index is a property used for setting the correct answer data; it's needed in order to remove categories from other data sets from the same index it was removed from the initial data
116
+ ,
117
+ data: model.data.map(function (category, index) {
118
+ return _objectSpread(_objectSpread({}, category), {}, {
119
+ index: index
120
+ });
121
+ }),
117
122
  title: model.title,
118
123
  onDataChange: this.changeData,
119
124
  addCategoryEnabled: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/charting-config.jsx"],"names":["styles","theme","container","marginTop","spacing","unit","marginBottom","display","flex","column","ChartingConfig","data","props","onChange","model","value","addCategoryEnabled","classes","charts","chartType","graph","domain","range","title","changeData","categoryDefaultLabel","e","changeAddRemoveEnabled","target","checked","React","Component","PropTypes","object","isRequired","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CADvB;AAETC,MAAAA,YAAY,EAAEL,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CAF1B;AAGTE,MAAAA,OAAO,EAAE,MAHA;AAITC,MAAAA,IAAI,EAAE;AAJG,KADY;AAOvBC,IAAAA,MAAM,EAAE;AACND,MAAAA,IAAI,EAAE;AADA;AAPe,GAAL;AAAA,CAApB;;IAYaE,c;;;;;;;;;;;;;;;mGAQE,UAAAC,IAAI;AAAA,aAAI,MAAKC,KAAL,CAAWC,QAAX,iCAAyB,MAAKD,KAAL,CAAWE,KAApC;AAA2CH,QAAAA,IAAI,EAAJA;AAA3C,SAAJ;AAAA,K;+GAEQ,UAAAI,KAAK;AAAA,aAAI,MAAKH,KAAL,CAAWC,QAAX,iCAAyB,MAAKD,KAAL,CAAWE,KAApC;AAA2CE,QAAAA,kBAAkB,EAAED;AAA/D,SAAJ;AAAA,K;;;;;;WAE9B,kBAAS;AAAA;;AACP,wBAAmC,KAAKH,KAAxC;AAAA,UAAQK,OAAR,eAAQA,OAAR;AAAA,UAAiBH,KAAjB,eAAiBA,KAAjB;AAAA,UAAwBI,MAAxB,eAAwBA,MAAxB;AAEA,0BACE,yEAGE;AAAK,QAAA,SAAS,EAAED,OAAO,CAACf;AAAxB,sBACE;AAAK,QAAA,SAAS,EAAEe,OAAO,CAACR,MAAxB;AAAgC,QAAA,GAAG,EAAC;AAApC,sBACE,oBAAC,sBAAD;AAAY,QAAA,SAAS,EAAC,KAAtB;AAA4B,QAAA,IAAI,EAAC;AAAjC,sBACE,iFADF,CADF,eAKE,oBAAC,eAAD;AACE,QAAA,WAAW,EAAE,IADf;AAEE,QAAA,SAAS,EAAEK,KAAK,CAACK,SAFnB;AAGE,QAAA,IAAI,EAAEL,KAAK,CAACM,KAHd;AAIE,QAAA,MAAM,EAAEN,KAAK,CAACO,MAJhB;AAKE,QAAA,KAAK,EAAEP,KAAK,CAACQ,KALf;AAME,QAAA,MAAM,EAAEJ,MANV;AAOE,QAAA,IAAI,EAAEJ,KAAK,CAACH,IAPd;AAQE,QAAA,KAAK,EAAEG,KAAK,CAACS,KARf;AASE,QAAA,YAAY,EAAE,KAAKC,UATrB;AAUE,QAAA,kBAAkB,EAAE,IAVtB;AAWE,QAAA,oBAAoB,EAAEV,KAAK,CAACW;AAX9B,QALF,eAkBG,8CACC,oBAAC,oBAAD;AACE,QAAA,OAAO,EAAEX,KAAK,CAACE,kBADjB;AAEE,QAAA,QAAQ,EAAE,kBAACU,CAAD,EAAO;AACf,UAAA,MAAI,CAACC,sBAAL,CAA4BD,CAAC,CAACE,MAAF,CAASC,OAArC;AACD;AAJH,QADD,+BAlBH,CADF,CAHF,CADF;AAqCD;;;EApDiCC,KAAK,CAACC,S;;;iCAA7BrB,c,eACQ;AACjBO,EAAAA,OAAO,EAAEe,sBAAUC,MAAV,CAAiBC,UADT;AAEjBpB,EAAAA,KAAK,EAAEkB,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBrB,EAAAA,QAAQ,EAAEmB,sBAAUG,IAAV,CAAeD,UAHR;AAIjBhB,EAAAA,MAAM,EAAEc,sBAAUI;AAJD,C;;eAsDN,wBAAWpC,MAAX,EAAmBU,cAAnB,C","sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Chart } from '@pie-lib/charting';\nimport Checkbox from '@material-ui/core/Checkbox';\n\nimport Typography from '@material-ui/core/Typography';\n\nconst styles = theme => ({\n container: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit * 3,\n display: 'flex',\n flex: 1,\n },\n column: {\n flex: 1\n }\n});\n\nexport class ChartingConfig extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array\n };\n\n changeData = data => this.props.onChange({ ...this.props.model, data });\n\n changeAddRemoveEnabled = value => this.props.onChange({ ...this.props.model, addCategoryEnabled: value });\n\n render() {\n const { classes, model, charts } = this.props;\n\n return (\n <div>\n Define Graph Attributes\n\n <div className={classes.container}>\n <div className={classes.column} key=\"graph\">\n <Typography component=\"div\" type=\"body1\">\n <span>Use the tools below to set background shapes</span>\n </Typography>\n\n <Chart\n defineChart={true}\n chartType={model.chartType}\n size={model.graph}\n domain={model.domain}\n range={model.range}\n charts={charts}\n data={model.data}\n title={model.title}\n onDataChange={this.changeData}\n addCategoryEnabled={true}\n categoryDefaultLabel={model.categoryDefaultLabel}\n />\n <div>\n <Checkbox\n checked={model.addCategoryEnabled}\n onChange={(e) => {\n this.changeAddRemoveEnabled(e.target.checked)\n }}\n />\n Student can add categories\n </div>\n </div>\n\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(ChartingConfig);\n"],"file":"charting-config.js"}
1
+ {"version":3,"sources":["../src/charting-config.jsx"],"names":["styles","theme","container","marginTop","spacing","unit","marginBottom","display","flex","column","ChartingConfig","data","props","onChange","model","value","addCategoryEnabled","classes","charts","chartType","graph","domain","range","map","category","index","title","changeData","categoryDefaultLabel","e","changeAddRemoveEnabled","target","checked","React","Component","PropTypes","object","isRequired","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,SAAS,EA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AK,CAACQ,KALf;AAME,QAAA,MAAM,EAAEJ,MANV,CAOE;AAPF;AAQE,QAAA,IAAI,EAAEJ,KAAK,CAACH,IAAN,CAAWY,GAAX,CAAe,UAACC,QAAD,EAAWC,KAAX;AAAA,iDAA2BD,QAA3B;AAAqCC,YAAAA,KAAK,EAAEA;AAA5C;AAAA,SAAf,CARR;AASE,QAAA,KAAK,EAAEX,KAAK,CAACY,KATf;AAUE,QAAA,YAAY,EAAE,KAAKC,UAVrB;AAWE,QAAA,kBAAkB,EAAE,IAXtB;AAYE,QAAA,oBAAoB,EAAEb,KAAK,CAACc;AAZ9B,QALF,eAmBG,8CACC,oBAAC,oBAAD;AACE,QAAA,OAAO,EAAEd,KAAK,CAACE,kBADjB;AAEE,QAAA,QAAQ,EAAE,kBAACa,CAAD,EAAO;AACf,UAAA,MAAI,CAACC,sBAAL,CAA4BD,CAAC,CAACE,MAAF,CAASC,OAArC;AACD;AAJH,QADD,+BAnBH,CADF,CAHF,CADF;AAsCD;;;EArDiCC,KAAK,CAACC,S;;;iCAA7BxB,c,eACQ;AACjBO,EAAAA,OAAO,EAAEkB,sBAAUC,MAAV,CAAiBC,UADT;AAEjBvB,EAAAA,KAAK,EAAEqB,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBxB,EAAAA,QAAQ,EAAEsB,sBAAUG,IAAV,CAAeD,UAHR;AAIjBnB,EAAAA,MAAM,EAAEiB,sBAAUI;AAJD,C;;eAuDN,wBAAWvC,MAAX,EAAmBU,cAAnB,C","sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Chart } from '@pie-lib/charting';\nimport Checkbox from '@material-ui/core/Checkbox';\n\nimport Typography from '@material-ui/core/Typography';\n\nconst styles = theme => ({\n container: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit * 3,\n display: 'flex',\n flex: 1,\n },\n column: {\n flex: 1\n }\n});\n\nexport class ChartingConfig extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array\n };\n\n changeData = data => this.props.onChange({ ...this.props.model, data });\n\n changeAddRemoveEnabled = value => this.props.onChange({ ...this.props.model, addCategoryEnabled: value });\n\n render() {\n const { classes, model, charts } = this.props;\n\n return (\n <div>\n Define Graph Attributes\n\n <div className={classes.container}>\n <div className={classes.column} key=\"graph\">\n <Typography component=\"div\" type=\"body1\">\n <span>Use the tools below to set background shapes</span>\n </Typography>\n\n <Chart\n defineChart={true}\n chartType={model.chartType}\n size={model.graph}\n domain={model.domain}\n range={model.range}\n charts={charts}\n // index is a property used for setting the correct answer data; it's needed in order to remove categories from other data sets from the same index it was removed from the initial data\n data={model.data.map((category, index) => ({ ...category, index: index }))}\n title={model.title}\n onDataChange={this.changeData}\n addCategoryEnabled={true}\n categoryDefaultLabel={model.categoryDefaultLabel}\n />\n <div>\n <Checkbox\n checked={model.addCategoryEnabled}\n onChange={(e) => {\n this.changeAddRemoveEnabled(e.target.checked)\n }}\n />\n Student can add categories\n </div>\n </div>\n\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(ChartingConfig);\n"],"file":"charting-config.js"}
@@ -41,7 +41,7 @@ var _chartingConfig = _interopRequireDefault(require("./charting-config"));
41
41
 
42
42
  var _correctResponse = _interopRequireDefault(require("./correct-response"));
43
43
 
44
- var _chartType = _interopRequireDefault(require("./chart-type"));
44
+ var _utils = require("./utils");
45
45
 
46
46
  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; }
47
47
 
@@ -88,16 +88,11 @@ var Configure = /*#__PURE__*/function (_React$Component) {
88
88
 
89
89
  var _super = _createSuper(Configure);
90
90
 
91
- function Configure() {
91
+ function Configure(props) {
92
92
  var _this;
93
93
 
94
94
  (0, _classCallCheck2["default"])(this, Configure);
95
-
96
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
97
- args[_key] = arguments[_key];
98
- }
99
-
100
- _this = _super.call.apply(_super, [this].concat(args));
95
+ _this = _super.call(this, props);
101
96
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onRationaleChange", function (rationale) {
102
97
  return _this.props.onModelChanged(_objectSpread(_objectSpread({}, _this.props.model), {}, {
103
98
  rationale: rationale
@@ -118,14 +113,50 @@ var Configure = /*#__PURE__*/function (_React$Component) {
118
113
  chartType: chartType
119
114
  }));
120
115
  });
116
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onConfigChange", function (config) {
117
+ var model = _this.props.model;
118
+ var _this$state = _this.state,
119
+ oldGridValues = _this$state.gridValues,
120
+ oldLabelValues = _this$state.labelValues;
121
+
122
+ var updatedModel = _objectSpread(_objectSpread({}, model), config);
123
+
124
+ var graph = updatedModel.graph,
125
+ range = updatedModel.range;
126
+ var gridValues = {};
127
+ var labelValues = {};
128
+ var rangeConstraints = (0, _utils.applyConstraints)(range, graph.height, oldGridValues.range, oldLabelValues.range);
129
+ gridValues.range = rangeConstraints.gridValues;
130
+ labelValues.range = rangeConstraints.labelValues;
131
+
132
+ _this.setState({
133
+ gridValues: gridValues,
134
+ labelValues: labelValues
135
+ });
136
+
137
+ _this.props.onModelChanged(updatedModel);
138
+ });
139
+
140
+ var _ref = props.model || {},
141
+ _range = _ref.range,
142
+ _graph = _ref.graph;
143
+
144
+ var _gridValues = {
145
+ range: (0, _utils.getGridValues)(_range, _graph.height, true)
146
+ };
147
+ var _labelValues = {
148
+ range: (0, _utils.getLabelValues)(_range.step || 1)
149
+ };
150
+ _this.state = {
151
+ gridValues: _gridValues,
152
+ labelValues: _labelValues
153
+ };
121
154
  return _this;
122
155
  }
123
156
 
124
157
  (0, _createClass2["default"])(Configure, [{
125
158
  key: "render",
126
159
  value: function render() {
127
- var _this2 = this;
128
-
129
160
  var _this$props = this.props,
130
161
  classes = _this$props.classes,
131
162
  model = _this$props.model,
@@ -136,28 +167,37 @@ var Configure = /*#__PURE__*/function (_React$Component) {
136
167
  log('[render] model', model);
137
168
  var graph = model.graph;
138
169
 
139
- var _ref = configuration || {},
140
- _ref$title = _ref.title,
141
- title = _ref$title === void 0 ? {} : _ref$title,
142
- _ref$rationale = _ref.rationale,
143
- rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
144
- _ref$scoringType = _ref.scoringType,
145
- scoringType = _ref$scoringType === void 0 ? {} : _ref$scoringType,
146
- _ref$studentInstructi = _ref.studentInstructions,
147
- studentInstructions = _ref$studentInstructi === void 0 ? {} : _ref$studentInstructi,
148
- _ref$teacherInstructi = _ref.teacherInstructions,
149
- teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
150
- _ref$prompt = _ref.prompt,
151
- prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
152
- _ref$spellCheck = _ref.spellCheck,
153
- spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck;
154
-
155
- var _ref2 = model || {},
156
- teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
157
- promptEnabled = _ref2.promptEnabled,
158
- rationaleEnabled = _ref2.rationaleEnabled,
159
- spellCheckEnabled = _ref2.spellCheckEnabled;
160
-
170
+ var _ref2 = configuration || {},
171
+ _ref2$title = _ref2.title,
172
+ title = _ref2$title === void 0 ? {} : _ref2$title,
173
+ _ref2$rationale = _ref2.rationale,
174
+ rationale = _ref2$rationale === void 0 ? {} : _ref2$rationale,
175
+ _ref2$scoringType = _ref2.scoringType,
176
+ scoringType = _ref2$scoringType === void 0 ? {} : _ref2$scoringType,
177
+ _ref2$studentInstruct = _ref2.studentInstructions,
178
+ studentInstructions = _ref2$studentInstruct === void 0 ? {} : _ref2$studentInstruct,
179
+ _ref2$teacherInstruct = _ref2.teacherInstructions,
180
+ teacherInstructions = _ref2$teacherInstruct === void 0 ? {} : _ref2$teacherInstruct,
181
+ _ref2$prompt = _ref2.prompt,
182
+ prompt = _ref2$prompt === void 0 ? {} : _ref2$prompt,
183
+ _ref2$spellCheck = _ref2.spellCheck,
184
+ spellCheck = _ref2$spellCheck === void 0 ? {} : _ref2$spellCheck,
185
+ _ref2$maxImageWidth = _ref2.maxImageWidth,
186
+ maxImageWidth = _ref2$maxImageWidth === void 0 ? {} : _ref2$maxImageWidth,
187
+ _ref2$maxImageHeight = _ref2.maxImageHeight,
188
+ maxImageHeight = _ref2$maxImageHeight === void 0 ? {} : _ref2$maxImageHeight;
189
+
190
+ var _ref3 = model || {},
191
+ teacherInstructionsEnabled = _ref3.teacherInstructionsEnabled,
192
+ promptEnabled = _ref3.promptEnabled,
193
+ rationaleEnabled = _ref3.rationaleEnabled,
194
+ spellCheckEnabled = _ref3.spellCheckEnabled;
195
+
196
+ var _this$state2 = this.state,
197
+ gridValues = _this$state2.gridValues,
198
+ labelValues = _this$state2.labelValues;
199
+ var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
200
+ var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
161
201
  return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
162
202
  settings: /*#__PURE__*/_react["default"].createElement(Panel, {
163
203
  model: model,
@@ -206,7 +246,9 @@ var Configure = /*#__PURE__*/function (_React$Component) {
206
246
  onChange: this.onTeacherInstructionsChange,
207
247
  imageSupport: imageSupport,
208
248
  nonEmpty: false,
209
- spellCheck: spellCheckEnabled
249
+ spellCheck: spellCheckEnabled,
250
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
251
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight
210
252
  })), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
211
253
  label: prompt.label,
212
254
  className: classes.promptHolder
@@ -217,7 +259,9 @@ var Configure = /*#__PURE__*/function (_React$Component) {
217
259
  imageSupport: imageSupport,
218
260
  nonEmpty: false,
219
261
  spellCheck: spellCheckEnabled,
220
- disableUnderline: true
262
+ disableUnderline: true,
263
+ maxImageWidth: defaultImageMaxWidth,
264
+ maxImageHeight: defaultImageMaxHeight
221
265
  })), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
222
266
  label: rationale.label || 'Rationale',
223
267
  className: classes.promptHolder
@@ -226,14 +270,16 @@ var Configure = /*#__PURE__*/function (_React$Component) {
226
270
  markup: model.rationale || '',
227
271
  onChange: this.onRationaleChange,
228
272
  imageSupport: imageSupport,
229
- spellCheck: spellCheckEnabled
230
- })), /*#__PURE__*/_react["default"].createElement(_chartType["default"], {
231
- value: model.chartType,
232
- onChange: function onChange(e) {
233
- return _this2.onChartTypeChange(e.target.value);
234
- }
273
+ spellCheck: spellCheckEnabled,
274
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
275
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight
276
+ })), /*#__PURE__*/_react["default"].createElement(_charting.ConfigureChartPanel, {
277
+ model: model,
278
+ onChange: this.onConfigChange,
279
+ gridValues: gridValues,
280
+ labelValues: labelValues,
281
+ charts: charts
235
282
  }), /*#__PURE__*/_react["default"].createElement(_chartingConfig["default"], {
236
- config: graph,
237
283
  model: model,
238
284
  onChange: onModelChanged,
239
285
  charts: charts
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/configure.jsx"],"names":["log","Panel","settings","toggle","radio","numberFields","styles","theme","title","fontSize","display","marginTop","spacing","unit","marginBottom","content","promptHolder","width","paddingBottom","prompt","paddingTop","charts","chartTypes","Bar","Histogram","LineDot","LineCross","DotPlot","LinePlot","Configure","rationale","props","onModelChanged","model","teacherInstructions","chartType","classes","configuration","onConfigurationChanged","imageSupport","graph","scoringType","studentInstructions","spellCheck","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","label","suffix","min","max","height","Properties","studentInstructionsEnabled","onTeacherInstructionsChange","onPromptChange","onRationaleChange","e","onChartTypeChange","target","value","React","Component","PropTypes","func","object","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;AACA,IAAQC,KAAR,GAA+CC,kBAA/C,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA+CD,kBAA/C,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAA+CF,kBAA/C,CAAuBE,KAAvB;AAAA,IAA8BC,YAA9B,GAA+CH,kBAA/C,CAA8BG,YAA9B;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE,QADL;AAELC,MAAAA,OAAO,EAAE,OAFJ;AAGLC,MAAAA,SAAS,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAH3B;AAILC,MAAAA,YAAY,EAAEP,KAAK,CAACK,OAAN,CAAcC;AAJvB,KADkB;AAOzBE,IAAAA,OAAO,EAAE;AACPJ,MAAAA,SAAS,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB;AADzB,KAPgB;AAUzBG,IAAAA,YAAY,EAAE;AACZC,MAAAA,KAAK,EAAE,MADK;AAEZC,MAAAA,aAAa,EAAEX,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAFxB;AAGZC,MAAAA,YAAY,EAAEP,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAHvB;AAIZF,MAAAA,SAAS,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB;AAJpB,KAVW;AAgBzBM,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAEb,KAAK,CAACK,O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MAAM,EAAEX;AAJV,QA/DF,eAsEE,gCAAC,2BAAD;AACE,QAAA,MAAM,EAAEmB,KADV;AAEE,QAAA,KAAK,EAAEP,KAFT;AAGE,QAAA,QAAQ,EAAED,cAHZ;AAIE,QAAA,MAAM,EAAEX;AAJV,QAtEF,CA/CF,CADF;AA+HD;;;EA9K4ByC,kBAAMC,S;;;iCAAxBlC,S,eACQ;AACjBG,EAAAA,cAAc,EAAEgC,sBAAUC,IADT;AAEjB3B,EAAAA,sBAAsB,EAAE0B,sBAAUC,IAFjB;AAGjB7B,EAAAA,OAAO,EAAE4B,sBAAUE,MAHF;AAIjB3B,EAAAA,YAAY,EAAEyB,sBAAUE,MAJP;AAKjBjC,EAAAA,KAAK,EAAE+B,sBAAUE,MAAV,CAAiBC,UALP;AAMjB9B,EAAAA,aAAa,EAAE2B,sBAAUE,MAAV,CAAiBC;AANf,C;iCADRtC,S,kBAUW;AAAEO,EAAAA,OAAO,EAAE;AAAX,C;;eAuKT,wBAAW9B,MAAX,EAAmBuB,SAAnB,C","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport { chartTypes } from '@pie-lib/charting';\nimport { settings, layout, InputContainer } from '@pie-lib/config-ui';\nimport PropTypes from 'prop-types';\nimport debug from 'debug';\nimport Typography from '@material-ui/core/Typography';\nimport EditableHtml from '@pie-lib/editable-html';\n\nimport ChartingConfig from './charting-config';\nimport CorrectResponse from './correct-response';\nimport ChartType from './chart-type';\n\nconst log = debug('@pie-element:graphing:configure');\nconst { Panel, toggle, radio, numberFields } = settings;\n\nconst styles = (theme) => ({\n title: {\n fontSize: '1.1rem',\n display: 'block',\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit,\n },\n content: {\n marginTop: theme.spacing.unit * 2,\n },\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n marginTop: theme.spacing.unit * 2,\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n },\n});\n\nconst charts = [\n chartTypes.Bar(),\n chartTypes.Histogram(),\n chartTypes.LineDot(),\n chartTypes.LineCross(),\n chartTypes.DotPlot(),\n chartTypes.LinePlot(),\n];\n\nexport class Configure extends React.Component {\n static propTypes = {\n onModelChanged: PropTypes.func,\n onConfigurationChanged: PropTypes.func,\n classes: PropTypes.object,\n imageSupport: PropTypes.object,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n };\n\n static defaultProps = { classes: {} };\n\n onRationaleChange = (rationale) =>\n this.props.onModelChanged({ ...this.props.model, rationale });\n\n onPromptChange = (prompt) =>\n this.props.onModelChanged({ ...this.props.model, prompt });\n\n onTeacherInstructionsChange = (teacherInstructions) =>\n this.props.onModelChanged({ ...this.props.model, teacherInstructions });\n\n onChartTypeChange = (chartType) =>\n this.props.onModelChanged({ ...this.props.model, chartType });\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged,\n onModelChanged,\n imageSupport,\n } = this.props;\n log('[render] model', model);\n const { graph } = model;\n const {\n title = {},\n rationale = {},\n scoringType = {},\n studentInstructions = {},\n teacherInstructions = {},\n prompt = {},\n spellCheck = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled } =\n model || {};\n\n return (\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={onModelChanged}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Item Type': {\n 'title.enabled': title.settings && toggle(title.label, true),\n graph: numberFields('Graph Display Size', {\n width: {\n label: 'Width',\n suffix: 'px',\n min: 400,\n max: 700,\n },\n height: {\n label: 'Height',\n suffix: 'px',\n min: 400,\n max: 700,\n },\n }),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, [\n 'all or nothing',\n 'partial scoring',\n ]),\n },\n }}\n />\n }\n >\n <div className={classes.content}>\n <Typography component=\"div\" type=\"body1\">\n <span>\n This interaction asks a student to draw a chart that meets\n specific criteria. The student will draw a category on the chart\n by clicking Add Category and dragging the top part of the\n category.\n </span>\n </Typography>\n\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n spellCheck={spellCheckEnabled}\n disableUnderline\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label || 'Rationale'}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChange}\n imageSupport={imageSupport}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n <ChartType\n value={model.chartType}\n onChange={(e) => this.onChartTypeChange(e.target.value)}\n />\n\n <ChartingConfig\n config={graph}\n model={model}\n onChange={onModelChanged}\n charts={charts}\n />\n\n <CorrectResponse\n config={graph}\n model={model}\n onChange={onModelChanged}\n charts={charts}\n />\n </div>\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default withStyles(styles)(Configure);\n"],"file":"configure.js"}
1
+ {"version":3,"sources":["../src/configure.jsx"],"names":["log","Panel","settings","toggle","radio","numberFields","styles","theme","title","fontSize","display","marginTop","spacing","unit","marginBottom","content","promptHolder","width","paddingBottom","prompt","paddingTop","charts","chartTypes","Bar","Histogram","LineDot","LineCross","DotPlot","LinePlot","Configure","props","rationale","onModelChanged","model","teacherInstructions","chartType","config","state","oldGridValues","gridValues","oldLabelValues","labelValues","updatedModel","graph","range","rangeConstraints","height","setState","step","classes","configuration","onConfigurationChanged","imageSupport","scoringType","studentInstructions","spellCheck","maxImageWidth","maxImageHeight","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","defaultImageMaxWidth","defaultImageMaxHeight","label","suffix","min","max","Properties","studentInstructionsEnabled","onTeacherInstructionsChange","onPromptChange","onRationaleChange","onConfigChange","React","Component","PropTypes","func","object","isRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,GAAG,GAAG,uBAAM,iCAAN,CAAZ;AACA,IAAQC,KAAR,GAA+CC,kBAA/C,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA+CD,kBAA/C,CAAeC,MAAf;AAAA,IAAuBC,KAAvB,GAA+CF,kBAA/C,CAAuBE,KAAvB;AAAA,IAA8BC,YAA9B,GAA+CH,kBAA/C,CAA8BG,YAA9B;;AAEA,IAAMC,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE,QADL;AAELC,MAAAA,OAAO,EAAE,OAFJ;AAGLC,MAAAA,SAAS,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAH3B;AAILC,MAAAA,YAAY,EAAEP,KAAK,CAACK,OAAN,CAAcC;AAJvB,KADkB;AAOzBE,IAAAA,OAAO,EAAE;AACPJ,MAAAA,SAAS,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB;AADzB,KAPgB;AAUzBG,IAAAA,YAAY,EAAE;AACZC,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AAA,QAAQ,EAAED,cAHZ;AAIE,QAAA,MAAM,EAAEX;AAJV,QA9EF,CA/CF,CADF;AAuID;;;EA5N4BqD,kBAAMC,S;;;iCAAxB9C,S,eACQ;AACjBG,EAAAA,cAAc,EAAE4C,sBAAUC,IADT;AAEjB1B,EAAAA,sBAAsB,EAAEyB,sBAAUC,IAFjB;AAGjB5B,EAAAA,OAAO,EAAE2B,sBAAUE,MAHF;AAIjB1B,EAAAA,YAAY,EAAEwB,sBAAUE,MAJP;AAKjB7C,EAAAA,KAAK,EAAE2C,sBAAUE,MAAV,CAAiBC,UALP;AAMjB7B,EAAAA,aAAa,EAAE0B,sBAAUE,MAAV,CAAiBC;AANf,C;iCADRlD,S,kBAyBW;AAAEoB,EAAAA,OAAO,EAAE;AAAX,C;;eAsMT,wBAAW3C,MAAX,EAAmBuB,SAAnB,C","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport { chartTypes, ConfigureChartPanel } from '@pie-lib/charting';\nimport { settings, layout, InputContainer } from '@pie-lib/config-ui';\nimport PropTypes from 'prop-types';\nimport debug from 'debug';\nimport Typography from '@material-ui/core/Typography';\nimport EditableHtml from '@pie-lib/editable-html';\n\nimport ChartingConfig from './charting-config';\nimport CorrectResponse from './correct-response';\nimport { applyConstraints, getGridValues, getLabelValues } from './utils';\n\n\nconst log = debug('@pie-element:graphing:configure');\nconst { Panel, toggle, radio, numberFields } = settings;\n\nconst styles = (theme) => ({\n title: {\n fontSize: '1.1rem',\n display: 'block',\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit,\n },\n content: {\n marginTop: theme.spacing.unit * 2,\n },\n promptHolder: {\n width: '100%',\n paddingBottom: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n marginTop: theme.spacing.unit * 2,\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%',\n },\n});\n\nconst charts = [\n chartTypes.Bar(),\n chartTypes.Histogram(),\n chartTypes.LineDot(),\n chartTypes.LineCross(),\n chartTypes.DotPlot(),\n chartTypes.LinePlot(),\n];\n\nexport class Configure extends React.Component {\n static propTypes = {\n onModelChanged: PropTypes.func,\n onConfigurationChanged: PropTypes.func,\n classes: PropTypes.object,\n imageSupport: PropTypes.object,\n model: PropTypes.object.isRequired,\n configuration: PropTypes.object.isRequired,\n };\n\n constructor(props) {\n super(props);\n const { range, graph } = props.model || {};\n\n const gridValues = {\n range: getGridValues(range, graph.height, true)\n };\n \n const labelValues = {\n range: getLabelValues(range.step || 1)\n };\n\n this.state = { gridValues, labelValues };\n };\n\n static defaultProps = { classes: {} };\n\n onRationaleChange = (rationale) =>\n this.props.onModelChanged({ ...this.props.model, rationale });\n\n onPromptChange = (prompt) =>\n this.props.onModelChanged({ ...this.props.model, prompt });\n\n onTeacherInstructionsChange = (teacherInstructions) =>\n this.props.onModelChanged({ ...this.props.model, teacherInstructions });\n\n onChartTypeChange = (chartType) =>\n this.props.onModelChanged({ ...this.props.model, chartType });\n\n onConfigChange = config => {\n const { model } = this.props;\n const { gridValues: oldGridValues, labelValues: oldLabelValues } = this.state;\n const updatedModel = { ...model, ...config };\n const { graph, range } = updatedModel;\n const gridValues = {};\n const labelValues = {};\n\n const rangeConstraints = applyConstraints(range, graph.height, oldGridValues.range, oldLabelValues.range);\n\n gridValues.range = rangeConstraints.gridValues;\n labelValues.range = rangeConstraints.labelValues;\n\n this.setState({ gridValues, labelValues });\n this.props.onModelChanged(updatedModel);\n };\n\n render() {\n const {\n classes,\n model,\n configuration,\n onConfigurationChanged,\n onModelChanged,\n imageSupport,\n } = this.props;\n log('[render] model', model);\n const { graph } = model;\n const {\n title = {},\n rationale = {},\n scoringType = {},\n studentInstructions = {},\n teacherInstructions = {},\n prompt = {},\n spellCheck = {},\n maxImageWidth = {},\n maxImageHeight = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled } =\n model || {};\n const { gridValues, labelValues } = this.state;\n\n const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;\n const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;\n\n return (\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n configuration={configuration}\n onChangeModel={onModelChanged}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Item Type': {\n 'title.enabled': title.settings && toggle(title.label, true),\n graph: numberFields('Graph Display Size', {\n width: {\n label: 'Width',\n suffix: 'px',\n min: 400,\n max: 700,\n },\n height: {\n label: 'Height',\n suffix: 'px',\n min: 400,\n max: 700,\n },\n }),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings &&\n toggle(teacherInstructions.label),\n studentInstructionsEnabled:\n studentInstructions.settings &&\n toggle(studentInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n promptEnabled: prompt.settings && toggle(prompt.label),\n scoringType:\n scoringType.settings &&\n radio(scoringType.label, [\n 'all or nothing',\n 'partial scoring',\n ]),\n },\n }}\n />\n }\n >\n <div className={classes.content}>\n <Typography component=\"div\" type=\"body1\">\n <span>\n This interaction asks a student to draw a chart that meets\n specific criteria. The student will draw a category on the chart\n by clicking Add Category and dragging the top part of the\n category.\n </span>\n </Typography>\n\n {teacherInstructionsEnabled && (\n <InputContainer\n label={teacherInstructions.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.teacherInstructions || ''}\n onChange={this.onTeacherInstructionsChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth}\n maxImageHeight={maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight}\n />\n </InputContainer>\n )}\n\n {promptEnabled && (\n <InputContainer\n label={prompt.label}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.prompt}\n onChange={this.onPromptChange}\n imageSupport={imageSupport}\n nonEmpty={false}\n spellCheck={spellCheckEnabled}\n disableUnderline\n maxImageWidth={defaultImageMaxWidth}\n maxImageHeight={defaultImageMaxHeight}\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label || 'Rationale'}\n className={classes.promptHolder}\n >\n <EditableHtml\n className={classes.prompt}\n markup={model.rationale || ''}\n onChange={this.onRationaleChange}\n imageSupport={imageSupport}\n spellCheck={spellCheckEnabled}\n maxImageWidth={maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth}\n maxImageHeight={maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight}\n />\n </InputContainer>\n )}\n\n <ConfigureChartPanel\n model={model}\n onChange={this.onConfigChange}\n gridValues={gridValues}\n labelValues={labelValues}\n charts={charts}\n />\n\n <ChartingConfig\n model={model}\n onChange={onModelChanged}\n charts={charts}\n />\n\n <CorrectResponse\n config={graph}\n model={model}\n onChange={onModelChanged}\n charts={charts}\n />\n </div>\n </layout.ConfigLayout>\n );\n }\n}\n\nexport default withStyles(styles)(Configure);\n"],"file":"configure.js"}
@@ -21,6 +21,10 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
21
21
 
22
22
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
23
 
24
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
25
+
26
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
27
+
24
28
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
29
 
26
30
  var React = _interopRequireWildcard(require("react"));
@@ -31,18 +35,25 @@ var _styles = require("@material-ui/core/styles");
31
35
 
32
36
  var _charting = require("@pie-lib/charting");
33
37
 
34
- 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); }
38
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
35
39
 
36
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
40
+ var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
37
41
 
38
- 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; }
42
+ var _excluded = ["editable", "interactive", "deletable"],
43
+ _excluded2 = ["interactive", "editable", "index"];
39
44
 
40
- 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; }
45
+ 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); }
46
+
47
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
41
48
 
42
49
  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); }; }
43
50
 
44
51
  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; } }
45
52
 
53
+ 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; }
54
+
55
+ 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; }
56
+
46
57
  var styles = function styles(theme) {
47
58
  return {
48
59
  container: {
@@ -62,21 +73,74 @@ var styles = function styles(theme) {
62
73
  };
63
74
  };
64
75
 
76
+ var addCategoryProps = function addCategoryProps(correctAnswer, data) {
77
+ return correctAnswer.map(function (correct, index) {
78
+ return _objectSpread(_objectSpread({}, correct), {}, {
79
+ editable: index < data.length ? data[index].editable : true,
80
+ interactive: index < data.length ? data[index].interactive : true,
81
+ deletable: index >= data.length ? true : false
82
+ });
83
+ });
84
+ };
85
+
86
+ var updateCorrectResponseData = function updateCorrectResponseData(correctAnswer, data) {
87
+ if (!correctAnswer) {
88
+ return data;
89
+ }
90
+
91
+ var correctAnswerData = (0, _toConsumableArray2["default"])(correctAnswer);
92
+ var correctResponseDefinition = [];
93
+ data.forEach(function (category, currentIndex) {
94
+ var _correctAnswer$curren, _correctAnswer$curren2;
95
+
96
+ var editable = category.editable;
97
+ var interactive = category.interactive;
98
+ var label = editable && (_correctAnswer$curren = correctAnswer[currentIndex]) !== null && _correctAnswer$curren !== void 0 && _correctAnswer$curren.label ? correctAnswer[currentIndex].label : category.label;
99
+ var value = interactive && (_correctAnswer$curren2 = correctAnswer[currentIndex]) !== null && _correctAnswer$curren2 !== void 0 && _correctAnswer$curren2.value ? correctAnswer[currentIndex].value : category.value;
100
+ correctResponseDefinition[currentIndex] = {
101
+ label: label,
102
+ value: value,
103
+ editable: category.editable,
104
+ interactive: category.interactive
105
+ };
106
+ });
107
+
108
+ if (correctResponseDefinition.length < correctAnswer.length) {
109
+ var missingCategories = correctAnswerData.slice(correctResponseDefinition.length, correctAnswer.length);
110
+ return addCategoryProps(correctResponseDefinition.concat(missingCategories), data);
111
+ }
112
+
113
+ return correctResponseDefinition;
114
+ };
115
+
116
+ var insertCategory = function insertCategory(correctAnswer, data) {
117
+ var positionToInsert = data.length - 1;
118
+ var _data = data[data.length - 1],
119
+ editable = _data.editable,
120
+ interactive = _data.interactive,
121
+ deletable = _data.deletable,
122
+ categoryToInsert = (0, _objectWithoutProperties2["default"])(_data, _excluded);
123
+ correctAnswer.splice(positionToInsert, 0, categoryToInsert);
124
+ var correctAnswerData = (0, _toConsumableArray2["default"])(correctAnswer);
125
+ return addCategoryProps(correctAnswerData, data);
126
+ };
127
+
128
+ var removeCategory = function removeCategory(correctAnswer, data, positionToRemove) {
129
+ correctAnswer.splice(positionToRemove, 1);
130
+ var correctAnswerData = (0, _toConsumableArray2["default"])(correctAnswer);
131
+ return addCategoryProps(correctAnswerData, data);
132
+ };
133
+
65
134
  var CorrectResponse = /*#__PURE__*/function (_React$Component) {
66
135
  (0, _inherits2["default"])(CorrectResponse, _React$Component);
67
136
 
68
137
  var _super = _createSuper(CorrectResponse);
69
138
 
70
- function CorrectResponse() {
139
+ function CorrectResponse(props) {
71
140
  var _this;
72
141
 
73
142
  (0, _classCallCheck2["default"])(this, CorrectResponse);
74
-
75
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
76
- args[_key] = arguments[_key];
77
- }
78
-
79
- _this = _super.call.apply(_super, [this].concat(args));
143
+ _this = _super.call(this, props);
80
144
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (data) {
81
145
  var _this$props = _this.props,
82
146
  model = _this$props.model,
@@ -87,22 +151,103 @@ var CorrectResponse = /*#__PURE__*/function (_React$Component) {
87
151
 
88
152
  onChange(_objectSpread(_objectSpread({}, model), {}, {
89
153
  correctAnswer: _objectSpread(_objectSpread({}, correctAnswer), {}, {
90
- data: data
154
+ data: data.map(function (_ref2) {
155
+ var interactive = _ref2.interactive,
156
+ editable = _ref2.editable,
157
+ index = _ref2.index,
158
+ keepAttrs = (0, _objectWithoutProperties2["default"])(_ref2, _excluded2);
159
+ return keepAttrs;
160
+ })
91
161
  })
92
162
  }));
93
163
  });
164
+ _this.state = {
165
+ categories: updateCorrectResponseData(props.model.correctAnswer.data, props.model.data)
166
+ };
94
167
  return _this;
95
168
  }
96
169
 
97
170
  (0, _createClass2["default"])(CorrectResponse, [{
171
+ key: "UNSAFE_componentWillReceiveProps",
172
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
173
+ var _nextProps$model = nextProps.model;
174
+ _nextProps$model = _nextProps$model === void 0 ? {} : _nextProps$model;
175
+ var _nextProps$model$data = _nextProps$model.data,
176
+ nextData = _nextProps$model$data === void 0 ? [] : _nextProps$model$data,
177
+ _nextProps$model$corr = _nextProps$model.correctAnswer.data,
178
+ nextCorrectAnswerData = _nextProps$model$corr === void 0 ? [] : _nextProps$model$corr;
179
+ var _this$props$model = this.props.model;
180
+ _this$props$model = _this$props$model === void 0 ? {} : _this$props$model;
181
+ var _this$props$model$dat = _this$props$model.data,
182
+ data = _this$props$model$dat === void 0 ? [] : _this$props$model$dat;
183
+ var categories = this.state.categories;
184
+ var nextCategories = [];
185
+
186
+ if (nextData.length > data.length && nextCorrectAnswerData.length > data.length) {
187
+ nextCategories = insertCategory(nextCorrectAnswerData, nextData);
188
+ }
189
+
190
+ if (nextData.length < data.length) {
191
+ var removedIndex = nextData.length; // we need to remove the category from the correct answer data and categories, from the same index it was removed from the data
192
+ // index is a property of the nextData category
193
+
194
+ for (var index = 0; index < nextData.length; index++) {
195
+ if (nextData[index].index !== index) {
196
+ removedIndex = index;
197
+ break;
198
+ }
199
+ }
200
+
201
+ this.props.model.correctAnswer.data.splice(removedIndex, 1);
202
+ nextCategories = removeCategory(categories, nextData, removedIndex);
203
+ }
204
+
205
+ if (!(0, _isEqual["default"])(nextCorrectAnswerData, this.props.model.correctAnswer.data)) {
206
+ nextCategories = nextCorrectAnswerData.map(function (correct, index) {
207
+ return _objectSpread(_objectSpread({}, correct), {}, {
208
+ editable: index < data.length ? data[index].editable : true,
209
+ interactive: index < data.length ? data[index].interactive : true
210
+ });
211
+ });
212
+ } else if ((0, _isEmpty["default"])(nextCategories)) {
213
+ nextCategories = updateCorrectResponseData(nextCorrectAnswerData, nextData);
214
+ nextCorrectAnswerData.map(function (answer, currentIndex) {
215
+ var dataExists = currentIndex < nextData.length;
216
+ var label;
217
+ var value;
218
+ var deletable;
219
+
220
+ if (dataExists) {
221
+ label = nextData[currentIndex].editable ? answer.label : nextData[currentIndex].label;
222
+ value = nextData[currentIndex].interactive ? answer.value : nextData[currentIndex].value;
223
+ } else {
224
+ label = answer.label;
225
+ value = answer.value;
226
+ deletable = true;
227
+ }
228
+
229
+ nextCorrectAnswerData[currentIndex] = {
230
+ label: label,
231
+ value: value
232
+ };
233
+ });
234
+ }
235
+
236
+ if (!(0, _isEqual["default"])(nextCategories, data) || (0, _isEmpty["default"])(nextCategories) && (0, _isEmpty["default"])(data)) {
237
+ this.setState({
238
+ categories: nextCategories
239
+ });
240
+ }
241
+ }
242
+ }, {
98
243
  key: "render",
99
244
  value: function render() {
100
245
  var _this2 = this;
101
246
 
102
247
  var _this$props2 = this.props,
103
- classes = _this$props2.classes,
104
248
  model = _this$props2.model,
105
249
  charts = _this$props2.charts;
250
+ var categories = this.state.categories;
106
251
  return /*#__PURE__*/React.createElement("div", null, "Define Correct Response", /*#__PURE__*/React.createElement("div", {
107
252
  key: "correct-response-graph-".concat(model.correctAnswer.name)
108
253
  }, /*#__PURE__*/React.createElement("p", null, model.correctAnswer.name), /*#__PURE__*/React.createElement(_charting.Chart, {
@@ -111,7 +256,7 @@ var CorrectResponse = /*#__PURE__*/function (_React$Component) {
111
256
  domain: model.domain,
112
257
  range: model.range,
113
258
  charts: charts,
114
- data: model.correctAnswer.data || [],
259
+ data: categories,
115
260
  title: model.title,
116
261
  onDataChange: function onDataChange(data) {
117
262
  return _this2.changeData(data);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/correct-response.jsx"],"names":["styles","theme","container","border","borderRadius","padding","spacing","unit","background","button","marginTop","cursor","width","CorrectResponse","data","props","model","onChange","correctAnswer","classes","charts","name","chartType","graph","domain","range","title","changeData","addCategoryEnabled","categoryDefaultLabel","React","Component","PropTypes","object","isRequired","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,MAAM,EAAE,mBADC;AAETC,MAAAA,YAAY,EAAE,KAFL;AAGTC,MAAAA,OAAO,YAAKJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAA1B,gBAAiCN,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAAtD,OAHE;AAITC,MAAAA,UAAU,EAAE;AAJH,KADY;AAOvBC,IAAAA,MAAM,EAAE;AACNC,MAAAA,SAAS,EAAET,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAD1B;AAENI,MAAAA,MAAM,EAAE,SAFF;AAGNH,MAAAA,UAAU,EAAE,MAHN;AAINH,MAAAA,OAAO,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CAJxB;AAKNK,MAAAA,KAAK,EAAE,aALD;AAMNR,MAAAA,YAAY,EAAE;AANR;AAPe,GAAL;AAAA,CAApB;;IAiBaS,e;;;;;;;;;;;;;;;mGAQE,UAAAC,IAAI,EAAI;AACnB,wBAA4B,MAAKC,KAAjC;AAAA,UAAQC,KAAR,eAAQA,KAAR;AAAA,UAAeC,QAAf,eAAeA,QAAf;;AACA,iBAA0BD,KAAK,IAAI,EAAnC;AAAA,UAAQE,aAAR,QAAQA,aAAR;;AAEAD,MAAAA,QAAQ,iCACHD,KADG;AAENE,QAAAA,aAAa,kCACRA,aADQ;AAEXJ,UAAAA,IAAI,EAAJA;AAFW;AAFP,SAAR;AAOD,K;;;;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ui/core/styles';\nimport { Chart } from '@pie-lib/charting';\n\nconst styles = theme => ({\n container: {\n border: '2px solid #ababab',\n borderRadius: '4px',\n padding: `${theme.spacing.unit * 2}px ${theme.spacing.unit * 4}px`,\n background: '#fafafa'\n },\n button: {\n marginTop: theme.spacing.unit * 3,\n cursor: 'pointer',\n background: '#eee',\n padding: theme.spacing.unit * 2,\n width: 'fit-content',\n borderRadius: '4px'\n }\n});\n\nexport class CorrectResponse extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array\n };\n\n changeData = data => {\n const { model, onChange } = this.props;\n const { correctAnswer } = model || {};\n\n onChange({\n ...model,\n correctAnswer: {\n ...correctAnswer,\n data\n }\n });\n };\n\n render() {\n const { classes, model, charts } = this.props;\n\n return (\n <div>\n Define Correct Response\n <div key={`correct-response-graph-${model.correctAnswer.name}`}>\n <p>{model.correctAnswer.name}</p>\n <Chart\n chartType={model.chartType}\n size={model.graph}\n domain={model.domain}\n range={model.range}\n charts={charts}\n data={model.correctAnswer.data || []}\n title={model.title}\n onDataChange={(data) => this.changeData(data)}\n addCategoryEnabled={model.addCategoryEnabled}\n categoryDefaultLabel={model.categoryDefaultLabel}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(CorrectResponse);\n"],"file":"correct-response.js"}
1
+ {"version":3,"sources":["../src/correct-response.jsx"],"names":["styles","theme","container","border","borderRadius","padding","spacing","unit","background","button","marginTop","cursor","width","addCategoryProps","correctAnswer","data","map","correct","index","editable","length","interactive","deletable","updateCorrectResponseData","correctAnswerData","correctResponseDefinition","forEach","category","currentIndex","label","value","missingCategories","slice","concat","insertCategory","positionToInsert","categoryToInsert","splice","removeCategory","positionToRemove","CorrectResponse","props","model","onChange","keepAttrs","state","categories","nextProps","nextData","nextCorrectAnswerData","nextCategories","removedIndex","answer","dataExists","setState","charts","name","chartType","graph","domain","range","title","changeData","addCategoryEnabled","categ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AK,CAACe,SADnB;AAEE,QAAA,IAAI,EAAEf,KAAK,CAACgB,KAFd;AAGE,QAAA,MAAM,EAAEhB,KAAK,CAACiB,MAHhB;AAIE,QAAA,KAAK,EAAEjB,KAAK,CAACkB,KAJf;AAKE,QAAA,MAAM,EAAEL,MALV;AAME,QAAA,IAAI,EAAET,UANR;AAOE,QAAA,KAAK,EAAEJ,KAAK,CAACmB,KAPf;AAQE,QAAA,YAAY,EAAE,sBAAC9C,IAAD;AAAA,iBAAU,MAAI,CAAC+C,UAAL,CAAgB/C,IAAhB,CAAV;AAAA,SARhB;AASE,QAAA,kBAAkB,EAAE2B,KAAK,CAACqB,kBAT5B;AAUE,QAAA,oBAAoB,EAAErB,KAAK,CAACsB;AAV9B,QAFF,CAFF,CADF;AAoBD;;;EA/HkCC,KAAK,CAACC,S;;;iCAA9B1B,e,eACQ;AACjB2B,EAAAA,OAAO,EAAEC,sBAAUC,MAAV,CAAiBC,UADT;AAEjB5B,EAAAA,KAAK,EAAE0B,sBAAUC,MAAV,CAAiBC,UAFP;AAGjB3B,EAAAA,QAAQ,EAAEyB,sBAAUG,IAAV,CAAeD,UAHR;AAIjBf,EAAAA,MAAM,EAAEa,sBAAUI;AAJD,C;;eAiIN,wBAAWxE,MAAX,EAAmBwC,eAAnB,C","sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Chart } from '@pie-lib/charting';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\n\nconst styles = (theme) => ({\n container: {\n border: '2px solid #ababab',\n borderRadius: '4px',\n padding: `${theme.spacing.unit * 2}px ${theme.spacing.unit * 4}px`,\n background: '#fafafa',\n },\n button: {\n marginTop: theme.spacing.unit * 3,\n cursor: 'pointer',\n background: '#eee',\n padding: theme.spacing.unit * 2,\n width: 'fit-content',\n borderRadius: '4px',\n },\n});\n\nconst addCategoryProps = (correctAnswer, data) => correctAnswer.map((correct, index) => ({ ...correct, editable: index < data.length ? data[index].editable : true, interactive: index < data.length ? data[index].interactive : true, deletable: index >= data.length ? true : false }));\n\nconst updateCorrectResponseData = (correctAnswer, data) => {\n if (!correctAnswer) {\n return data;\n }\n\n const correctAnswerData = [...correctAnswer];\n\n let correctResponseDefinition = [];\n\n data.forEach((category, currentIndex) => {\n const editable = category.editable;\n const interactive = category.interactive;\n\n const label = (editable && correctAnswer[currentIndex]?.label)\n ? correctAnswer[currentIndex].label\n : category.label\n\n const value = (interactive && correctAnswer[currentIndex]?.value)\n ? correctAnswer[currentIndex].value\n : category.value\n\n correctResponseDefinition[currentIndex] = {\n label: label,\n value: value,\n editable: category.editable,\n interactive: category.interactive,\n };\n });\n\n if (correctResponseDefinition.length < correctAnswer.length) {\n const missingCategories = correctAnswerData.slice(correctResponseDefinition.length, correctAnswer.length)\n\n return addCategoryProps(correctResponseDefinition.concat(missingCategories), data);\n }\n\n return correctResponseDefinition;\n};\n\nconst insertCategory = (correctAnswer, data) => {\n const positionToInsert = data.length - 1;\n const { editable, interactive, deletable, ...categoryToInsert } = data[data.length - 1];\n\n correctAnswer.splice(positionToInsert, 0, categoryToInsert);\n const correctAnswerData = [...correctAnswer];\n\n return addCategoryProps(correctAnswerData, data);\n}\n\nconst removeCategory = (correctAnswer, data, positionToRemove) => {\n correctAnswer.splice(positionToRemove, 1);\n\n const correctAnswerData = [...correctAnswer];\n\n return addCategoryProps(correctAnswerData, data);\n}\n\nexport class CorrectResponse extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n categories: updateCorrectResponseData(\n props.model.correctAnswer.data,\n props.model.data\n )\n };\n }\n\n changeData = (data) => {\n const { model, onChange } = this.props;\n const { correctAnswer } = model || {};\n\n onChange({\n ...model,\n correctAnswer: {\n ...correctAnswer,\n data: data.map(({ interactive, editable, index, ...keepAttrs }) => keepAttrs),\n },\n });\n };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n const {\n model: {\n data: nextData = [],\n correctAnswer: { data: nextCorrectAnswerData = [] },\n } = {},\n } = nextProps;\n\n const {\n model: {\n data = [],\n } = {},\n } = this.props;\n\n const { categories } = this.state;\n let nextCategories = [];\n\n if (nextData.length > data.length && nextCorrectAnswerData.length > data.length) {\n nextCategories = insertCategory(nextCorrectAnswerData, nextData);\n }\n\n if (nextData.length < data.length) {\n let removedIndex = nextData.length;\n\n // we need to remove the category from the correct answer data and categories, from the same index it was removed from the data\n // index is a property of the nextData category\n for (let index = 0; index < nextData.length; index++) {\n if (nextData[index].index !== index) {\n removedIndex = index;\n break;\n }\n }\n\n this.props.model.correctAnswer.data.splice(removedIndex, 1);\n nextCategories = removeCategory(categories, nextData, removedIndex);\n }\n\n if (!isEqual(nextCorrectAnswerData, this.props.model.correctAnswer.data)) {\n nextCategories = nextCorrectAnswerData.map((correct, index) => ({ ...correct, editable: index < data.length ? data[index].editable : true, interactive: index < data.length ? data[index].interactive : true }));\n }else if (isEmpty(nextCategories)) {\n nextCategories = updateCorrectResponseData(\n nextCorrectAnswerData,\n nextData\n );\n\n nextCorrectAnswerData.map((answer, currentIndex) => {\n const dataExists = currentIndex < nextData.length;\n let label;\n let value;\n let deletable;\n\n if (dataExists) {\n label = nextData[currentIndex].editable ? answer.label : nextData[currentIndex].label;\n value = nextData[currentIndex].interactive ? answer.value : nextData[currentIndex].value;\n } else {\n label = answer.label;\n value = answer.value;\n deletable = true;\n }\n\n nextCorrectAnswerData[currentIndex] = {\n label: label,\n value: value,\n };\n });\n }\n\n if (!isEqual(nextCategories, data) || (isEmpty(nextCategories) && isEmpty(data))) {\n this.setState({ categories: nextCategories });\n }\n }\n\n render() {\n const { model, charts } = this.props;\n const { categories } = this.state;\n\n return (\n <div>\n Define Correct Response\n <div key={`correct-response-graph-${model.correctAnswer.name}`}>\n <p>{model.correctAnswer.name}</p>\n <Chart\n chartType={model.chartType}\n size={model.graph}\n domain={model.domain}\n range={model.range}\n charts={charts}\n data={categories}\n title={model.title}\n onDataChange={(data) => this.changeData(data)}\n addCategoryEnabled={model.addCategoryEnabled}\n categoryDefaultLabel={model.categoryDefaultLabel}\n />\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(CorrectResponse);\n"],"file":"correct-response.js"}
@@ -73,6 +73,16 @@ var _default = {
73
73
  title: {
74
74
  settings: false,
75
75
  label: 'Graph Title'
76
+ },
77
+ maxImageWidth: {
78
+ teacherInstructions: 300,
79
+ prompt: 300,
80
+ rationale: 300
81
+ },
82
+ maxImageHeight: {
83
+ teacherInstructions: 300,
84
+ prompt: 300,
85
+ rationale: 300
76
86
  }
77
87
  }
78
88
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/defaults.js"],"names":["model","addCategoryEnabled","categoryDefaultLabel","chartType","correctAnswer","data","domain","label","graph","width","height","prompt","promptEnabled","rationale","range","max","min","scoringType","title","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","configuration","spellCheck","settings","enabled","studentInstructions","teacherInstructions"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;eAEe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,kBAAkB,EAAE,IADf;AAELC,IAAAA,oBAAoB,EAAE,UAFjB;AAGLC,IAAAA,SAAS,EAAE,WAHN;AAILC,IAAAA,aAAa,EAAE,EAJV;AAKLC,IAAAA,IAAI,EAAE,EALD;AAMLC,IAAAA,MAAM,EAAE;AACNC,MAAAA,KAAK,EAAE;AADD,KANH;AASLC,IAAAA,KAAK,EAAE;AACLC,MAAAA,KAAK,EAAE,GADF;AAELC,MAAAA,MAAM,EAAE;AAFH,KATF;AAaLC,IAAAA,MAAM,EAAE,sBAbH;AAcLC,IAAAA,aAAa,EAAE,IAdV;AAeLC,IAAAA,SAAS,EAAE,sBAfN;AAgBLC,IAAAA,KAAK,EAAE;AACLP,MAAAA,KAAK,EAAE,QADF;AAELQ,MAAAA,GAAG,EAAE,GAFA;AAGLC,MAAAA,GAAG,EAAE;AAHA,KAhBF;AAqBLC,IAAAA,WAAW,EAAE,gBArBR;AAsBLC,IAAAA,KAAK,EAAE,kBAtBF;AAuBLC,IAAAA,gBAAgB,EAAE,IAvBb;AAwBLC,IAAAA,0BAA0B,EAAE,IAxBvB;AAyBLC,IAAAA,0BAA0B,EAAE;AAzBvB,GADM;AA4BbC,EAAAA,aAAa,EAAE;AACbC,IAAAA,UAAU,EAAE;AACVhB,MAAAA,KAAK,EAAE,YADG;AAEViB,MAAAA,QAAQ,EAAC,KAFC;AAGVC,MAAAA,OAAO,EAAC;AAHE,KADC;AAMbd,IAAAA,MAAM,EAAE;AACNa,MAAAA,QAAQ,EAAE,IADJ;AAENjB,MAAAA,KAAK,EAAE;AAFD,KANK;AAUbM,IAAAA,SAAS,EAAE;AACTW,MAAAA,QAAQ,EAAE,IADD;AAETjB,MAAAA,KAAK,EAAE;AAFE,KAVE;AAcbU,IAAAA,WAAW,EAAE;AACXO,MAAAA,QAAQ,EAAE,KADC;AAEXjB,MAAAA,KAAK,EAAE;AAFI,KAdA;AAkBbmB,IAAAA,mBAAmB,EAAE;AACnBF,MAAAA,QAAQ,EAAE,KADS;AAEnBjB,MAAAA,KAAK,EAAE;AAFY,KAlBR;AAsBboB,IAAAA,mBAAmB,EAAE;AACnBH,MAAAA,QAAQ,EAAE,IADS;AAEnBjB,MAAAA,KAAK,EAAE;AAFY,KAtBR;AA0BbW,IAAAA,KAAK,EAAE;AACLM,MAAAA,QAAQ,EAAE,KADL;AAELjB,MAAAA,KAAK,EAAE;AAFF;AA1BM;AA5BF,C","sourcesContent":["/**\n * NOTE: There's no functionality described for graphTitle,\n * rationale, scoringType, studentInstructions, teacherInstructions\n * so there's no implementation (they are only added in model)\n */\n\n\n// const createCategory = (label, value) => ({\n// label,\n// value,\n// interactive: true,\n// editable: true\n// });\n\nexport default {\n model: {\n addCategoryEnabled: true,\n categoryDefaultLabel: 'Category',\n chartType: 'lineCross',\n correctAnswer: {},\n data: [],\n domain: {\n label: 'Fruits',\n },\n graph: {\n width: 480,\n height: 480\n },\n prompt: 'Here goes item stem!',\n promptEnabled: true,\n rationale: 'Rationale goes here!',\n range: {\n label: 'Amount',\n max: 5.5,\n min: 0,\n },\n scoringType: 'all or nothing',\n title: 'This is a chart!',\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n },\n configuration: {\n spellCheck: {\n label: 'Spellcheck',\n settings:false,\n enabled:true\n },\n prompt: {\n settings: true,\n label: 'Item Stem'\n },\n rationale: {\n settings: true,\n label: 'Rationale'\n },\n scoringType: {\n settings: false,\n label: 'Scoring Type'\n },\n studentInstructions: {\n settings: false,\n label: 'Student Instructions'\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions'\n },\n title: {\n settings: false,\n label: 'Graph Title'\n }\n }\n};\n"],"file":"defaults.js"}
1
+ {"version":3,"sources":["../src/defaults.js"],"names":["model","addCategoryEnabled","categoryDefaultLabel","chartType","correctAnswer","data","domain","label","graph","width","height","prompt","promptEnabled","rationale","range","max","min","scoringType","title","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","configuration","spellCheck","settings","enabled","studentInstructions","teacherInstructions","maxImageWidth","maxImageHeight"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;eAEe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,kBAAkB,EAAE,IADf;AAELC,IAAAA,oBAAoB,EAAE,UAFjB;AAGLC,IAAAA,SAAS,EAAE,WAHN;AAILC,IAAAA,aAAa,EAAE,EAJV;AAKLC,IAAAA,IAAI,EAAE,EALD;AAMLC,IAAAA,MAAM,EAAE;AACNC,MAAAA,KAAK,EAAE;AADD,KANH;AASLC,IAAAA,KAAK,EAAE;AACLC,MAAAA,KAAK,EAAE,GADF;AAELC,MAAAA,MAAM,EAAE;AAFH,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AE,GADR;AAEbhB,MAAAA,MAAM,EAAE,GAFK;AAGbE,MAAAA,SAAS,EAAE;AAHE,KA9BF;AAmCbgB,IAAAA,cAAc,EAAE;AACdF,MAAAA,mBAAmB,EAAE,GADP;AAEdhB,MAAAA,MAAM,EAAE,GAFM;AAGdE,MAAAA,SAAS,EAAE;AAHG;AAnCH;AA5BF,C","sourcesContent":["/**\n * NOTE: There's no functionality described for graphTitle,\n * rationale, scoringType, studentInstructions, teacherInstructions\n * so there's no implementation (they are only added in model)\n */\n\n\n// const createCategory = (label, value) => ({\n// label,\n// value,\n// interactive: true,\n// editable: true\n// });\n\nexport default {\n model: {\n addCategoryEnabled: true,\n categoryDefaultLabel: 'Category',\n chartType: 'lineCross',\n correctAnswer: {},\n data: [],\n domain: {\n label: 'Fruits',\n },\n graph: {\n width: 480,\n height: 480\n },\n prompt: 'Here goes item stem!',\n promptEnabled: true,\n rationale: 'Rationale goes here!',\n range: {\n label: 'Amount',\n max: 5.5,\n min: 0,\n },\n scoringType: 'all or nothing',\n title: 'This is a chart!',\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n },\n configuration: {\n spellCheck: {\n label: 'Spellcheck',\n settings:false,\n enabled:true\n },\n prompt: {\n settings: true,\n label: 'Item Stem'\n },\n rationale: {\n settings: true,\n label: 'Rationale'\n },\n scoringType: {\n settings: false,\n label: 'Scoring Type'\n },\n studentInstructions: {\n settings: false,\n label: 'Student Instructions'\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions'\n },\n title: {\n settings: false,\n label: 'Graph Title'\n },\n maxImageWidth: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n },\n maxImageHeight: {\n teacherInstructions: 300,\n prompt: 300,\n rationale: 300,\n }\n }\n};\n"],"file":"defaults.js"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getLabelValues = exports.getGridValues = exports.applyConstraints = exports.VALID_LABEL_VALUES = void 0;
9
+
10
+ var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
11
+
12
+ // this file is almost duplicated from graphing/configure/src/utils.js; the same logic must be used in charting
13
+ var VALID_GRID_VALUES = [0.01, 0.02, 0.04, 0.05, 0.0625, 0.1, 0.125, 0.2, 0.25, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 20, 40, 50, 64, 100, 500, 1000]; // same as VALID_GRID_VALUES but next values are excluded: 0.04, 0.0625, 0.125, 3, 4, 8, 12, 15, 40, 64
14
+
15
+ var PREFERRED_VALID_GRID_VALUES = [0.01, 0.02, 0.05, 0.1, 0.2, 0.25, 0.5, 1, 2, 5, 10, 20, 50, 100, 500, 1000];
16
+ var VALID_LABEL_VALUES = {
17
+ '0.01': [0, 0.01, 0.02, 0.04, 0.05, 0.1],
18
+ '0.02': [0, 0.02, 0.04, 0.1],
19
+ '0.04': [0, 0.04, 0.08, 0.16, 0.2],
20
+ '0.05': [0, 0.05, 0.1, 0.2, 0.25],
21
+ '0.0625': [0, 0.0625, 0.125, 0.25, 0.5],
22
+ '0.1': [0, 0.1, 0.2, 0.4, 0.5, 1],
23
+ '0.125': [0, 0.125, 0.25, 0.5, 1],
24
+ '0.2': [0, 0.2, 0.5, 0.1],
25
+ '0.25': [0, 0.25, 0.5, 1, 2],
26
+ '0.5': [0, 0.5, 1, 2],
27
+ '1': [0, 1, 2, 4, 5, 10],
28
+ '2': [0, 2, 4, 8, 10],
29
+ '3': [0, 3, 6, 12, 15],
30
+ '4': [0, 4, 8, 16, 20],
31
+ '5': [0, 5, 10, 20, 25],
32
+ '8': [0, 8, 16, 32, 40, 64],
33
+ '10': [0, 10, 20, 40, 50, 100],
34
+ '12': [0, 12, 24],
35
+ '15': [0, 15, 30, 60],
36
+ '20': [0, 20, 40, 80, 100],
37
+ '40': [0, 40, 80, 160, 200],
38
+ '50': [0, 50, 100, 200, 250],
39
+ '64': [0, 64, 128],
40
+ '100': [0, 100, 200, 400, 500],
41
+ '500': [0, 500, 1000, 2500],
42
+ '1000': [0, 1000, 2000, 4000, 5000]
43
+ };
44
+ exports.VALID_LABEL_VALUES = VALID_LABEL_VALUES;
45
+
46
+ var getGridValues = function getGridValues(axis, size) {
47
+ var prefferedValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
48
+ var minValue = 10 * (axis.max - axis.min) / size;
49
+ var maxValue = minValue * 10;
50
+ var values = prefferedValues ? PREFERRED_VALID_GRID_VALUES : VALID_GRID_VALUES;
51
+ return values.filter(function (value) {
52
+ return value >= minValue && value <= maxValue;
53
+ });
54
+ };
55
+
56
+ exports.getGridValues = getGridValues;
57
+
58
+ var getLabelValues = function getLabelValues(value) {
59
+ return VALID_LABEL_VALUES[value] || [];
60
+ };
61
+
62
+ exports.getLabelValues = getLabelValues;
63
+
64
+ var applyConstraints = function applyConstraints(axis, size, oldGridValues, oldLabelValues) {
65
+ var gridValues = getGridValues(axis, size);
66
+ var labelValues = getLabelValues(axis.step || 1);
67
+
68
+ if (!(0, _isEqual["default"])(oldGridValues, gridValues) && !gridValues.includes(axis.step)) {
69
+ var preferredValues = getGridValues(axis, size, true);
70
+ var lowestValue = preferredValues[0] || 1;
71
+ axis.step = lowestValue;
72
+ labelValues = getLabelValues(lowestValue);
73
+
74
+ if (!labelValues.includes(axis.labelStep)) {
75
+ axis.labelStep = lowestValue;
76
+ }
77
+
78
+ return {
79
+ gridValues: gridValues,
80
+ labelValues: labelValues
81
+ };
82
+ }
83
+
84
+ if (!(0, _isEqual["default"])(oldLabelValues, labelValues) && !labelValues.includes(axis.labelStep)) {
85
+ axis.labelStep = axis.step;
86
+ }
87
+
88
+ return {
89
+ gridValues: gridValues,
90
+ labelValues: labelValues
91
+ };
92
+ };
93
+
94
+ exports.applyConstraints = applyConstraints;
95
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils.js"],"names":["VALID_GRID_VALUES","PREFERRED_VALID_GRID_VALUES","VALID_LABEL_VALUES","getGridValues","axis","size","prefferedValues","minValue","max","min","maxValue","values","filter","value","getLabelValues","applyConstraints","oldGridValues","oldLabelValues","gridValues","labelValues","step","includes","preferredValues","lowestValue","labelStep"],"mappings":";;;;;;;;;AACA;;AADA;AAGA,IAAMA,iBAAiB,GAAG,CACxB,IADwB,EAClB,IADkB,EACZ,IADY,EACN,IADM,EACA,MADA,EACQ,GADR,EACa,KADb,EACoB,GADpB,EACyB,IADzB,EAC+B,GAD/B,EAExB,CAFwB,EAErB,CAFqB,EAElB,CAFkB,EAEf,CAFe,EAEZ,CAFY,EAET,CAFS,EAEN,EAFM,EAEF,EAFE,EAEE,EAFF,EAEM,EAFN,EAEU,EAFV,EAEc,EAFd,EAEkB,EAFlB,EAEsB,GAFtB,EAE2B,GAF3B,EAEgC,IAFhC,CAA1B,C,CAKA;;AACA,IAAMC,2BAA2B,GAAG,CAAE,IAAF,EAAQ,IAAR,EAAc,IAAd,EAAoB,GAApB,EAAyB,GAAzB,EAA8B,IAA9B,EAAoC,GAApC,EAAyC,CAAzC,EAA4C,CAA5C,EAA+C,CAA/C,EAAkD,EAAlD,EAAsD,EAAtD,EAA0D,EAA1D,EAA8D,GAA9D,EAAmE,GAAnE,EAAwE,IAAxE,CAApC;AAEO,IAAMC,kBAAkB,GAAG;AAChC,UAAQ,CAAC,CAAD,EAAI,IAAJ,EAAU,IAAV,EAAgB,IAAhB,EAAsB,IAAtB,EAA4B,GAA5B,CADwB;AAEhC,UAAQ,CAAC,CAAD,EAAI,IAAJ,EAAU,IAAV,EAAgB,GAAhB,CAFwB;AAGhC,UAAQ,CAAC,CAAD,EAAI,IAAJ,EAAU,IAAV,EAAgB,IAAhB,EAAsB,GAAtB,CAHwB;AAIhC,UAAQ,CAAC,CAAD,EAAI,IAAJ,EAAU,GAAV,EAAe,GAAf,EAAoB,IAApB,CAJwB;AAKhC,YAAU,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OC,IAAP,EAAaW,aAAb,EAA4BC,cAA5B,EAA+C;AAC7E,MAAMC,UAAU,GAAGf,aAAa,CAACC,IAAD,EAAOC,IAAP,CAAhC;AACA,MAAIc,WAAW,GAAGL,cAAc,CAACV,IAAI,CAACgB,IAAL,IAAa,CAAd,CAAhC;;AAEA,MAAI,CAAC,yBAAQJ,aAAR,EAAuBE,UAAvB,CAAD,IAAuC,CAACA,UAAU,CAACG,QAAX,CAAoBjB,IAAI,CAACgB,IAAzB,CAA5C,EAA4E;AAC1E,QAAME,eAAe,GAAGnB,aAAa,CAACC,IAAD,EAAOC,IAAP,EAAa,IAAb,CAArC;AACA,QAAMkB,WAAW,GAAGD,eAAe,CAAC,CAAD,CAAf,IAAsB,CAA1C;AAEAlB,IAAAA,IAAI,CAACgB,IAAL,GAAYG,WAAZ;AACAJ,IAAAA,WAAW,GAAGL,cAAc,CAACS,WAAD,CAA5B;;AAEA,QAAI,CAACJ,WAAW,CAACE,QAAZ,CAAqBjB,IAAI,CAACoB,SAA1B,CAAL,EAA2C;AACzCpB,MAAAA,IAAI,CAACoB,SAAL,GAAiBD,WAAjB;AACD;;AAED,WAAO;AAAEL,MAAAA,UAAU,EAAVA,UAAF;AAAcC,MAAAA,WAAW,EAAXA;AAAd,KAAP;AACD;;AAED,MAAI,CAAC,yBAAQF,cAAR,EAAwBE,WAAxB,CAAD,IAAyC,CAACA,WAAW,CAACE,QAAZ,CAAqBjB,IAAI,CAACoB,SAA1B,CAA9C,EAAoF;AAClFpB,IAAAA,IAAI,CAACoB,SAAL,GAAiBpB,IAAI,CAACgB,IAAtB;AACD;;AAED,SAAO;AAAEF,IAAAA,UAAU,EAAVA,UAAF;AAAcC,IAAAA,WAAW,EAAXA;AAAd,GAAP;AACD,CAvBM","sourcesContent":["// this file is almost duplicated from graphing/configure/src/utils.js; the same logic must be used in charting\nimport isEqual from 'lodash/isEqual';\n\nconst VALID_GRID_VALUES = [\n 0.01, 0.02, 0.04, 0.05, 0.0625, 0.1, 0.125, 0.2, 0.25, 0.5,\n 1, 2, 3, 4, 5, 8, 10, 12, 15, 20, 40, 50, 64, 100, 500, 1000\n];\n\n// same as VALID_GRID_VALUES but next values are excluded: 0.04, 0.0625, 0.125, 3, 4, 8, 12, 15, 40, 64\nconst PREFERRED_VALID_GRID_VALUES = [ 0.01, 0.02, 0.05, 0.1, 0.2, 0.25, 0.5, 1, 2, 5, 10, 20, 50, 100, 500, 1000 ];\n\nexport const VALID_LABEL_VALUES = {\n '0.01': [0, 0.01, 0.02, 0.04, 0.05, 0.1],\n '0.02': [0, 0.02, 0.04, 0.1],\n '0.04': [0, 0.04, 0.08, 0.16, 0.2],\n '0.05': [0, 0.05, 0.1, 0.2, 0.25],\n '0.0625': [0, 0.0625, 0.125, 0.25, 0.5],\n '0.1': [0, 0.1, 0.2, 0.4, 0.5, 1],\n '0.125': [0, 0.125, 0.25, 0.5, 1],\n '0.2': [0, 0.2, 0.5, 0.1],\n '0.25': [0, 0.25, 0.5, 1, 2],\n '0.5': [0, 0.5, 1, 2],\n '1': [0, 1, 2, 4, 5, 10],\n '2': [0, 2, 4, 8, 10],\n '3': [0, 3, 6, 12, 15],\n '4': [0, 4, 8, 16, 20],\n '5': [0, 5, 10, 20, 25],\n '8': [0, 8, 16, 32, 40, 64],\n '10': [0, 10, 20, 40, 50, 100],\n '12': [0, 12, 24],\n '15': [0, 15, 30, 60],\n '20': [0, 20, 40, 80, 100],\n '40': [0, 40, 80, 160, 200],\n '50': [0, 50, 100, 200, 250],\n '64': [0, 64, 128],\n '100': [0, 100, 200, 400, 500],\n '500': [0, 500, 1000, 2500],\n '1000': [0, 1000, 2000, 4000, 5000]\n};\n\nexport const getGridValues = (axis, size, prefferedValues = false) => {\n const minValue = 10 * (axis.max - axis.min) / size;\n const maxValue = minValue * 10;\n const values = prefferedValues ? PREFERRED_VALID_GRID_VALUES : VALID_GRID_VALUES;\n\n return values.filter(value => value >= minValue && value <= maxValue);\n};\n\nexport const getLabelValues = value => VALID_LABEL_VALUES[value] || [];\n\nexport const applyConstraints = (axis, size, oldGridValues, oldLabelValues) => {\n const gridValues = getGridValues(axis, size);\n let labelValues = getLabelValues(axis.step || 1);\n\n if (!isEqual(oldGridValues, gridValues) && !gridValues.includes(axis.step)) {\n const preferredValues = getGridValues(axis, size, true);\n const lowestValue = preferredValues[0] || 1;\n\n axis.step = lowestValue;\n labelValues = getLabelValues(lowestValue);\n\n if (!labelValues.includes(axis.labelStep)) {\n axis.labelStep = lowestValue;\n }\n\n return { gridValues, labelValues };\n }\n\n if (!isEqual(oldLabelValues, labelValues) && !labelValues.includes(axis.labelStep)) {\n axis.labelStep = axis.step;\n }\n\n return { gridValues, labelValues };\n};"],"file":"utils.js"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/charting-configure",
3
3
  "private": true,
4
- "version": "3.0.0",
4
+ "version": "5.0.1",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -9,9 +9,9 @@
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.2",
11
11
  "@pie-framework/pie-configure-events": "^1.2.0",
12
- "@pie-lib/charting": "^5.0.0",
13
- "@pie-lib/config-ui": "^10.13.3",
14
- "@pie-lib/editable-html": "^7.22.6",
12
+ "@pie-lib/charting": "^5.1.2",
13
+ "@pie-lib/config-ui": "^11.0.6",
14
+ "@pie-lib/editable-html": "^9.0.2",
15
15
  "classnames": "^2.2.5",
16
16
  "debug": "^4.1.1",
17
17
  "prop-types": "^15.6.2",
@@ -120,6 +120,48 @@
120
120
  }
121
121
  }
122
122
  },
123
+ "maxImageWidth": {
124
+ "title": "ConfigureMaxImageDimensionsProp",
125
+ "type": "object",
126
+ "properties": {
127
+ "teacherInstructions": {
128
+ "description": "Indicates the max dimension for images in teacher instructions",
129
+ "type": "number",
130
+ "title": "teacherInstructions"
131
+ },
132
+ "prompt": {
133
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
134
+ "type": "number",
135
+ "title": "prompt"
136
+ },
137
+ "rationale": {
138
+ "description": "Indicates the max dimension for images in rationale",
139
+ "type": "number",
140
+ "title": "rationale"
141
+ }
142
+ }
143
+ },
144
+ "maxImageHeight": {
145
+ "title": "ConfigureMaxImageDimensionsProp",
146
+ "type": "object",
147
+ "properties": {
148
+ "teacherInstructions": {
149
+ "description": "Indicates the max dimension for images in teacher instructions",
150
+ "type": "number",
151
+ "title": "teacherInstructions"
152
+ },
153
+ "prompt": {
154
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
155
+ "type": "number",
156
+ "title": "prompt"
157
+ },
158
+ "rationale": {
159
+ "description": "Indicates the max dimension for images in rationale",
160
+ "type": "number",
161
+ "title": "rationale"
162
+ }
163
+ }
164
+ },
123
165
  "showPrompt": {
124
166
  "description": "Determines whether prompt field will be displayed or not",
125
167
  "default": true,
@@ -176,6 +218,27 @@
176
218
  "title": "enabled"
177
219
  }
178
220
  }
221
+ },
222
+ "ConfigureMaxImageDimensionsProp": {
223
+ "title": "ConfigureMaxImageDimensionsProp",
224
+ "type": "object",
225
+ "properties": {
226
+ "teacherInstructions": {
227
+ "description": "Indicates the max dimension for images in teacher instructions",
228
+ "type": "number",
229
+ "title": "teacherInstructions"
230
+ },
231
+ "prompt": {
232
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
233
+ "type": "number",
234
+ "title": "prompt"
235
+ },
236
+ "rationale": {
237
+ "description": "Indicates the max dimension for images in rationale",
238
+ "type": "number",
239
+ "title": "rationale"
240
+ }
241
+ }
179
242
  }
180
243
  },
181
244
  "$schema": "http://json-schema.org/draft-07/schema#"
@@ -91,6 +91,38 @@ Indicates the label for the item that has to be displayed in the Settings Panel
91
91
  Indicates the value of the item if it affects config-ui
92
92
  (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
93
93
 
94
+ # `maxImageWidth` (object)
95
+
96
+ Properties of the `maxImageWidth` object:
97
+
98
+ ## `teacherInstructions` (number)
99
+
100
+ Indicates the max dimension for images in teacher instructions
101
+
102
+ ## `prompt` (number)
103
+
104
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
105
+
106
+ ## `rationale` (number)
107
+
108
+ Indicates the max dimension for images in rationale
109
+
110
+ # `maxImageHeight` (object)
111
+
112
+ Properties of the `maxImageHeight` object:
113
+
114
+ ## `teacherInstructions` (number)
115
+
116
+ Indicates the max dimension for images in teacher instructions
117
+
118
+ ## `prompt` (number)
119
+
120
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
121
+
122
+ ## `rationale` (number)
123
+
124
+ Indicates the max dimension for images in rationale
125
+
94
126
  # `showPrompt` (boolean)
95
127
 
96
128
  Determines whether prompt field will be displayed or not
@@ -142,4 +174,20 @@ Indicates the label for the item that has to be displayed in the Settings Panel
142
174
  ### `enabled` (boolean)
143
175
 
144
176
  Indicates the value of the item if it affects config-ui
145
- (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
177
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
178
+
179
+ ## `ConfigureMaxImageDimensionsProp` (object)
180
+
181
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
182
+
183
+ ### `teacherInstructions` (number)
184
+
185
+ Indicates the max dimension for images in teacher instructions
186
+
187
+ ### `prompt` (number)
188
+
189
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
190
+
191
+ ### `rationale` (number)
192
+
193
+ Indicates the max dimension for images in rationale
@@ -8,21 +8,15 @@ exports.model = (id, element) => ({
8
8
  data: [
9
9
  {
10
10
  label: 'A',
11
- value: 1,
12
- interactive: false,
13
- editable: false
11
+ value: 1
14
12
  },
15
13
  {
16
14
  label: 'B',
17
- value: 1,
18
- interactive: true,
19
- editable: false
15
+ value: 1
20
16
  },
21
17
  {
22
18
  label: 'C',
23
- value: 1,
24
- interactive: true,
25
- editable: false
19
+ value: 1
26
20
  },
27
21
  ]
28
22
  },
@@ -548,6 +548,27 @@
548
548
  }
549
549
  }
550
550
  },
551
+ "ConfigureMaxImageDimensionsProp": {
552
+ "title": "ConfigureMaxImageDimensionsProp",
553
+ "type": "object",
554
+ "properties": {
555
+ "teacherInstructions": {
556
+ "description": "Indicates the max dimension for images in teacher instructions",
557
+ "type": "number",
558
+ "title": "teacherInstructions"
559
+ },
560
+ "prompt": {
561
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
562
+ "type": "number",
563
+ "title": "prompt"
564
+ },
565
+ "rationale": {
566
+ "description": "Indicates the max dimension for images in rationale",
567
+ "type": "number",
568
+ "title": "rationale"
569
+ }
570
+ }
571
+ },
551
572
  "Answer": {
552
573
  "title": "Answer",
553
574
  "type": "object",
@@ -197,6 +197,22 @@ Indicates the label for the item that has to be displayed in the Settings Panel
197
197
  Indicates the value of the item if it affects config-ui
198
198
  (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
199
199
 
200
+ ## `ConfigureMaxImageDimensionsProp` (object)
201
+
202
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
203
+
204
+ ### `teacherInstructions` (number)
205
+
206
+ Indicates the max dimension for images in teacher instructions
207
+
208
+ ### `prompt` (number)
209
+
210
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
211
+
212
+ ### `rationale` (number)
213
+
214
+ Indicates the max dimension for images in rationale
215
+
200
216
  ## `Answer` (object)
201
217
 
202
218
  Properties of the `Answer` object:
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "3.0.0",
7
+ "version": "5.0.1",
8
8
  "description": "",
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -13,10 +13,10 @@
13
13
  "dependencies": {
14
14
  "@material-ui/core": "^3.9.2",
15
15
  "@pie-framework/pie-player-events": "^0.1.0",
16
- "@pie-lib/charting": "^5.0.0",
17
- "@pie-lib/correct-answer-toggle": "^2.3.39",
18
- "@pie-lib/math-rendering": "^2.4.3",
19
- "@pie-lib/render-ui": "^4.12.9",
16
+ "@pie-lib/charting": "^5.1.2",
17
+ "@pie-lib/correct-answer-toggle": "^2.3.41",
18
+ "@pie-lib/math-rendering": "^2.4.5",
19
+ "@pie-lib/render-ui": "^4.13.1",
20
20
  "classnames": "^2.2.5",
21
21
  "debug": "^4.1.1",
22
22
  "lodash": "^4.17.15",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "author": "",
27
27
  "license": "ISC",
28
- "gitHead": "2b16a41c0627a27ee758af9285afde4d226dc12b",
28
+ "gitHead": "30ddb939cb470e2b4f0281aec44143a9188e3106",
29
29
  "main": "lib/index.js",
30
30
  "module": "src/index.js"
31
31
  }
@@ -1,72 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _react = _interopRequireDefault(require("react"));
11
-
12
- var _styles = require("@material-ui/core/styles");
13
-
14
- var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
15
-
16
- var _FormControl = _interopRequireDefault(require("@material-ui/core/FormControl"));
17
-
18
- var _InputLabel = _interopRequireDefault(require("@material-ui/core/InputLabel"));
19
-
20
- var _Select = _interopRequireDefault(require("@material-ui/core/Select"));
21
-
22
- var _OutlinedInput = _interopRequireDefault(require("@material-ui/core/OutlinedInput"));
23
-
24
- var ChartType = (0, _styles.withStyles)(function (theme) {
25
- return {
26
- formControl: {
27
- width: '100%'
28
- },
29
- chartType: {
30
- paddingTop: theme.spacing.unit * 2,
31
- paddingBottom: theme.spacing.unit * 2
32
- },
33
- chartTypeLabel: {
34
- transform: 'translate(0px, -16px) scale(0.75) !important'
35
- }
36
- };
37
- })(function (_ref) {
38
- var onChange = _ref.onChange,
39
- value = _ref.value,
40
- classes = _ref.classes;
41
- return /*#__PURE__*/_react["default"].createElement("div", {
42
- className: classes.chartType
43
- }, /*#__PURE__*/_react["default"].createElement(_FormControl["default"], {
44
- variant: "outlined",
45
- className: classes.formControl
46
- }, /*#__PURE__*/_react["default"].createElement(_InputLabel["default"], {
47
- htmlFor: "type-helper",
48
- className: classes.chartTypeLabel
49
- }, "ChartType"), /*#__PURE__*/_react["default"].createElement(_Select["default"], {
50
- value: value,
51
- onChange: onChange,
52
- input: /*#__PURE__*/_react["default"].createElement(_OutlinedInput["default"], {
53
- name: "type",
54
- id: "type-helper"
55
- })
56
- }, /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
57
- value: 'histogram'
58
- }, "Histogram"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
59
- value: 'bar'
60
- }, "Bar"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
61
- value: 'lineDot'
62
- }, "Line Dot"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
63
- value: 'lineCross'
64
- }, "Line Cross"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
65
- value: 'dotPlot'
66
- }, "Dot Plot"), /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
67
- value: 'linePlot'
68
- }, "Line Plot"))));
69
- });
70
- var _default = ChartType;
71
- exports["default"] = _default;
72
- //# sourceMappingURL=chart-type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/chart-type.js"],"names":["ChartType","theme","formControl","width","chartType","paddingTop","spacing","unit","paddingBottom","chartTypeLabel","transform","onChange","value","classes"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,SAAS,GAAG,wBAAW,UAAAC,KAAK;AAAA,SAAK;AACrCC,IAAAA,WAAW,EAAE;AACXC,MAAAA,KAAK,EAAE;AADI,KADwB;AAIrCC,IAAAA,SAAS,EAAE;AACTC,MAAAA,UAAU,EAAEJ,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB,CADxB;AAETC,MAAAA,aAAa,EAAEP,KAAK,CAACK,OAAN,CAAcC,IAAd,GAAqB;AAF3B,KAJ0B;AAQrCE,IAAAA,cAAc,EAAE;AACdC,MAAAA,SAAS,EAAE;AADG;AARqB,GAAL;AAAA,CAAhB,EAWd,gBAAkC;AAAA,MAA/BC,QAA+B,QAA/BA,QAA+B;AAAA,MAArBC,KAAqB,QAArBA,KAAqB;AAAA,MAAdC,OAAc,QAAdA,OAAc;AACpC,sBACE;AAAK,IAAA,SAAS,EAAEA,OAAO,CAACT;AAAxB,kBACE,gCAAC,uBAAD;AAAa,IAAA,OAAO,EAAC,UAArB;AAAgC,IAAA,SAAS,EAAES,OAAO,CAACX;AAAnD,kBACE,gCAAC,sBAAD;AAAY,IAAA,OAAO,EAAC,aAApB;AAAkC,IAAA,SAAS,EAAEW,OAAO,CAACJ;AAArD,iBADF,eAGE,gCAAC,kBAAD;AACE,IAAA,KAAK,EAAEG,KADT;AAEE,IAAA,QAAQ,EAAED,QAFZ;AAGE,IAAA,KAAK,eAAE,gCAAC,yBAAD;AAAe,MAAA,IAAI,EAAC,MAApB;AAA2B,MAAA,EAAE,EAAC;AAA9B;AAHT,kBAKE,gCAAC,oBAAD;AAAU,IAAA,KAAK,EAAE;AAAjB,iBALF,eAME,gCAAC,oBAAD;AAAU,IAAA,KAAK,EAAE;AAAjB,WANF,eAOE,gCAAC,oBAAD;AAAU,IAAA,KAAK,EAAE;AAAjB,gBAPF,eAQE,gCAAC,oBAAD;AAAU,IAAA,KAAK,EAAE;AAAjB,kBARF,eASE,gCAAC,oBAAD;AAAU,IAAA,KAAK,EAAE;AAAjB,gBATF,eAUE,gCAAC,oBAAD;AAAU,IAAA,KAAK,EAAE;AAAjB,iBAVF,CAHF,CADF,CADF;AAoBD,CAhCiB,CAAlB;eAkCeX,S","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport MenuItem from '@material-ui/core/MenuItem';\nimport FormControl from '@material-ui/core/FormControl';\nimport InputLabel from '@material-ui/core/InputLabel';\nimport Select from '@material-ui/core/Select';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\n\nconst ChartType = withStyles(theme => ({\n formControl: {\n width: '100%'\n },\n chartType: {\n paddingTop: theme.spacing.unit * 2,\n paddingBottom: theme.spacing.unit * 2\n },\n chartTypeLabel: {\n transform: 'translate(0px, -16px) scale(0.75) !important'\n }\n}))(({ onChange, value, classes }) => {\n return (\n <div className={classes.chartType}>\n <FormControl variant=\"outlined\" className={classes.formControl}>\n <InputLabel htmlFor=\"type-helper\" className={classes.chartTypeLabel}>ChartType</InputLabel>\n\n <Select\n value={value}\n onChange={onChange}\n input={<OutlinedInput name=\"type\" id=\"type-helper\" />}\n >\n <MenuItem value={'histogram'}>Histogram</MenuItem>\n <MenuItem value={'bar'}>Bar</MenuItem>\n <MenuItem value={'lineDot'}>Line Dot</MenuItem>\n <MenuItem value={'lineCross'}>Line Cross</MenuItem>\n <MenuItem value={'dotPlot'}>Dot Plot</MenuItem>\n <MenuItem value={'linePlot'}>Line Plot</MenuItem>\n </Select>\n </FormControl>\n </div>\n );\n});\n\nexport default ChartType;\n"],"file":"chart-type.js"}