@pie-element/hotspot 4.8.4-next.808 → 4.8.4-next.812
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/configure/lib/defaults.js +2 -1
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/root.js +22 -17
- package/configure/lib/root.js.map +1 -1
- package/configure/lib/utils.js +13 -1
- package/configure/lib/utils.js.map +1 -1
- package/configure/src/__tests__/__snapshots__/root.test.js.snap +32 -4
- package/configure/src/defaults.js +2 -1
- package/configure/src/root.jsx +33 -26
- package/configure/src/utils.js +23 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","promptEnabled","imageUrl","shapes","rectangles","polygons","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","settings","label","rationale","spellCheck","enabled","teacherInstructions","preserveAspectRatio"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KAAK,EAAE;AACLC,IAAAA,MAAM,EAAE,6BADH;AAELC,IAAAA,qBAAqB,EAAE,QAFlB;AAGLC,IAAAA,aAAa,EAAE,IAHV;AAILC,IAAAA,QAAQ,EAAE,EAJL;AAKLC,IAAAA,MAAM,EAAE;AACNC,MAAAA,UAAU,EAAE,EADN;AAENC,MAAAA,QAAQ,EAAE;AAFJ,KALH;AASLC,IAAAA,eAAe,EAAE,IATZ;AAULC,IAAAA,cAAc,EAAE,KAVX;AAWLC,IAAAA,UAAU,EAAE;AACVC,MAAAA,MAAM,EAAE,CADE;AAEVC,MAAAA,KAAK,EAAE;AAFG,KAXP;AAeLC,IAAAA,YAAY,EAAE,2BAfT;AAgBLC,IAAAA,WAAW,EAAE,CACX,2BADW,CAhBR;AAmBLC,IAAAA,YAAY,EAAE,MAnBT;AAoBLC,IAAAA,WAAW,EAAE,CACX,MADW,CApBR;AAuBLC,IAAAA,gBAAgB,EAAE,IAvBb;AAwBLC,IAAAA,0BAA0B,EAAE,IAxBvB;AAyBLC,IAAAA,0BAA0B,EAAE,IAzBvB;AA0BLC,IAAAA,WAAW,EAAE;AA1BR,GADM;AA6BbC,EAAAA,aAAa,EAAE;AACbb,IAAAA,eAAe,EAAE;AACfc,MAAAA,QAAQ,EAAE,IADK;AAEfC,MAAAA,KAAK,EAAE;AAFQ,KADJ;AAKbd,IAAAA,cAAc,EAAE;AACda,MAAAA,QAAQ,EAAE,KADI;AAEdC,MAAAA,KAAK,EAAE;AAFO,KALH;AASbC,IAAAA,SAAS,EAAE;AACTF,MAAAA,QAAQ,EAAE,IADD;AAETC,MAAAA,KAAK,EAAE;AAFE,KATE;AAabtB,IAAAA,MAAM,EAAE;AACNqB,MAAAA,QAAQ,EAAE,IADJ;AAENC,MAAAA,KAAK,EAAE;AAFD,KAbK;AAiBbE,IAAAA,UAAU,EAAE;AACVF,MAAAA,KAAK,EAAE,YADG;AAEVD,MAAAA,QAAQ,EAAC,KAFC;AAGVI,MAAAA,OAAO,EAAC;AAHE,KAjBC;AAsBbC,IAAAA,mBAAmB,EAAE;AACnBL,MAAAA,QAAQ,EAAE,IADS;AAEnBC,MAAAA,KAAK,EAAE;AAFY,KAtBR;AA0BbK,IAAAA,mBAAmB,EAAE;AACnBN,MAAAA,QAAQ,EAAE,KADS;AAEnBI,MAAAA,OAAO,EAAE,IAFU;AAGnBH,MAAAA,KAAK,EAAE;AAHY;
|
|
1
|
+
{"version":3,"sources":["../src/defaults.js"],"names":["model","prompt","toolbarEditorPosition","promptEnabled","imageUrl","shapes","rectangles","polygons","multipleCorrect","partialScoring","dimensions","height","width","hotspotColor","hotspotList","outlineColor","outlineList","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled","strokeWidth","configuration","settings","label","rationale","spellCheck","enabled","teacherInstructions","preserveAspectRatio","minShapes"],"mappings":";;;;;;eAAe;AACbA,EAAAA,KA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AHE,KAjBC;AAsBbC,IAAAA,mBAAmB,EAAE;AACnBL,MAAAA,QAAQ,EAAE,IADS;AAEnBC,MAAAA,KAAK,EAAE;AAFY,KAtBR;AA0BbK,IAAAA,mBAAmB,EAAE;AACnBN,MAAAA,QAAQ,EAAE,KADS;AAEnBI,MAAAA,OAAO,EAAE,IAFU;AAGnBH,MAAAA,KAAK,EAAE;AAHY,KA1BR;AA+BbM,IAAAA,SAAS,EAAE;AA/BE;AA7BF,C","sourcesContent":["export default {\n model: {\n prompt: 'This is the question prompt',\n toolbarEditorPosition: 'bottom',\n promptEnabled: true,\n imageUrl: '',\n shapes: {\n rectangles: [],\n polygons: []\n },\n multipleCorrect: true,\n partialScoring: false,\n dimensions: {\n height: 0,\n width: 0\n },\n hotspotColor: 'rgba(137, 183, 244, 0.65)',\n hotspotList: [\n 'rgba(137, 183, 244, 0.65)'\n ],\n outlineColor: 'blue',\n outlineList: [\n 'blue'\n ],\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n strokeWidth: 5\n },\n configuration: {\n multipleCorrect: {\n settings: true,\n label: 'Multiple Correct Responses'\n },\n partialScoring: {\n settings: false,\n label: 'Allow Partial Scoring'\n },\n rationale: {\n settings: true,\n label: 'Rationale'\n },\n prompt: {\n settings: true,\n label: 'Prompt'\n },\n spellCheck: {\n label: 'Spellcheck',\n settings:false,\n enabled:true\n },\n teacherInstructions: {\n settings: true,\n label: 'Teacher Instructions'\n },\n preserveAspectRatio: {\n settings: false,\n enabled: true,\n label: 'Preserve aspect ratio'\n },\n minShapes: 2\n }\n};\n"],"file":"defaults.js"}
|
package/configure/lib/root.js
CHANGED
|
@@ -29,10 +29,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
29
29
|
|
|
30
30
|
var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
|
|
31
31
|
|
|
32
|
-
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
33
|
-
|
|
34
32
|
var _styles = require("@material-ui/core/styles");
|
|
35
33
|
|
|
34
|
+
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
35
|
+
|
|
36
36
|
var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
|
|
37
37
|
|
|
38
38
|
var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
|
|
@@ -41,6 +41,8 @@ var _hotspotPalette = _interopRequireDefault(require("./hotspot-palette"));
|
|
|
41
41
|
|
|
42
42
|
var _hotspotContainer = _interopRequireDefault(require("./hotspot-container"));
|
|
43
43
|
|
|
44
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
45
|
+
|
|
44
46
|
var _utils = require("./utils");
|
|
45
47
|
|
|
46
48
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -132,10 +134,7 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
132
134
|
_ref$spellCheck = _ref.spellCheck,
|
|
133
135
|
spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
|
|
134
136
|
_ref$preserveAspectRa = _ref.preserveAspectRatio,
|
|
135
|
-
preserveAspectRatio = _ref$preserveAspectRa === void 0 ? {} : _ref$preserveAspectRa
|
|
136
|
-
maxSelections = _ref.maxSelections,
|
|
137
|
-
minShapes = _ref.minShapes,
|
|
138
|
-
maxShapes = _ref.maxShapes;
|
|
137
|
+
preserveAspectRatio = _ref$preserveAspectRa === void 0 ? {} : _ref$preserveAspectRa;
|
|
139
138
|
|
|
140
139
|
var _ref2 = model || {},
|
|
141
140
|
teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
|
|
@@ -144,16 +143,13 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
144
143
|
spellCheckEnabled = _ref2.spellCheckEnabled,
|
|
145
144
|
errors = _ref2.errors;
|
|
146
145
|
|
|
147
|
-
var toolbarOpts = {};
|
|
148
|
-
var configSettings = maxSelections || minShapes || maxShapes;
|
|
149
|
-
var maxSelectionsValidation = maxSelections ? "\nNo more than ".concat(maxSelections, " shapes should be selected.") : '';
|
|
150
|
-
var minShapesValidation = minShapes ? "\nThere should be at least ".concat(minShapes, " shapes defined.") : '';
|
|
151
|
-
var maxShapesValidation = maxShapes ? "\nNo more than ".concat(maxShapes, " shapes should be defined.") : '';
|
|
152
|
-
|
|
153
146
|
var _ref3 = errors || {},
|
|
154
147
|
shapesError = _ref3.shapesError,
|
|
155
148
|
selectionsError = _ref3.selectionsError;
|
|
156
149
|
|
|
150
|
+
var toolbarOpts = {};
|
|
151
|
+
var validationMessage = (0, _utils.generateValidationMessage)(configuration);
|
|
152
|
+
|
|
157
153
|
switch (model.toolbarEditorPosition) {
|
|
158
154
|
case 'top':
|
|
159
155
|
toolbarOpts.position = 'top';
|
|
@@ -216,24 +212,26 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
216
212
|
imageSupport: imageSupport,
|
|
217
213
|
toolbarOpts: toolbarOpts,
|
|
218
214
|
spellCheck: spellCheckEnabled
|
|
219
|
-
})), /*#__PURE__*/_react["default"].createElement(
|
|
220
|
-
className: classes.label,
|
|
215
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
216
|
+
className: (0, _classnames["default"])(classes.label, classes.flexContainer)
|
|
217
|
+
}, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
218
|
+
className: classes.subheading,
|
|
221
219
|
variant: "subheading"
|
|
222
|
-
}, "Define Hotspot"),
|
|
220
|
+
}, "Define Hotspot"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
|
|
223
221
|
classes: {
|
|
224
222
|
tooltip: classes.tooltip
|
|
225
223
|
},
|
|
226
224
|
disableFocusListener: true,
|
|
227
225
|
disableTouchListener: true,
|
|
228
226
|
placement: 'left',
|
|
229
|
-
title:
|
|
227
|
+
title: validationMessage
|
|
230
228
|
}, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
|
|
231
229
|
fontSize: 'small',
|
|
232
230
|
color: 'primary',
|
|
233
231
|
style: {
|
|
234
232
|
"float": 'right'
|
|
235
233
|
}
|
|
236
|
-
})), shapesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
234
|
+
}))), shapesError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
237
235
|
className: classes.errorText
|
|
238
236
|
}, shapesError), selectionsError && /*#__PURE__*/_react["default"].createElement("div", {
|
|
239
237
|
className: classes.errorText
|
|
@@ -316,6 +314,9 @@ var styles = function styles(theme) {
|
|
|
316
314
|
paddingTop: theme.spacing.unit * 2,
|
|
317
315
|
width: '100%'
|
|
318
316
|
},
|
|
317
|
+
subheading: {
|
|
318
|
+
marginRight: '5px'
|
|
319
|
+
},
|
|
319
320
|
regular: {
|
|
320
321
|
marginBottom: theme.spacing.unit * 3
|
|
321
322
|
},
|
|
@@ -323,6 +324,10 @@ var styles = function styles(theme) {
|
|
|
323
324
|
justifyContent: 'space-between',
|
|
324
325
|
margin: 0
|
|
325
326
|
},
|
|
327
|
+
flexContainer: {
|
|
328
|
+
display: 'flex',
|
|
329
|
+
alignItems: 'center'
|
|
330
|
+
},
|
|
326
331
|
tooltip: {
|
|
327
332
|
fontSize: '12px',
|
|
328
333
|
whiteSpace: 'pre',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/root.jsx"],"names":["Panel","settings","toggle","Root","fieldType","color","onColorChanged","props","cType","value","resizeType","model","dimensions","shapes","configuration","preserveAspectRatio","onUpdateImageDimension","onUpdateShapes","nextImageDimensions","updatedDimensions","enabled","shapesArray","updatedShapes","classes","imageSupport","onConfigurationChanged","onImageUpload","onModelChangedByConfig","onPromptChanged","onRationaleChanged","onTeacherInstructionsChanged","multipleCorrect","partialScoring","prompt","teacherInstructions","rationale","spellCheck","maxSelections","minShapes","maxShapes","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","errors","toolbarOpts","configSettings","maxSelectionsValidation","minShapesValidation","maxShapesValidation","shapesError","selectionsError","toolbarEditorPosition","position","base","label","Properties","regular","tooltip","errorText","hotspotColor","hotspotList","outlineColor","outlineList","handleColorChange","imageUrl","strokeWidth","width","e","handleOnUpdateImageDimensions","field","height","React","Component","styles","theme","marginTop","spacing","unit","container","display","flex","paddingTop","marginBottom","switchElement","justifyContent","margin","fontSize","whiteSpace","maxWidth","padding","propTypes","PropTypes","object","isRequired","shape","add","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,KAAR,GAA0BC,kBAA1B,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA0BD,kBAA1B,CAAeC,MAAf;;IAEaC,I;;;;;;;;;;;;;;;0GACS,UAACC,SAAD,EAAYC,KAAZ,EAAsB;AACxC,UAAQC,cAAR,GAA2B,MAAKC,KAAhC,CAAQD,cAAR;AACA,UAAME,KAAK,aAAMJ,SAAN,UAAX;AAEAE,MAAAA,cAAc,CAACE,KAAD,EAAQH,KAAR,CAAd;AACD,K;sHAE+B,UAACI,KAAD,EAAQC,UAAR,EAAuB;AACrD,wBAKI,MAAKH,KALT;AAAA,0CACEI,KADF;AAAA,UACWC,UADX,qBACWA,UADX;AAAA,UACuBC,MADvB,qBACuBA,MADvB;AAAA,8CAEEC,aAFF,CAEmBC,mBAFnB;AAAA,UAEmBA,mBAFnB,sCAEyC,EAFzC;AAAA,UAGEC,sBAHF,eAGEA,sBAHF;AAAA,UAIEC,cAJF,eAIEA,cAJF;;AAOA,UAAMC,mBAAmB,mCAAQN,UAAR,4CAAqBF,UAArB,EAAkCD,KAAlC,EAAzB,CARqD,CAUrD;;;AACA,UAAMU,iBAAiB,GAAG,kCACxBP,UADwB,EAExBM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AAE4E,sBAAUK,IAAV,CAAeH,UAXxB;AAYf7E,EAAAA,cAAc,EAAE2E,sBAAUK,IAAV,CAAeH,UAZhB;AAafnE,EAAAA,sBAAsB,EAAEiE,sBAAUK,IAAV,CAAeH,UAbxB;AAcfjE,EAAAA,kBAAkB,EAAE+D,sBAAUK,IAAV,CAAeH,UAdpB;AAefrE,EAAAA,sBAAsB,EAAEmE,sBAAUK,IAAV,CAAeH,UAfxB;AAgBfhE,EAAAA,4BAA4B,EAAE8D,sBAAUK,IAAV,CAAeH;AAhB9B,CAAjB;;eAmBe,wBAAWpB,MAAX,EAAmBvE,IAAnB,C","sourcesContent":["import React from 'react';\nimport {\n settings,\n layout,\n InputContainer,\n NumberTextField\n} from '@pie-lib/config-ui';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport Typography from '@material-ui/core/Typography';\nimport { withStyles } from '@material-ui/core/styles';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\n\nimport HotspotPalette from './hotspot-palette';\nimport HotspotContainer from './hotspot-container';\nimport { updateImageDimensions, getUpdatedShapes, getAllShapes, groupShapes } from './utils';\n\nconst { Panel, toggle } = settings;\n\nexport class Root extends React.Component {\n handleColorChange = (fieldType, color) => {\n const { onColorChanged } = this.props;\n const cType = `${fieldType}Color`;\n\n onColorChanged(cType, color);\n };\n\n handleOnUpdateImageDimensions = (value, resizeType) => {\n const {\n model: { dimensions, shapes },\n configuration: { preserveAspectRatio = {} },\n onUpdateImageDimension,\n onUpdateShapes,\n } = this.props;\n\n const nextImageDimensions = { ...dimensions, [resizeType]: value };\n\n // if preserveAspectRatio.enabled, updateImageDimensions function makes sure aspect ratio is kept\n const updatedDimensions = updateImageDimensions(\n dimensions,\n nextImageDimensions,\n preserveAspectRatio.enabled,\n resizeType\n );\n // transform shapes map into shapes array\n const shapesArray = getAllShapes(shapes);\n // transform all the shapes to fit the re-sized image\n const updatedShapes = getUpdatedShapes(dimensions, updatedDimensions, shapesArray);\n // transform shapes array back into shapes map\n\n onUpdateShapes(groupShapes(updatedShapes));\n onUpdateImageDimension(updatedDimensions);\n };\n\n render() {\n const {\n classes,\n configuration,\n model,\n imageSupport,\n onConfigurationChanged,\n onImageUpload,\n onModelChangedByConfig,\n onPromptChanged,\n onRationaleChanged,\n onUpdateImageDimension,\n onTeacherInstructionsChanged,\n onUpdateShapes\n } = this.props;\n const {\n multipleCorrect = {},\n partialScoring = {},\n prompt = {},\n teacherInstructions = {},\n rationale = {},\n spellCheck = {},\n preserveAspectRatio = {},\n maxSelections,\n minShapes,\n maxShapes\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled, errors } = model || {};\n const toolbarOpts = {};\n const configSettings = maxSelections || minShapes || maxShapes;\n const maxSelectionsValidation = maxSelections ? `\\nNo more than ${maxSelections} shapes should be selected.` : '';\n const minShapesValidation = minShapes ? `\\nThere should be at least ${minShapes} shapes defined.` : '';\n const maxShapesValidation = maxShapes ? `\\nNo more than ${maxShapes} shapes should be defined.` : '';\n\n const { shapesError, selectionsError } = errors || {};\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n return (\n <div className={classes.base}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onModelChangedByConfig}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings': {\n multipleCorrect:\n multipleCorrect.settings && toggle(multipleCorrect.label),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n promptEnabled:\n prompt.settings && toggle(prompt.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n }\n }}\n />\n }\n >\n <div className={classes.regular}>\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.prompt}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.prompt}>\n <EditableHtml\n markup={model.prompt || ''}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.prompt}\n >\n <EditableHtml\n markup={model.rationale || ''}\n onChange={onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n <Typography className={classes.label} variant=\"subheading\">\n Define Hotspot\n </Typography>\n\n {configSettings && <Tooltip\n classes={{tooltip: classes.tooltip}}\n disableFocusListener\n disableTouchListener\n placement={'left'}\n title={`Validation requirements:${maxSelectionsValidation}${minShapesValidation}${maxShapesValidation}`}\n >\n <Info fontSize={'small'} color={'primary'} style={{ float: 'right' }}/>\n </Tooltip>}\n\n {shapesError && <div className={classes.errorText}>{shapesError}</div>}\n {selectionsError && <div className={classes.errorText}>{selectionsError}</div>}\n\n <HotspotPalette\n hotspotColor={model.hotspotColor}\n hotspotList={model.hotspotList}\n outlineColor={model.outlineColor}\n outlineList={model.outlineList}\n onHotspotColorChange={color =>\n this.handleColorChange('hotspot', color)\n }\n onOutlineColorChange={color =>\n this.handleColorChange('outline', color)\n }\n />\n\n <HotspotContainer\n dimensions={model.dimensions}\n imageUrl={model.imageUrl}\n multipleCorrect={model.multipleCorrect}\n hotspotColor={model.hotspotColor}\n outlineColor={model.outlineColor}\n onUpdateImageDimension={onUpdateImageDimension}\n onUpdateShapes={onUpdateShapes}\n onImageUpload={onImageUpload}\n shapes={model.shapes}\n strokeWidth={model.strokeWidth}\n preserveAspectRatioEnabled={preserveAspectRatio.enabled}\n />\n\n {model.imageUrl && (\n <div>\n <Typography className={classes.label} variant=\"subheading\">\n Image Dimensions\n </Typography>\n\n <div className={classes.dimensions}>\n <NumberTextField\n key=\"hotspot-manual-width\"\n label=\"Width\"\n value={model.dimensions.width}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'width')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n <NumberTextField\n key=\"hotspot-manual-height\"\n label=\"Height\"\n value={model.dimensions.height}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'height')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n </div>\n </div>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n base: {\n marginTop: theme.spacing.unit * 3\n },\n container: {\n display: 'flex',\n marginTop: theme.spacing.unit\n },\n dimensions: {\n display: 'flex'\n },\n field: {\n flex: 1,\n width: '90%'\n },\n label: {\n marginTop: theme.spacing.unit * 4\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n regular: {\n marginBottom: theme.spacing.unit * 3\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0'\n }\n});\n\nRoot.propTypes = {\n classes: PropTypes.object.isRequired,\n configuration: PropTypes.object,\n model: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func,\n delete: PropTypes.func\n }),\n onImageUpload: PropTypes.func.isRequired,\n onColorChanged: PropTypes.func.isRequired,\n onPromptChanged: PropTypes.func.isRequired,\n onUpdateImageDimension: PropTypes.func.isRequired,\n onUpdateShapes: PropTypes.func.isRequired,\n onModelChangedByConfig: PropTypes.func.isRequired,\n onRationaleChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n onTeacherInstructionsChanged: PropTypes.func.isRequired,\n};\n\nexport default withStyles(styles)(Root);\n"],"file":"root.js"}
|
|
1
|
+
{"version":3,"sources":["../src/root.jsx"],"names":["Panel","settings","toggle","Root","fieldType","color","onColorChanged","props","cType","value","resizeType","model","dimensions","shapes","configuration","preserveAspectRatio","onUpdateImageDimension","onUpdateShapes","nextImageDimensions","updatedDimensions","enabled","shapesArray","updatedShapes","classes","imageSupport","onConfigurationChanged","onImageUpload","onModelChangedByConfig","onPromptChanged","onRationaleChanged","onTeacherInstructionsChanged","multipleCorrect","partialScoring","prompt","teacherInstructions","rationale","spellCheck","teacherInstructionsEnabled","promptEnabled","rationaleEnabled","spellCheckEnabled","errors","shapesError","selectionsError","toolbarOpts","validationMessage","toolbarEditorPosition","position","base","label","Properties","regular","flexContainer","subheading","tooltip","errorText","hotspotColor","hotspotList","outlineColor","outlineList","handleColorChange","imageUrl","strokeWidth","width","e","handleOnUpdateImageDimensions","field","height","React","Component","styles","theme","marginTop","spacing","unit","container","display","flex","paddingTop","marginRight","marginBottom","switchElement","justifyContent","margin","alignItems","fontSize","whiteSpace","maxWidth","padding","propTypes","PropTypes","object","isRequired","shape","add","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAQA,IAAQA,KAAR,GAA0BC,kBAA1B,CAAQD,KAAR;AAAA,IAAeE,MAAf,GAA0BD,kBAA1B,CAAeC,MAAf;;IAEaC,I;;;;;;;;;;;;;;;0GACS,UAACC,SAAD,EAAYC,KAAZ,EAAsB;AACxC,UAAQC,cAAR,GAA2B,MAAKC,KAAhC,CAAQD,cAAR;AACA,UAAME,KAAK,aAAMJ,SAAN,UAAX;AAEAE,MAAAA,cAAc,CAACE,KAAD,EAAQH,KAAR,CAAd;AACD,K;sHAE+B,UAACI,KAAD,EA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EAAEkE,sBAAUG,KAAV,CAAgB;AAC5BC,IAAAA,GAAG,EAAEJ,sBAAUK,IADa;AAE5B,cAAQL,sBAAUK;AAFU,GAAhB,CAJC;AAQfrE,EAAAA,aAAa,EAAEgE,sBAAUK,IAAV,CAAeH,UARf;AASftF,EAAAA,cAAc,EAAEoF,sBAAUK,IAAV,CAAeH,UAThB;AAUfhE,EAAAA,eAAe,EAAE8D,sBAAUK,IAAV,CAAeH,UAVjB;AAWf5E,EAAAA,sBAAsB,EAAE0E,sBAAUK,IAAV,CAAeH,UAXxB;AAYf3E,EAAAA,cAAc,EAAEyE,sBAAUK,IAAV,CAAeH,UAZhB;AAafjE,EAAAA,sBAAsB,EAAE+D,sBAAUK,IAAV,CAAeH,UAbxB;AAcf/D,EAAAA,kBAAkB,EAAE6D,sBAAUK,IAAV,CAAeH,UAdpB;AAefnE,EAAAA,sBAAsB,EAAEiE,sBAAUK,IAAV,CAAeH,UAfxB;AAgBf9D,EAAAA,4BAA4B,EAAE4D,sBAAUK,IAAV,CAAeH;AAhB9B,CAAjB;;eAmBe,wBAAWtB,MAAX,EAAmBnE,IAAnB,C","sourcesContent":["import React from 'react';\nimport {\n settings,\n layout,\n InputContainer,\n NumberTextField\n} from '@pie-lib/config-ui';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { withStyles } from '@material-ui/core/styles';\nimport Typography from '@material-ui/core/Typography';\nimport Info from '@material-ui/icons/Info';\nimport Tooltip from '@material-ui/core/Tooltip';\nimport HotspotPalette from './hotspot-palette';\nimport HotspotContainer from './hotspot-container';\nimport classNames from 'classnames';\nimport {\n updateImageDimensions,\n generateValidationMessage,\n getUpdatedShapes,\n getAllShapes,\n groupShapes\n} from './utils';\n\nconst { Panel, toggle } = settings;\n\nexport class Root extends React.Component {\n handleColorChange = (fieldType, color) => {\n const { onColorChanged } = this.props;\n const cType = `${fieldType}Color`;\n\n onColorChanged(cType, color);\n };\n\n handleOnUpdateImageDimensions = (value, resizeType) => {\n const {\n model: { dimensions, shapes },\n configuration: { preserveAspectRatio = {} },\n onUpdateImageDimension,\n onUpdateShapes,\n } = this.props;\n\n const nextImageDimensions = { ...dimensions, [resizeType]: value };\n\n // if preserveAspectRatio.enabled, updateImageDimensions function makes sure aspect ratio is kept\n const updatedDimensions = updateImageDimensions(\n dimensions,\n nextImageDimensions,\n preserveAspectRatio.enabled,\n resizeType\n );\n // transform shapes map into shapes array\n const shapesArray = getAllShapes(shapes);\n // transform all the shapes to fit the re-sized image\n const updatedShapes = getUpdatedShapes(dimensions, updatedDimensions, shapesArray);\n // transform shapes array back into shapes map\n\n onUpdateShapes(groupShapes(updatedShapes));\n onUpdateImageDimension(updatedDimensions);\n };\n\n render() {\n const {\n classes,\n configuration,\n model,\n imageSupport,\n onConfigurationChanged,\n onImageUpload,\n onModelChangedByConfig,\n onPromptChanged,\n onRationaleChanged,\n onUpdateImageDimension,\n onTeacherInstructionsChanged,\n onUpdateShapes\n } = this.props;\n const {\n multipleCorrect = {},\n partialScoring = {},\n prompt = {},\n teacherInstructions = {},\n rationale = {},\n spellCheck = {},\n preserveAspectRatio = {}\n } = configuration || {};\n const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled, errors } = model || {};\n const { shapesError, selectionsError } = errors || {};\n const toolbarOpts = {};\n\n const validationMessage = generateValidationMessage(configuration);\n\n switch (model.toolbarEditorPosition) {\n case 'top':\n toolbarOpts.position = 'top';\n break;\n default:\n toolbarOpts.position = 'bottom';\n break;\n }\n\n return (\n <div className={classes.base}>\n <layout.ConfigLayout\n settings={\n <Panel\n model={model}\n onChangeModel={onModelChangedByConfig}\n configuration={configuration}\n onChangeConfiguration={onConfigurationChanged}\n groups={{\n 'Settings': {\n multipleCorrect:\n multipleCorrect.settings && toggle(multipleCorrect.label),\n partialScoring:\n partialScoring.settings && toggle(partialScoring.label),\n promptEnabled:\n prompt.settings && toggle(prompt.label),\n },\n Properties: {\n teacherInstructionsEnabled:\n teacherInstructions.settings && toggle(teacherInstructions.label),\n rationaleEnabled: rationale.settings && toggle(rationale.label),\n spellCheckEnabled:\n spellCheck.settings && toggle(spellCheck.label),\n }\n }}\n />\n }\n >\n <div className={classes.regular}>\n {teacherInstructionsEnabled && (\n <InputContainer label={teacherInstructions.label} className={classes.prompt}>\n <EditableHtml\n markup={model.teacherInstructions || ''}\n onChange={onTeacherInstructionsChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n {promptEnabled && (\n <InputContainer label={prompt.label} className={classes.prompt}>\n <EditableHtml\n markup={model.prompt || ''}\n onChange={onPromptChanged}\n imageSupport={imageSupport}\n nonEmpty={false}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n {rationaleEnabled && (\n <InputContainer\n label={rationale.label}\n className={classes.prompt}\n >\n <EditableHtml\n markup={model.rationale || ''}\n onChange={onRationaleChanged}\n imageSupport={imageSupport}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n />\n </InputContainer>\n )}\n\n <div className={classNames(classes.label, classes.flexContainer)}>\n <Typography className={classes.subheading} variant=\"subheading\">\n Define Hotspot\n </Typography>\n <Tooltip\n classes={{ tooltip: classes.tooltip }}\n disableFocusListener\n disableTouchListener\n placement={'left'}\n title={validationMessage}\n >\n <Info fontSize={'small'} color={'primary'} style={{ float: 'right' }}/>\n </Tooltip>\n </div>\n {shapesError && <div className={classes.errorText}>{shapesError}</div>}\n {selectionsError && <div className={classes.errorText}>{selectionsError}</div>}\n\n <HotspotPalette\n hotspotColor={model.hotspotColor}\n hotspotList={model.hotspotList}\n outlineColor={model.outlineColor}\n outlineList={model.outlineList}\n onHotspotColorChange={color =>\n this.handleColorChange('hotspot', color)\n }\n onOutlineColorChange={color =>\n this.handleColorChange('outline', color)\n }\n />\n\n <HotspotContainer\n dimensions={model.dimensions}\n imageUrl={model.imageUrl}\n multipleCorrect={model.multipleCorrect}\n hotspotColor={model.hotspotColor}\n outlineColor={model.outlineColor}\n onUpdateImageDimension={onUpdateImageDimension}\n onUpdateShapes={onUpdateShapes}\n onImageUpload={onImageUpload}\n shapes={model.shapes}\n strokeWidth={model.strokeWidth}\n preserveAspectRatioEnabled={preserveAspectRatio.enabled}\n />\n\n {model.imageUrl && (\n <div>\n <Typography className={classes.label} variant=\"subheading\">\n Image Dimensions\n </Typography>\n\n <div className={classes.dimensions}>\n <NumberTextField\n key=\"hotspot-manual-width\"\n label=\"Width\"\n value={model.dimensions.width}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'width')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n <NumberTextField\n key=\"hotspot-manual-height\"\n label=\"Height\"\n value={model.dimensions.height}\n min={0}\n onChange={(e, value) => this.handleOnUpdateImageDimensions(value, 'height')}\n showErrorWhenOutsideRange\n className={classes.field}\n />\n </div>\n </div>\n )}\n </div>\n </layout.ConfigLayout>\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n base: {\n marginTop: theme.spacing.unit * 3\n },\n container: {\n display: 'flex',\n marginTop: theme.spacing.unit\n },\n dimensions: {\n display: 'flex'\n },\n field: {\n flex: 1,\n width: '90%'\n },\n label: {\n marginTop: theme.spacing.unit * 4\n },\n prompt: {\n paddingTop: theme.spacing.unit * 2,\n width: '100%'\n },\n subheading: {\n marginRight: '5px'\n },\n regular: {\n marginBottom: theme.spacing.unit * 3\n },\n switchElement: {\n justifyContent: 'space-between',\n margin: 0\n },\n flexContainer: {\n display: 'flex',\n alignItems: 'center'\n },\n tooltip: {\n fontSize: '12px',\n whiteSpace: 'pre',\n maxWidth: '500px',\n },\n errorText: {\n fontSize: '12px',\n color: 'red',\n padding: '5px 0'\n }\n});\n\nRoot.propTypes = {\n classes: PropTypes.object.isRequired,\n configuration: PropTypes.object,\n model: PropTypes.object.isRequired,\n imageSupport: PropTypes.shape({\n add: PropTypes.func,\n delete: PropTypes.func\n }),\n onImageUpload: PropTypes.func.isRequired,\n onColorChanged: PropTypes.func.isRequired,\n onPromptChanged: PropTypes.func.isRequired,\n onUpdateImageDimension: PropTypes.func.isRequired,\n onUpdateShapes: PropTypes.func.isRequired,\n onModelChangedByConfig: PropTypes.func.isRequired,\n onRationaleChanged: PropTypes.func.isRequired,\n onConfigurationChanged: PropTypes.func.isRequired,\n onTeacherInstructionsChanged: PropTypes.func.isRequired,\n};\n\nexport default withStyles(styles)(Root);\n"],"file":"root.js"}
|
package/configure/lib/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.updateImageDimensions = exports.groupShapes = exports.getUpdatedShapes = exports.getUpdatedRectangle = exports.getUpdatedPlygon = exports.getAllShapes = void 0;
|
|
8
|
+
exports.updateImageDimensions = exports.groupShapes = exports.getUpdatedShapes = exports.getUpdatedRectangle = exports.getUpdatedPlygon = exports.getAllShapes = exports.generateValidationMessage = void 0;
|
|
9
9
|
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
11
|
|
|
@@ -145,4 +145,16 @@ var groupShapes = function groupShapes(shapesArray) {
|
|
|
145
145
|
};
|
|
146
146
|
|
|
147
147
|
exports.groupShapes = groupShapes;
|
|
148
|
+
|
|
149
|
+
var generateValidationMessage = function generateValidationMessage(config) {
|
|
150
|
+
var minShapes = config.minShapes,
|
|
151
|
+
maxShapes = config.maxShapes,
|
|
152
|
+
maxSelections = config.maxSelections;
|
|
153
|
+
var shapesMessage = "\nThere should be at least ".concat(minShapes, " ") + (maxShapes ? "and at most ".concat(maxShapes, " ") : '') + 'shapes defined.';
|
|
154
|
+
var selectionsMessage = "\nThere should be at least 1 " + (maxSelections ? "and at most ".concat(maxSelections, " ") : '') + 'shape' + (maxSelections ? 's' : '') + ' selected.';
|
|
155
|
+
var message = 'Validation requirements:' + shapesMessage + selectionsMessage;
|
|
156
|
+
return message;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
exports.generateValidationMessage = generateValidationMessage;
|
|
148
160
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils.js"],"names":["updateImageDimensions","initialDim","nextDim","keepAspectRatio","resizeType","imageAspectRatio","width","height","getDelta","referenceInitialValue","referenceNextValue","currentValue","getUpdatedRectangle","shape","x","y","getUpdatedPlygon","points","map","point","getUpdatedShapes","shapes","group","getAllShapes","shapesMap","shapesArray","shapesKeys","Object","keys","length","reduce","acc","currentShapeKey","concat","index","groupShapes","rectangles","polygons","shapeProps"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;AAEA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,UAAD,EAAaC,OAAb,EAAsBC,eAAtB,EAAuCC,UAAvC,EAAsD;AAClF;AACA,MAAID,eAAJ,EAAqB;AACnB,QAAME,gBAAgB,GAAGJ,UAAU,CAACK,KAAX,GAAmBL,UAAU,CAACM,MAAvD;;AAEA,QAAIH,UAAU,KAAK,QAAnB,EAA6B;AAC3B;AACA,aAAO;AACLE,QAAAA,KAAK,EAAEJ,OAAO,CAACK,MAAR,GAAiBF,gBADnB;AAELE,QAAAA,MAAM,EAAEL,OAAO,CAACK;AAFX,OAAP;AAID,KATkB,CAWnB;;;AACA,WAAO;AACLD,MAAAA,KAAK,EAAEJ,OAAO,CAACI,KADV;AAELC,MAAAA,MAAM,EAAEL,OAAO,CAACI,KAAR,GAAgBD;AAFnB,KAAP;AAID,GAlBiF,CAoBlF;;;AACA,SAAO;AACLC,IAAAA,KAAK,EAAEJ,OAAO,CAACI,KADV;AAELC,IAAAA,MAAM,EAAEL,OAAO,CAACK;AAFX,GAAP;AAID,CAzBD,C,CA2BA;AACA;AACA;;;;;AACA,IAAMC,QAA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A,WAAc,CAACV,WAAD,EAAiB;AACnCA,EAAAA,WAAW,GAAGA,WAAW,IAAI,EAA7B;AACA,MAAMD,SAAS,GAAG;AAChBY,IAAAA,UAAU,EAAE,EADI;AAEhBC,IAAAA,QAAQ,EAAE;AAFM,GAAlB;;AAKA,MAAIZ,WAAW,CAACI,MAAhB,EAAwB;AACtB,WAAOJ,WAAW,CAACK,MAAZ,CAAmB,UAACC,GAAD,QAAmC;AAAA,UAA3BT,KAA2B,QAA3BA,KAA2B;AAAA,UAAjBgB,UAAiB;AAC3DP,MAAAA,GAAG,CAACT,KAAD,CAAH,iDAAkBS,GAAG,CAACT,KAAD,CAAH,IAAc,EAAhC,IAAqCgB,UAArC;AACA,aAAOP,GAAP;AACD,KAHM,EAGJP,SAHI,CAAP;AAID;;AAED,SAAO,2BAAUA,SAAV,CAAP;AACD,CAfD","sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\n\nconst updateImageDimensions = (initialDim, nextDim, keepAspectRatio, resizeType) => {\n // if we want to keep image aspect ratio\n if (keepAspectRatio) {\n const imageAspectRatio = initialDim.width / initialDim.height;\n\n if (resizeType === 'height') {\n // if we want to change image height => we update the width accordingly\n return {\n width: nextDim.height * imageAspectRatio,\n height: nextDim.height\n }\n }\n\n // if we want to change image width => we update the height accordingly\n return {\n width: nextDim.width,\n height: nextDim.width / imageAspectRatio\n }\n }\n\n // if we don't want to keep aspect ratio, we just update both values\n return {\n width: nextDim.width,\n height: nextDim.height\n }\n};\n\n// referenceInitialValue = the initial value of the Stage\n// referenceNextValue = the next value of the Stage\n// currentValue = the value that has to be re-sized influenced by the changes that were made on the Stage\nconst getDelta = (referenceInitialValue, referenceNextValue, currentValue) => (referenceNextValue / referenceInitialValue) * currentValue;\n\nconst getUpdatedRectangle = (initialDim, nextDim, shape) => ({\n ...shape,\n width: getDelta(initialDim.width, nextDim.width, shape.width),\n height: getDelta(initialDim.height, nextDim.height, shape.height),\n x: getDelta(initialDim.width, nextDim.width, shape.x),\n y: getDelta(initialDim.height, nextDim.height, shape.y),\n});\n\nconst getUpdatedPlygon = (initialDim, nextDim, shape) => ({\n ...shape,\n points: shape.points.map(point => ({\n x: getDelta(initialDim.width, nextDim.width, point.x),\n y: getDelta(initialDim.height, nextDim.height, point.y),\n }))\n});\n\n// initialDim = the initial dimensions: { width, height } of the Stage\n// nextDim = the next dimensions: { width, height } of the Stage\n// shapes = array of shapes that have to be re-sized and re-positioned\nconst getUpdatedShapes = (initialDim, nextDim, shapes) => {\n return shapes.map(shape => {\n if (shape.group === 'rectangles') {\n return getUpdatedRectangle(initialDim, nextDim, shape);\n }\n\n if (shape.group === 'polygons') {\n return getUpdatedPlygon(initialDim, nextDim, shape);\n }\n });\n};\n\n// converts shapes map to shapes array\n// example:\n// from: { rectangles: [r1], polygons: [p1, p2]}\n// to: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// if a shape has index defined, keep it, otherwise initialize it\n// index is used for the UNDO function\nconst getAllShapes = (shapesMap) => {\n shapesMap = shapesMap || {};\n const shapesArray = [];\n const shapesKeys = Object.keys(shapesMap);\n\n return shapesKeys.length\n ? shapesKeys.reduce((acc, currentShapeKey) =>\n acc.concat(\n shapesMap[currentShapeKey]\n ? shapesMap[currentShapeKey].map((shape, index) => ({\n ...shape,\n group: currentShapeKey,\n index: shape.index || acc.length + index\n }))\n : []),\n shapesArray)\n : shapesArray;\n};\n\n// converts shapes array to shapes map\n// is the reverse of getAllShapes function\n// example:\n// from: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// to: { rectangles: [r1], polygons: [p1, p2]}\nconst groupShapes = (shapesArray) => {\n shapesArray = shapesArray || [];\n const shapesMap = {\n rectangles: [],\n polygons: []\n };\n\n if (shapesArray.length) {\n return shapesArray.reduce((acc, { group, ...shapeProps }) => {\n acc[group] = [...(acc[group] || []), shapeProps];\n return acc;\n }, shapesMap);\n }\n\n return cloneDeep(shapesMap);\n};\n\n
|
|
1
|
+
{"version":3,"sources":["../src/utils.js"],"names":["updateImageDimensions","initialDim","nextDim","keepAspectRatio","resizeType","imageAspectRatio","width","height","getDelta","referenceInitialValue","referenceNextValue","currentValue","getUpdatedRectangle","shape","x","y","getUpdatedPlygon","points","map","point","getUpdatedShapes","shapes","group","getAllShapes","shapesMap","shapesArray","shapesKeys","Object","keys","length","reduce","acc","currentShapeKey","concat","index","groupShapes","rectangles","polygons","shapeProps","generateValidationMessage","config","minShapes","maxShapes","maxSelections","shapesMessage","selectionsMessage","message"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;AAEA,IAAMA,qBAAqB,GAAG,SAAxBA,qBAAwB,CAACC,UAAD,EAAaC,OAAb,EAAsBC,eAAtB,EAAuCC,UAAvC,EAAsD;AAClF;AACA,MAAID,eAAJ,EAAqB;AACnB,QAAME,gBAAgB,GAAGJ,UAAU,CAACK,KAAX,GAAmBL,UAAU,CAACM,MAAvD;;AAEA,QAAIH,UAAU,KAAK,QAAnB,EAA6B;AAC3B;AACA,aAAO;AACLE,QAAAA,KAAK,EAAEJ,OAAO,CAACK,MAAR,GAAiBF,gBADnB;AAELE,QAAAA,MAAM,EAAEL,OAAO,CAACK;AAFX,OAAP;AAID,KATkB,CAWnB;;;AACA,WAAO;AACLD,MAAAA,KAAK,EAAEJ,OAAO,CAACI,KADV;AAELC,MAAAA,MAAM,EAAEL,OAAO,CAACI,KAAR,GAAgBD;AAFnB,KAAP;AAID,GAlBiF,CAoBlF;;;AACA,SAAO;AACLC,IAAAA,KAAK,EAAEJ,OAAO,CAACI,KADV;AAELC,IAAAA,MAAM,EAAEL,OAAO,CAACK;AAFX,GAAP;AAID,CAzBD,C,CA2BA;AACA;AACA;;;;;AACA,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACC,qBAAD,EAAwBC,kBAAxB,EAA4CC,YAA5C;AAAA,SAA8DD,kBAAkB,GAAGD,qBAAtB,GAA+CE,YAA5G;AAAA,CAAjB;;AA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AAAA,QAAQ,EAAE;AAFM,GAAlB;;AAKA,MAAIZ,WAAW,CAACI,MAAhB,EAAwB;AACtB,WAAOJ,WAAW,CAACK,MAAZ,CAAmB,UAACC,GAAD,QAAmC;AAAA,UAA3BT,KAA2B,QAA3BA,KAA2B;AAAA,UAAjBgB,UAAiB;AAC3DP,MAAAA,GAAG,CAACT,KAAD,CAAH,iDAAkBS,GAAG,CAACT,KAAD,CAAH,IAAc,EAAhC,IAAqCgB,UAArC;AACA,aAAOP,GAAP;AACD,KAHM,EAGJP,SAHI,CAAP;AAID;;AAED,SAAO,2BAAUA,SAAV,CAAP;AACD,CAfD;;;;AAiBA,IAAMe,yBAAyB,GAAG,SAA5BA,yBAA4B,CAAAC,MAAM,EAAI;AAC1C,MAAQC,SAAR,GAAgDD,MAAhD,CAAQC,SAAR;AAAA,MAAmBC,SAAnB,GAAgDF,MAAhD,CAAmBE,SAAnB;AAAA,MAA8BC,aAA9B,GAAgDH,MAAhD,CAA8BG,aAA9B;AAEA,MAAMC,aAAa,GAAG,qCAA8BH,SAA9B,UACnBC,SAAS,yBAAkBA,SAAlB,SAAiC,EADvB,IAC6B,iBADnD;AAGA,MAAMG,iBAAiB,GAAG,mCACvBF,aAAa,yBAAkBA,aAAlB,SAAqC,EAD3B,IACiC,OADjC,IAEvBA,aAAa,GAAG,GAAH,GAAS,EAFC,IAEM,YAFhC;AAIA,MAAMG,OAAO,GAAG,6BAA6BF,aAA7B,GAA6CC,iBAA7D;AAEA,SAAOC,OAAP;AACD,CAbD","sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\n\nconst updateImageDimensions = (initialDim, nextDim, keepAspectRatio, resizeType) => {\n // if we want to keep image aspect ratio\n if (keepAspectRatio) {\n const imageAspectRatio = initialDim.width / initialDim.height;\n\n if (resizeType === 'height') {\n // if we want to change image height => we update the width accordingly\n return {\n width: nextDim.height * imageAspectRatio,\n height: nextDim.height\n }\n }\n\n // if we want to change image width => we update the height accordingly\n return {\n width: nextDim.width,\n height: nextDim.width / imageAspectRatio\n }\n }\n\n // if we don't want to keep aspect ratio, we just update both values\n return {\n width: nextDim.width,\n height: nextDim.height\n }\n};\n\n// referenceInitialValue = the initial value of the Stage\n// referenceNextValue = the next value of the Stage\n// currentValue = the value that has to be re-sized influenced by the changes that were made on the Stage\nconst getDelta = (referenceInitialValue, referenceNextValue, currentValue) => (referenceNextValue / referenceInitialValue) * currentValue;\n\nconst getUpdatedRectangle = (initialDim, nextDim, shape) => ({\n ...shape,\n width: getDelta(initialDim.width, nextDim.width, shape.width),\n height: getDelta(initialDim.height, nextDim.height, shape.height),\n x: getDelta(initialDim.width, nextDim.width, shape.x),\n y: getDelta(initialDim.height, nextDim.height, shape.y),\n});\n\nconst getUpdatedPlygon = (initialDim, nextDim, shape) => ({\n ...shape,\n points: shape.points.map(point => ({\n x: getDelta(initialDim.width, nextDim.width, point.x),\n y: getDelta(initialDim.height, nextDim.height, point.y),\n }))\n});\n\n// initialDim = the initial dimensions: { width, height } of the Stage\n// nextDim = the next dimensions: { width, height } of the Stage\n// shapes = array of shapes that have to be re-sized and re-positioned\nconst getUpdatedShapes = (initialDim, nextDim, shapes) => {\n return shapes.map(shape => {\n if (shape.group === 'rectangles') {\n return getUpdatedRectangle(initialDim, nextDim, shape);\n }\n\n if (shape.group === 'polygons') {\n return getUpdatedPlygon(initialDim, nextDim, shape);\n }\n });\n};\n\n// converts shapes map to shapes array\n// example:\n// from: { rectangles: [r1], polygons: [p1, p2]}\n// to: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// if a shape has index defined, keep it, otherwise initialize it\n// index is used for the UNDO function\nconst getAllShapes = (shapesMap) => {\n shapesMap = shapesMap || {};\n const shapesArray = [];\n const shapesKeys = Object.keys(shapesMap);\n\n return shapesKeys.length\n ? shapesKeys.reduce((acc, currentShapeKey) =>\n acc.concat(\n shapesMap[currentShapeKey]\n ? shapesMap[currentShapeKey].map((shape, index) => ({\n ...shape,\n group: currentShapeKey,\n index: shape.index || acc.length + index\n }))\n : []),\n shapesArray)\n : shapesArray;\n};\n\n// converts shapes array to shapes map\n// is the reverse of getAllShapes function\n// example:\n// from: [{ ...r1, group: 'rectangles' }, { ...p1, group: 'polygons' }, { ...p2, group: 'polygons' }]\n// to: { rectangles: [r1], polygons: [p1, p2]}\nconst groupShapes = (shapesArray) => {\n shapesArray = shapesArray || [];\n const shapesMap = {\n rectangles: [],\n polygons: []\n };\n\n if (shapesArray.length) {\n return shapesArray.reduce((acc, { group, ...shapeProps }) => {\n acc[group] = [...(acc[group] || []), shapeProps];\n return acc;\n }, shapesMap);\n }\n\n return cloneDeep(shapesMap);\n};\n\nconst generateValidationMessage = config => {\n const { minShapes, maxShapes, maxSelections } = config;\n\n const shapesMessage = `\\nThere should be at least ${minShapes} ` +\n (maxShapes ? `and at most ${maxShapes} ` : '') + 'shapes defined.';\n\n const selectionsMessage = `\\nThere should be at least 1 ` +\n (maxSelections ? `and at most ${maxSelections} ` : '') + 'shape' +\n (maxSelections ? 's' : '') + ' selected.';\n\n const message = 'Validation requirements:' + shapesMessage + selectionsMessage;\n\n return message;\n};\n\nexport {\n updateImageDimensions,\n generateValidationMessage,\n getUpdatedShapes,\n getAllShapes,\n groupShapes,\n getUpdatedRectangle,\n getUpdatedPlygon\n};\n"],"file":"utils.js"}
|
|
@@ -7,6 +7,7 @@ exports[`Root render renders 1`] = `
|
|
|
7
7
|
<Panel
|
|
8
8
|
configuration={
|
|
9
9
|
Object {
|
|
10
|
+
"minShapes": 2,
|
|
10
11
|
"multipleCorrect": Object {
|
|
11
12
|
"label": "Multiple Correct Responses",
|
|
12
13
|
"settings": true,
|
|
@@ -176,11 +177,38 @@ exports[`Root render renders 1`] = `
|
|
|
176
177
|
}
|
|
177
178
|
>
|
|
178
179
|
<div>
|
|
179
|
-
<
|
|
180
|
-
|
|
180
|
+
<div
|
|
181
|
+
className=""
|
|
181
182
|
>
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
<WithStyles(Typography)
|
|
184
|
+
variant="subheading"
|
|
185
|
+
>
|
|
186
|
+
Define Hotspot
|
|
187
|
+
</WithStyles(Typography)>
|
|
188
|
+
<WithStyles(Tooltip)
|
|
189
|
+
classes={
|
|
190
|
+
Object {
|
|
191
|
+
"tooltip": undefined,
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
disableFocusListener={true}
|
|
195
|
+
disableTouchListener={true}
|
|
196
|
+
placement="left"
|
|
197
|
+
title="Validation requirements:
|
|
198
|
+
There should be at least 2 shapes defined.
|
|
199
|
+
There should be at least 1 shape selected."
|
|
200
|
+
>
|
|
201
|
+
<pure(InfoIcon)
|
|
202
|
+
color="primary"
|
|
203
|
+
fontSize="small"
|
|
204
|
+
style={
|
|
205
|
+
Object {
|
|
206
|
+
"float": "right",
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/>
|
|
210
|
+
</WithStyles(Tooltip)>
|
|
211
|
+
</div>
|
|
184
212
|
<WithStyles(Palette)
|
|
185
213
|
hotspotColor="rgba(137, 183, 244, 0.65)"
|
|
186
214
|
hotspotList={
|
package/configure/src/root.jsx
CHANGED
|
@@ -7,14 +7,20 @@ import {
|
|
|
7
7
|
} from '@pie-lib/config-ui';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import EditableHtml from '@pie-lib/editable-html';
|
|
10
|
-
import Typography from '@material-ui/core/Typography';
|
|
11
10
|
import { withStyles } from '@material-ui/core/styles';
|
|
11
|
+
import Typography from '@material-ui/core/Typography';
|
|
12
12
|
import Info from '@material-ui/icons/Info';
|
|
13
13
|
import Tooltip from '@material-ui/core/Tooltip';
|
|
14
|
-
|
|
15
14
|
import HotspotPalette from './hotspot-palette';
|
|
16
15
|
import HotspotContainer from './hotspot-container';
|
|
17
|
-
import
|
|
16
|
+
import classNames from 'classnames';
|
|
17
|
+
import {
|
|
18
|
+
updateImageDimensions,
|
|
19
|
+
generateValidationMessage,
|
|
20
|
+
getUpdatedShapes,
|
|
21
|
+
getAllShapes,
|
|
22
|
+
groupShapes
|
|
23
|
+
} from './utils';
|
|
18
24
|
|
|
19
25
|
const { Panel, toggle } = settings;
|
|
20
26
|
|
|
@@ -75,19 +81,13 @@ export class Root extends React.Component {
|
|
|
75
81
|
teacherInstructions = {},
|
|
76
82
|
rationale = {},
|
|
77
83
|
spellCheck = {},
|
|
78
|
-
preserveAspectRatio = {}
|
|
79
|
-
maxSelections,
|
|
80
|
-
minShapes,
|
|
81
|
-
maxShapes
|
|
84
|
+
preserveAspectRatio = {}
|
|
82
85
|
} = configuration || {};
|
|
83
86
|
const { teacherInstructionsEnabled, promptEnabled, rationaleEnabled, spellCheckEnabled, errors } = model || {};
|
|
87
|
+
const { shapesError, selectionsError } = errors || {};
|
|
84
88
|
const toolbarOpts = {};
|
|
85
|
-
const configSettings = maxSelections || minShapes || maxShapes;
|
|
86
|
-
const maxSelectionsValidation = maxSelections ? `\nNo more than ${maxSelections} shapes should be selected.` : '';
|
|
87
|
-
const minShapesValidation = minShapes ? `\nThere should be at least ${minShapes} shapes defined.` : '';
|
|
88
|
-
const maxShapesValidation = maxShapes ? `\nNo more than ${maxShapes} shapes should be defined.` : '';
|
|
89
89
|
|
|
90
|
-
const
|
|
90
|
+
const validationMessage = generateValidationMessage(configuration);
|
|
91
91
|
|
|
92
92
|
switch (model.toolbarEditorPosition) {
|
|
93
93
|
case 'top':
|
|
@@ -168,20 +168,20 @@ export class Root extends React.Component {
|
|
|
168
168
|
</InputContainer>
|
|
169
169
|
)}
|
|
170
170
|
|
|
171
|
-
<
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
171
|
+
<div className={classNames(classes.label, classes.flexContainer)}>
|
|
172
|
+
<Typography className={classes.subheading} variant="subheading">
|
|
173
|
+
Define Hotspot
|
|
174
|
+
</Typography>
|
|
175
|
+
<Tooltip
|
|
176
|
+
classes={{ tooltip: classes.tooltip }}
|
|
177
|
+
disableFocusListener
|
|
178
|
+
disableTouchListener
|
|
179
|
+
placement={'left'}
|
|
180
|
+
title={validationMessage}
|
|
181
|
+
>
|
|
182
|
+
<Info fontSize={'small'} color={'primary'} style={{ float: 'right' }}/>
|
|
183
|
+
</Tooltip>
|
|
184
|
+
</div>
|
|
185
185
|
{shapesError && <div className={classes.errorText}>{shapesError}</div>}
|
|
186
186
|
{selectionsError && <div className={classes.errorText}>{selectionsError}</div>}
|
|
187
187
|
|
|
@@ -269,6 +269,9 @@ const styles = theme => ({
|
|
|
269
269
|
paddingTop: theme.spacing.unit * 2,
|
|
270
270
|
width: '100%'
|
|
271
271
|
},
|
|
272
|
+
subheading: {
|
|
273
|
+
marginRight: '5px'
|
|
274
|
+
},
|
|
272
275
|
regular: {
|
|
273
276
|
marginBottom: theme.spacing.unit * 3
|
|
274
277
|
},
|
|
@@ -276,6 +279,10 @@ const styles = theme => ({
|
|
|
276
279
|
justifyContent: 'space-between',
|
|
277
280
|
margin: 0
|
|
278
281
|
},
|
|
282
|
+
flexContainer: {
|
|
283
|
+
display: 'flex',
|
|
284
|
+
alignItems: 'center'
|
|
285
|
+
},
|
|
279
286
|
tooltip: {
|
|
280
287
|
fontSize: '12px',
|
|
281
288
|
whiteSpace: 'pre',
|
package/configure/src/utils.js
CHANGED
|
@@ -110,5 +110,27 @@ const groupShapes = (shapesArray) => {
|
|
|
110
110
|
return cloneDeep(shapesMap);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
const generateValidationMessage = config => {
|
|
114
|
+
const { minShapes, maxShapes, maxSelections } = config;
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
const shapesMessage = `\nThere should be at least ${minShapes} ` +
|
|
117
|
+
(maxShapes ? `and at most ${maxShapes} ` : '') + 'shapes defined.';
|
|
118
|
+
|
|
119
|
+
const selectionsMessage = `\nThere should be at least 1 ` +
|
|
120
|
+
(maxSelections ? `and at most ${maxSelections} ` : '') + 'shape' +
|
|
121
|
+
(maxSelections ? 's' : '') + ' selected.';
|
|
122
|
+
|
|
123
|
+
const message = 'Validation requirements:' + shapesMessage + selectionsMessage;
|
|
124
|
+
|
|
125
|
+
return message;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
updateImageDimensions,
|
|
130
|
+
generateValidationMessage,
|
|
131
|
+
getUpdatedShapes,
|
|
132
|
+
getAllShapes,
|
|
133
|
+
groupShapes,
|
|
134
|
+
getUpdatedRectangle,
|
|
135
|
+
getUpdatedPlygon
|
|
136
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/hotspot",
|
|
3
|
-
"version": "4.8.4-next.
|
|
3
|
+
"version": "4.8.4-next.812+286cba65e",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "pie framework developers",
|
|
21
21
|
"license": "ISC",
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "286cba65e15e1f83006b50de3250e0f942fb0a79",
|
|
23
23
|
"scripts": {
|
|
24
24
|
"postpublish": "../../scripts/postpublish"
|
|
25
25
|
},
|