@pie-element/hotspot 9.3.4-next.0 → 10.0.0-beta.0

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.
Files changed (103) hide show
  1. package/configure/lib/DeleteWidget.js +30 -43
  2. package/configure/lib/DeleteWidget.js.map +1 -1
  3. package/configure/lib/button.js +26 -45
  4. package/configure/lib/button.js.map +1 -1
  5. package/configure/lib/buttons/circle.js +20 -27
  6. package/configure/lib/buttons/circle.js.map +1 -1
  7. package/configure/lib/buttons/polygon.js +26 -33
  8. package/configure/lib/buttons/polygon.js.map +1 -1
  9. package/configure/lib/buttons/rectangle.js +26 -33
  10. package/configure/lib/buttons/rectangle.js.map +1 -1
  11. package/configure/lib/defaults.js +2 -3
  12. package/configure/lib/defaults.js.map +1 -1
  13. package/configure/lib/hotspot-circle.js +132 -198
  14. package/configure/lib/hotspot-circle.js.map +1 -1
  15. package/configure/lib/hotspot-container.js +250 -355
  16. package/configure/lib/hotspot-container.js.map +1 -1
  17. package/configure/lib/hotspot-drawable.js +360 -472
  18. package/configure/lib/hotspot-drawable.js.map +1 -1
  19. package/configure/lib/hotspot-palette.js +92 -139
  20. package/configure/lib/hotspot-palette.js.map +1 -1
  21. package/configure/lib/hotspot-polygon.js +212 -317
  22. package/configure/lib/hotspot-polygon.js.map +1 -1
  23. package/configure/lib/hotspot-rectangle.js +128 -192
  24. package/configure/lib/hotspot-rectangle.js.map +1 -1
  25. package/configure/lib/icons.js.map +1 -1
  26. package/configure/lib/image-konva.js +46 -86
  27. package/configure/lib/image-konva.js.map +1 -1
  28. package/configure/lib/index.js +162 -222
  29. package/configure/lib/index.js.map +1 -1
  30. package/configure/lib/root.js +301 -393
  31. package/configure/lib/root.js.map +1 -1
  32. package/configure/lib/shapes/circle.js +69 -101
  33. package/configure/lib/shapes/circle.js.map +1 -1
  34. package/configure/lib/shapes/index.js +4 -12
  35. package/configure/lib/shapes/index.js.map +1 -1
  36. package/configure/lib/shapes/polygon.js +64 -96
  37. package/configure/lib/shapes/polygon.js.map +1 -1
  38. package/configure/lib/shapes/rectagle.js +69 -101
  39. package/configure/lib/shapes/rectagle.js.map +1 -1
  40. package/configure/lib/shapes/utils.js +2 -8
  41. package/configure/lib/shapes/utils.js.map +1 -1
  42. package/configure/lib/upload-control.js +25 -52
  43. package/configure/lib/upload-control.js.map +1 -1
  44. package/configure/lib/utils.js +84 -137
  45. package/configure/lib/utils.js.map +1 -1
  46. package/configure/package.json +11 -10
  47. package/configure/src/__tests__/hotspot-container.test.js +50 -19
  48. package/configure/src/__tests__/hotspot-drawable.test.js +55 -34
  49. package/configure/src/__tests__/index.test.js +167 -5
  50. package/configure/src/__tests__/root.test.js +89 -63
  51. package/configure/src/button.jsx +12 -20
  52. package/configure/src/hotspot-circle.jsx +5 -18
  53. package/configure/src/hotspot-container.jsx +82 -98
  54. package/configure/src/hotspot-drawable.jsx +43 -45
  55. package/configure/src/hotspot-palette.jsx +45 -37
  56. package/configure/src/hotspot-polygon.jsx +4 -20
  57. package/configure/src/hotspot-rectangle.jsx +4 -17
  58. package/configure/src/index.js +12 -2
  59. package/configure/src/root.jsx +85 -79
  60. package/configure/src/upload-control.jsx +6 -16
  61. package/controller/lib/defaults.js +2 -3
  62. package/controller/lib/defaults.js.map +1 -1
  63. package/controller/lib/index.js +151 -205
  64. package/controller/lib/index.js.map +1 -1
  65. package/controller/lib/utils.js +14 -34
  66. package/controller/lib/utils.js.map +1 -1
  67. package/controller/package.json +2 -2
  68. package/lib/hotspot/circle.js +110 -169
  69. package/lib/hotspot/circle.js.map +1 -1
  70. package/lib/hotspot/container.js +174 -260
  71. package/lib/hotspot/container.js.map +1 -1
  72. package/lib/hotspot/icons.js.map +1 -1
  73. package/lib/hotspot/image-konva-tooltip.js +65 -112
  74. package/lib/hotspot/image-konva-tooltip.js.map +1 -1
  75. package/lib/hotspot/index.js +135 -198
  76. package/lib/hotspot/index.js.map +1 -1
  77. package/lib/hotspot/polygon.js +150 -214
  78. package/lib/hotspot/polygon.js.map +1 -1
  79. package/lib/hotspot/rectangle.js +128 -185
  80. package/lib/hotspot/rectangle.js.map +1 -1
  81. package/lib/index.js +187 -256
  82. package/lib/index.js.map +1 -1
  83. package/lib/session-updater.js +12 -18
  84. package/lib/session-updater.js.map +1 -1
  85. package/package.json +14 -11
  86. package/src/__tests__/container.test.jsx +27 -175
  87. package/src/__tests__/index.test.js +70 -30
  88. package/src/hotspot/circle.jsx +2 -13
  89. package/src/hotspot/container.jsx +35 -50
  90. package/src/hotspot/index.jsx +16 -28
  91. package/src/hotspot/polygon.jsx +4 -13
  92. package/src/hotspot/rectangle.jsx +5 -15
  93. package/src/index.js +21 -12
  94. package/configure/src/__tests__/DeleteWidget.test.js +0 -64
  95. package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +0 -192
  96. package/configure/src/__tests__/__snapshots__/hotspot-drawable.test.js.snap +0 -562
  97. package/configure/src/__tests__/__snapshots__/root.test.js.snap +0 -469
  98. package/src/__tests__/__snapshots__/container.test.jsx.snap +0 -264
  99. package/src/__tests__/__snapshots__/index.test.js.snap +0 -81
  100. package/src/__tests__/__snapshots__/polygon.test.jsx.snap +0 -192
  101. package/src/__tests__/__snapshots__/rectangle.test.jsx.snap +0 -127
  102. package/src/__tests__/polygon.test.jsx +0 -230
  103. package/src/__tests__/rectangle.test.jsx +0 -232
