@pie-element/hotspot 4.8.0 → 4.8.1-beta.587

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 (95) hide show
  1. package/CHANGELOG.md +474 -0
  2. package/configure/CHANGELOG.md +417 -0
  3. package/configure/lib/button.js.map +1 -1
  4. package/configure/lib/defaults.js +24 -2
  5. package/configure/lib/defaults.js.map +1 -1
  6. package/configure/lib/hotspot-container.js +44 -23
  7. package/configure/lib/hotspot-container.js.map +1 -1
  8. package/configure/lib/hotspot-drawable.js +11 -5
  9. package/configure/lib/hotspot-drawable.js.map +1 -1
  10. package/configure/lib/hotspot-palette.js +1 -1
  11. package/configure/lib/hotspot-palette.js.map +1 -1
  12. package/configure/lib/hotspot-polygon.js +1 -1
  13. package/configure/lib/hotspot-polygon.js.map +1 -1
  14. package/configure/lib/hotspot-rectangle.js +1 -1
  15. package/configure/lib/hotspot-rectangle.js.map +1 -1
  16. package/configure/lib/index.js +17 -3
  17. package/configure/lib/index.js.map +1 -1
  18. package/configure/lib/root.js +133 -27
  19. package/configure/lib/root.js.map +1 -1
  20. package/configure/lib/upload-control.js.map +1 -1
  21. package/configure/lib/utils.js +18 -4
  22. package/configure/lib/utils.js.map +1 -1
  23. package/configure/package.json +4 -4
  24. package/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap +2 -1
  25. package/configure/src/__tests__/__snapshots__/root.test.js.snap +56 -4
  26. package/configure/src/__tests__/hotspot-container.test.js +98 -71
  27. package/configure/src/__tests__/hotspot-drawable.test.js +48 -49
  28. package/configure/src/__tests__/index.test.js +28 -51
  29. package/configure/src/__tests__/root.test.js +162 -82
  30. package/configure/src/__tests__/utils.test.js +112 -98
  31. package/configure/src/button.jsx +4 -4
  32. package/configure/src/defaults.js +36 -18
  33. package/configure/src/hotspot-container.jsx +107 -97
  34. package/configure/src/hotspot-drawable.jsx +59 -53
  35. package/configure/src/hotspot-palette.jsx +12 -25
  36. package/configure/src/hotspot-polygon.jsx +20 -22
  37. package/configure/src/hotspot-rectangle.jsx +5 -15
  38. package/configure/src/index.js +32 -18
  39. package/configure/src/root.jsx +120 -51
  40. package/configure/src/upload-control.jsx +9 -20
  41. package/configure/src/utils.js +51 -22
  42. package/controller/CHANGELOG.md +61 -0
  43. package/controller/lib/defaults.js +2 -2
  44. package/controller/lib/defaults.js.map +1 -1
  45. package/controller/lib/index.js +57 -9
  46. package/controller/lib/index.js.map +1 -1
  47. package/controller/lib/utils.js.map +1 -1
  48. package/controller/package.json +2 -2
  49. package/controller/src/__tests__/index.test.js +99 -55
  50. package/controller/src/defaults.js +5 -9
  51. package/controller/src/index.js +58 -34
  52. package/controller/src/utils.js +9 -6
  53. package/docs/config-schema.json +217 -0
  54. package/docs/config-schema.json.md +169 -0
  55. package/docs/demo/config.js +2 -2
  56. package/docs/demo/generate.js +54 -35
  57. package/docs/demo/session.js +2 -2
  58. package/docs/pie-schema.json +59 -0
  59. package/docs/pie-schema.json.md +47 -0
  60. package/lib/hotspot/container.js +44 -7
  61. package/lib/hotspot/container.js.map +1 -1
  62. package/lib/hotspot/icons.js.map +1 -1
  63. package/lib/hotspot/image.js +35 -8
  64. package/lib/hotspot/image.js.map +1 -1
  65. package/lib/hotspot/index.js +72 -18
  66. package/lib/hotspot/index.js.map +1 -1
  67. package/lib/hotspot/polygon.js +51 -32
  68. package/lib/hotspot/polygon.js.map +1 -1
  69. package/lib/hotspot/rectangle.js +51 -32
  70. package/lib/hotspot/rectangle.js.map +1 -1
  71. package/lib/index.js +4 -1
  72. package/lib/index.js.map +1 -1
  73. package/lib/session-updater.js.map +1 -1
  74. package/package.json +7 -4
  75. package/src/__tests__/__snapshots__/{container-test.jsx.snap → container.test.jsx.snap} +8 -0
  76. package/src/__tests__/__snapshots__/image.test.jsx.snap +43 -0
  77. package/src/__tests__/__snapshots__/{polygon-test.jsx.snap → polygon.test.jsx.snap} +11 -0
  78. package/src/__tests__/__snapshots__/{rectangle-test.jsx.snap → rectangle.test.jsx.snap} +11 -0
  79. package/src/__tests__/container.test.jsx +214 -0
  80. package/src/__tests__/{image-test.jsx → image.test.jsx} +10 -2
  81. package/src/__tests__/polygon.test.jsx +235 -0
  82. package/src/__tests__/rectangle.test.jsx +237 -0
  83. package/src/__tests__/{session-updater-test.jsx → session-updater.test.jsx} +22 -31
  84. package/src/hotspot/container.jsx +60 -23
  85. package/src/hotspot/icons.js +4 -2
  86. package/src/hotspot/image.jsx +26 -13
  87. package/src/hotspot/index.jsx +73 -33
  88. package/src/hotspot/polygon.jsx +51 -40
  89. package/src/hotspot/rectangle.jsx +51 -40
  90. package/src/index.js +10 -18
  91. package/src/session-updater.js +1 -1
  92. package/src/__tests__/__snapshots__/image-test.jsx.snap +0 -21
  93. package/src/__tests__/container-test.jsx +0 -143
  94. package/src/__tests__/polygon-test.jsx +0 -76
  95. package/src/__tests__/rectangle-test.jsx +0 -77
