@pie-element/explicit-constructed-response 3.9.2 → 3.9.3-next.1016

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 (40) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/configure/CHANGELOG.md +176 -0
  3. package/configure/lib/alternateResponses.js +45 -12
  4. package/configure/lib/alternateResponses.js.map +1 -1
  5. package/configure/lib/alternateSection.js +116 -19
  6. package/configure/lib/alternateSection.js.map +1 -1
  7. package/configure/lib/defaults.js +30 -0
  8. package/configure/lib/defaults.js.map +1 -1
  9. package/configure/lib/ecr-toolbar.js +19 -7
  10. package/configure/lib/ecr-toolbar.js.map +1 -1
  11. package/configure/lib/index.js +3 -3
  12. package/configure/lib/main.js +250 -42
  13. package/configure/lib/main.js.map +1 -1
  14. package/configure/lib/markupUtils.js +29 -3
  15. package/configure/lib/markupUtils.js.map +1 -1
  16. package/configure/lib/utils.js +15 -0
  17. package/configure/lib/utils.js.map +1 -0
  18. package/configure/package.json +3 -3
  19. package/controller/CHANGELOG.md +61 -0
  20. package/controller/lib/index.js +99 -6
  21. package/controller/lib/index.js.map +1 -1
  22. package/controller/package.json +1 -1
  23. package/docs/config-schema.json +116 -0
  24. package/docs/config-schema.json.md +89 -1
  25. package/docs/demo/generate.js +3 -1
  26. package/docs/pie-schema.json +57 -0
  27. package/docs/pie-schema.json.md +45 -0
  28. package/lib/index.js +5 -1
  29. package/lib/index.js.map +1 -1
  30. package/lib/main.js +75 -24
  31. package/lib/main.js.map +1 -1
  32. package/lib/print.js +115 -0
  33. package/lib/print.js.map +1 -0
  34. package/package.json +11 -7
  35. package/module/configure.js +0 -2121
  36. package/module/controller.js +0 -20840
  37. package/module/demo.js +0 -44
  38. package/module/element.js +0 -240
  39. package/module/index.html +0 -16
  40. package/module/manifest.json +0 -10