@@ -1,422 +1,330 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports["default"] = exports.Root = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
7
+ exports.default = exports.Root = void 0;
22
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
9
  var _react = _interopRequireDefault(require("react"));
25
-
26
10
  var _configUi = require("@pie-lib/config-ui");
27
-
28
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
29
-
30
12
  var _editableHtml = _interopRequireDefault(require("@pie-lib/editable-html"));
31
-
32
- var _styles = require("@material-ui/core/styles");
33
-
34
- var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
35
-
36
- var _Info = _interopRequireDefault(require("@material-ui/icons/Info"));
37
-
38
- var _Tooltip = _interopRequireDefault(require("@material-ui/core/Tooltip"));
39
-
13
+ var _styles = require("@mui/material/styles");
14
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
15
+ var _Info = _interopRequireDefault(require("@mui/icons-material/Info"));
16
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
40
17
  var _hotspotPalette = _interopRequireDefault(require("./hotspot-palette"));
41
-
42
18
  var _hotspotContainer = _interopRequireDefault(require("./hotspot-container"));
43
-
44
19
  var _utils = require("./utils");
45
-
46
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
47
-
48
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
49
-
50
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
51
-
52
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
-
54
- var Panel = _configUi.settings.Panel,
55
- toggle = _configUi.settings.toggle,
56
- dropdown = _configUi.settings.dropdown;
57
-
58
- var Root = /*#__PURE__*/function (_React$Component) {
59
- (0, _inherits2["default"])(Root, _React$Component);
60
-
61
- var _super = _createSuper(Root);
62
-
63
- function Root() {
64
- var _this;
65
-
66
- (0, _classCallCheck2["default"])(this, Root);
67
-
68
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
69
- args[_key] = arguments[_key];
70
- }
71
-
72
- _this = _super.call.apply(_super, [this].concat(args));
73
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleColorChange", function (fieldType, color) {
74
- var onColorChanged = _this.props.onColorChanged;
75
- var cType = "".concat(fieldType, "Color");
20
+ const {
21
+ Panel,
22
+ toggle,
23
+ dropdown
24
+ } = _configUi.settings;
25
+ const DimensionsContainer = (0, _styles.styled)('div')(({
26
+ theme
27
+ }) => ({
28
+ display: 'flex',
29
+ marginBottom: theme.spacing(1.5)
30
+ }));
31
+ const FieldContainer = (0, _styles.styled)('div')({
32
+ flex: 1,
33
+ width: '90%'
34
+ });
35
+ const PromptContainer = (0, _styles.styled)(_configUi.InputContainer)(({
36
+ theme
37
+ }) => ({
38
+ paddingTop: theme.spacing(1),
39
+ marginTop: theme.spacing(2),
40
+ marginBottom: theme.spacing(2),
41
+ width: '100%'
42
+ }));
43
+ const SubHeading = (0, _styles.styled)(_Typography.default)(({
44
+ theme
45
+ }) => ({
46
+ marginRight: theme.spacing(1)
47
+ }));
48
+ const FlexContainer = (0, _styles.styled)('div')({
49
+ display: 'flex',
50
+ alignItems: 'center'
51
+ });
52
+ const StyledTooltip = (0, _styles.styled)(_Tooltip.default)(({
53
+ theme
54
+ }) => ({
55
+ '& .MuiTooltip-tooltip': {
56
+ fontSize: theme.typography.fontSize - 2,
57
+ whiteSpace: 'pre',
58
+ maxWidth: '500px'
59
+ }
60
+ }));
61
+ const ErrorText = (0, _styles.styled)('div')(({
62
+ theme
63
+ }) => ({
64
+ fontSize: theme.typography.fontSize - 2,
65
+ color: theme.palette.error.main,
66
+ paddingTop: theme.spacing(1)
67
+ }));
68
+ class Root extends _react.default.Component {
69
+ constructor(...args) {
70
+ super(...args);
71
+ (0, _defineProperty2.default)(this, "handleColorChange", (fieldType, color) => {
72
+ const {
73
+ onColorChanged
74
+ } = this.props;
75
+ const cType = `${fieldType}Color`;
76
76
  onColorChanged(cType, color);
77
77
  });
78
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleOnUpdateImageDimensions", function (value, resizeType) {
79
- var _this$props = _this.props,
80
- _this$props$model = _this$props.model,
81
- dimensions = _this$props$model.dimensions,
82
- shapes = _this$props$model.shapes,
83
- _this$props$configura = _this$props.configuration.preserveAspectRatio,
84
- preserveAspectRatio = _this$props$configura === void 0 ? {} : _this$props$configura,
85
- onUpdateImageDimension = _this$props.onUpdateImageDimension,
86
- onUpdateShapes = _this$props.onUpdateShapes;
87
-
88
- var nextImageDimensions = _objectSpread(_objectSpread({}, dimensions), {}, (0, _defineProperty2["default"])({}, resizeType, value)); // if preserveAspectRatio.enabled, updateImageDimensions function makes sure aspect ratio is kept
89
-
90
-
91
- var updatedDimensions = (0, _utils.updateImageDimensions)(dimensions, nextImageDimensions, preserveAspectRatio.enabled, resizeType); // transform shapes map into shapes array
92
-
93
- var shapesArray = (0, _utils.getAllShapes)(shapes); // transform all the shapes to fit the re-sized image
78
+ (0, _defineProperty2.default)(this, "handleOnUpdateImageDimensions", (value, resizeType) => {
79
+ const {
80
+ model: {
81
+ dimensions,
82
+ shapes
83
+ },
84
+ configuration: {
85
+ preserveAspectRatio = {}
86
+ },
87
+ onUpdateImageDimension,
88
+ onUpdateShapes
89
+ } = this.props;
90
+ const nextImageDimensions = {
91
+ ...dimensions,
92
+ [resizeType]: value
93
+ };
94
94
 
95
- var updatedShapes = (0, _utils.getUpdatedShapes)(dimensions, updatedDimensions, shapesArray); // transform shapes array back into shapes map
95
+ // if preserveAspectRatio.enabled, updateImageDimensions function makes sure aspect ratio is kept
96
+ const updatedDimensions = (0, _utils.updateImageDimensions)(dimensions, nextImageDimensions, preserveAspectRatio.enabled, resizeType);
97
+ // transform shapes map into shapes array
98
+ const shapesArray = (0, _utils.getAllShapes)(shapes);
99
+ // transform all the shapes to fit the re-sized image
100
+ const updatedShapes = (0, _utils.getUpdatedShapes)(dimensions, updatedDimensions, shapesArray);
101
+ // transform shapes array back into shapes map
96
102
 
97
103
  onUpdateShapes((0, _utils.groupShapes)(updatedShapes));
98
104
  onUpdateImageDimension(updatedDimensions);
99
105
  });
100
- return _this;
101
106
  }
102
-
103
- (0, _createClass2["default"])(Root, [{
104
- key: "render",
105
- value: function render() {
106
- var _this2 = this;
107
-
108
- var _this$props2 = this.props,
109
- classes = _this$props2.classes,
110
- configuration = _this$props2.configuration,
111
- model = _this$props2.model,
112
- imageSupport = _this$props2.imageSupport,
113
- uploadSoundSupport = _this$props2.uploadSoundSupport,
114
- onConfigurationChanged = _this$props2.onConfigurationChanged,
115
- onImageUpload = _this$props2.onImageUpload,
116
- onModelChangedByConfig = _this$props2.onModelChangedByConfig,
117
- onPromptChanged = _this$props2.onPromptChanged,
118
- onRationaleChanged = _this$props2.onRationaleChanged,
119
- onUpdateImageDimension = _this$props2.onUpdateImageDimension,
120
- onTeacherInstructionsChanged = _this$props2.onTeacherInstructionsChanged,
121
- onUpdateShapes = _this$props2.onUpdateShapes;
122
-
123
- var _ref = configuration || {},
124
- _ref$baseInputConfigu = _ref.baseInputConfiguration,
125
- baseInputConfiguration = _ref$baseInputConfigu === void 0 ? {} : _ref$baseInputConfigu,
126
- _ref$contentDimension = _ref.contentDimensions,
127
- contentDimensions = _ref$contentDimension === void 0 ? {} : _ref$contentDimension,
128
- _ref$maxImageWidth = _ref.maxImageWidth,
129
- maxImageWidth = _ref$maxImageWidth === void 0 ? {} : _ref$maxImageWidth,
130
- _ref$maxImageHeight = _ref.maxImageHeight,
131
- maxImageHeight = _ref$maxImageHeight === void 0 ? {} : _ref$maxImageHeight,
132
- _ref$multipleCorrect = _ref.multipleCorrect,
133
- multipleCorrect = _ref$multipleCorrect === void 0 ? {} : _ref$multipleCorrect,
134
- _ref$partialScoring = _ref.partialScoring,
135
- partialScoring = _ref$partialScoring === void 0 ? {} : _ref$partialScoring,
136
- _ref$preserveAspectRa = _ref.preserveAspectRatio,
137
- preserveAspectRatio = _ref$preserveAspectRa === void 0 ? {} : _ref$preserveAspectRa,
138
- _ref$prompt = _ref.prompt,
139
- prompt = _ref$prompt === void 0 ? {} : _ref$prompt,
140
- _ref$rationale = _ref.rationale,
141
- rationale = _ref$rationale === void 0 ? {} : _ref$rationale,
142
- settingsPanelDisabled = _ref.settingsPanelDisabled,
143
- _ref$spellCheck = _ref.spellCheck,
144
- spellCheck = _ref$spellCheck === void 0 ? {} : _ref$spellCheck,
145
- _ref$teacherInstructi = _ref.teacherInstructions,
146
- teacherInstructions = _ref$teacherInstructi === void 0 ? {} : _ref$teacherInstructi,
147
- _ref$withRubric = _ref.withRubric,
148
- withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric,
149
- _ref$mathMlOptions = _ref.mathMlOptions,
150
- mathMlOptions = _ref$mathMlOptions === void 0 ? {} : _ref$mathMlOptions,
151
- _ref$language = _ref.language,
152
- language = _ref$language === void 0 ? {} : _ref$language,
153
- _ref$languageChoices = _ref.languageChoices,
154
- languageChoices = _ref$languageChoices === void 0 ? {} : _ref$languageChoices;
155
-
156
- var _ref2 = model || {},
157
- errors = _ref2.errors,
158
- extraCSSRules = _ref2.extraCSSRules,
159
- promptEnabled = _ref2.promptEnabled,
160
- rationaleEnabled = _ref2.rationaleEnabled,
161
- spellCheckEnabled = _ref2.spellCheckEnabled,
162
- teacherInstructionsEnabled = _ref2.teacherInstructionsEnabled,
163
- toolbarEditorPosition = _ref2.toolbarEditorPosition;
164
-
165
- var _ref3 = errors || {},
166
- promptError = _ref3.prompt,
167
- rationaleError = _ref3.rationale,
168
- shapesError = _ref3.shapes,
169
- selectionsError = _ref3.selections,
170
- teacherInstructionsError = _ref3.teacherInstructions;
171
-
172
- var validationMessage = (0, _utils.generateValidationMessage)(configuration);
173
- var defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
174
- var defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
175
- var toolbarOpts = {
176
- position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
177
- };
178
- var panelSettings = {
179
- multipleCorrect: multipleCorrect.settings && toggle(multipleCorrect.label),
180
- partialScoring: partialScoring.settings && toggle(partialScoring.label),
181
- promptEnabled: prompt.settings && toggle(prompt.label),
182
- 'language.enabled': language.settings && toggle(language.label, true),
183
- language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
184
- };
185
- var panelProperties = {
186
- teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
187
- rationaleEnabled: rationale.settings && toggle(rationale.label),
188
- spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
189
- rubricEnabled: (withRubric === null || withRubric === void 0 ? void 0 : withRubric.settings) && toggle(withRubric === null || withRubric === void 0 ? void 0 : withRubric.label)
190
- };
191
-
192
- var getPluginProps = function getPluginProps() {
193
- var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
194
- return _objectSpread(_objectSpread({}, baseInputConfiguration), props);
195
- };
196
-
197
- return /*#__PURE__*/_react["default"].createElement(_configUi.layout.ConfigLayout, {
198
- extraCSSRules: extraCSSRules,
199
- dimensions: contentDimensions,
200
- hideSettings: settingsPanelDisabled,
201
- settings: /*#__PURE__*/_react["default"].createElement(Panel, {
202
- model: model,
203
- onChangeModel: onModelChangedByConfig,
204
- configuration: configuration,
205
- onChangeConfiguration: onConfigurationChanged,
206
- groups: {
207
- Settings: panelSettings,
208
- Properties: panelProperties
209
- }
210
- })
211
- }, teacherInstructionsEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
212
- label: teacherInstructions.label,
213
- className: classes.promptContainer
214
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
215
- markup: model.teacherInstructions || '',
216
- onChange: onTeacherInstructionsChanged,
217
- imageSupport: imageSupport,
218
- nonEmpty: false,
219
- error: teacherInstructionsError,
220
- toolbarOpts: toolbarOpts,
221
- pluginProps: getPluginProps(teacherInstructions === null || teacherInstructions === void 0 ? void 0 : teacherInstructions.inputConfiguration),
222
- spellCheck: spellCheckEnabled,
223
- maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
224
- maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
225
- uploadSoundSupport: uploadSoundSupport,
226
- languageCharactersProps: [{
227
- language: 'spanish'
228
- }, {
229
- language: 'special'
230
- }],
231
- mathMlOptions: mathMlOptions
232
- }), teacherInstructionsError && /*#__PURE__*/_react["default"].createElement("div", {
233
- className: classes.errorText
234
- }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
235
- label: prompt.label,
236
- className: classes.promptContainer
237
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
238
- markup: model.prompt || '',
239
- onChange: onPromptChanged,
240
- imageSupport: imageSupport,
241
- nonEmpty: false,
242
- error: promptError,
243
- toolbarOpts: toolbarOpts,
244
- pluginProps: getPluginProps(prompt === null || prompt === void 0 ? void 0 : prompt.inputConfiguration),
245
- spellCheck: spellCheckEnabled,
246
- maxImageWidth: defaultImageMaxWidth,
247
- maxImageHeight: defaultImageMaxHeight,
248
- uploadSoundSupport: uploadSoundSupport,
249
- languageCharactersProps: [{
250
- language: 'spanish'
251
- }, {
252
- language: 'special'
253
- }],
254
- mathMlOptions: mathMlOptions
255
- }), promptError && /*#__PURE__*/_react["default"].createElement("div", {
256
- className: classes.errorText
257
- }, promptError)), /*#__PURE__*/_react["default"].createElement("div", {
258
- className: classes.flexContainer
259
- }, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
260
- className: classes.subheading,
261
- variant: "subheading"
262
- }, "Define Hotspot"), /*#__PURE__*/_react["default"].createElement(_Tooltip["default"], {
263
- classes: {
264
- tooltip: classes.tooltip
265
- },
266
- disableFocusListener: true,
267
- disableTouchListener: true,
268
- placement: 'left',
269
- title: validationMessage
270
- }, /*#__PURE__*/_react["default"].createElement(_Info["default"], {
271
- fontSize: 'small',
272
- color: 'primary',
273
- style: {
274
- "float": 'right'
275
- }
276
- }))), /*#__PURE__*/_react["default"].createElement(_hotspotPalette["default"], {
277
- hotspotColor: model.hotspotColor,
278
- hotspotList: model.hotspotList,
279
- outlineColor: model.outlineColor,
280
- outlineList: model.outlineList,
281
- onHotspotColorChange: function onHotspotColorChange(color) {
282
- return _this2.handleColorChange('hotspot', color);
283
- },
284
- onOutlineColorChange: function onOutlineColorChange(color) {
285
- return _this2.handleColorChange('outline', color);
107
+ render() {
108
+ const {
109
+ configuration,
110
+ model,
111
+ imageSupport,
112
+ uploadSoundSupport,
113
+ onConfigurationChanged,
114
+ onImageUpload,
115
+ onModelChangedByConfig,
116
+ onPromptChanged,
117
+ onRationaleChanged,
118
+ onUpdateImageDimension,
119
+ onTeacherInstructionsChanged,
120
+ onUpdateShapes
121
+ } = this.props;
122
+ const {
123
+ baseInputConfiguration = {},
124
+ contentDimensions = {},
125
+ maxImageWidth = {},
126
+ maxImageHeight = {},
127
+ multipleCorrect = {},
128
+ partialScoring = {},
129
+ preserveAspectRatio = {},
130
+ prompt = {},
131
+ rationale = {},
132
+ settingsPanelDisabled,
133
+ spellCheck = {},
134
+ teacherInstructions = {},
135
+ withRubric = {},
136
+ mathMlOptions = {},
137
+ language = {},
138
+ languageChoices = {}
139
+ } = configuration || {};
140
+ const {
141
+ errors,
142
+ extraCSSRules,
143
+ promptEnabled,
144
+ rationaleEnabled,
145
+ spellCheckEnabled,
146
+ teacherInstructionsEnabled,
147
+ toolbarEditorPosition
148
+ } = model || {};
149
+ const {
150
+ prompt: promptError,
151
+ rationale: rationaleError,
152
+ shapes: shapesError,
153
+ selections: selectionsError,
154
+ teacherInstructions: teacherInstructionsError
155
+ } = errors || {};
156
+ const validationMessage = (0, _utils.generateValidationMessage)(configuration);
157
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
158
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
159
+ const toolbarOpts = {
160
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
161
+ };
162
+ const panelSettings = {
163
+ multipleCorrect: multipleCorrect.settings && toggle(multipleCorrect.label),
164
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
165
+ promptEnabled: prompt.settings && toggle(prompt.label),
166
+ 'language.enabled': language.settings && toggle(language.label, true),
167
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
168
+ };
169
+ const panelProperties = {
170
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
171
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
172
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
173
+ rubricEnabled: withRubric?.settings && toggle(withRubric?.label)
174
+ };
175
+ const getPluginProps = (props = {}) => ({
176
+ ...baseInputConfiguration,
177
+ ...props
178
+ });
179
+ return /*#__PURE__*/_react.default.createElement(_configUi.layout.ConfigLayout, {
180
+ extraCSSRules: extraCSSRules,
181
+ dimensions: contentDimensions,
182
+ hideSettings: settingsPanelDisabled,
183
+ settings: /*#__PURE__*/_react.default.createElement(Panel, {
184
+ model: model,
185
+ onChangeModel: onModelChangedByConfig,
186
+ configuration: configuration,
187
+ onChangeConfiguration: onConfigurationChanged,
188
+ groups: {
189
+ Settings: panelSettings,
190
+ Properties: panelProperties
286
191
  }
287
- }), /*#__PURE__*/_react["default"].createElement(_hotspotContainer["default"], {
288
- dimensions: model.dimensions,
289
- imageUrl: model.imageUrl,
290
- multipleCorrect: model.multipleCorrect,
291
- hasErrors: !!shapesError || !!selectionsError,
292
- hotspotColor: model.hotspotColor,
293
- outlineColor: model.outlineColor,
294
- selectedHotspotColor: model.selectedHotspotColor,
295
- hoverOutlineColor: model.hoverOutlineColor,
296
- onUpdateImageDimension: onUpdateImageDimension,
297
- onUpdateShapes: onUpdateShapes,
298
- onImageUpload: onImageUpload,
299
- shapes: model.shapes,
300
- strokeWidth: model.strokeWidth,
301
- preserveAspectRatioEnabled: preserveAspectRatio.enabled,
302
- insertImage: imageSupport && imageSupport.add
303
- }), shapesError && /*#__PURE__*/_react["default"].createElement("div", {
304
- className: classes.errorText
305
- }, shapesError), selectionsError && /*#__PURE__*/_react["default"].createElement("div", {
306
- className: classes.errorText
307
- }, selectionsError), model.imageUrl && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
308
- variant: "subheading"
309
- }, "Image Dimensions"), /*#__PURE__*/_react["default"].createElement("div", {
310
- className: classes.dimensions
311
- }, /*#__PURE__*/_react["default"].createElement(_configUi.NumberTextField, {
312
- key: "hotspot-manual-width",
313
- label: "Width",
314
- value: model.dimensions.width,
315
- min: 0,
316
- onChange: function onChange(e, value) {
317
- return _this2.handleOnUpdateImageDimensions(value, 'width');
318
- },
319
- showErrorWhenOutsideRange: true,
320
- className: classes.field
321
- }), /*#__PURE__*/_react["default"].createElement(_configUi.NumberTextField, {
322
- key: "hotspot-manual-height",
323
- label: "Height",
324
- value: model.dimensions.height,
325
- min: 0,
326
- onChange: function onChange(e, value) {
327
- return _this2.handleOnUpdateImageDimensions(value, 'height');
328
- },
329
- showErrorWhenOutsideRange: true,
330
- className: classes.field
331
- }))), rationaleEnabled && /*#__PURE__*/_react["default"].createElement(_configUi.InputContainer, {
332
- label: rationale.label,
333
- className: classes.promptContainer
334
- }, /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
335
- markup: model.rationale || '',
336
- onChange: onRationaleChanged,
337
- imageSupport: imageSupport,
338
- error: rationaleError,
339
- toolbarOpts: toolbarOpts,
340
- pluginProps: getPluginProps(rationale === null || rationale === void 0 ? void 0 : rationale.inputConfiguration),
341
- spellCheck: spellCheckEnabled,
342
- maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
343
- maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
344
- uploadSoundSupport: uploadSoundSupport,
345
- languageCharactersProps: [{
346
- language: 'spanish'
347
- }, {
348
- language: 'special'
349
- }],
350
- mathMlOptions: mathMlOptions
351
- }), rationaleError && /*#__PURE__*/_react["default"].createElement("div", {
352
- className: classes.errorText
353
- }, rationaleError)));
354
- }
355
- }]);
356
- return Root;
357
- }(_react["default"].Component);
358
-
192
+ })
193
+ }, teacherInstructionsEnabled && /*#__PURE__*/_react.default.createElement(PromptContainer, {
194
+ label: teacherInstructions.label
195
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
196
+ markup: model.teacherInstructions || '',
197
+ onChange: onTeacherInstructionsChanged,
198
+ imageSupport: imageSupport,
199
+ nonEmpty: false,
200
+ error: teacherInstructionsError,
201
+ toolbarOpts: toolbarOpts,
202
+ pluginProps: getPluginProps(teacherInstructions?.inputConfiguration),
203
+ spellCheck: spellCheckEnabled,
204
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
205
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
206
+ uploadSoundSupport: uploadSoundSupport,
207
+ languageCharactersProps: [{
208
+ language: 'spanish'
209
+ }, {
210
+ language: 'special'
211
+ }],
212
+ mathMlOptions: mathMlOptions
213
+ }), teacherInstructionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, teacherInstructionsError)), promptEnabled && /*#__PURE__*/_react.default.createElement(PromptContainer, {
214
+ label: prompt.label
215
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
216
+ markup: model.prompt || '',
217
+ onChange: onPromptChanged,
218
+ imageSupport: imageSupport,
219
+ nonEmpty: false,
220
+ error: promptError,
221
+ toolbarOpts: toolbarOpts,
222
+ pluginProps: getPluginProps(prompt?.inputConfiguration),
223
+ spellCheck: spellCheckEnabled,
224
+ maxImageWidth: defaultImageMaxWidth,
225
+ maxImageHeight: defaultImageMaxHeight,
226
+ uploadSoundSupport: uploadSoundSupport,
227
+ languageCharactersProps: [{
228
+ language: 'spanish'
229
+ }, {
230
+ language: 'special'
231
+ }],
232
+ mathMlOptions: mathMlOptions
233
+ }), promptError && /*#__PURE__*/_react.default.createElement(ErrorText, null, promptError)), /*#__PURE__*/_react.default.createElement(FlexContainer, null, /*#__PURE__*/_react.default.createElement(SubHeading, {
234
+ variant: "h6"
235
+ }, "Define Hotspot"), /*#__PURE__*/_react.default.createElement(StyledTooltip, {
236
+ disableFocusListener: true,
237
+ disableTouchListener: true,
238
+ placement: 'left',
239
+ title: validationMessage
240
+ }, /*#__PURE__*/_react.default.createElement(_Info.default, {
241
+ fontSize: 'small',
242
+ color: 'primary',
243
+ style: {
244
+ float: 'right'
245
+ }
246
+ }))), /*#__PURE__*/_react.default.createElement(_hotspotPalette.default, {
247
+ hotspotColor: model.hotspotColor,
248
+ hotspotList: model.hotspotList,
249
+ outlineColor: model.outlineColor,
250
+ outlineList: model.outlineList,
251
+ onHotspotColorChange: color => this.handleColorChange('hotspot', color),
252
+ onOutlineColorChange: color => this.handleColorChange('outline', color)
253
+ }), /*#__PURE__*/_react.default.createElement(_hotspotContainer.default, {
254
+ dimensions: model.dimensions,
255
+ imageUrl: model.imageUrl,
256
+ multipleCorrect: model.multipleCorrect,
257
+ hasErrors: !!shapesError || !!selectionsError,
258
+ hotspotColor: model.hotspotColor,
259
+ outlineColor: model.outlineColor,
260
+ selectedHotspotColor: model.selectedHotspotColor,
261
+ hoverOutlineColor: model.hoverOutlineColor,
262
+ onUpdateImageDimension: onUpdateImageDimension,
263
+ onUpdateShapes: onUpdateShapes,
264
+ onImageUpload: onImageUpload,
265
+ shapes: model.shapes,
266
+ strokeWidth: model.strokeWidth,
267
+ preserveAspectRatioEnabled: preserveAspectRatio.enabled,
268
+ insertImage: imageSupport && imageSupport.add
269
+ }), shapesError && /*#__PURE__*/_react.default.createElement(ErrorText, null, shapesError), selectionsError && /*#__PURE__*/_react.default.createElement(ErrorText, null, selectionsError), model.imageUrl && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Typography.default, {
270
+ variant: "h6"
271
+ }, "Image Dimensions"), /*#__PURE__*/_react.default.createElement(DimensionsContainer, null, /*#__PURE__*/_react.default.createElement(FieldContainer, null, /*#__PURE__*/_react.default.createElement(_configUi.NumberTextField, {
272
+ key: "hotspot-manual-width",
273
+ label: "Width",
274
+ value: model.dimensions.width,
275
+ min: 0,
276
+ onChange: (e, value) => this.handleOnUpdateImageDimensions(value, 'width'),
277
+ showErrorWhenOutsideRange: true
278
+ })), /*#__PURE__*/_react.default.createElement(FieldContainer, null, /*#__PURE__*/_react.default.createElement(_configUi.NumberTextField, {
279
+ key: "hotspot-manual-height",
280
+ label: "Height",
281
+ value: model.dimensions.height,
282
+ min: 0,
283
+ onChange: (e, value) => this.handleOnUpdateImageDimensions(value, 'height'),
284
+ showErrorWhenOutsideRange: true
285
+ })))), rationaleEnabled && /*#__PURE__*/_react.default.createElement(PromptContainer, {
286
+ label: rationale.label
287
+ }, /*#__PURE__*/_react.default.createElement(_editableHtml.default, {
288
+ markup: model.rationale || '',
289
+ onChange: onRationaleChanged,
290
+ imageSupport: imageSupport,
291
+ error: rationaleError,
292
+ toolbarOpts: toolbarOpts,
293
+ pluginProps: getPluginProps(rationale?.inputConfiguration),
294
+ spellCheck: spellCheckEnabled,
295
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
296
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
297
+ uploadSoundSupport: uploadSoundSupport,
298
+ languageCharactersProps: [{
299
+ language: 'spanish'
300
+ }, {
301
+ language: 'special'
302
+ }],
303
+ mathMlOptions: mathMlOptions
304
+ }), rationaleError && /*#__PURE__*/_react.default.createElement(ErrorText, null, rationaleError)));
305
+ }
306
+ }
359
307
  exports.Root = Root;
