@pie-element/drag-in-the-blank 3.9.1-next.99 → 3.10.3-next.1008

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,206 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.13.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.13.5...@pie-element/drag-in-the-blank@3.13.6) (2022-03-28)
7
+
8
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.13.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.13.4...@pie-element/drag-in-the-blank@3.13.5) (2022-03-22)
15
+
16
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.13.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.13.3...@pie-element/drag-in-the-blank@3.13.4) (2022-03-08)
23
+
24
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
25
+
26
+
27
+
28
+
29
+
30
+ ## [3.13.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.13.2...@pie-element/drag-in-the-blank@3.13.3) (2022-03-08)
31
+
32
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
33
+
34
+
35
+
36
+
37
+
38
+ ## [3.13.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.13.1...@pie-element/drag-in-the-blank@3.13.2) (2022-02-21)
39
+
40
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
41
+
42
+
43
+
44
+
45
+
46
+ ## [3.13.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.13.0...@pie-element/drag-in-the-blank@3.13.1) (2022-02-04)
47
+
48
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
49
+
50
+
51
+
52
+
53
+
54
+ # [3.13.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.12.8...@pie-element/drag-in-the-blank@3.13.0) (2022-01-24)
55
+
56
+
57
+ ### Bug Fixes
58
+
59
+ * use preview prompt for prompt, rationale and teacher instructions to fix table rendering PD-1456 ([f330601](https://github.com/pie-framework/pie-elements/commit/f3306019a2d1c8ce3e2783823dfe9ef0a0394e4f))
60
+ * **drag-in-the-blank:** fix validation behavior PD-1404 ([02f3f5c](https://github.com/pie-framework/pie-elements/commit/02f3f5ca82b03d54e055a3d746027e8b5ac66790))
61
+
62
+
63
+ ### Features
64
+
65
+ * **drag-in-the-blank, inline-dropdown:** move rationale after the item content PD-1379 ([fd71c58](https://github.com/pie-framework/pie-elements/commit/fd71c5853bdd63b31a746241dd5649e5de051300))
66
+
67
+
68
+
69
+
70
+
71
+ ## [3.12.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.12.7...@pie-element/drag-in-the-blank@3.12.8) (2022-01-10)
72
+
73
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
74
+
75
+
76
+
77
+
78
+
79
+ ## [3.12.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.12.6...@pie-element/drag-in-the-blank@3.12.7) (2021-12-23)
80
+
81
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
82
+
83
+
84
+
85
+
86
+
87
+ ## [3.12.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.12.4...@pie-element/drag-in-the-blank@3.12.5) (2021-12-13)
88
+
89
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
90
+
91
+
92
+
93
+
94
+
95
+ ## [3.12.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.12.1...@pie-element/drag-in-the-blank@3.12.2) (2021-11-29)
96
+
97
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
98
+
99
+
100
+
101
+
102
+
103
+ ## [3.12.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.11.4...@pie-element/drag-in-the-blank@3.12.1) (2021-11-11)
104
+
105
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
106
+
107
+
108
+
109
+
110
+
111
+ # [3.12.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.10.2...@pie-element/drag-in-the-blank@3.12.0) (2021-11-11)
112
+
113
+
114
+ ### Bug Fixes
115
+
116
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
117
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
118
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
119
+
120
+
121
+ ### Features
122
+
123
+ * **drag-in-the-blank:** set toolbar editor position to bottom ([8a16b0f](https://github.com/pie-framework/pie-elements/commit/8a16b0f2965af63ab6e20267131cc1da19dce8e1))
124
+
125
+
126
+
127
+
128
+
129
+
130
+ ## [3.11.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.11.3...@pie-element/drag-in-the-blank@3.11.4) (2021-10-18)
131
+
132
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
133
+
134
+
135
+
136
+
137
+
138
+ ## [3.11.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.11.2...@pie-element/drag-in-the-blank@3.11.3) (2021-10-04)
139
+
140
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
141
+
142
+
143
+
144
+
145
+
146
+ ## [3.11.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.11.1...@pie-element/drag-in-the-blank@3.11.2) (2021-09-20)
147
+
148
+
149
+ ### Bug Fixes
150
+
151
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
152
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
153
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
154
+
155
+
156
+
157
+
158
+
159
+ ## [3.11.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.11.0...@pie-element/drag-in-the-blank@3.11.1) (2021-09-01)
160
+
161
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
162
+
163
+
164
+
165
+
166
+
167
+ # [3.11.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.10.2...@pie-element/drag-in-the-blank@3.11.0) (2021-08-05)
168
+
169
+
170
+ ### Features
171
+
172
+ * **drag-in-the-blank:** set toolbar editor position to bottom ([8a16b0f](https://github.com/pie-framework/pie-elements/commit/8a16b0f2965af63ab6e20267131cc1da19dce8e1))
173
+
174
+
175
+
176
+
177
+
178
+ ## [3.10.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.10.0...@pie-element/drag-in-the-blank@3.10.2) (2021-08-05)
179
+
180
+
181
+ ### Bug Fixes
182
+
183
+ * force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
184
+
185
+
186
+
187
+
188
+
189
+ # [3.10.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.9.0...@pie-element/drag-in-the-blank@3.10.0) (2021-06-29)
190
+
191
+
192
+ ### Bug Fixes
193
+
194
+ * Removed excess white space at the beginning of all items - PD-1184 ([#602](https://github.com/pie-framework/pie-elements/issues/602)) ([25b9f72](https://github.com/pie-framework/pie-elements/commit/25b9f72d2fe73bd46ea1a5c3611ff82eef3efb84))
195
+
196
+
197
+ ### Features
198
+
199
+ * **drag-in-the-blank:** don't allow identical answer choices PD-192 ([#606](https://github.com/pie-framework/pie-elements/issues/606)) ([2847859](https://github.com/pie-framework/pie-elements/commit/28478599876dfed60deb81712e3cc914a903ae99))
200
+ * remove audio and video buttons from various fields of various items PD-1180 ([#601](https://github.com/pie-framework/pie-elements/issues/601)) ([8766b25](https://github.com/pie-framework/pie-elements/commit/8766b25690f5dde6c3e896860d63e205bf3c831b))
201
+
202
+
203
+
204
+
205
+
6
206
  # [3.9.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@3.8.3...@pie-element/drag-in-the-blank@3.9.0) (2021-04-07)
7
207
 
8
208
 
@@ -3,6 +3,149 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.6.19](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.18...@pie-element/drag-in-the-blank-configure@3.6.19) (2022-03-28)
7
+
8
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.6.18](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.17...@pie-element/drag-in-the-blank-configure@3.6.18) (2022-03-22)
15
+
16
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.6.17](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.16...@pie-element/drag-in-the-blank-configure@3.6.17) (2022-03-08)
23
+
24
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
25
+
26
+
27
+
28
+
29
+
30
+ ## [3.6.16](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.15...@pie-element/drag-in-the-blank-configure@3.6.16) (2022-03-08)
31
+
32
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
33
+
34
+
35
+
36
+
37
+
38
+ ## [3.6.15](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.14...@pie-element/drag-in-the-blank-configure@3.6.15) (2022-02-21)
39
+
40
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
41
+
42
+
43
+
44
+
45
+
46
+ ## [3.6.14](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.13...@pie-element/drag-in-the-blank-configure@3.6.14) (2022-02-04)
47
+
48
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
49
+
50
+
51
+
52
+
53
+
54
+ ## [3.6.13](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.12...@pie-element/drag-in-the-blank-configure@3.6.13) (2022-01-24)
55
+
56
+
57
+ ### Bug Fixes
58
+
59
+ * **drag-in-the-blank:** fix validation behavior PD-1404 ([02f3f5c](https://github.com/pie-framework/pie-elements/commit/02f3f5ca82b03d54e055a3d746027e8b5ac66790))
60
+
61
+
62
+
63
+
64
+
65
+ ## [3.6.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.11...@pie-element/drag-in-the-blank-configure@3.6.12) (2022-01-10)
66
+
67
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
68
+
69
+
70
+
71
+
72
+
73
+ ## [3.6.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.10...@pie-element/drag-in-the-blank-configure@3.6.11) (2021-12-23)
74
+
75
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
76
+
77
+
78
+
79
+
80
+
81
+ ## [3.6.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.8...@pie-element/drag-in-the-blank-configure@3.6.9) (2021-12-13)
82
+
83
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
84
+
85
+
86
+
87
+
88
+
89
+ ## [3.6.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.5...@pie-element/drag-in-the-blank-configure@3.6.6) (2021-11-29)
90
+
91
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
92
+
93
+
94
+
95
+
96
+
97
+ ## [3.6.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.4...@pie-element/drag-in-the-blank-configure@3.6.5) (2021-10-04)
98
+
99
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
100
+
101
+
102
+
103
+
104
+
105
+ ## [3.6.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.3...@pie-element/drag-in-the-blank-configure@3.6.4) (2021-09-20)
106
+
107
+
108
+ ### Bug Fixes
109
+
110
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
111
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
112
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
113
+
114
+
115
+
116
+
117
+
118
+ ## [3.6.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.2...@pie-element/drag-in-the-blank-configure@3.6.3) (2021-08-05)
119
+
120
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
121
+
122
+
123
+
124
+
125
+
126
+ ## [3.6.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.6.0...@pie-element/drag-in-the-blank-configure@3.6.2) (2021-08-05)
127
+
128
+
129
+ ### Bug Fixes
130
+
131
+ * force bump ([5ea7295](https://github.com/pie-framework/pie-elements/commit/5ea7295e4755fbc492a76e7ec69e5fc35b196919))
132
+
133
+
134
+
135
+
136
+
137
+ # [3.6.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.5.4...@pie-element/drag-in-the-blank-configure@3.6.0) (2021-06-29)
138
+
139
+
140
+ ### Features
141
+
142
+ * **drag-in-the-blank:** don't allow identical answer choices PD-192 ([#606](https://github.com/pie-framework/pie-elements/issues/606)) ([2847859](https://github.com/pie-framework/pie-elements/commit/28478599876dfed60deb81712e3cc914a903ae99))
143
+ * remove audio and video buttons from various fields of various items PD-1180 ([#601](https://github.com/pie-framework/pie-elements/issues/601)) ([8766b25](https://github.com/pie-framework/pie-elements/commit/8766b25690f5dde6c3e896860d63e205bf3c831b))
144
+
145
+
146
+
147
+
148
+
6
149
  ## [3.5.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@3.5.3...@pie-element/drag-in-the-blank-configure@3.5.4) (2021-04-07)
7
150
 
8
151
  **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
@@ -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["default"] = exports.tileSource = exports.BlankContent = void 0;
8
+ exports.tileSource = exports["default"] = exports.BlankContent = void 0;
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/choice.jsx"],"names":["GripIcon","style","margin","propTypes","PropTypes","object","BlankContent","theme","choice","border","palette","primary","main","disabled","props","connectDragSource","onClick","onRemoveChoice","display","minWidth","minHeight","background","boxSizing","borderRadius","overflow","position","padding","top","left","color","zIndex","__html","value","right","e","preventDefault","stopPropagation","tileSource","canDrag","alert","beginDrag","id","targetId","instanceId","connect","monitor","dragSource","isDragging"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,OAAe;AAAA,MAAZC,KAAY,Q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2E,GAAvB;AAAA,CAAnD,EAGXzC,YAHW,C","sourcesContent":["import React from 'react';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport Delete from '@material-ui/icons/Delete';\nimport { DragSource } from 'react-dnd';\nimport { withStyles } from '@material-ui/core/styles';\nimport { choiceIsEmpty } from './markupUtils';\nimport PropTypes from 'prop-types';\n\nconst GripIcon = ({ style }) => {\n return (\n <span style={style}>\n <MoreVert\n style={{\n margin: '0 -16px'\n }}\n />\n <MoreVert />\n </span>\n );\n};\n\nGripIcon.propTypes = {\n style: PropTypes.object,\n};\n\nexport const BlankContent = withStyles(theme => ({\n choice: {\n border: `solid 0px ${theme.palette.primary.main}`\n },\n disabled: {}\n}))(props => {\n const { connectDragSource, choice, onClick, onRemoveChoice } = props;\n\n return connectDragSource(\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n position: 'relative',\n padding: '8px 35px 8px 35px'\n }}\n onClick={onClick}\n >\n <GripIcon\n style={{\n position: 'absolute',\n top: '6px',\n left: '15px',\n color: '#9B9B9B',\n zIndex: 2\n }}\n />\n <span\n dangerouslySetInnerHTML={{\n __html: choice.value\n }}\n />\n <Delete\n style={{\n position: 'absolute',\n top: '6px',\n right: '0',\n color: '#9B9B9B',\n zIndex: 2\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n\n onRemoveChoice(e);\n }}\n />\n </div>\n );\n});\n\nexport const tileSource = {\n canDrag(props) {\n if (choiceIsEmpty(props.choice)) {\n alert('You need to define a value for an answer choice before it can be associated with a response area.');\n return false;\n }\n\n return !props.disabled;\n },\n beginDrag(props) {\n return {\n id: props.targetId,\n value: props.choice,\n instanceId: props.instanceId\n };\n }\n};\n\nexport default DragSource('drag-in-the-blank-choice', tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging()\n}))(BlankContent);\n"],"file":"choice.js"}
1
+ {"version":3,"sources":["../src/choice.jsx"],"names":["GripIcon","style","margin","propTypes","PropTypes","object","BlankContent","theme","choice","border","palette","primary","main","disabled","props","connectDragSource","onClick","onRemoveChoice","display","minWidth","minHeight","background","boxSizing","borderRadius","overflow","position","padding","top","left","color","zIndex","__html","value","right","e","preventDefault","stopPropagation","tileSource","canDrag","alert","beginDrag","id","targetId","instanceId","connect","monitor","dragSource","isDragging"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,OAAe;AAAA,MAAZC,KAAY,QAAZA,KAAY;AAC9B,sBACE;AAAM,IAAA,KAAK,EAAEA;AAAb,kBACE,gCAAC,oBAAD;AACE,IAAA,KAAK,EAAE;AACLC,MAAAA,MAAM,EAAE;AADH;AADT,IADF,eAME,gCAAC,oBAAD,OANF,CADF;AAUD,CAXD;;AAaAF,QAAQ,CAACG,SAAT,GAAqB;AACnBF,EAAAA,KAAK,EAAEG,sBAAUC;AADE,CAArB;AAIO,IAAMC,YAAY,GAAG,wBAAW,UAAAC,KAAK;AAAA,SAAK;AAC/CC,IAAAA,MAAM,EAAE;AACNC,MAAAA,MAAM,sBAAeF,KAAK,CAACG,OAAN,CAAcC,OAAd,CAAsBC,IAArC;AADA,KADuC;AAI/CC,IAAAA,QAAQ,EAAE;AAJqC,GAAL;AAAA,CAAhB,EAKxB,UAAAC,KAAK,EAAI;AACX,MAAQC,iBAAR,GAA+DD,KAA/D,CAAQC,iBAAR;AAAA,MAA2BP,MAA3B,GAA+DM,KAA/D,CAA2BN,MAA3B;AAAA,MAAmCQ,OAAnC,GAA+DF,KAA/D,CAAmCE,OAAnC;AAAA,MAA4CC,cAA5C,GAA+DH,KAA/D,CAA4CG,cAA5C;AAEA,SAAOF,iBAAiB,eACtB;AACE,IAAA,KAAK,EAAE;AACLG,MAAAA,OAAO,EAAE,aADJ;AAELC,MAAAA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KAAK,CAACD,QAAd;AACD,GARuB;AASxB2B,EAAAA,SATwB,qBASd1B,KATc,EASP;AACf,WAAO;AACL2B,MAAAA,EAAE,EAAE3B,KAAK,CAAC4B,QADL;AAELV,MAAAA,KAAK,EAAElB,KAAK,CAACN,MAFR;AAGLmC,MAAAA,UAAU,EAAE7B,KAAK,CAAC6B;AAHb,KAAP;AAKD;AAfuB,CAAnB;;;eAkBQ,0BAAW,0BAAX,EAAuCN,UAAvC,EAAmD,UAACO,OAAD,EAAUC,OAAV;AAAA,SAAuB;AACvF9B,IAAAA,iBAAiB,EAAE6B,OAAO,CAACE,UAAR,EADoE;AAEvFC,IAAAA,UAAU,EAAEF,OAAO,CAACE,UAAR;AAF2E,GAAvB;AAAA,CAAnD,EAGXzC,YAHW,C","sourcesContent":["import React from 'react';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport Delete from '@material-ui/icons/Delete';\nimport { DragSource } from 'react-dnd';\nimport { withStyles } from '@material-ui/core/styles';\nimport { choiceIsEmpty } from './markupUtils';\nimport PropTypes from 'prop-types';\n\nconst GripIcon = ({ style }) => {\n return (\n <span style={style}>\n <MoreVert\n style={{\n margin: '0 -16px'\n }}\n />\n <MoreVert />\n </span>\n );\n};\n\nGripIcon.propTypes = {\n style: PropTypes.object,\n};\n\nexport const BlankContent = withStyles(theme => ({\n choice: {\n border: `solid 0px ${theme.palette.primary.main}`\n },\n disabled: {}\n}))(props => {\n const { connectDragSource, choice, onClick, onRemoveChoice } = props;\n\n return connectDragSource(\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n position: 'relative',\n padding: '8px 35px 8px 35px'\n }}\n onClick={onClick}\n >\n <GripIcon\n style={{\n position: 'absolute',\n top: '6px',\n left: '15px',\n color: '#9B9B9B',\n zIndex: 2\n }}\n />\n <span\n dangerouslySetInnerHTML={{\n __html: choice.value\n }}\n />\n <Delete\n style={{\n position: 'absolute',\n top: '6px',\n right: '0',\n color: '#9B9B9B',\n zIndex: 2\n }}\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n\n onRemoveChoice(e);\n }}\n />\n </div>\n );\n});\n\nexport const tileSource = {\n canDrag(props) {\n if (choiceIsEmpty(props.choice)) {\n alert('You need to define a value for an answer choice before it can be associated with a response area.');\n return false;\n }\n\n return !props.disabled;\n },\n beginDrag(props) {\n return {\n id: props.targetId,\n value: props.choice,\n instanceId: props.instanceId\n };\n }\n};\n\nexport default DragSource('drag-in-the-blank-choice', tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging()\n}))(BlankContent);\n"],"file":"choice.js"}
@@ -49,22 +49,23 @@ var _DialogTitle = _interopRequireDefault(require("@material-ui/core/DialogTitle
49
49
 
50
50
  var _DialogActions = _interopRequireDefault(require("@material-ui/core/DialogActions"));
51
51
 
52
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
52
+ 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; }
53
53
 
54
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
54
+ 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; }
55
55
 
56
56
  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); }; }
57
57
 
58
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
58
+ 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; } }
59
59
 
60
60
  window.renMath = _mathRendering.renderMath;
61
61
 
62
62
  var InfoDialog = function InfoDialog(_ref) {
63
63
  var open = _ref.open,
64
+ title = _ref.title,
64
65
  onOk = _ref.onOk;
65
66
  return /*#__PURE__*/_react["default"].createElement(_Dialog["default"], {
66
67
  open: open
67
- }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, "Identical answer choices are not allowed and will be discarded"), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, onOk && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
68
+ }, /*#__PURE__*/_react["default"].createElement(_DialogTitle["default"], null, title || ''), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, onOk && /*#__PURE__*/_react["default"].createElement(_Button["default"], {
68
69
  onClick: onOk,
69
70
  color: "primary"
70
71
  }, "OK")));
@@ -72,7 +73,8 @@ var InfoDialog = function InfoDialog(_ref) {
72
73
 
73
74
  InfoDialog.propTypes = {
74
75
  open: _propTypes["default"].bool,
75
- onOk: _propTypes["default"].func
76
+ onOk: _propTypes["default"].func,
77
+ title: _propTypes["default"].string
76
78
  };
77
79
 
78
80
  var styles = function styles(theme) {
@@ -113,6 +115,12 @@ var Choices = /*#__PURE__*/function (_React$Component) {
113
115
  open: false
114
116
  }
115
117
  });
118
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "rerenderMath", function () {
119
+ //eslint-disable-next-line
120
+ var domNode = _reactDom["default"].findDOMNode((0, _assertThisInitialized2["default"])(_this));
121
+
122
+ (0, _mathRendering.renderMath)(domNode);
123
+ });
116
124
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChoiceChanged", function (prevValue, val, key) {
117
125
  var _this$props = _this.props,
118
126
  onChange = _this$props.onChange,
@@ -120,22 +128,26 @@ var Choices = /*#__PURE__*/function (_React$Component) {
120
128
  var choices = model.choices,
121
129
  correctResponse = model.correctResponse,
122
130
  alternateResponses = model.alternateResponses;
123
- var exists = (choices || []).filter(function (c) {
124
- return c.value === val;
125
- });
126
-
127
- if (exists.length) {
128
- var _newChoices = (choices || []).filter(function (c) {
129
- return c.id !== key;
130
- });
131
+ var duplicatedValue = (choices || []).find(function (c) {
132
+ return c.value === val && c.id !== key;
133
+ }); // discard the new added choice or the changes if the choice would be a duplicate to one that already exists
134
+
135
+ if (duplicatedValue) {
136
+ if (prevValue === '') {
137
+ // remove the new added choice from choices
138
+ var _newChoices = (choices || []).filter(function (c) {
139
+ return c.id !== key;
140
+ });
131
141
 
132
- onChange(_newChoices);
142
+ onChange(_newChoices);
143
+ }
133
144
 
134
145
  _this.setState({
135
146
  dialog: {
136
147
  open: true,
148
+ message: 'Identical answer choices are not allowed and the changes will be discarded',
137
149
  onOk: function onOk() {
138
- _this.setState({
150
+ return _this.setState({
139
151
  dialog: {
140
152
  open: false
141
153
  }
@@ -252,12 +264,14 @@ var Choices = /*#__PURE__*/function (_React$Component) {
252
264
  }
253
265
 
254
266
  (0, _createClass2["default"])(Choices, [{
267
+ key: "componentDidMount",
268
+ value: function componentDidMount() {
269
+ this.rerenderMath();
270
+ }
271
+ }, {
255
272
  key: "componentDidUpdate",
256
273
  value: function componentDidUpdate() {
257
- //eslint-disable-next-line
258
- var domNode = _reactDom["default"].findDOMNode(this);
259
-
260
- (0, _mathRendering.renderMath)(domNode);
274
+ this.rerenderMath();
261
275
 
262
276
  if (this.focusedNodeRef) {
263
277
  this.focusedNodeRef.focus('end');
@@ -273,18 +287,23 @@ var Choices = /*#__PURE__*/function (_React$Component) {
273
287
  dialog = _this$state.dialog;
274
288
  var _this$props5 = this.props,
275
289
  classes = _this$props5.classes,
276
- duplicates = _this$props5.duplicates;
290
+ duplicates = _this$props5.duplicates,
291
+ toolbarOpts = _this$props5.toolbarOpts,
292
+ maxChoices = _this$props5.maxChoices,
293
+ choices = _this$props5.model.choices;
277
294
  var visibleChoices = this.getVisibleChoices() || [];
278
295
  return /*#__PURE__*/_react["default"].createElement("div", {
279
296
  className: classes.design
280
297
  }, /*#__PURE__*/_react["default"].createElement(InfoDialog, {
281
298
  open: dialog.open,
299
+ title: dialog.message,
282
300
  onOk: dialog.onOk
283
301
  }), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
284
302
  className: classes.addButton,
285
303
  variant: "contained",
286
304
  color: "primary",
287
- onClick: this.onAddChoice
305
+ onClick: this.onAddChoice,
306
+ disabled: maxChoices && choices && maxChoices === choices.length
288
307
  }, "Add Choice"), /*#__PURE__*/_react["default"].createElement("div", {
289
308
  className: classes.altChoices
290
309
  }, visibleChoices.map(function (c, index) {
@@ -317,7 +336,8 @@ var Choices = /*#__PURE__*/function (_React$Component) {
317
336
  focusedEl: undefined
318
337
  });
319
338
  },
320
- disableUnderline: true
339
+ disableUnderline: true,
340
+ toolbarOpts: toolbarOpts
321
341
  }));
322
342
  }
323
343
 
@@ -344,7 +364,9 @@ exports.Choices = Choices;
344
364
  duplicates: _propTypes["default"].bool,
345
365
  model: _propTypes["default"].object.isRequired,
346
366
  onChange: _propTypes["default"].func.isRequired,
347
- classes: _propTypes["default"].object.isRequired
367
+ classes: _propTypes["default"].object.isRequired,
368
+ toolbarOpts: _propTypes["default"].object,
369
+ maxChoices: _propTypes["default"].number
348
370
  });
349
371
  var Styled = (0, _styles.withStyles)(styles)(Choices);
350
372
  var _default = Styled;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/choices.jsx"],"names":["window","renMath","renderMath","InfoDialog","open","onOk","propTypes","PropTypes","bool","func","styles","theme","design","marginTop","spacing","unit","altChoices","alignItems","display","flexWrap","justifyContent","padding","marginBottom","Choices","dialog","prevValue","val","key","props","onChange","model","choices","correctResponse","alternateResponses","exists","filter","c","value","length","newChoices","id","setState","map","usedForResponse","Object","keys","forEach","responseKey","values","alternate","indexOf","alert","newChoicesWithoutTheEmptyOne","choice","focusedEl","oldChoices","duplicates","v","domNode","ReactDOM","findDOMNode","focusedNodeRef","focus","state","classes","visibleChoices","getVisibleChoices","addButton","onAddChoice","index","minWidth","zIndex","ref","prompt","video","disabled","audio","onChoiceChanged","undefined","onChoiceFocus","handleChoiceRemove","React","Component","object","isRequired","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEAA,MAAM,CAACC,OAAP,GAAiBC,yBAAjB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,MAAGC,IAAH,QAAGA,IAAH;AAAA,MAASC,IAAT,QAASA,IAAT;AAAA,sBACjB,gCAAC,kBAAD;AA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A,gBAAgB;AAlBlB,YAPF,CADF;AA8BD;;AAED,4BACE,gCAAC,kBAAD;AACE,UAAA,GAAG,EAAET,KADP;AAEE,UAAA,UAAU,EAAEb,UAFd;AAGE,UAAA,QAAQ,EAAC,GAHX;AAIE,UAAA,MAAM,EAAEpB,CAJV;AAKE,UAAA,OAAO,EAAE;AAAA,mBAAM,MAAI,CAAC2C,aAAL,CAAmB3C,CAAC,CAACI,EAArB,CAAN;AAAA,WALX;AAME,UAAA,cAAc,EAAE;AAAA,mBAAM,MAAI,CAACwC,kBAAL,CAAwB5C,CAAC,CAACI,EAA1B,CAAN;AAAA;AANlB,UADF;AAUD,OA5CD,CAJJ,CAbF,CADF;AAmED;;;EA7N0ByC,kBAAMC,S;;;iCAAtB3D,O,eACQ;AACjBiC,EAAAA,UAAU,EAAEjD,sBAAUC,IADL;AAEjBsB,EAAAA,KAAK,EAAEvB,sBAAU4E,MAAV,CAAiBC,UAFP;AAGjBvD,EAAAA,QAAQ,EAAEtB,sBAAUE,IAAV,CAAe2E,UAHR;AAIjBpB,EAAAA,OAAO,EAAEzD,sBAAU4E,MAAV,CAAiBC;AAJT,C;AA+NrB,IAAMC,MAAM,GAAG,wBAAW3E,MAAX,EAAmBa,OAAnB,CAAf;eAEe8D,M","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport find from 'lodash/find';\nimport Button from '@material-ui/core/Button';\nimport Choice from './choice';\nimport { choiceIsEmpty } from './markupUtils';\nimport { withStyles } from '@material-ui/core/styles';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport DialogActions from '@material-ui/core/DialogActions';\n\nwindow.renMath = renderMath;\n\nconst InfoDialog = ({ open, onOk }) => (\n <Dialog open={open}>\n <DialogTitle>Identical answer choices are not allowed and will be discarded</DialogTitle>\n <DialogActions>\n {onOk && (\n <Button onClick={onOk} color=\"primary\">\n OK\n </Button>\n )}\n </DialogActions>\n </Dialog>\n);\n\nInfoDialog.propTypes = {\n open: PropTypes.bool,\n onOk: PropTypes.func,\n};\n\nconst styles = theme => ({\n design: {\n marginTop: theme.spacing.unit * 2\n },\n altChoices: {\n alignItems: 'flex-start',\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'space-evenly',\n padding: '20px 0 0 0',\n '& > *': {\n marginBottom: '20px'\n }\n }\n});\n\nexport class Choices extends React.Component {\n static propTypes = {\n duplicates: PropTypes.bool,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired\n };\n\n state = {\n dialog: {\n open: false\n }\n };\n\n componentDidUpdate() {\n //eslint-disable-next-line\n const domNode = ReactDOM.findDOMNode(this);\n\n renderMath(domNode);\n\n if (this.focusedNodeRef) {\n this.focusedNodeRef.focus('end');\n }\n }\n\n onChoiceChanged = (prevValue, val, key) => {\n const { onChange, model } = this.props;\n const { choices, correctResponse, alternateResponses } = model;\n const exists = (choices || []).filter(c => c.value === val);\n\n if(exists.length) {\n const newChoices = (choices || []).filter(c => c.id !== key);\n\n onChange(newChoices);\n\n this.setState({\n dialog: {\n open: true,\n onOk: () => {\n this.setState(\n {\n dialog: {\n open: false\n }\n }\n );\n }\n }\n });\n\n return;\n }\n\n const newChoices = choices\n ? choices.map(c => {\n if (c.id === key) {\n return { ...c, value: val };\n }\n\n return c;\n })\n : [];\n\n if (choiceIsEmpty({ value: val })) {\n // if the edited content is empty, its usage has to be searched in the correct response definitions\n let usedForResponse = false;\n\n if (correctResponse) {\n Object.keys(correctResponse).forEach(responseKey => {\n if (correctResponse[responseKey] === key) {\n usedForResponse = true;\n }\n });\n }\n\n if (alternateResponses) {\n Object.values(alternateResponses).forEach(alternate => {\n if (alternate.indexOf(key) >= 0) {\n usedForResponse = true;\n }\n });\n }\n\n if (usedForResponse) {\n alert('Answer choices cannot be blank.');\n } else {\n if (!choiceIsEmpty({ value: prevValue })) {\n // if the previous value was not empty, it means that the choice can be deleted\n const newChoicesWithoutTheEmptyOne = newChoices.filter(choice => choice.id !== key);\n\n onChange(newChoicesWithoutTheEmptyOne);\n } else {\n onChange(newChoices);\n }\n }\n } else {\n onChange(newChoices);\n }\n };\n\n onChoiceFocus = id => this.setState({\n focusedEl: id\n });\n\n onAddChoice = () => {\n const { model: { choices: oldChoices }, onChange } = this.props;\n\n this.setState({\n focusedEl: `${oldChoices.length}`\n }, () => {\n onChange([\n ...oldChoices,\n {\n id: `${oldChoices.length}`,\n value: ''\n }\n ]\n );\n });\n };\n\n handleChoiceRemove = id => {\n const { onChange, model: { choices } } = this.props;\n const newChoices = choices.filter(c => c.id !== id);\n\n onChange(newChoices);\n };\n\n getVisibleChoices = () => {\n const {\n duplicates,\n model: { choices, correctResponse }\n } = this.props;\n\n if (!choices) {\n return [];\n }\n\n if (duplicates) {\n return choices;\n }\n\n // if duplicates not allowed, remove the choices that are used to define the correct response\n return choices.filter(choice => !find(correctResponse, v => v === choice.id));\n };\n\n render() {\n const { focusedEl, dialog } = this.state;\n const {\n classes,\n duplicates,\n } = this.props;\n const visibleChoices = this.getVisibleChoices() || [];\n\n return (\n <div className={classes.design}>\n <InfoDialog\n open={dialog.open}\n onOk={dialog.onOk}\n />\n <Button\n className={classes.addButton}\n variant=\"contained\"\n color=\"primary\"\n onClick={this.onAddChoice}\n >\n Add Choice\n </Button>\n <div\n className={classes.altChoices}\n >\n {\n visibleChoices.map((c, index) => {\n if (focusedEl === c.id) {\n return (\n <div\n key={index}\n style={{\n minWidth: '100%',\n zIndex: '100'\n }}\n >\n <EditableHtml\n ref={ref => (this.focusedNodeRef = ref)}\n className={classes.prompt}\n markup={c.value}\n pluginProps={{\n video: {\n disabled: true\n },\n audio: {\n disabled: true\n }\n }}\n onChange={val => this.onChoiceChanged(c.value, val, c.id)}\n onDone={() => {\n this.setState({\n focusedEl: undefined\n });\n }}\n disableUnderline\n />\n </div>\n );\n }\n\n return (\n <Choice\n key={index}\n duplicates={duplicates}\n targetId=\"0\"\n choice={c}\n onClick={() => this.onChoiceFocus(c.id)}\n onRemoveChoice={() => this.handleChoiceRemove(c.id)}\n />\n );\n })\n }\n </div>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Choices);\n\nexport default Styled;\n"],"file":"choices.js"}
1
+ {"version":3,"sources":["../src/choices.jsx"],"names":["window","renMath","renderMath","InfoDialog","open","title","onOk","propTypes","PropTypes","bool","func","string","styles","theme","design","marginTop","spacing","unit","altChoices","alignItems","display","flexWrap","justifyContent","padding","marginBottom","Choices","dialog","domNode","ReactDOM","findDOMNode","prevValue","val","key","props","onChange","model","choices","correctResponse","alternateResponses","duplicatedValue","find","c","value","id","newChoices","filter","setState","message","map","usedForResponse","Object","keys","forEach","responseKey","values","alternate","indexOf","alert","newChoicesWithoutTheEmptyOne","choice","focusedEl","oldChoices","length","duplicates","v","rerenderMath","focusedNodeRef","focus","state","classes","toolbarOpts","maxChoices","visibleChoices","getVisibleChoices","addButton","onAddChoice","index","minWidth","zIndex","ref","prompt","video","disabled","audio","onChoiceChanged","undefined","onChoiceFocus","handleChoiceRemove","React","Component","object","isRequired","number","Styled"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEAA,MAAM,CAACC,OAAP,GAAiBC,yBAAjB;;AAEA,IAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,MAAGC,IAAH,QAAGA,IAAH;AAAA,MAASC,KAAT,QAASA,KAAT;AAAA,MAAgBC,IAAhB,QAAgBA,IAAhB;AAAA,sBACjB,gCAAC,kBAAD;AAAQ,IAAA,IAAI,EAAEF;AAAd,kBACE,gCAAC,uBAAD,QAAcC,KAAK,IAAI,EAAvB,CADF,eAEE,gCAAC,yBAAD,QACGC,IAAI,iBACH,gCAAC,kBAAD;AAAQ,IAAA,OAAO,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AAE/D,sBAAUoF;AANL,C;AA4OrB,IAAMC,MAAM,GAAG,wBAAWjF,MAAX,EAAmBa,OAAnB,CAAf;eAEeoE,M","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport PropTypes from 'prop-types';\nimport EditableHtml from '@pie-lib/editable-html';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport find from 'lodash/find';\nimport Button from '@material-ui/core/Button';\nimport Choice from './choice';\nimport { choiceIsEmpty } from './markupUtils';\nimport { withStyles } from '@material-ui/core/styles';\nimport Dialog from '@material-ui/core/Dialog';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport DialogActions from '@material-ui/core/DialogActions';\n\nwindow.renMath = renderMath;\n\nconst InfoDialog = ({ open, title, onOk }) => (\n <Dialog open={open}>\n <DialogTitle>{title || ''}</DialogTitle>\n <DialogActions>\n {onOk && (\n <Button onClick={onOk} color=\"primary\">\n OK\n </Button>\n )}\n </DialogActions>\n </Dialog>\n);\n\nInfoDialog.propTypes = {\n open: PropTypes.bool,\n onOk: PropTypes.func,\n title: PropTypes.string\n};\n\nconst styles = theme => ({\n design: {\n marginTop: theme.spacing.unit * 2\n },\n altChoices: {\n alignItems: 'flex-start',\n display: 'flex',\n flexWrap: 'wrap',\n justifyContent: 'space-evenly',\n padding: '20px 0 0 0',\n '& > *': {\n marginBottom: '20px'\n }\n }\n});\n\nexport class Choices extends React.Component {\n static propTypes = {\n duplicates: PropTypes.bool,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n classes: PropTypes.object.isRequired,\n toolbarOpts: PropTypes.object,\n maxChoices: PropTypes.number\n };\n\n state = {\n dialog: {\n open: false\n }\n };\n\n componentDidMount() {\n this.rerenderMath();\n }\n\n componentDidUpdate() {\n this.rerenderMath();\n\n if (this.focusedNodeRef) {\n this.focusedNodeRef.focus('end');\n }\n }\n\n rerenderMath = () => {\n //eslint-disable-next-line\n const domNode = ReactDOM.findDOMNode(this);\n\n renderMath(domNode);\n }\n\n onChoiceChanged = (prevValue, val, key) => {\n const { onChange, model } = this.props;\n const { choices, correctResponse, alternateResponses } = model;\n const duplicatedValue = (choices || []).find(c => c.value === val && c.id !== key);\n\n // discard the new added choice or the changes if the choice would be a duplicate to one that already exists\n if (duplicatedValue) {\n if (prevValue === '') {\n // remove the new added choice from choices\n const newChoices = (choices || []).filter(c => c.id !== key);\n\n onChange(newChoices);\n }\n\n this.setState({\n dialog: {\n open: true,\n message: 'Identical answer choices are not allowed and the changes will be discarded',\n onOk: () => this.setState({ dialog: { open: false }})\n }\n });\n\n return;\n }\n\n const newChoices = choices\n ? choices.map(c => {\n if (c.id === key) {\n return { ...c, value: val };\n }\n\n return c;\n })\n : [];\n\n if (choiceIsEmpty({ value: val })) {\n // if the edited content is empty, its usage has to be searched in the correct response definitions\n let usedForResponse = false;\n\n if (correctResponse) {\n Object.keys(correctResponse).forEach(responseKey => {\n if (correctResponse[responseKey] === key) {\n usedForResponse = true;\n }\n });\n }\n\n if (alternateResponses) {\n Object.values(alternateResponses).forEach(alternate => {\n if (alternate.indexOf(key) >= 0) {\n usedForResponse = true;\n }\n });\n }\n\n if (usedForResponse) {\n alert('Answer choices cannot be blank.');\n } else {\n if (!choiceIsEmpty({ value: prevValue })) {\n // if the previous value was not empty, it means that the choice can be deleted\n const newChoicesWithoutTheEmptyOne = newChoices.filter(choice => choice.id !== key);\n\n onChange(newChoicesWithoutTheEmptyOne);\n } else {\n onChange(newChoices);\n }\n }\n } else {\n onChange(newChoices);\n }\n };\n\n onChoiceFocus = id => this.setState({\n focusedEl: id\n });\n\n onAddChoice = () => {\n const { model: { choices: oldChoices }, onChange } = this.props;\n\n this.setState({\n focusedEl: `${oldChoices.length}`\n }, () => {\n onChange([\n ...oldChoices,\n {\n id: `${oldChoices.length}`,\n value: ''\n }\n ]\n );\n });\n };\n\n handleChoiceRemove = id => {\n const { onChange, model: { choices } } = this.props;\n const newChoices = choices.filter(c => c.id !== id);\n\n onChange(newChoices);\n };\n\n getVisibleChoices = () => {\n const {\n duplicates,\n model: { choices, correctResponse }\n } = this.props;\n\n if (!choices) {\n return [];\n }\n\n if (duplicates) {\n return choices;\n }\n\n // if duplicates not allowed, remove the choices that are used to define the correct response\n return choices.filter(choice => !find(correctResponse, v => v === choice.id));\n };\n\n render() {\n const { focusedEl, dialog } = this.state;\n const {\n classes,\n duplicates,\n toolbarOpts,\n maxChoices,\n model: { choices }\n } = this.props;\n const visibleChoices = this.getVisibleChoices() || [];\n\n return (\n <div className={classes.design}>\n <InfoDialog\n open={dialog.open}\n title={dialog.message}\n onOk={dialog.onOk}\n />\n <Button\n className={classes.addButton}\n variant=\"contained\"\n color=\"primary\"\n onClick={this.onAddChoice}\n disabled={maxChoices && choices && maxChoices === choices.length}\n >\n Add Choice\n </Button>\n <div\n className={classes.altChoices}\n >\n {\n visibleChoices.map((c, index) => {\n if (focusedEl === c.id) {\n return (\n <div\n key={index}\n style={{\n minWidth: '100%',\n zIndex: '100'\n }}\n >\n <EditableHtml\n ref={ref => (this.focusedNodeRef = ref)}\n className={classes.prompt}\n markup={c.value}\n pluginProps={{\n video: {\n disabled: true\n },\n audio: {\n disabled: true\n }\n }}\n onChange={val => this.onChoiceChanged(c.value, val, c.id)}\n onDone={() => {\n this.setState({\n focusedEl: undefined\n });\n }}\n disableUnderline\n toolbarOpts={toolbarOpts}\n />\n </div>\n );\n }\n\n return (\n <Choice\n key={index}\n duplicates={duplicates}\n targetId=\"0\"\n choice={c}\n onClick={() => this.onChoiceFocus(c.id)}\n onRemoveChoice={() => this.handleChoiceRemove(c.id)}\n />\n );\n })\n }\n </div>\n </div>\n );\n }\n}\n\nconst Styled = withStyles(styles)(Choices);\n\nexport default Styled;\n"],"file":"choices.js"}