@@ -7,48 +7,48 @@ const imageDimensions = { width, height };
7
7
 
8
8
  describe('updateImageDimensions', () => {
9
9
  it.each`
10
- initialDimensions | nextDimensions | keepAspectRatio | resizeType | expectedWidth | expectedHeight
11
- ${imageDimensions} | ${{
12
- width,
13
- height: 300
14
- }} | ${true} | ${'height'} | ${600} | ${300}
15
- ${imageDimensions} | ${{
16
- width: 400,
17
- height
18
- }} | ${true} | ${'width'} | ${400} | ${200}
19
- ${imageDimensions} | ${{
20
- width,
21
- height: 300
22
- }} | ${true} | ${undefined} | ${200} | ${100}
23
- ${imageDimensions} | ${{
24
- width: 600,
25
- height
26
- }} | ${true} | ${undefined} | ${600} | ${300}
27
- ${imageDimensions} | ${{
28
- width,
29
- height: 300
30
- }} | ${false} | ${'height'} | ${200} | ${300}
31
- ${imageDimensions} | ${{
32
- width: 600,
33
- height
34
- }} | ${false} | ${'width'} | ${600} | ${100}
35
- ${imageDimensions} | ${{
36
- width: 10,
37
- height: 10
38
- }}| ${false} | ${undefined} | ${10} | ${10}
39
- `('initialDimensions = $initialDimensions, nextDimensions = $nextDimensions, keepAspectRatio = $keepAspectRatio, resizeType = $resizeType => width = $expectedWidth & height = $expectedHeight',
10
+ initialDimensions | nextDimensions | keepAspectRatio | resizeType | expectedWidth | expectedHeight
11
+ ${imageDimensions} | ${{
12
+ width,
13
+ height: 300,
14
+ }} | ${true} | ${'height'} | ${600} | ${300}
15
+ ${imageDimensions} | ${{
16
+ width: 400,
17
+ height,
18
+ }} | ${true} | ${'width'} | ${400} | ${200}
19
+ ${imageDimensions} | ${{
20
+ width,
21
+ height: 300,
22
+ }} | ${true} | ${undefined} | ${200} | ${100}
23
+ ${imageDimensions} | ${{
24
+ width: 600,
25
+ height,
26
+ }} | ${true} | ${undefined} | ${600} | ${300}
27
+ ${imageDimensions} | ${{
28
+ width,
29
+ height: 300,
30
+ }} | ${false} | ${'height'} | ${200} | ${300}
31
+ ${imageDimensions} | ${{
32
+ width: 600,
33
+ height,
34
+ }} | ${false} | ${'width'} | ${600} | ${100}
35
+ ${imageDimensions} | ${{
36
+ width: 10,
37
+ height: 10,
38
+ }} | ${false} | ${undefined} | ${10} | ${10}
39
+ `(
40
+ 'initialDimensions = $initialDimensions, nextDimensions = $nextDimensions, keepAspectRatio = $keepAspectRatio, resizeType = $resizeType => width = $expectedWidth & height = $expectedHeight',
40
41
  async ({ initialDimensions, nextDimensions, keepAspectRatio, resizeType, expectedWidth, expectedHeight }) => {
41
-
42
42
  const result = updateImageDimensions(initialDimensions, nextDimensions, keepAspectRatio, resizeType);
43
43
 
44
44
  expect(result).toEqual({
45
45
  width: expectedWidth,
46
- height: expectedHeight
46
+ height: expectedHeight,
47
47
  });
48
- });
48
+ },
49
+ );
49
50
  });
50
51
 
51
-
52
52
  describe('getUpdatedRectangle', () => {
53
53
  const rectangle = (x, y, w, h) => ({ x, y, width: w, height: h });
54
54
  const heightUpdateLarge = { width, height: 300 };
@@ -58,22 +58,22 @@ describe('getUpdatedRectangle', () => {
58
58
  const bothUpdate = { width: 20, height: 50 };
59
59
 
60
60
  it.each`
61
- initialDimensions | nextDimensions | shape | expected
62
- ${imageDimensions} | ${heightUpdateLarge} | ${rectangle(10, 10, 100, 50)} | ${rectangle(10, 30, 100, 150)}
63
- ${imageDimensions} | ${heightUpdateSmall} | ${rectangle(10, 10, 100, 50)} | ${rectangle(10, 5, 100, 25)}
64
- ${imageDimensions} | ${bothUpdate} | ${rectangle(10, 10, 100, 50)} | ${rectangle(1, 5, 10, 25)}
65
- ${imageDimensions} | ${widthUpdateLarge} | ${rectangle(10, 10, 100, 50)} | ${rectangle(15, 10, 150, 50)}
66
- ${imageDimensions} | ${widthUpdateSmall} | ${rectangle(10, 10, 100, 50)} | ${rectangle(5, 10, 50, 50)}
67
- `('initialDimensions = $initialDimensions, nextDimensions = $nextDimensions, shape = $shape => $expected',
61
+ initialDimensions | nextDimensions | shape | expected
62
+ ${imageDimensions} | ${heightUpdateLarge} | ${rectangle(10, 10, 100, 50)} | ${rectangle(10, 30, 100, 150)}
63
+ ${imageDimensions} | ${heightUpdateSmall} | ${rectangle(10, 10, 100, 50)} | ${rectangle(10, 5, 100, 25)}
64
+ ${imageDimensions} | ${bothUpdate} | ${rectangle(10, 10, 100, 50)} | ${rectangle(1, 5, 10, 25)}
65
+ ${imageDimensions} | ${widthUpdateLarge} | ${rectangle(10, 10, 100, 50)} | ${rectangle(15, 10, 150, 50)}
66
+ ${imageDimensions} | ${widthUpdateSmall} | ${rectangle(10, 10, 100, 50)} | ${rectangle(5, 10, 50, 50)}
67
+ `(
68
+ 'initialDimensions = $initialDimensions, nextDimensions = $nextDimensions, shape = $shape => $expected',
68
69
  async ({ initialDimensions, nextDimensions, shape, expected }) => {
69
-
70
70
  const result = getUpdatedRectangle(initialDimensions, nextDimensions, shape);
71
71
 
72
72
  expect(result).toEqual(expected);
73
- });
73
+ },
74
+ );
74
75
  });