360
-
361
- var styles = function styles(theme) {
362
- return {
363
- dimensions: {
364
- display: 'flex',
365
- marginBottom: theme.spacing.unit * 1.5
366
- },
367
- field: {
368
- flex: 1,
369
- width: '90%'
370
- },
371
- promptContainer: {
372
- paddingTop: theme.spacing.unit * 2,
373
- marginBottom: theme.spacing.unit * 2,
374
- width: '100%'
375
- },
376
- subheading: {
377
- marginRight: theme.spacing.unit
378
- },
379
- flexContainer: {
380
- display: 'flex',
381
- alignItems: 'center'
382
- },
383
- tooltip: {
384
- fontSize: theme.typography.fontSize - 2,
385
- whiteSpace: 'pre',
386
- maxWidth: '500px'
387
- },
388
- errorText: {
389
- fontSize: theme.typography.fontSize - 2,
390
- color: theme.palette.error.main,
391
- paddingTop: theme.spacing.unit
392
- }
393
- };
394
- };
395
-
396
308
  Root.propTypes = {
397
- classes: _propTypes["default"].object.isRequired,
398
- configuration: _propTypes["default"].object,
399
- model: _propTypes["default"].object.isRequired,
400
- imageSupport: _propTypes["default"].shape({
401
- add: _propTypes["default"].func,
402
- "delete": _propTypes["default"].func
309
+ configuration: _propTypes.default.object,
310
+ model: _propTypes.default.object.isRequired,
311
+ imageSupport: _propTypes.default.shape({
312
+ add: _propTypes.default.func,
313
+ delete: _propTypes.default.func
403
314
  }),
404
- uploadSoundSupport: _propTypes["default"].shape({
405
- add: _propTypes["default"].func,
406
- "delete": _propTypes["default"].func
315
+ uploadSoundSupport: _propTypes.default.shape({
316
+ add: _propTypes.default.func,
317
+ delete: _propTypes.default.func
407
318
  }),
408
- onImageUpload: _propTypes["default"].func.isRequired,
409
- onColorChanged: _propTypes["default"].func.isRequired,
410
- onPromptChanged: _propTypes["default"].func.isRequired,
411
- onUpdateImageDimension: _propTypes["default"].func.isRequired,
412
- onUpdateShapes: _propTypes["default"].func.isRequired,
413
- onModelChangedByConfig: _propTypes["default"].func.isRequired,
414
- onRationaleChanged: _propTypes["default"].func.isRequired,
415
- onConfigurationChanged: _propTypes["default"].func.isRequired,
416
- onTeacherInstructionsChanged: _propTypes["default"].func.isRequired
319
+ onImageUpload: _propTypes.default.func.isRequired,
320
+ onColorChanged: _propTypes.default.func.isRequired,
321
+ onPromptChanged: _propTypes.default.func.isRequired,
322
+ onUpdateImageDimension: _propTypes.default.func.isRequired,
323
+ onUpdateShapes: _propTypes.default.func.isRequired,
324
+ onModelChangedByConfig: _propTypes.default.func.isRequired,
325
+ onRationaleChanged: _propTypes.default.func.isRequired,
326
+ onConfigurationChanged: _propTypes.default.func.isRequired,
327
+ onTeacherInstructionsChanged: _propTypes.default.func.isRequired
417
328
  };
418
-
419
- var _default = (0, _styles.withStyles)(styles)(Root);
420
-
421
- exports["default"] = _default;
329
+ var _default = exports.default = Root;
422
330
  //# sourceMappingURL=root.js.map