package/CHANGELOG.md CHANGED
@@ -3,6 +3,210 @@
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.12.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.12.5...@pie-element/explicit-constructed-response@3.12.6) (2022-03-28)
7
+
8
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.12.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.12.4...@pie-element/explicit-constructed-response@3.12.5) (2022-03-22)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * test ([61f9577](https://github.com/pie-framework/pie-elements/commit/61f95775a3086c6a4fce64c46b31b15b081f4243))
20
+
21
+
22
+
23
+
24
+
25
+ ## [3.12.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.12.3...@pie-element/explicit-constructed-response@3.12.4) (2022-03-08)
26
+
27
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
28
+
29
+
30
+
31
+
32
+
33
+ ## [3.12.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.12.2...@pie-element/explicit-constructed-response@3.12.3) (2022-03-08)
34
+
35
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
36
+
37
+
38
+
39
+
40
+
41
+ ## [3.12.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.12.1...@pie-element/explicit-constructed-response@3.12.2) (2022-02-21)
42
+
43
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
44
+
45
+
46
+
47
+
48
+
49
+ ## [3.12.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.12.0...@pie-element/explicit-constructed-response@3.12.1) (2022-02-04)
50
+
51
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
52
+
53
+
54
+
55
+
56
+
57
+ # [3.12.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.11.9...@pie-element/explicit-constructed-response@3.12.0) (2022-01-24)
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * **explicit-constructed-response:** Displayed delta, theta, times and tan symbols correctly PD-1507 ([29d97ec](https://github.com/pie-framework/pie-elements/commit/29d97ec68c6b66056595eb9444b9984aeb04472e))
63
+ * **multiple-choice, explicit-constructed-response, extended-text-entry:** print do not show teacher instructions, rationale or prompt if they are diabled DNA-13089 ([06b9555](https://github.com/pie-framework/pie-elements/commit/06b9555b25e094e0b2bce0e6a852a206c6d2c17d))
64
+ * 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))
65
+ * **explicit-constructed-response:** call session change depending on input max length PD-1353 ([2664a10](https://github.com/pie-framework/pie-elements/commit/2664a108cce80a9e3a9d34141613836cf057e25e))
66
+ * **explicit-constructed-response:** fix authoring bug when changing markup PD-1413. Show all choices and change title when maxLengthPerChoice is enabled PD-1396 ([b7944f4](https://github.com/pie-framework/pie-elements/commit/b7944f4ee7ae82eb7d40b7ec13dd1c5214157690))
67
+ * **explicit-constructed-response:** Fixed characters limit PD-1396 PD-1395 ([fcbf149](https://github.com/pie-framework/pie-elements/commit/fcbf149e49b5ead36585935e0b5616a970d0a81e))
68
+ * **multiple-choice-print, ecr-print:** fix toggle issue, change options.mode to options.role ([0b3f534](https://github.com/pie-framework/pie-elements/commit/0b3f534bb4d2f969e21528e74516345e84f18d72))
69
+
70
+
71
+ ### Features
72
+
73
+ * **explicit-constructed-response:** Added a max limit of characters and adjusted the width PD-794 ([135f176](https://github.com/pie-framework/pie-elements/commit/135f176402187e9a6120b88768ae7fb0152ac418))
74
+ * **explicit-constructed-response:** added the ability to choose the display property of the element [PD-1418] ([ac3ad81](https://github.com/pie-framework/pie-elements/commit/ac3ad8182911077b0eb3096944304c935bdf5e9a))
75
+ * **explicit-constructed-response:** Calculate maxChoicesLength if it's undefined. Fixed delete response area and choices bug. BREAKING CHANGE: add maxChoicesLength prop ([97431b9](https://github.com/pie-framework/pie-elements/commit/97431b9c3fbdafd84e040653c54d5f04bae16a1d))
76
+ * **explicit-constructed-response:** implement print PD-1284 ([3a387ba](https://github.com/pie-framework/pie-elements/commit/3a387ba5e9aff0e94cbb6465550bd07185ba7eff))
77
+
78
+
79
+
80
+
81
+
82
+ ## [3.11.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.11.8...@pie-element/explicit-constructed-response@3.11.9) (2022-01-10)
83
+
84
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
85
+
86
+
87
+
88
+
89
+
90
+ ## [3.11.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.11.7...@pie-element/explicit-constructed-response@3.11.8) (2021-12-23)
91
+
92
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
93
+
94
+
95
+
96
+
97
+
98
+ ## [3.11.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.11.5...@pie-element/explicit-constructed-response@3.11.6) (2021-12-13)
99
+
100
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
101
+
102
+
103
+
104
+
105
+
106
+ ## [3.11.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.11.2...@pie-element/explicit-constructed-response@3.11.3) (2021-12-01)
107
+
108
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
109
+
110
+
111
+
112
+
113
+
114
+ ## [3.11.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.11.1...@pie-element/explicit-constructed-response@3.11.2) (2021-11-29)
115
+
116
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
117
+
118
+
119
+
120
+
121
+
122
+ ## [3.11.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.10.5...@pie-element/explicit-constructed-response@3.11.1) (2021-11-11)
123
+
124
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
125
+
126
+
127
+
128
+
129
+
130
+ # [3.11.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.9.2...@pie-element/explicit-constructed-response@3.11.0) (2021-11-11)
131
+
132
+
133
+ ### Bug Fixes
134
+
135
+ * **explicit-constructed-response:** call session change depending on input max length PD-1353 ([2664a10](https://github.com/pie-framework/pie-elements/commit/2664a108cce80a9e3a9d34141613836cf057e25e))
136
+ * **multiple-choice-print, ecr-print:** fix toggle issue, change options.mode to options.role ([0b3f534](https://github.com/pie-framework/pie-elements/commit/0b3f534bb4d2f969e21528e74516345e84f18d72))
137
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
138
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
139
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
140
+
141
+
142
+ ### Features
143
+
144
+ * **explicit-constructed-response:** Added a max limit of characters and adjusted the width PD-794 ([135f176](https://github.com/pie-framework/pie-elements/commit/135f176402187e9a6120b88768ae7fb0152ac418))
145
+ * **explicit-constructed-response:** Calculate maxChoicesLength if it's undefined. Fixed delete response area and choices bug. BREAKING CHANGE: add maxChoicesLength prop ([97431b9](https://github.com/pie-framework/pie-elements/commit/97431b9c3fbdafd84e040653c54d5f04bae16a1d))
146
+ * **explicit-constructed-response:** implement print PD-1284 ([3a387ba](https://github.com/pie-framework/pie-elements/commit/3a387ba5e9aff0e94cbb6465550bd07185ba7eff))
147
+ * **explicit-constructed-response:** set toolbar editor position to bottom ([75cc827](https://github.com/pie-framework/pie-elements/commit/75cc827c14307f4cf96389112cbc4311eff3795a))
148
+
149
+
150
+
151
+
152
+
153
+
154
+ ## [3.10.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.10.4...@pie-element/explicit-constructed-response@3.10.5) (2021-11-01)
155
+
156
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
157
+
158
+
159
+
160
+
161
+
162
+ ## [3.10.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.10.3...@pie-element/explicit-constructed-response@3.10.4) (2021-10-18)
163
+
164
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
165
+
166
+
167
+
168
+
169
+
170
+ ## [3.10.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.10.2...@pie-element/explicit-constructed-response@3.10.3) (2021-10-04)
171
+
172
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
173
+
174
+
175
+
176
+
177
+
178
+ ## [3.10.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.10.1...@pie-element/explicit-constructed-response@3.10.2) (2021-09-20)
179
+
180
+
181
+ ### Bug Fixes
182
+
183
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
184
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
185
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
186
+
187
+
188
+
189
+
190
+
191
+ ## [3.10.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.10.0...@pie-element/explicit-constructed-response@3.10.1) (2021-09-01)
192
+
193
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response
194
+
195
+
196
+
197
+
198
+
199
+ # [3.10.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.9.2...@pie-element/explicit-constructed-response@3.10.0) (2021-08-05)
200
+
201
+
202
+ ### Features
203
+
204
+ * **explicit-constructed-response:** set toolbar editor position to bottom ([75cc827](https://github.com/pie-framework/pie-elements/commit/75cc827c14307f4cf96389112cbc4311eff3795a))
205
+
206
+
207
+
208
+
209
+
6
210
  ## [3.9.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response@3.9.0...@pie-element/explicit-constructed-response@3.9.2) (2021-08-05)
7
211
 
8
212
 
@@ -3,6 +3,182 @@
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.7.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.7.5...@pie-element/explicit-constructed-response-configure@3.7.6) (2022-03-28)
7
+
8
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.7.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.7.4...@pie-element/explicit-constructed-response-configure@3.7.5) (2022-03-22)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * test ([61f9577](https://github.com/pie-framework/pie-elements/commit/61f95775a3086c6a4fce64c46b31b15b081f4243))
20
+
21
+
22
+
23
+
24
+
25
+ ## [3.7.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.7.3...@pie-element/explicit-constructed-response-configure@3.7.4) (2022-03-08)
26
+
27
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
28
+
29
+
30
+
31
+
32
+
33
+ ## [3.7.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.7.2...@pie-element/explicit-constructed-response-configure@3.7.3) (2022-03-08)
34
+
35
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
36
+
37
+
38
+
39
+
40
+
41
+ ## [3.7.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.7.1...@pie-element/explicit-constructed-response-configure@3.7.2) (2022-02-21)
42
+
43
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
44
+
45
+
46
+
47
+
48
+
49
+ ## [3.7.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.7.0...@pie-element/explicit-constructed-response-configure@3.7.1) (2022-02-04)
50
+
51
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
52
+
53
+
54
+
55
+
56
+
57
+ # [3.7.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.6.9...@pie-element/explicit-constructed-response-configure@3.7.0) (2022-01-24)
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * **explicit-constructed-response:** Displayed delta, theta, times and tan symbols correctly PD-1507 ([29d97ec](https://github.com/pie-framework/pie-elements/commit/29d97ec68c6b66056595eb9444b9984aeb04472e))
63
+ * **explicit-constructed-response:** fix authoring bug when changing markup PD-1413. Show all choices and change title when maxLengthPerChoice is enabled PD-1396 ([b7944f4](https://github.com/pie-framework/pie-elements/commit/b7944f4ee7ae82eb7d40b7ec13dd1c5214157690))
64
+ * **explicit-constructed-response:** Fixed characters limit PD-1396 PD-1395 ([fcbf149](https://github.com/pie-framework/pie-elements/commit/fcbf149e49b5ead36585935e0b5616a970d0a81e))
65
+
66
+
67
+ ### Features
68
+
69
+ * **explicit-constructed-response:** Added a max limit of characters and adjusted the width PD-794 ([135f176](https://github.com/pie-framework/pie-elements/commit/135f176402187e9a6120b88768ae7fb0152ac418))
70
+ * **explicit-constructed-response:** added the ability to choose the display property of the element [PD-1418] ([ac3ad81](https://github.com/pie-framework/pie-elements/commit/ac3ad8182911077b0eb3096944304c935bdf5e9a))
71
+ * **explicit-constructed-response:** Calculate maxChoicesLength if it's undefined. Fixed delete response area and choices bug. BREAKING CHANGE: add maxChoicesLength prop ([97431b9](https://github.com/pie-framework/pie-elements/commit/97431b9c3fbdafd84e040653c54d5f04bae16a1d))
72
+
73
+
74
+
75
+
76
+
77
+ ## [3.6.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.6.8...@pie-element/explicit-constructed-response-configure@3.6.9) (2022-01-10)
78
+
79
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
80
+
81
+
82
+
83
+
84
+
85
+ ## [3.6.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.6.7...@pie-element/explicit-constructed-response-configure@3.6.8) (2021-12-23)
86
+
87
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
88
+
89
+
90
+
91
+
92
+
93
+ ## [3.6.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.6.5...@pie-element/explicit-constructed-response-configure@3.6.6) (2021-12-13)
94
+
95
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
96
+
97
+
98
+
99
+
100
+
101
+ ## [3.6.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.6.2...@pie-element/explicit-constructed-response-configure@3.6.3) (2021-12-01)
102
+
103
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
104
+
105
+
106
+
107
+
108
+
109
+ ## [3.6.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.6.1...@pie-element/explicit-constructed-response-configure@3.6.2) (2021-11-29)
110
+
111
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
112
+
113
+
114
+
115
+
116
+
117
+ ## [3.6.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.5.31...@pie-element/explicit-constructed-response-configure@3.6.1) (2021-11-11)
118
+
119
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
120
+
121
+
122
+
123
+
124
+
125
+ # [3.6.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.5.27...@pie-element/explicit-constructed-response-configure@3.6.0) (2021-11-11)
126
+
127
+
128
+ ### Bug Fixes
129
+
130
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
131
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
132
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
133
+
134
+
135
+ ### Features
136
+
137
+ * **explicit-constructed-response:** Added a max limit of characters and adjusted the width PD-794 ([135f176](https://github.com/pie-framework/pie-elements/commit/135f176402187e9a6120b88768ae7fb0152ac418))
138
+ * **explicit-constructed-response:** Calculate maxChoicesLength if it's undefined. Fixed delete response area and choices bug. BREAKING CHANGE: add maxChoicesLength prop ([97431b9](https://github.com/pie-framework/pie-elements/commit/97431b9c3fbdafd84e040653c54d5f04bae16a1d))
139
+
140
+
141
+
142
+
143
+
144
+
145
+ ## [3.5.31](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.5.30...@pie-element/explicit-constructed-response-configure@3.5.31) (2021-10-18)
146
+
147
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
148
+
149
+
150
+
151
+
152
+
153
+ ## [3.5.30](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.5.29...@pie-element/explicit-constructed-response-configure@3.5.30) (2021-10-04)
154
+
155
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
156
+
157
+
158
+
159
+
160
+
161
+ ## [3.5.29](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.5.28...@pie-element/explicit-constructed-response-configure@3.5.29) (2021-09-20)
162
+
163
+
164
+ ### Bug Fixes
165
+
166
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
167
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
168
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
169
+
170
+
171
+
172
+
173
+
174
+ ## [3.5.28](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.5.27...@pie-element/explicit-constructed-response-configure@3.5.28) (2021-08-05)
175
+
176
+ **Note:** Version bump only for package @pie-element/explicit-constructed-response-configure
177
+
178
+
179
+
180
+
181
+
6
182
  ## [3.5.27](https://github.com/pie-framework/pie-elements/compare/@pie-element/explicit-constructed-response-configure@3.5.25...@pie-element/explicit-constructed-response-configure@3.5.27) (2021-08-05)
7
183
 
8
184
 
@@ -33,15 +33,17 @@ var _map = _interopRequireDefault(require("lodash/map"));
33
33
 
34
34
  var _reduce = _interopRequireDefault(require("lodash/reduce"));
35
35
 
36
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
37
+
36
38
  var _alternateSection = _interopRequireDefault(require("./alternateSection"));
37
39
 
38
- 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; }
40
+ 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; }
39
41
 
40
- 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; }
42
+ 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; }
41
43
 
42
44
  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); }; }
43
45
 
44
- 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; } }
46
+ 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; } }
45
47
 
46
48
  var AlternateResponses = /*#__PURE__*/function (_React$Component) {
47
49
  (0, _inherits2["default"])(AlternateResponses, _React$Component);
@@ -58,12 +60,17 @@ var AlternateResponses = /*#__PURE__*/function (_React$Component) {
58
60
  }
59
61
 
60
62
  _this = _super.call.apply(_super, [this].concat(args));
61
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {});
63
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
64
+ maxLengthPerChoice: (0, _cloneDeep["default"])(_this.props.model.maxLengthPerChoice)
65
+ });
62
66
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "updateChoicesIfNeeded", function (props) {
63
- if (!_this.state.choices || !(0, _isEqual["default"])(_this.state.choices, props.model.choices) || !(0, _isEqual["default"])(props.model.choices, _this.props.model.choices)) {
64
- var choices = props.model.choices;
67
+ if (!_this.state.choices || !(0, _isEqual["default"])(_this.state.choices, props.model.choices) || !(0, _isEqual["default"])(props.model.choices, _this.props.model.choices) || _this.state.values && Object.keys(_this.state.values).length !== Object.keys(_this.props.model.choices).length || props.maxLengthPerChoiceEnabled !== _this.props.maxLengthPerChoiceEnabled) {
68
+ var _props$model = props.model,
69
+ choices = _props$model.choices,
70
+ maxLengthPerChoice = _props$model.maxLengthPerChoice;
65
71
  var selectedValues = (0, _reduce["default"])(choices, function (obj, c, key) {
66
- if (c && c.length > 1) {
72
+ // if maxLengthPerChoiceEnabled is true, we display all the choices
73
+ if (c && (props.maxLengthPerChoiceEnabled || c.length > 1)) {
67
74
  obj[key] = c[0];
68
75
  }
69
76
 
@@ -72,7 +79,8 @@ var AlternateResponses = /*#__PURE__*/function (_React$Component) {
72
79
 
73
80
  _this.setState({
74
81
  choices: props.model.choices,
75
- values: selectedValues
82
+ values: selectedValues,
83
+ maxLengthPerChoice: (0, _cloneDeep["default"])(maxLengthPerChoice)
76
84
  });
77
85
  }
78
86
  });
@@ -142,6 +150,14 @@ var AlternateResponses = /*#__PURE__*/function (_React$Component) {
142
150
  });
143
151
  }
144
152
  });
153
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onLengthChanged", function (value, key) {
154
+ var _this$props = _this.props,
155
+ model = _this$props.model,
156
+ onLengthChange = _this$props.onLengthChange;
157
+ var maxLengthPerChoice = model.maxLengthPerChoice;
158
+ maxLengthPerChoice[key] = value;
159
+ onLengthChange(maxLengthPerChoice);
160
+ });
145
161
  return _this;
146
162
  }
147
163
 
@@ -161,12 +177,20 @@ var AlternateResponses = /*#__PURE__*/function (_React$Component) {
161
177
  var _this2 = this;
162
178
 
163
179
  var choices = this.state.choices;
180
+ var _this$props2 = this.props,
181
+ _this$props2$model = _this$props2.model,
182
+ maxLengthPerChoice = _this$props2$model.maxLengthPerChoice,
183
+ maxLengthPerChoiceEnabled = _this$props2$model.maxLengthPerChoiceEnabled,
184
+ spellCheck = _this$props2.spellCheck,
185
+ choicesErrors = _this$props2.choicesErrors;
164
186
  return /*#__PURE__*/_react["default"].createElement("div", null, (0, _map["default"])(choices, function (c, key) {
165
- if (c && c.length > 1) {
187
+ // if maxLengthPerChoiceEnabled is true, we display all the choices
188
+ if (c && (maxLengthPerChoiceEnabled || c.length > 1)) {
166
189
  var selected = _this2.state.values[key];
167
190
  return /*#__PURE__*/_react["default"].createElement(_alternateSection["default"], {
168
191
  key: key,
169
192
  value: selected && selected.value,
193
+ errors: choicesErrors && choicesErrors[key],
170
194
  onSelect: function onSelect(choice) {
171
195
  return _this2.onSectionSelect(choice, key);
172
196
  },
@@ -176,8 +200,14 @@ var AlternateResponses = /*#__PURE__*/function (_React$Component) {
176
200
  choiceRemoved: function choiceRemoved(value) {
177
201
  return _this2.onChoiceRemoved(value, key);
178
202
  },
203
+ lengthChanged: function lengthChanged(value) {
204
+ return _this2.onLengthChanged(value, key);
205
+ },
179
206
  selectChoices: [selected],
180
- choices: c
207
+ choices: c,
208
+ maxLength: maxLengthPerChoice[key],
209
+ showMaxLength: maxLengthPerChoiceEnabled,
210
+ spellCheck: spellCheck
181
211
  });
182
212
  }
183
213
  }), choices && Object.keys(this.state.values).length !== Object.keys(choices).length && /*#__PURE__*/_react["default"].createElement(_alternateSection["default"], {
@@ -191,7 +221,8 @@ var AlternateResponses = /*#__PURE__*/function (_React$Component) {
191
221
  choiceRemoved: function choiceRemoved(value) {
192
222
  return _this2.onChoiceRemoved(value);
193
223
  },
194
- selectChoices: this.getRemainingChoices()
224
+ selectChoices: this.getRemainingChoices(),
225
+ spellCheck: spellCheck
195
226
  }));
196
227
  }
197
228
  }]);
@@ -201,7 +232,9 @@ var AlternateResponses = /*#__PURE__*/function (_React$Component) {
201
232
  exports.AlternateResponses = AlternateResponses;
202
233
  (0, _defineProperty2["default"])(AlternateResponses, "propTypes", {
203
234
  model: _propTypes["default"].object.isRequired,
204
- onChange: _propTypes["default"].func.isRequired
235
+ onChange: _propTypes["default"].func.isRequired,
236
+ onLengthChange: _propTypes["default"].func.isRequired,
237
+ maxLengthPerChoiceEnabled: _propTypes["default"].bool.isRequired
205
238
  });
206
239
  var _default = AlternateResponses;
207
240
  exports["default"] = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/alternateResponses.jsx"],"names":["AlternateResponses","props","state","choices","model","selectedValues","obj","c","key","length","setState","values","valueKey","arr","push","label","value","choice","onChange","sectionChoices","isNew","find","newChoices","reduce","newVal","section","nextProps","updateChoicesIfNeeded","selected","onSectionSelect","onChoiceChanged","onChoiceRemoved","Object","keys","getRemainingChoices","React","Component","PropTypes","object","isRequired","func"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;IAEaA,kB;;;;;;;;;;;;;;;8FAMH,E;8GAUgB,UAAAC,KAAK,EAAI;AAC/B,UAAI,CAAC,MAAKC,KAAL,CAAWC,OAAZ,IACC,CAAC,yBAAQ,MAAKD,KAAL,CAAWC,OAAnB,EAA4BF,KAAK,CAACG,KAAN,CAAYD,OAAxC,CADF,IAEC,CAAC,yBAAQF,KAAK,CAACG,KAAN,CAAYD,OAApB,EAA6B,MAAKF,KAAL,CAAWG,KAAX,CAAiBD,OAA9C,CAFN,EAGE;AAAA,YACQA,OADR,GACoBF,KAAK,CAACG,KAD1B,CACQD,OADR;AAGA,YAAME,cAAc,GAAG,wBAAOF,OAAP,EAAgB,UAACG,GAAD,EAAMC,CAAN,EAASC,GAAT,EAAiB;AACtD,cAAID,CAAC,IAAIA,CAAC,CAACE,MAAF,GAAW,CAApB,EAAuB;AACrBH,YAAAA,GAAG,CAACE,GAAD,CAAH,GAAWD,CAAC,CAAC,CAAD,CAAZ;AACD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,EAAE,CAACoB,QAAD,CANjB;AAOE,YAAA,OAAO,EAAErB;AAPX,YADF;AAWD;AACF,OAhBA,CADH,EAmBIJ,OAAO,IACP6B,MAAM,CAACC,IAAP,CAAY,KAAK/B,KAAL,CAAWS,MAAvB,EAA+BF,MAA/B,KAA0CuB,MAAM,CAACC,IAAP,CAAY9B,OAAZ,EAAqBM,MAD/D,iBAEA,gCAAC,4BAAD;AACE,QAAA,KAAK,EAAC,EADR;AAEE,QAAA,QAAQ,EAAE,kBAAAQ,MAAM;AAAA,iBAAI,MAAI,CAACY,eAAL,CAAqBZ,MAArB,EAA6BA,MAAM,CAACD,KAApC,CAAJ;AAAA,SAFlB;AAGE,QAAA,aAAa,EAAE,uBAAAC,MAAM;AAAA,iBAAI,MAAI,CAACa,eAAL,CAAqBb,MAArB,CAAJ;AAAA,SAHvB;AAIE,QAAA,aAAa,EAAE,uBAAAD,KAAK;AAAA,iBAAI,MAAI,CAACe,eAAL,CAAqBf,KAArB,CAAJ;AAAA,SAJtB;AAKE,QAAA,aAAa,EAAE,KAAKkB,mBAAL;AALjB,QArBJ,CADF;AAgCD;;;EArKqCC,kBAAMC,S;;;iCAAjCpC,kB,eACQ;AACjBI,EAAAA,KAAK,EAAEiC,sBAAUC,MAAV,CAAiBC,UADP;AAEjBrB,EAAAA,QAAQ,EAAEmB,sBAAUG,IAAV,CAAeD;AAFR,C;eAuKNvC,kB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isEqual from 'lodash/isEqual';\nimport map from 'lodash/map';\nimport reduce from 'lodash/reduce';\n\nimport AlternateSection from './alternateSection';\n\nexport class AlternateResponses extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired\n };\n\n state = {};\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.updateChoicesIfNeeded(nextProps);\n }\n\n componentDidMount() {\n this.updateChoicesIfNeeded(this.props);\n }\n\n updateChoicesIfNeeded = props => {\n if (!this.state.choices\n || !isEqual(this.state.choices, props.model.choices)\n || !isEqual(props.model.choices, this.props.model.choices)\n ) {\n const { choices } = props.model;\n\n const selectedValues = reduce(choices, (obj, c, key) => {\n if (c && c.length > 1) {\n obj[key] = c[0];\n }\n\n return obj;\n }, {});\n\n this.setState({\n choices: props.model.choices,\n values: selectedValues\n });\n }\n };\n\n getRemainingChoices = valueKey => {\n const { choices } = this.state;\n\n return reduce(choices, (arr, c, key) => {\n if (c && c.length === 1 && !valueKey) {\n arr.push({\n label: c[0].label,\n value: key\n });\n }\n\n return arr;\n }, []);\n };\n\n onChoiceChanged = (choice, key) => {\n const { onChange } = this.props;\n const { choices } = this.state;\n const sectionChoices = (choices[key] || []);\n\n const isNew = !sectionChoices.find(c => c.value === choice.value);\n\n const newChoices = sectionChoices.reduce((arr, c) => {\n const newVal = c.value === choice.value ? choice : c;\n\n arr.push(newVal);\n\n return arr;\n }, []);\n\n if (isNew) {\n newChoices.push(choice);\n }\n\n onChange({\n ...choices,\n [key]: newChoices\n });\n };\n\n onChoiceRemoved = (value, section) => {\n const { onChange } = this.props;\n const { choices } = this.state;\n const sectionChoices = (choices[section] || []);\n\n const newChoices = sectionChoices.reduce((arr, c) => {\n if (c.value === value) {\n return arr;\n }\n\n arr.push(c);\n\n return arr;\n }, []);\n\n onChange({\n ...choices,\n [section]: newChoices\n });\n };\n\n onSectionSelect = (choice, key) => {\n const { onChange } = this.props;\n const { choices, values } = this.state;\n\n if (choices[key] && choices[key].length > 1) {\n if (!choice) {\n onChange({\n ...choices,\n [key]: [choices[key][0]]\n });\n }\n } else {\n this.setState({\n choices: {\n ...choices,\n [key]: [\n ...choices[key],\n {\n label: '',\n value: '1'\n }\n ]\n },\n values: {\n ...values,\n [key]: choices[key][0]\n }\n });\n }\n };\n\n render() {\n const { choices } = this.state;\n\n return (\n <div>\n {map(choices, (c, key) => {\n if (c && c.length > 1) {\n const selected = this.state.values[key];\n\n return (\n <AlternateSection\n key={key}\n value={selected && selected.value}\n onSelect={choice => this.onSectionSelect(choice, key)}\n choiceChanged={choice => this.onChoiceChanged(choice, key)}\n choiceRemoved={value => this.onChoiceRemoved(value, key)}\n selectChoices={[selected]}\n choices={c}\n />\n );\n }\n })}\n {\n choices &&\n Object.keys(this.state.values).length !== Object.keys(choices).length &&\n <AlternateSection\n value=\"\"\n onSelect={choice => this.onSectionSelect(choice, choice.value)}\n choiceChanged={choice => this.onChoiceChanged(choice)}\n choiceRemoved={value => this.onChoiceRemoved(value)}\n selectChoices={this.getRemainingChoices()}\n />\n }\n </div>\n );\n }\n}\n\nexport default AlternateResponses;\n"],"file":"alternateResponses.js"}
1
+ {"version":3,"sources":["../src/alternateResponses.jsx"],"names":["AlternateResponses","maxLengthPerChoice","props","model","state","choices","values","Object","keys","length","maxLengthPerChoiceEnabled","selectedValues","obj","c","key","setState","valueKey","arr","push","label","value","choice","onChange","sectionChoices","isNew","find","newChoices","reduce","newVal","section","onLengthChange","nextProps","updateChoicesIfNeeded","spellCheck","choicesErrors","selected","onSectionSelect","onChoiceChanged","onChoiceRemoved","onLengthChanged","getRemainingChoices","React","Component","PropTypes","object","isRequired","func","bool"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;IAEaA,kB;;;;;;;;;;;;;;;8FAQH;AAAEC,MAAAA,kBAAkB,EAAE,2BAAU,MAAKC,KAAL,CAAWC,KAAX,CAAiBF,kBAA3B;AAAtB,K;8GAUgB,UAAAC,KAAK,EAAI;AAC/B,UAAI,CAAC,MAAKE,KAAL,CAAWC,OAAZ,IACC,CAAC,yBAAQ,MAAKD,KAAL,CAAWC,OAAnB,EAA4BH,KAAK,CAACC,KAAN,CAAYE,OAAxC,CADF,IAEC,CAAC,yBAAQH,KAAK,CAACC,KAAN,CAAYE,OAApB,EAA6B,MAAKH,KAAL,CAAWC,KAAX,CAAiBE,OAA9C,CAFF,IAGE,MAAKD,KAAL,CAAWE,MAAX,IAAqBC,MAA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yBAAyB,EAAEiC,sBAAUI,IAAV,CAAeF;AAJzB,C;eA6LN7C,kB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isEqual from 'lodash/isEqual';\nimport map from 'lodash/map';\nimport reduce from 'lodash/reduce';\nimport cloneDeep from 'lodash/cloneDeep';\n\nimport AlternateSection from './alternateSection';\n\nexport class AlternateResponses extends React.Component {\n static propTypes = {\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n onLengthChange: PropTypes.func.isRequired,\n maxLengthPerChoiceEnabled: PropTypes.bool.isRequired\n };\n\n state = { maxLengthPerChoice: cloneDeep(this.props.model.maxLengthPerChoice) };\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.updateChoicesIfNeeded(nextProps);\n }\n\n componentDidMount() {\n this.updateChoicesIfNeeded(this.props);\n }\n\n updateChoicesIfNeeded = props => {\n if (!this.state.choices\n || !isEqual(this.state.choices, props.model.choices)\n || !isEqual(props.model.choices, this.props.model.choices)\n || (this.state.values && Object.keys(this.state.values).length !== Object.keys(this.props.model.choices).length)\n || props.maxLengthPerChoiceEnabled !== this.props.maxLengthPerChoiceEnabled\n ) {\n const { choices, maxLengthPerChoice } = props.model;\n\n const selectedValues = reduce(choices, (obj, c, key) => {\n // if maxLengthPerChoiceEnabled is true, we display all the choices\n if (c && (props.maxLengthPerChoiceEnabled || c.length > 1)) {\n obj[key] = c[0];\n }\n\n return obj;\n }, {});\n\n this.setState({\n choices: props.model.choices,\n values: selectedValues,\n maxLengthPerChoice: cloneDeep(maxLengthPerChoice)\n });\n }\n };\n\n getRemainingChoices = valueKey => {\n const { choices } = this.state;\n\n return reduce(choices, (arr, c, key) => {\n if (c && c.length === 1 && !valueKey) {\n arr.push({\n label: c[0].label,\n value: key\n });\n }\n\n return arr;\n }, []);\n };\n\n onChoiceChanged = (choice, key) => {\n const { onChange } = this.props;\n const { choices } = this.state;\n const sectionChoices = (choices[key] || []);\n\n const isNew = !sectionChoices.find(c => c.value === choice.value);\n\n const newChoices = sectionChoices.reduce((arr, c) => {\n const newVal = c.value === choice.value ? choice : c;\n\n arr.push(newVal);\n\n return arr;\n }, []);\n\n if (isNew) {\n newChoices.push(choice);\n }\n\n onChange({\n ...choices,\n [key]: newChoices\n });\n };\n\n onChoiceRemoved = (value, section) => {\n const { onChange } = this.props;\n const { choices } = this.state;\n const sectionChoices = (choices[section] || []);\n\n const newChoices = sectionChoices.reduce((arr, c) => {\n if (c.value === value) {\n return arr;\n }\n\n arr.push(c);\n\n return arr;\n }, []);\n\n onChange({\n ...choices,\n [section]: newChoices\n });\n };\n\n onSectionSelect = (choice, key) => {\n const { onChange } = this.props;\n const { choices, values } = this.state;\n\n if (choices[key] && choices[key].length > 1) {\n if (!choice) {\n onChange({\n ...choices,\n [key]: [choices[key][0]]\n });\n }\n } else {\n this.setState({\n choices: {\n ...choices,\n [key]: [\n ...choices[key],\n {\n label: '',\n value: '1'\n }\n ]\n },\n values: {\n ...values,\n [key]: choices[key][0]\n }\n });\n }\n };\n\n onLengthChanged = (value, key) => {\n const { model, onLengthChange } = this.props;\n const { maxLengthPerChoice } = model;\n\n maxLengthPerChoice[key] = value;\n onLengthChange(maxLengthPerChoice);\n }\n\n render() {\n const { choices } = this.state;\n const { model: { maxLengthPerChoice, maxLengthPerChoiceEnabled }, spellCheck, choicesErrors } = this.props\n\n return (\n <div>\n {map(choices, (c, key) => {\n // if maxLengthPerChoiceEnabled is true, we display all the choices\n if (c && (maxLengthPerChoiceEnabled || c.length > 1)) {\n const selected = this.state.values[key];\n\n return (\n <AlternateSection\n key={key}\n value={selected && selected.value}\n errors={choicesErrors && choicesErrors[key]}\n onSelect={choice => this.onSectionSelect(choice, key)}\n choiceChanged={choice => this.onChoiceChanged(choice, key)}\n choiceRemoved={value => this.onChoiceRemoved(value, key)}\n lengthChanged={value => this.onLengthChanged(value, key)}\n selectChoices={[selected]}\n choices={c}\n maxLength={maxLengthPerChoice[key]}\n showMaxLength={maxLengthPerChoiceEnabled}\n spellCheck = {spellCheck}\n />\n );\n }\n })}\n {\n choices &&\n Object.keys(this.state.values).length !== Object.keys(choices).length &&\n <AlternateSection\n value=\"\"\n onSelect={choice => this.onSectionSelect(choice, choice.value)}\n choiceChanged={choice => this.onChoiceChanged(choice)}\n choiceRemoved={value => this.onChoiceRemoved(value)}\n selectChoices={this.getRemainingChoices()}\n spellCheck = {spellCheck}\n />\n }\n </div>\n );\n }\n}\n\nexport default AlternateResponses;\n"],"file":"alternateResponses.js"}