75
76
 
76
-
77
77
  describe('getUpdatedPolygon', () => {
78
78
  const updatedDimensions = { width: width / 2, height: height * 2 };
79
79
 
@@ -87,29 +87,42 @@ describe('getUpdatedPolygon', () => {
87
87
  const squareUpdated = [updatedPoint(10, 10), updatedPoint(100, 10), updatedPoint(100, 100), updatedPoint(10, 100)];
88
88
 
89
89
  const pentagon = [point(10, 10), point(20, 0), point(30, 0), point(40, 10), point(25, 20)];
90
- const pentagonUpdated = [updatedPoint(10, 10), updatedPoint(20, 0), updatedPoint(30, 0), updatedPoint(40, 10), updatedPoint(25, 20)];
90
+ const pentagonUpdated = [
91
+ updatedPoint(10, 10),
92
+ updatedPoint(20, 0),
93
+ updatedPoint(30, 0),
94
+ updatedPoint(40, 10),
95
+ updatedPoint(25, 20),
96
+ ];
91
97
 
92
98
  const hexagon = [point(10, 10), point(20, 0), point(30, 0), point(40, 10), point(30, 20), point(20, 20)];
93
- const hexagonUpdated = [updatedPoint(10, 10), updatedPoint(20, 0), updatedPoint(30, 0), updatedPoint(40, 10), updatedPoint(30, 20), updatedPoint(20, 20)];
99
+ const hexagonUpdated = [
100
+ updatedPoint(10, 10),
101
+ updatedPoint(20, 0),
102
+ updatedPoint(30, 0),
103
+ updatedPoint(40, 10),
104
+ updatedPoint(30, 20),
105
+ updatedPoint(20, 20),
106
+ ];
94
107
 
95
- const polygon = points => ({ points });
108
+ const polygon = (points) => ({ points });
96
109
 
97
110
  it.each`
98
- initialDimensions | nextDimensions | shape | expected
99
- ${imageDimensions} | ${updatedDimensions} | ${polygon(triangle)} | ${polygon(triangleUpdated)}
100
- ${imageDimensions} | ${updatedDimensions} | ${polygon(square)} | ${polygon(squareUpdated)}
101
- ${imageDimensions} | ${updatedDimensions} | ${polygon(pentagon)} | ${polygon(pentagonUpdated)}
102
- ${imageDimensions} | ${updatedDimensions} | ${polygon(hexagon)} | ${polygon(hexagonUpdated)}
103
- `('initialDimensions = $initialDimensions, nextDimensions = $nextDimensions, shape = $shape => $expected',
111
+ initialDimensions | nextDimensions | shape | expected
112
+ ${imageDimensions} | ${updatedDimensions} | ${polygon(triangle)} | ${polygon(triangleUpdated)}
113
+ ${imageDimensions} | ${updatedDimensions} | ${polygon(square)} | ${polygon(squareUpdated)}
114
+ ${imageDimensions} | ${updatedDimensions} | ${polygon(pentagon)} | ${polygon(pentagonUpdated)}
115
+ ${imageDimensions} | ${updatedDimensions} | ${polygon(hexagon)} | ${polygon(hexagonUpdated)}
116
+ `(
117
+ 'initialDimensions = $initialDimensions, nextDimensions = $nextDimensions, shape = $shape => $expected',
104
118
  async ({ initialDimensions, nextDimensions, shape, expected }) => {
105
-
106
119
  const result = getUpdatedPlygon(initialDimensions, nextDimensions, shape);
107
120
 
108
121
  expect(result).toEqual(expected);
109
- });
122
+ },
123
+ );
110
124
  });
111
125
 
112
-
113
126
  const shapesArray = [
114
127
  {
115
128
  height: 100,
@@ -117,36 +130,38 @@ const shapesArray = [
117
130
  x: 1,
118
131
  y: 1,
119
132
  group: 'rectangles',
120
- index: 0
121
- }, {
133
+ index: 0,
134
+ },
135
+ {
122
136
  height: 200,
123
137
  width: 200,
124
138
  x: 200,
125
139
  y: 1,
126
140
  group: 'rectangles',
127
- index: 1
141
+ index: 1,
128
142
  },
129
143
  {
130
144
  points: [
131
145
  { x: 1, y: 200 },
132
146
  { x: 1, y: 200 },
133
147
  { y: 200, x: 200 },
134
- { y: 200, x: 200 }],
148
+ { y: 200, x: 200 },
149
+ ],
135
150
  group: 'polygons',
136
- index: 2
137
- }, {
151
+ index: 2,
152
+ },
153
+ {
138
154
  points: [
139
155
  { x: 200, y: 100 },
140
156
  { x: 200, y: 200 },
141
157
  { x: 400, y: 200 },
142
- { x: 400, y: 200 }
158
+ { x: 400, y: 200 },
143
159
  ],
144
160
  group: 'polygons',
145
- index: 3
146
- }
161
+ index: 3,
162
+ },
147
163
  ];
148
164
 
149
-
150
165
  const shapesMap = {
151
166
  rectangles: [
152
167
  {
@@ -154,59 +169,58 @@ const shapesMap = {
154
169
  width: 100,
155
170
  x: 1,
156
171
  y: 1,
157
- index: 0
158
- }, {
172
+ index: 0,
173
+ },
174
+ {
159
175
  height: 200,
160
176
  width: 200,
161
177
  x: 200,
162
178
  y: 1,
163
- index: 1
164
- }
165
- ], polygons: [
179
+ index: 1,
180
+ },
181
+ ],
182
+ polygons: [
166
183
  {
167
184
  points: [
168
185
  { x: 1, y: 200 },
169
186
  { x: 1, y: 200 },
170
187
  { y: 200, x: 200 },
171
- { y: 200, x: 200 }],
188
+ { y: 200, x: 200 },
189
+ ],
172
190
  index: 2,
173
- }, {
191
+ },
192
+ {
174
193
  points: [
175
194
  { x: 200, y: 100 },
176
195
  { x: 200, y: 200 },
177
196
  { x: 400, y: 200 },
178
- { x: 400, y: 200 }
197
+ { x: 400, y: 200 },
179
198
  ],
180
- index: 3
181
- }
182
- ]
199
+ index: 3,
200
+ },
201
+ ],
183
202
  };
184
203
 
185
-
186
204
  describe('getAllShapes', () => {
187
205
  it.each`
188
- shapesMap | expected
189
- ${shapesMap} | ${shapesArray}
190
- ${null} | ${[]}
191
- ${undefined} | ${[]}
192
- ${{}} | ${[]}
193
- `('TURNS shapes = $shapesMap INTO $expected',
194
- async ({ shapesMap, expected }) => {
195
- expect(getAllShapes(shapesMap)).toEqual(expected);
196
- });
197
-
206
+ shapesMap | expected
207
+ ${shapesMap} | ${shapesArray}
208
+ ${null} | ${[]}
209
+ ${undefined} | ${[]}
210
+ ${{}} | ${[]}
211
+ `('TURNS shapes = $shapesMap INTO $expected', async ({ shapesMap, expected }) => {
212
+ expect(getAllShapes(shapesMap)).toEqual(expected);
213
+ });
198
214
  });
199
215
 
200
216
  describe('groupShapes', () => {
201
217
  it.each`
202
- shapesArray | expected
203
- ${shapesArray} | ${shapesMap}
204
- ${null} | ${{ rectangles: [], polygons: [] }}
205
- ${undefined} | ${{ rectangles: [], polygons: [] }}
206
- ${[]} | ${{ rectangles: [], polygons: [] }}
207
- `('TURNS shapes = $shapesArray INTO $expected',
208
- async ({ shapesArray, expected }) => {
209
- expect(groupShapes(shapesArray)).toEqual(expected);
210
- });
218
+ shapesArray | expected
219
+ ${shapesArray} | ${shapesMap}
220
+ ${null} | ${{ rectangles: [], polygons: [] }}
221
+ ${undefined} | ${{ rectangles: [], polygons: [] }}
222
+ ${[]} | ${{ rectangles: [], polygons: [] }}
223
+ `('TURNS shapes = $shapesArray INTO $expected', async ({ shapesArray, expected }) => {
224
+ expect(groupShapes(shapesArray)).toEqual(expected);
225
+ });
211
226
  });
212
-
@@ -22,20 +22,20 @@ RawButton.propTypes = {
22
22
  className: PropTypes.string,
23
23
  disabled: PropTypes.bool,
24
24
  label: PropTypes.string,
25
- onClick: PropTypes.func
25
+ onClick: PropTypes.func,
26
26
  };
27
27
 
28
28
  RawButton.defaultProps = {
29
29
  className: '',
30
30
  disabled: false,
31
31
  label: 'Add',
32
- onClick: () => {}
32
+ onClick: () => {},
33
33
  };
34
34
 
35
35
  const styles = () => ({
36
36
  addButton: {
37
- marginLeft: 8
38
- }
37
+ marginLeft: 8,
38
+ },
39
39
  });
40
40
 
41
41
  const ButtonStyled = withStyles(styles)(RawButton);
@@ -1,56 +1,74 @@
1
1
  export default {
2
2
  model: {
3
3
  prompt: 'This is the question prompt',
4
+ toolbarEditorPosition: 'bottom',
4
5
  promptEnabled: true,
5
6
  imageUrl: '',
6
7
  shapes: {
7
8
  rectangles: [],
8
- polygons: []
9
+ polygons: [],
9
10
  },
10
11
  multipleCorrect: true,
11
12
  partialScoring: false,
12
13
  dimensions: {
13
14
  height: 0,
14
- width: 0
15
+ width: 0,
15
16
  },
16
- hotspotColor: 'rgba(137, 183, 244, 0.65)',
17
- hotspotList: [
18
- 'rgba(137, 183, 244, 0.65)'
19
- ],
17
+ hotspotColor: 'rgba(137, 183, 244, 0.25)',
18
+ hotspotList: ['rgba(137, 183, 244, 0.25)'],
20
19
  outlineColor: 'blue',
21
- outlineList: [
22
- 'blue'
23
- ],
20
+ outlineList: ['blue'],
24
21
  rationaleEnabled: true,
25
22
  teacherInstructionsEnabled: true,
26
23
  studentInstructionsEnabled: true,
27
- strokeWidth: 5
24
+ strokeWidth: 5,
28
25
  },
29
26
  configuration: {
30
27
  multipleCorrect: {
31
28
  settings: true,
32
- label: 'Multiple Correct Responses'
29
+ label: 'Multiple Correct Responses',
33
30
  },
34
31
  partialScoring: {
35
32
  settings: false,
36
- label: 'Allow Partial Scoring'
33
+ label: 'Allow Partial Scoring',
37
34
  },
38
35
  rationale: {
39
36
  settings: true,
40
- label: 'Rationale'
37
+ label: 'Rationale',
41
38
  },
42
39
  prompt: {
43
40
  settings: true,
44
- label: 'Prompt'
41
+ label: 'Prompt',
42
+ },
43
+ settingsPanelDisabled: false,
44
+ spellCheck: {
45
+ label: 'Spellcheck',
46
+ settings: false,
47
+ enabled: true,
45
48
  },
46
49
  teacherInstructions: {
47
50
  settings: true,
48
- label: 'Teacher Instructions'
51
+ label: 'Teacher Instructions',
49
52
  },
50
53
  preserveAspectRatio: {
51
54
  settings: false,
52
55
  enabled: true,
53
- label: 'Preserve aspect ratio'
54
- }
55
- }
56
+ label: 'Preserve aspect ratio',
57
+ },
58
+ minShapes: 2,
59
+ maxImageWidth: {
60
+ teacherInstructions: 300,
61
+ prompt: 300,
62
+ rationale: 300,
63
+ },
64
+ maxImageHeight: {
65
+ teacherInstructions: 300,
66
+ prompt: 300,
67
+ rationale: 300,
68
+ },
69
+ withRubric: {
70
+ settings: false,
71
+ label: 'Add Rubric',
72
+ },
73
+ },
56
74
  };