@pie-element/charting 12.1.2-next.5 → 12.1.3
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.json +487 -0
- package/CHANGELOG.md +2007 -0
- package/LICENSE.md +5 -0
- package/README.md +1 -0
- package/configure/CHANGELOG.json +292 -0
- package/configure/CHANGELOG.md +1774 -0
- package/configure/lib/charting-config.js +192 -0
- package/configure/lib/charting-config.js.map +1 -0
- package/configure/lib/configure.js +312 -0
- package/configure/lib/configure.js.map +1 -0
- package/configure/lib/correct-response.js +244 -0
- package/configure/lib/correct-response.js.map +1 -0
- package/configure/lib/defaults.js +233 -0
- package/configure/lib/defaults.js.map +1 -0
- package/configure/lib/index.js +120 -0
- package/configure/lib/index.js.map +1 -0
- package/configure/lib/utils.js +80 -0
- package/configure/lib/utils.js.map +1 -0
- package/configure/package.json +29 -0
- package/controller/CHANGELOG.json +262 -0
- package/controller/CHANGELOG.md +1212 -0
- package/controller/lib/defaults.js +42 -0
- package/controller/lib/defaults.js.map +1 -0
- package/controller/lib/index.js +434 -0
- package/controller/lib/index.js.map +1 -0
- package/controller/package.json +24 -0
- package/docs/config-schema.json +2440 -0
- package/docs/config-schema.json.md +1802 -0
- package/docs/demo/config.js +8 -0
- package/docs/demo/generate.js +63 -0
- package/docs/demo/index.html +1 -0
- package/docs/demo/session.js +26 -0
- package/docs/pie-schema.json +1731 -0
- package/docs/pie-schema.json.md +945 -0
- package/lib/index.js +78 -0
- package/lib/index.js.map +1 -0
- package/lib/main.js +167 -0
- package/lib/main.js.map +1 -0
- package/package.json +21 -85
- package/configure.js +0 -2
- package/controller.js +0 -1
- package/dist/author/charting-config.d.ts +0 -30
- package/dist/author/charting-config.js +0 -126
- package/dist/author/configure.d.ts +0 -29
- package/dist/author/configure.js +0 -205
- package/dist/author/correct-response.d.ts +0 -27
- package/dist/author/correct-response.js +0 -115
- package/dist/author/defaults.d.ts +0 -229
- package/dist/author/defaults.js +0 -186
- package/dist/author/index.d.ts +0 -51
- package/dist/author/index.js +0 -74
- package/dist/author/utils.d.ts +0 -42
- package/dist/author/utils.js +0 -244
- package/dist/browser/author/index.js +0 -1242
- package/dist/browser/author/index.js.map +0 -1
- package/dist/browser/chart-CQhg5LMe.js +0 -64941
- package/dist/browser/chart-CQhg5LMe.js.map +0 -1
- package/dist/browser/charting.css +0 -2
- package/dist/browser/controller/index.js +0 -194
- package/dist/browser/controller/index.js.map +0 -1
- package/dist/browser/delivery/index.js +0 -517
- package/dist/browser/delivery/index.js.map +0 -1
- package/dist/browser/dist-CmxUEgpe.js +0 -334
- package/dist/browser/dist-CmxUEgpe.js.map +0 -1
- package/dist/charting.css +0 -2
- package/dist/controller/defaults.d.ts +0 -44
- package/dist/controller/defaults.js +0 -33
- package/dist/controller/index.d.ts +0 -28
- package/dist/controller/index.js +0 -153
- package/dist/delivery/index.d.ts +0 -21
- package/dist/delivery/index.js +0 -46
- package/dist/delivery/main.d.ts +0 -23
- package/dist/delivery/main.js +0 -128
- package/dist/index.d.ts +0 -1
- package/dist/index.iife.d.ts +0 -8
- package/dist/index.iife.js +0 -403
- package/dist/index.js +0 -2
- package/dist/runtime-support.d.ts +0 -12
- package/dist/runtime-support.js +0 -12
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getUpdatedCategories = exports.default = exports.CorrectResponse = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
12
|
+
var _charting = require("@pie-lib/charting");
|
|
13
|
+
var _lodashEs = require("lodash-es");
|
|
14
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
const Container = (0, _styles.styled)('div')(({
|
|
17
|
+
theme
|
|
18
|
+
}) => ({
|
|
19
|
+
marginBottom: theme.spacing(2.5),
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flex: 1
|
|
22
|
+
}));
|
|
23
|
+
const Column = (0, _styles.styled)('div')({
|
|
24
|
+
flex: 1
|
|
25
|
+
});
|
|
26
|
+
const ChartError = (0, _styles.styled)('div')(({
|
|
27
|
+
theme
|
|
28
|
+
}) => ({
|
|
29
|
+
border: `2px solid ${theme.palette.error.main}`
|
|
30
|
+
}));
|
|
31
|
+
const ErrorText = (0, _styles.styled)(_Typography.default)(({
|
|
32
|
+
theme
|
|
33
|
+
}) => ({
|
|
34
|
+
fontSize: theme.typography.fontSize - 2,
|
|
35
|
+
color: theme.palette.error.main,
|
|
36
|
+
paddingTop: theme.spacing(1)
|
|
37
|
+
}));
|
|
38
|
+
const Title = (0, _styles.styled)('div')(({
|
|
39
|
+
theme
|
|
40
|
+
}) => ({
|
|
41
|
+
marginBottom: theme.spacing(1)
|
|
42
|
+
}));
|
|
43
|
+
const addCategoryProps = (correctAnswer, data) => correctAnswer.map((correct, index) => ({
|
|
44
|
+
...correct,
|
|
45
|
+
editable: index < data.length ? data[index].editable : true,
|
|
46
|
+
interactive: index < data.length ? data[index].interactive : true,
|
|
47
|
+
deletable: index >= data.length ? true : false
|
|
48
|
+
}));
|
|
49
|
+
const updateCorrectResponseData = (correctAnswer, data) => {
|
|
50
|
+
if (!correctAnswer) {
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
const correctAnswerData = [...correctAnswer];
|
|
54
|
+
let correctResponseDefinition = [];
|
|
55
|
+
(data || []).forEach((category, currentIndex) => {
|
|
56
|
+
const editable = category.editable;
|
|
57
|
+
const interactive = category.interactive;
|
|
58
|
+
const label = editable && correctAnswer[currentIndex]?.label ? correctAnswer[currentIndex].label : category.label;
|
|
59
|
+
const value = interactive && correctAnswer[currentIndex]?.value || interactive && correctAnswer[currentIndex]?.value == 0 ? correctAnswer[currentIndex].value : category.value;
|
|
60
|
+
correctResponseDefinition[currentIndex] = {
|
|
61
|
+
label: label,
|
|
62
|
+
value: value,
|
|
63
|
+
editable: category.editable,
|
|
64
|
+
interactive: category.interactive
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
if (correctResponseDefinition.length < correctAnswer.length) {
|
|
68
|
+
const missingCategories = (correctAnswerData || []).slice(correctResponseDefinition.length, correctAnswer.length);
|
|
69
|
+
return addCategoryProps((correctResponseDefinition || []).concat(missingCategories), data);
|
|
70
|
+
}
|
|
71
|
+
return correctResponseDefinition;
|
|
72
|
+
};
|
|
73
|
+
const insertCategory = (correctAnswer, data) => {
|
|
74
|
+
const positionToInsert = data.length - 1;
|
|
75
|
+
// eslint-disable-next-line no-unused-vars
|
|
76
|
+
const {
|
|
77
|
+
editable,
|
|
78
|
+
interactive,
|
|
79
|
+
deletable,
|
|
80
|
+
...categoryToInsert
|
|
81
|
+
} = data[data.length - 1];
|
|
82
|
+
(correctAnswer || []).splice(positionToInsert, 0, categoryToInsert);
|
|
83
|
+
const correctAnswerData = [...correctAnswer];
|
|
84
|
+
return addCategoryProps(correctAnswerData, data);
|
|
85
|
+
};
|
|
86
|
+
const removeCategory = (correctAnswer, data, positionToRemove) => {
|
|
87
|
+
(correctAnswer || []).splice(positionToRemove, 1);
|
|
88
|
+
const correctAnswerData = [...correctAnswer];
|
|
89
|
+
return addCategoryProps(correctAnswerData, data);
|
|
90
|
+
};
|
|
91
|
+
const getUpdatedCategories = (nextProps, prevProps, prevState) => {
|
|
92
|
+
const nextData = nextProps && nextProps.model && nextProps.model.data || [];
|
|
93
|
+
const data = prevProps && prevProps.model && prevProps.model.data || [];
|
|
94
|
+
const nextCorrectAnswerDataCopy = (0, _lodashEs.cloneDeep)(nextProps && nextProps.model && nextProps.model.correctAnswer && nextProps.model.correctAnswer.data || []);
|
|
95
|
+
const categoriesCopy = (0, _lodashEs.cloneDeep)(prevState ? prevState.categories : []);
|
|
96
|
+
let nextCategories = [];
|
|
97
|
+
|
|
98
|
+
// Handle categories insertion in Define Chart
|
|
99
|
+
if (nextData.length > data.length) {
|
|
100
|
+
nextCategories = insertCategory(nextCorrectAnswerDataCopy, nextData);
|
|
101
|
+
return nextCategories;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Handle categories removal from Define Chart
|
|
105
|
+
if (nextData.length < data.length) {
|
|
106
|
+
let removedIndex = nextData.length;
|
|
107
|
+
|
|
108
|
+
// we need to remove the category from the correct answer data and categories, from the same index it was removed from the data
|
|
109
|
+
// index is a property of the nextData category
|
|
110
|
+
for (let index = 0; index < nextData.length; index++) {
|
|
111
|
+
if (nextData[index].index !== index) {
|
|
112
|
+
removedIndex = index;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
nextCategories = removeCategory(categoriesCopy, nextData, removedIndex);
|
|
117
|
+
return nextCategories;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Handle category value or label changes in Define Chart
|
|
121
|
+
// Handle categories update in Define Correct Response Chart
|
|
122
|
+
nextCategories = updateCorrectResponseData(nextCorrectAnswerDataCopy, nextData);
|
|
123
|
+
return nextCategories;
|
|
124
|
+
};
|
|
125
|
+
exports.getUpdatedCategories = getUpdatedCategories;
|
|
126
|
+
class CorrectResponse extends React.Component {
|
|
127
|
+
constructor(props) {
|
|
128
|
+
super(props);
|
|
129
|
+
(0, _defineProperty2.default)(this, "changeData", data => {
|
|
130
|
+
const {
|
|
131
|
+
model,
|
|
132
|
+
onChange
|
|
133
|
+
} = this.props;
|
|
134
|
+
const {
|
|
135
|
+
correctAnswer
|
|
136
|
+
} = model || {};
|
|
137
|
+
onChange({
|
|
138
|
+
...model,
|
|
139
|
+
correctAnswer: {
|
|
140
|
+
...correctAnswer,
|
|
141
|
+
// eslint-disable-next-line no-unused-vars
|
|
142
|
+
data: data.map(({
|
|
143
|
+
interactive,
|
|
144
|
+
editable,
|
|
145
|
+
index,
|
|
146
|
+
...keepAttrs
|
|
147
|
+
}) => keepAttrs)
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
this.state = {
|
|
152
|
+
categories: []
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
componentDidMount() {
|
|
156
|
+
const initialCategories = getUpdatedCategories(this.props, this.props, null);
|
|
157
|
+
this.setState({
|
|
158
|
+
categories: initialCategories || updateCorrectResponseData(this.props.model.correctAnswer.data, this.props.model.data)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
componentDidUpdate(prevProps, prevState) {
|
|
162
|
+
const nextCategories = getUpdatedCategories(this.props, prevProps, prevState);
|
|
163
|
+
if (nextCategories && !(0, _lodashEs.isEqual)(nextCategories, this.state.categories)) {
|
|
164
|
+
this.changeData(nextCategories);
|
|
165
|
+
this.setState({
|
|
166
|
+
categories: nextCategories
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
render() {
|
|
171
|
+
const {
|
|
172
|
+
model,
|
|
173
|
+
charts,
|
|
174
|
+
error,
|
|
175
|
+
studentNewCategoryDefaultLabel,
|
|
176
|
+
correctAnswerErrors,
|
|
177
|
+
mathMlOptions = {},
|
|
178
|
+
labelsPlaceholders = {}
|
|
179
|
+
} = this.props;
|
|
180
|
+
const {
|
|
181
|
+
categories
|
|
182
|
+
} = this.state;
|
|
183
|
+
const {
|
|
184
|
+
domain = {},
|
|
185
|
+
range = {}
|
|
186
|
+
} = model || {};
|
|
187
|
+
const {
|
|
188
|
+
identicalError,
|
|
189
|
+
categoriesError
|
|
190
|
+
} = correctAnswerErrors || {};
|
|
191
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Title, null, "Define Correct Response"), /*#__PURE__*/React.createElement(Container, null, /*#__PURE__*/React.createElement(Column, {
|
|
192
|
+
key: "graph"
|
|
193
|
+
}, /*#__PURE__*/React.createElement(_Typography.default, {
|
|
194
|
+
component: "div",
|
|
195
|
+
type: "body1"
|
|
196
|
+
}, /*#__PURE__*/React.createElement("span", null, "Use the tools below to define the correct answer.")), identicalError || categoriesError ? /*#__PURE__*/React.createElement(ChartError, {
|
|
197
|
+
key: `correct-response-graph-${model.correctAnswer.name}`
|
|
198
|
+
}, /*#__PURE__*/React.createElement(_charting.Chart, {
|
|
199
|
+
chartType: model.chartType,
|
|
200
|
+
size: model.graph,
|
|
201
|
+
domain: domain,
|
|
202
|
+
range: range,
|
|
203
|
+
charts: charts,
|
|
204
|
+
data: categories,
|
|
205
|
+
title: model.title,
|
|
206
|
+
onDataChange: this.changeData,
|
|
207
|
+
addCategoryEnabled: model.addCategoryEnabled,
|
|
208
|
+
categoryDefaultLabel: studentNewCategoryDefaultLabel,
|
|
209
|
+
error: error,
|
|
210
|
+
mathMlOptions: mathMlOptions,
|
|
211
|
+
labelsPlaceholders: labelsPlaceholders
|
|
212
|
+
})) : /*#__PURE__*/React.createElement("div", {
|
|
213
|
+
key: `correct-response-graph-${model.correctAnswer.name}`
|
|
214
|
+
}, /*#__PURE__*/React.createElement(_charting.Chart, {
|
|
215
|
+
chartType: model.chartType,
|
|
216
|
+
size: model.graph,
|
|
217
|
+
domain: domain,
|
|
218
|
+
range: range,
|
|
219
|
+
charts: charts,
|
|
220
|
+
data: categories,
|
|
221
|
+
title: model.title,
|
|
222
|
+
onDataChange: this.changeData,
|
|
223
|
+
addCategoryEnabled: model.addCategoryEnabled,
|
|
224
|
+
categoryDefaultLabel: studentNewCategoryDefaultLabel,
|
|
225
|
+
error: error,
|
|
226
|
+
mathMlOptions: mathMlOptions,
|
|
227
|
+
labelsPlaceholders: labelsPlaceholders
|
|
228
|
+
})), (identicalError || categoriesError) && /*#__PURE__*/React.createElement(ErrorText, {
|
|
229
|
+
component: "div",
|
|
230
|
+
type: "body1"
|
|
231
|
+
}, /*#__PURE__*/React.createElement("span", null, identicalError || categoriesError)))));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.CorrectResponse = CorrectResponse;
|
|
235
|
+
(0, _defineProperty2.default)(CorrectResponse, "propTypes", {
|
|
236
|
+
correctAnswerErrors: _propTypes.default.object,
|
|
237
|
+
studentNewCategoryDefaultLabel: _propTypes.default.string,
|
|
238
|
+
model: _propTypes.default.object.isRequired,
|
|
239
|
+
onChange: _propTypes.default.func.isRequired,
|
|
240
|
+
charts: _propTypes.default.array,
|
|
241
|
+
error: _propTypes.default.string
|
|
242
|
+
});
|
|
243
|
+
var _default = exports.default = CorrectResponse;
|
|
244
|
+
//# sourceMappingURL=correct-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correct-response.js","names":["React","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_styles","_charting","_lodashEs","_Typography","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Container","styled","theme","marginBottom","spacing","display","flex","Column","ChartError","border","palette","error","main","ErrorText","Typography","fontSize","typography","color","paddingTop","Title","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","getUpdatedCategories","nextProps","prevProps","prevState","nextData","model","nextCorrectAnswerDataCopy","cloneDeep","categoriesCopy","categories","nextCategories","removedIndex","exports","CorrectResponse","Component","constructor","props","_defineProperty2","onChange","keepAttrs","state","componentDidMount","initialCategories","setState","componentDidUpdate","isEqual","changeData","render","charts","studentNewCategoryDefaultLabel","correctAnswerErrors","mathMlOptions","labelsPlaceholders","domain","range","identicalError","categoriesError","createElement","key","component","type","name","Chart","chartType","size","graph","title","onDataChange","addCategoryEnabled","categoryDefaultLabel","PropTypes","object","string","isRequired","func","array","_default"],"sources":["../src/correct-response.jsx"],"sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { Chart } from '@pie-lib/charting';\nimport { cloneDeep, isEqual } from 'lodash-es';\n\nimport Typography from '@mui/material/Typography';\n\nconst Container = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(2.5),\n display: 'flex',\n flex: 1,\n}));\n\nconst Column = styled('div')({\n flex: 1,\n});\n\nconst ChartError = styled('div')(({ theme }) => ({\n border: `2px solid ${theme.palette.error.main}`,\n}));\n\nconst ErrorText = styled(Typography)(({ theme }) => ({\n fontSize: theme.typography.fontSize - 2,\n color: theme.palette.error.main,\n paddingTop: theme.spacing(1),\n}));\n\nconst Title = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(1),\n}));\n\nconst addCategoryProps = (correctAnswer, data) =>\n correctAnswer.map((correct, index) => ({\n ...correct,\n editable: index < data.length ? data[index].editable : true,\n interactive: index < data.length ? data[index].interactive : true,\n deletable: index >= data.length ? true : false,\n }));\n\nconst updateCorrectResponseData = (correctAnswer, data) => {\n if (!correctAnswer) {\n return data;\n }\n\n const correctAnswerData = [...correctAnswer];\n let correctResponseDefinition = [];\n\n (data || []).forEach((category, currentIndex) => {\n const editable = category.editable;\n const interactive = category.interactive;\n const label = editable && correctAnswer[currentIndex]?.label ? correctAnswer[currentIndex].label : category.label;\n const value =\n (interactive && correctAnswer[currentIndex]?.value) || (interactive && correctAnswer[currentIndex]?.value == 0)\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 // eslint-disable-next-line no-unused-vars\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 const correctAnswerData = [...correctAnswer];\n\n return addCategoryProps(correctAnswerData, data);\n};\n\nexport const getUpdatedCategories = (nextProps, prevProps, prevState) => {\n const nextData = (nextProps && nextProps.model && nextProps.model.data) || [];\n const data = (prevProps && prevProps.model && prevProps.model.data) || [];\n const nextCorrectAnswerDataCopy = cloneDeep(\n (nextProps && nextProps.model && nextProps.model.correctAnswer && nextProps.model.correctAnswer.data) || [],\n );\n\n const categoriesCopy = cloneDeep(prevState ? prevState.categories : []);\n\n let nextCategories = [];\n\n // Handle categories insertion in Define Chart\n if (nextData.length > data.length) {\n nextCategories = insertCategory(nextCorrectAnswerDataCopy, nextData);\n return nextCategories;\n }\n\n // Handle categories removal from Define Chart\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 nextCategories = removeCategory(categoriesCopy, nextData, removedIndex);\n return nextCategories;\n }\n\n // Handle category value or label changes in Define Chart\n // Handle categories update in Define Correct Response Chart\n nextCategories = updateCorrectResponseData(nextCorrectAnswerDataCopy, nextData);\n\n return nextCategories;\n};\n\nexport class CorrectResponse extends React.Component {\n static propTypes = {\n correctAnswerErrors: PropTypes.object,\n studentNewCategoryDefaultLabel: PropTypes.string,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array,\n error: PropTypes.string,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n categories: [],\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 // eslint-disable-next-line no-unused-vars\n data: data.map(({ interactive, editable, index, ...keepAttrs }) => keepAttrs),\n },\n });\n };\n\n componentDidMount() {\n const initialCategories = getUpdatedCategories(this.props, this.props, null);\n\n this.setState({\n categories:\n initialCategories || updateCorrectResponseData(this.props.model.correctAnswer.data, this.props.model.data),\n });\n }\n\n componentDidUpdate(prevProps, prevState) {\n const nextCategories = getUpdatedCategories(this.props, prevProps, prevState);\n\n if (nextCategories && !isEqual(nextCategories, this.state.categories)) {\n this.changeData(nextCategories);\n this.setState({ categories: nextCategories });\n }\n }\n\n render() {\n const {\n model,\n charts,\n error,\n studentNewCategoryDefaultLabel,\n correctAnswerErrors,\n mathMlOptions = {},\n labelsPlaceholders = {},\n } = this.props;\n const { categories } = this.state;\n\n const { domain = {}, range = {} } = model || {};\n const { identicalError, categoriesError } = correctAnswerErrors || {};\n\n return (\n <div>\n <Title>Define Correct Response</Title>\n <Container>\n <Column key=\"graph\">\n <Typography component=\"div\" type=\"body1\">\n <span>Use the tools below to define the correct answer.</span>\n </Typography>\n\n {identicalError || categoriesError ? (\n <ChartError key={`correct-response-graph-${model.correctAnswer.name}`}>\n <Chart\n chartType={model.chartType}\n size={model.graph}\n domain={domain}\n range={range}\n charts={charts}\n data={categories}\n title={model.title}\n onDataChange={this.changeData}\n addCategoryEnabled={model.addCategoryEnabled}\n categoryDefaultLabel={studentNewCategoryDefaultLabel}\n error={error}\n mathMlOptions={mathMlOptions}\n labelsPlaceholders={labelsPlaceholders}\n />\n </ChartError>\n ) : (\n <div key={`correct-response-graph-${model.correctAnswer.name}`}>\n <Chart\n chartType={model.chartType}\n size={model.graph}\n domain={domain}\n range={range}\n charts={charts}\n data={categories}\n title={model.title}\n onDataChange={this.changeData}\n addCategoryEnabled={model.addCategoryEnabled}\n categoryDefaultLabel={studentNewCategoryDefaultLabel}\n error={error}\n mathMlOptions={mathMlOptions}\n labelsPlaceholders={labelsPlaceholders}\n />\n </div>\n )}\n\n {(identicalError || categoriesError) && (\n <ErrorText component=\"div\" type=\"body1\">\n <span>{identicalError || categoriesError}</span>\n </ErrorText>\n )}\n </Column>\n </Container>\n </div>\n );\n }\n}\n\nexport default CorrectResponse;\n"],"mappings":";;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,WAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAAkD,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,C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AW;MAC9BsB,kBAAkB,EAAE3C,KAAK,CAAC2C,kBAAmB;MAC7CC,oBAAoB,EAAEpB,8BAA+B;MACrDjE,KAAK,EAAEA,KAAM;MACbmE,aAAa,EAAEA,aAAc;MAC7BC,kBAAkB,EAAEA;IAAmB,CACxC,CACE,CACN,EAEA,CAACG,cAAc,IAAIC,eAAe,kBACjC/G,KAAA,CAAAgH,aAAA,CAACvE,SAAS;MAACyE,SAAS,EAAC,KAAK;MAACC,IAAI,EAAC;IAAO,gBACrCnH,KAAA,CAAAgH,aAAA,eAAOF,cAAc,IAAIC,eAAsB,CACtC,CAEP,CACC,CACR,CAAC;EAEV;AACF;AAACxB,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAAA,IAAAI,gBAAA,CAAAzE,OAAA,EAzHYqE,eAAe,eACP;EACjBiB,mBAAmB,EAAEoB,kBAAS,CAACC,MAAM;EACrCtB,8BAA8B,EAAEqB,kBAAS,CAACE,MAAM;EAChD/C,KAAK,EAAE6C,kBAAS,CAACC,MAAM,CAACE,UAAU;EAClCnC,QAAQ,EAAEgC,kBAAS,CAACI,IAAI,CAACD,UAAU;EACnCzB,MAAM,EAAEsB,kBAAS,CAACK,KAAK;EACvB3F,KAAK,EAAEsF,kBAAS,CAACE;AACnB,CAAC;AAAA,IAAAI,QAAA,GAAA5C,OAAA,CAAApE,OAAA,GAmHYqE,eAAe","ignoreList":[]}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* NOTE: There's no functionality described for graphTitle,
|
|
9
|
+
* rationale, scoringType, studentInstructions, teacherInstructions
|
|
10
|
+
* so there's no implementation (they are only added in model)
|
|
11
|
+
*/
|
|
12
|
+
// const createCategory = (label, value) => ({
|
|
13
|
+
// label,
|
|
14
|
+
// value,
|
|
15
|
+
// interactive: true,
|
|
16
|
+
// editable: true
|
|
17
|
+
// });
|
|
18
|
+
var _default = exports.default = {
|
|
19
|
+
model: {
|
|
20
|
+
addCategoryEnabled: true,
|
|
21
|
+
changeAddCategoryEnabled: false,
|
|
22
|
+
changeEditableEnabled: false,
|
|
23
|
+
changeInteractiveEnabled: false,
|
|
24
|
+
chartType: 'lineCross',
|
|
25
|
+
correctAnswer: {},
|
|
26
|
+
data: [],
|
|
27
|
+
domain: {},
|
|
28
|
+
graph: {
|
|
29
|
+
width: 480,
|
|
30
|
+
height: 480
|
|
31
|
+
},
|
|
32
|
+
prompt: '',
|
|
33
|
+
promptEnabled: true,
|
|
34
|
+
range: {
|
|
35
|
+
label: '',
|
|
36
|
+
max: 1,
|
|
37
|
+
min: 0,
|
|
38
|
+
labelStep: 1
|
|
39
|
+
},
|
|
40
|
+
rationale: '',
|
|
41
|
+
rationaleEnabled: true,
|
|
42
|
+
scoringType: 'all or nothing',
|
|
43
|
+
studentInstructionsEnabled: true,
|
|
44
|
+
studentNewCategoryDefaultLabel: 'New Category',
|
|
45
|
+
teacherInstructions: '',
|
|
46
|
+
teacherInstructionsEnabled: true,
|
|
47
|
+
title: ''
|
|
48
|
+
},
|
|
49
|
+
configuration: {
|
|
50
|
+
baseInputConfiguration: {
|
|
51
|
+
h3: {
|
|
52
|
+
disabled: true
|
|
53
|
+
},
|
|
54
|
+
audio: {
|
|
55
|
+
disabled: false
|
|
56
|
+
},
|
|
57
|
+
video: {
|
|
58
|
+
disabled: false
|
|
59
|
+
},
|
|
60
|
+
image: {
|
|
61
|
+
disabled: false
|
|
62
|
+
},
|
|
63
|
+
textAlign: {
|
|
64
|
+
disabled: true
|
|
65
|
+
},
|
|
66
|
+
showParagraphs: {
|
|
67
|
+
disabled: false
|
|
68
|
+
},
|
|
69
|
+
separateParagraphs: {
|
|
70
|
+
disabled: true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
spellCheck: {
|
|
74
|
+
label: 'Spellcheck',
|
|
75
|
+
settings: false,
|
|
76
|
+
enabled: true
|
|
77
|
+
},
|
|
78
|
+
chartDimensions: {
|
|
79
|
+
settings: false,
|
|
80
|
+
label: 'Chart Dimensions',
|
|
81
|
+
showInConfigPanel: true,
|
|
82
|
+
width: {
|
|
83
|
+
min: 50,
|
|
84
|
+
max: 700,
|
|
85
|
+
step: 20
|
|
86
|
+
},
|
|
87
|
+
height: {
|
|
88
|
+
min: 400,
|
|
89
|
+
max: 700,
|
|
90
|
+
step: 20
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
authorNewCategoryDefaults: {
|
|
94
|
+
settings: false,
|
|
95
|
+
label: 'Category',
|
|
96
|
+
interactive: true,
|
|
97
|
+
editable: false
|
|
98
|
+
},
|
|
99
|
+
availableChartTypes: {
|
|
100
|
+
bar: 'Bar Chart',
|
|
101
|
+
histogram: 'Histogram',
|
|
102
|
+
lineDot: 'Line Chart ●',
|
|
103
|
+
lineCross: 'Line Chart x',
|
|
104
|
+
dotPlot: 'Dot/Line Plot ⬤',
|
|
105
|
+
linePlot: 'Dot/Line Plot X'
|
|
106
|
+
},
|
|
107
|
+
chartTypeLabel: 'ChartType',
|
|
108
|
+
studentNewCategoryDefaultLabel: {
|
|
109
|
+
settings: false,
|
|
110
|
+
label: 'Category'
|
|
111
|
+
},
|
|
112
|
+
prompt: {
|
|
113
|
+
settings: true,
|
|
114
|
+
label: 'Item Stem',
|
|
115
|
+
required: false,
|
|
116
|
+
inputConfiguration: {
|
|
117
|
+
audio: {
|
|
118
|
+
disabled: false
|
|
119
|
+
},
|
|
120
|
+
video: {
|
|
121
|
+
disabled: false
|
|
122
|
+
},
|
|
123
|
+
image: {
|
|
124
|
+
disabled: false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
rationale: {
|
|
129
|
+
settings: true,
|
|
130
|
+
label: 'Rationale',
|
|
131
|
+
required: false,
|
|
132
|
+
inputConfiguration: {
|
|
133
|
+
audio: {
|
|
134
|
+
disabled: false
|
|
135
|
+
},
|
|
136
|
+
video: {
|
|
137
|
+
disabled: false
|
|
138
|
+
},
|
|
139
|
+
image: {
|
|
140
|
+
disabled: false
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
scoringType: {
|
|
145
|
+
settings: false,
|
|
146
|
+
label: 'Scoring Type'
|
|
147
|
+
},
|
|
148
|
+
settingsPanelDisabled: false,
|
|
149
|
+
studentInstructions: {
|
|
150
|
+
settings: false,
|
|
151
|
+
label: 'Student Instructions'
|
|
152
|
+
},
|
|
153
|
+
teacherInstructions: {
|
|
154
|
+
settings: true,
|
|
155
|
+
label: 'Teacher Instructions',
|
|
156
|
+
required: false,
|
|
157
|
+
inputConfiguration: {
|
|
158
|
+
audio: {
|
|
159
|
+
disabled: false
|
|
160
|
+
},
|
|
161
|
+
video: {
|
|
162
|
+
disabled: false
|
|
163
|
+
},
|
|
164
|
+
image: {
|
|
165
|
+
disabled: false
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
title: {
|
|
170
|
+
settings: false,
|
|
171
|
+
label: 'Chart Title'
|
|
172
|
+
},
|
|
173
|
+
instruction: {
|
|
174
|
+
settings: false,
|
|
175
|
+
label: 'This item type provides various types of interactive charts. Depending upon how an item is configured,\n' + ' students can change the heights of bars (or other similar chart elements) created by the author; relabel bars\n' + ' created by the author; and/or add new bars, label them, and set their heights.'
|
|
176
|
+
},
|
|
177
|
+
titlePlaceholder: {
|
|
178
|
+
settings: false,
|
|
179
|
+
label: 'Click here to add a title'
|
|
180
|
+
},
|
|
181
|
+
labelsPlaceholders: {
|
|
182
|
+
left: 'Click here to add a label for this axis',
|
|
183
|
+
right: '',
|
|
184
|
+
top: '',
|
|
185
|
+
bottom: 'Click here to add a label for this axis'
|
|
186
|
+
},
|
|
187
|
+
maxImageWidth: {
|
|
188
|
+
teacherInstructions: 300,
|
|
189
|
+
prompt: 300,
|
|
190
|
+
rationale: 300
|
|
191
|
+
},
|
|
192
|
+
maxImageHeight: {
|
|
193
|
+
teacherInstructions: 300,
|
|
194
|
+
prompt: 300,
|
|
195
|
+
rationale: 300
|
|
196
|
+
},
|
|
197
|
+
withRubric: {
|
|
198
|
+
settings: false,
|
|
199
|
+
label: 'Add Rubric'
|
|
200
|
+
},
|
|
201
|
+
language: {
|
|
202
|
+
settings: false,
|
|
203
|
+
label: 'Specify Language',
|
|
204
|
+
enabled: false
|
|
205
|
+
},
|
|
206
|
+
languageChoices: {
|
|
207
|
+
label: 'Language Choices',
|
|
208
|
+
options: []
|
|
209
|
+
},
|
|
210
|
+
chartingOptions: {
|
|
211
|
+
changeInteractive: {
|
|
212
|
+
settings: false,
|
|
213
|
+
authoringLabel: 'Student can set value',
|
|
214
|
+
settingsLabel: 'Allow non-interactive categories'
|
|
215
|
+
},
|
|
216
|
+
changeEditable: {
|
|
217
|
+
settings: false,
|
|
218
|
+
authoringLabel: 'Student can edit name',
|
|
219
|
+
settingsLabel: 'Allow editable category names'
|
|
220
|
+
},
|
|
221
|
+
addCategory: {
|
|
222
|
+
settings: false,
|
|
223
|
+
authoringLabel: 'Student can add categories',
|
|
224
|
+
settingsLabel: 'Allow changes to whether students can add categories'
|
|
225
|
+
},
|
|
226
|
+
mathMlOptions: {
|
|
227
|
+
mmlOutput: false,
|
|
228
|
+
mmlEditing: false
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","names":["_default","exports","default","model","addCategoryEnabled","changeAddCategoryEnabled","changeEditableEnabled","changeInteractiveEnabled","chartType","correctAnswer","data","domain","graph","width","height","prompt","promptEnabled","range","label","max","min","labelStep","rationale","rationaleEnabled","scoringType","studentInstructionsEnabled","studentNewCategoryDefaultLabel","teacherInstructions","teacherInstructionsEnabled","title","configuration","baseInputConfiguration","h3","disabled","audio","video","image","textAlign","showParagraphs","separateParagraphs","spellCheck","settings","enabled","chartDimensions","showInConfigPanel","step","authorNewCategoryDefaults","interactive","editable","availableChartTypes","bar","histogram","lineDot","lineCross","dotPlot","linePlot","chartTypeLabel","required","inputConfiguration","settingsPanelDisabled","studentInstructions","instruction","titlePlaceholder","labelsPlaceholders","left","right","top","bottom","maxImageWidth","maxImageHeight","withRubric","language","languageChoices","options","chartingOptions","changeInteractive","authoringLabel","settingsLabel","changeEditable","addCategory","mathMlOptions","mmlOutput","mmlEditing"],"sources":["../src/defaults.js"],"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// const createCategory = (label, value) => ({\n// label,\n// value,\n// interactive: true,\n// editable: true\n// });\n\nexport default {\n model: {\n addCategoryEnabled: true,\n changeAddCategoryEnabled: false,\n changeEditableEnabled: false,\n changeInteractiveEnabled: false,\n chartType: 'lineCross',\n correctAnswer: {},\n data: [],\n domain: {},\n graph: { width: 480, height: 480 },\n prompt: '',\n promptEnabled: true,\n range: { label: '', max: 1, min: 0, labelStep: 1 },\n rationale: '',\n rationaleEnabled: true,\n scoringType: 'all or nothing',\n studentInstructionsEnabled: true,\n studentNewCategoryDefaultLabel: 'New Category',\n teacherInstructions: '',\n teacherInstructionsEnabled: true,\n title: '',\n },\n configuration: {\n baseInputConfiguration: {\n h3: { disabled: true },\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n textAlign: { disabled: true },\n showParagraphs: { disabled: false },\n separateParagraphs: { disabled: true },\n },\n spellCheck: {\n label: 'Spellcheck',\n settings: false,\n enabled: true,\n },\n chartDimensions: {\n settings: false,\n label: 'Chart Dimensions',\n showInConfigPanel: true,\n width: {\n min: 50,\n max: 700,\n step: 20,\n },\n height: {\n min: 400,\n max: 700,\n step: 20,\n },\n },\n authorNewCategoryDefaults: {\n settings: false,\n label: 'Category',\n interactive: true,\n editable: false,\n },\n availableChartTypes: {\n bar: 'Bar Chart',\n histogram: 'Histogram',\n lineDot: 'Line Chart ●',\n lineCross: 'Line Chart x',\n dotPlot: 'Dot/Line Plot ⬤',\n linePlot: 'Dot/Line Plot X',\n },\n chartTypeLabel: 'ChartType',\n studentNewCategoryDefaultLabel: {\n settings: false,\n label: 'Category',\n },\n prompt: {\n settings: true,\n label: 'Item Stem',\n required: false,\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n rationale: {\n settings: true,\n label: 'Rationale',\n required: false,\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n scoringType: {\n settings: false,\n label: 'Scoring Type',\n },\n settingsPanelDisabled: false,\n studentInstructions: {\n settings: false,\n label: 'Student Instructions',\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions',\n required: false,\n inputConfiguration: {\n audio: { disabled: false },\n video: { disabled: false },\n image: { disabled: false },\n },\n },\n title: {\n settings: false,\n label: 'Chart Title',\n },\n instruction: {\n settings: false,\n label:\n 'This item type provides various types of interactive charts. Depending upon how an item is configured,\\n' +\n ' students can change the heights of bars (or other similar chart elements) created by the author; relabel bars\\n' +\n ' created by the author; and/or add new bars, label them, and set their heights.',\n },\n titlePlaceholder: {\n settings: false,\n label: 'Click here to add a title',\n },\n labelsPlaceholders: {\n left: 'Click here to add a label for this axis',\n right: '',\n top: '',\n bottom: 'Click here to add a label for this axis',\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 withRubric: {\n settings: false,\n label: 'Add Rubric',\n },\n language: {\n settings: false,\n label: 'Specify Language',\n enabled: false,\n },\n languageChoices: {\n label: 'Language Choices',\n options: [],\n },\n chartingOptions: {\n changeInteractive: {\n settings: false,\n authoringLabel: 'Student can set value',\n settingsLabel: 'Allow non-interactive categories',\n },\n changeEditable: {\n settings: false,\n authoringLabel: 'Student can edit name',\n settingsLabel: 'Allow editable category names',\n },\n addCategory: {\n settings: false,\n authoringLabel: 'Student can add categories',\n settingsLabel: 'Allow changes to whether students can add categories',\n },\n mathMlOptions: {\n mmlOutput: false,\n mmlEditing: false,\n },\n },\n },\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA,IAAAA,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEe;EACbC,KAAK,EAAE;IACLC,kBAAkB,EAAE,IAAI;IACxBC,wBAAwB,EAAE,KAAK;IAC/BC,qBAAqB,EAAE,KAAK;IAC5BC,wBAAwB,EAAE,KAAK;IAC/BC,SAAS,EAAE,WAAW;IACtBC,aAAa,EAAE,CAAC,CAAC;IACjBC,IAAI,EAAE,EAAE;IACRC,MAAM,EAAE,CAAC,CAAC;IACVC,KAAK,EAAE;MAAEC,KAAK,EAAE,GAAG;MAAEC,MAAM,EAAE;IAAI,CAAC;IAClCC,MAAM,EAAE,EAAE;IACVC,aAAa,EAAE,IAAI;IACnBC,KAAK,EAAE;MAAEC,KAAK,EAAE,EAAE;MAAEC,GAAG,EAAE,CAAC;MAAEC,GAAG,EAAE,CAAC;MAAEC,SAAS,EAAE;IAAE,CAAC;IAClDC,SAAS,EAAE,EAAE;IACbC,gBAAgB,EAAE,IAAI;IACtBC,WAAW,EAAE,gBAAgB;IAC7BC,0BAA0B,EAAE,IAAI;IAChCC,8BAA8B,EAAE,cAAc;IAC9CC,mBAAmB,EAAE,EAAE;IACvBC,0BAA0B,EAAE,IAAI;IAChCC,KAAK,EAAE;EACT,CAAC;EACDC,aAAa,EAAE;IACbC,sBAAsB,EAAE;MACtBC,EAAE,EAAE;QAAEC,QAAQ,EAAE;MAAK,CAAC;MACtBC,KAAK,EAAE;QAAED,QAAQ,EAAE;MAAM,CAAC;MAC1BE,KAAK,EAAE;QAAEF,QAAQ,EAAE;MAAM,CAAC;MAC1BG,KAAK,EAAE;QAAEH,QA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EAAE;MACbzC,mBAAmB,EAAE,GAAG;MACxBZ,MAAM,EAAE,GAAG;MACXO,SAAS,EAAE;IACb,CAAC;IACD+C,cAAc,EAAE;MACd1C,mBAAmB,EAAE,GAAG;MACxBZ,MAAM,EAAE,GAAG;MACXO,SAAS,EAAE;IACb,CAAC;IACDgD,UAAU,EAAE;MACV7B,QAAQ,EAAE,KAAK;MACfvB,KAAK,EAAE;IACT,CAAC;IACDqD,QAAQ,EAAE;MACR9B,QAAQ,EAAE,KAAK;MACfvB,KAAK,EAAE,kBAAkB;MACzBwB,OAAO,EAAE;IACX,CAAC;IACD8B,eAAe,EAAE;MACftD,KAAK,EAAE,kBAAkB;MACzBuD,OAAO,EAAE;IACX,CAAC;IACDC,eAAe,EAAE;MACfC,iBAAiB,EAAE;QACjBlC,QAAQ,EAAE,KAAK;QACfmC,cAAc,EAAE,uBAAuB;QACvCC,aAAa,EAAE;MACjB,CAAC;MACDC,cAAc,EAAE;QACdrC,QAAQ,EAAE,KAAK;QACfmC,cAAc,EAAE,uBAAuB;QACvCC,aAAa,EAAE;MACjB,CAAC;MACDE,WAAW,EAAE;QACXtC,QAAQ,EAAE,KAAK;QACfmC,cAAc,EAAE,4BAA4B;QAC5CC,aAAa,EAAE;MACjB,CAAC;MACDG,aAAa,EAAE;QACbC,SAAS,EAAE,KAAK;QAChBC,UAAU,EAAE;MACd;IACF;EACF;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _client = require("react-dom/client");
|
|
11
|
+
var _pieConfigureEvents = require("@pie-framework/pie-configure-events");
|
|
12
|
+
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
+
var _configure = _interopRequireDefault(require("./configure"));
|
|
14
|
+
var _defaults = _interopRequireDefault(require("./defaults"));
|
|
15
|
+
var _mathRendering = require("@pie-lib/math-rendering");
|
|
16
|
+
const log = (0, _debug.default)('pie-elements:graphing:configure');
|
|
17
|
+
class GraphLinesConfigure extends HTMLElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this._root = null;
|
|
21
|
+
this._model = GraphLinesConfigure.createDefaultModel();
|
|
22
|
+
this._configuration = _defaults.default.configuration;
|
|
23
|
+
}
|
|
24
|
+
set model(m) {
|
|
25
|
+
this._model = GraphLinesConfigure.createDefaultModel(m);
|
|
26
|
+
this._render();
|
|
27
|
+
}
|
|
28
|
+
set configuration(c) {
|
|
29
|
+
const newConfiguration = {
|
|
30
|
+
..._defaults.default.configuration,
|
|
31
|
+
...c
|
|
32
|
+
};
|
|
33
|
+
this._configuration = newConfiguration;
|
|
34
|
+
|
|
35
|
+
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
36
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
37
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
38
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
39
|
+
if (newConfiguration?.language?.enabled) {
|
|
40
|
+
if (newConfiguration?.languageChoices?.options?.length) {
|
|
41
|
+
this._model.language = newConfiguration?.languageChoices.options[0].value;
|
|
42
|
+
}
|
|
43
|
+
} else if (newConfiguration.language.settings && this._model.language) {
|
|
44
|
+
this._configuration.language.enabled = true;
|
|
45
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
46
|
+
this._configuration.languageChoices.options = [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// check if the language is already included in the languageChoices.options array
|
|
50
|
+
// and if not, then add it.
|
|
51
|
+
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
52
|
+
this._configuration.languageChoices.options.push({
|
|
53
|
+
value: this._model.language,
|
|
54
|
+
label: this._model.language
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
delete this._model.language;
|
|
59
|
+
}
|
|
60
|
+
this._render();
|
|
61
|
+
}
|
|
62
|
+
onModelChanged(model) {
|
|
63
|
+
this._model = model;
|
|
64
|
+
this._render();
|
|
65
|
+
log('[onModelChanged]: ', this._model);
|
|
66
|
+
this.dispatchEvent(new _pieConfigureEvents.ModelUpdatedEvent(this._model));
|
|
67
|
+
}
|
|
68
|
+
onConfigurationChanged(config) {
|
|
69
|
+
this._configuration = config;
|
|
70
|
+
this._render();
|
|
71
|
+
}
|
|
72
|
+
insertImage(handler) {
|
|
73
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertImageEvent(handler));
|
|
74
|
+
}
|
|
75
|
+
onDeleteImage(src, done) {
|
|
76
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
|
|
77
|
+
}
|
|
78
|
+
insertSound(handler) {
|
|
79
|
+
this.dispatchEvent(new _pieConfigureEvents.InsertSoundEvent(handler));
|
|
80
|
+
}
|
|
81
|
+
onDeleteSound(src, done) {
|
|
82
|
+
this.dispatchEvent(new _pieConfigureEvents.DeleteSoundEvent(src, done));
|
|
83
|
+
}
|
|
84
|
+
_render() {
|
|
85
|
+
if (this._model) {
|
|
86
|
+
const el = /*#__PURE__*/_react.default.createElement(_configure.default, {
|
|
87
|
+
onModelChanged: this.onModelChanged.bind(this),
|
|
88
|
+
onConfigurationChanged: this.onConfigurationChanged.bind(this),
|
|
89
|
+
model: this._model,
|
|
90
|
+
configuration: this._configuration,
|
|
91
|
+
imageSupport: {
|
|
92
|
+
add: this.insertImage.bind(this),
|
|
93
|
+
delete: this.onDeleteImage.bind(this)
|
|
94
|
+
},
|
|
95
|
+
uploadSoundSupport: {
|
|
96
|
+
add: this.insertSound.bind(this),
|
|
97
|
+
delete: this.onDeleteSound.bind(this)
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (!this._root) {
|
|
101
|
+
this._root = (0, _client.createRoot)(this);
|
|
102
|
+
}
|
|
103
|
+
this._root.render(el);
|
|
104
|
+
queueMicrotask(() => {
|
|
105
|
+
(0, _mathRendering.renderMath)(this);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
disconnectedCallback() {
|
|
110
|
+
if (this._root) {
|
|
111
|
+
this._root.unmount();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.default = GraphLinesConfigure;
|
|
116
|
+
(0, _defineProperty2.default)(GraphLinesConfigure, "createDefaultModel", (model = {}) => ({
|
|
117
|
+
..._defaults.default.model,
|
|
118
|
+
...model
|
|
119
|
+
}));
|
|
120
|
+
//# sourceMappingURL=index.js.map
|