@pie-element/image-cloze-association 10.1.2-next.2 → 10.1.2

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 (130) hide show
  1. package/CHANGELOG.json +437 -0
  2. package/CHANGELOG.md +1997 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +197 -0
  6. package/configure/CHANGELOG.md +1600 -0
  7. package/configure/lib/defaults.js +86 -0
  8. package/configure/lib/defaults.js.map +1 -0
  9. package/configure/lib/index.js +99 -0
  10. package/configure/lib/index.js.map +1 -0
  11. package/configure/lib/root.js +135 -0
  12. package/configure/lib/root.js.map +1 -0
  13. package/configure/package.json +23 -0
  14. package/configure/src/__tests__/index.test.js +155 -0
  15. package/configure/src/defaults.js +59 -0
  16. package/configure/src/index.js +114 -0
  17. package/configure/src/root.jsx +116 -0
  18. package/controller/CHANGELOG.json +137 -0
  19. package/controller/CHANGELOG.md +1149 -0
  20. package/controller/lib/defaults.js +14 -0
  21. package/controller/lib/defaults.js.map +1 -0
  22. package/controller/lib/index.js +304 -0
  23. package/controller/lib/index.js.map +1 -0
  24. package/controller/lib/utils.js +70 -0
  25. package/controller/lib/utils.js.map +1 -0
  26. package/controller/package.json +19 -0
  27. package/controller/src/__tests__/index.test.js +711 -0
  28. package/controller/src/defaults.js +7 -0
  29. package/controller/src/index.js +322 -0
  30. package/controller/src/utils.js +72 -0
  31. package/docs/config-schema.json +1382 -0
  32. package/docs/config-schema.json.md +1021 -0
  33. package/docs/demo/config.js +8 -0
  34. package/docs/demo/generate.js +74 -0
  35. package/docs/demo/index.html +1 -0
  36. package/docs/demo/session.js +16 -0
  37. package/docs/pie-schema.json +1085 -0
  38. package/docs/pie-schema.json.md +810 -0
  39. package/lib/constants.js +12 -0
  40. package/lib/constants.js.map +1 -0
  41. package/lib/evaluation-icon.js +60 -0
  42. package/lib/evaluation-icon.js.map +1 -0
  43. package/lib/image-container.js +94 -0
  44. package/lib/image-container.js.map +1 -0
  45. package/lib/image-drop-target.js +130 -0
  46. package/lib/image-drop-target.js.map +1 -0
  47. package/lib/index.js +220 -0
  48. package/lib/index.js.map +1 -0
  49. package/lib/interactive-section.js +104 -0
  50. package/lib/interactive-section.js.map +1 -0
  51. package/lib/possible-response.js +161 -0
  52. package/lib/possible-response.js.map +1 -0
  53. package/lib/possible-responses.js +58 -0
  54. package/lib/possible-responses.js.map +1 -0
  55. package/lib/root.js +491 -0
  56. package/lib/root.js.map +1 -0
  57. package/lib/static-html-span.js +35 -0
  58. package/lib/static-html-span.js.map +1 -0
  59. package/lib/utils-correctness.js +89 -0
  60. package/lib/utils-correctness.js.map +1 -0
  61. package/package.json +21 -86
  62. package/src/__tests__/index.test.js +174 -0
  63. package/src/__tests__/root.test.jsx +99 -0
  64. package/src/__tests__/utils.test.js +207 -0
  65. package/src/constants.js +5 -0
  66. package/src/evaluation-icon.jsx +54 -0
  67. package/src/image-container.jsx +90 -0
  68. package/src/image-drop-target.jsx +140 -0
  69. package/src/index.js +245 -0
  70. package/src/interactive-section.jsx +94 -0
  71. package/src/possible-response.jsx +152 -0
  72. package/src/possible-responses.jsx +52 -0
  73. package/src/root.jsx +490 -0
  74. package/src/static-html-span.jsx +30 -0
  75. package/src/utils-correctness.js +95 -0
  76. package/configure.js +0 -2
  77. package/controller.js +0 -1
  78. package/dist/author/defaults.d.ts +0 -88
  79. package/dist/author/defaults.js +0 -58
  80. package/dist/author/index.d.ts +0 -34
  81. package/dist/author/index.js +0 -71
  82. package/dist/author/root.d.ts +0 -14
  83. package/dist/author/root.js +0 -80
  84. package/dist/browser/Check-DL1c-mLM.js +0 -10708
  85. package/dist/browser/Check-DL1c-mLM.js.map +0 -1
  86. package/dist/browser/author/index.js +0 -38597
  87. package/dist/browser/author/index.js.map +0 -1
  88. package/dist/browser/controller/index.js +0 -171
  89. package/dist/browser/controller/index.js.map +0 -1
  90. package/dist/browser/delivery/index.js +0 -2699
  91. package/dist/browser/delivery/index.js.map +0 -1
  92. package/dist/browser/dist-BphSS14E.js +0 -346
  93. package/dist/browser/dist-BphSS14E.js.map +0 -1
  94. package/dist/browser/humps-CZ4RCLab.js +0 -67
  95. package/dist/browser/humps-CZ4RCLab.js.map +0 -1
  96. package/dist/browser/image-cloze-association.css +0 -2
  97. package/dist/controller/defaults.d.ts +0 -16
  98. package/dist/controller/defaults.js +0 -10
  99. package/dist/controller/index.d.ts +0 -23
  100. package/dist/controller/index.js +0 -122
  101. package/dist/controller/utils.d.ts +0 -14
  102. package/dist/controller/utils.js +0 -36
  103. package/dist/delivery/constants.d.ts +0 -14
  104. package/dist/delivery/evaluation-icon.d.ts +0 -28
  105. package/dist/delivery/evaluation-icon.js +0 -38
  106. package/dist/delivery/image-container.d.ts +0 -13
  107. package/dist/delivery/image-container.js +0 -61
  108. package/dist/delivery/image-drop-target.d.ts +0 -45
  109. package/dist/delivery/image-drop-target.js +0 -90
  110. package/dist/delivery/index.d.ts +0 -20
  111. package/dist/delivery/index.js +0 -110
  112. package/dist/delivery/interactive-section.d.ts +0 -15
  113. package/dist/delivery/interactive-section.js +0 -72
  114. package/dist/delivery/possible-response.d.ts +0 -34
  115. package/dist/delivery/possible-response.js +0 -100
  116. package/dist/delivery/possible-responses.d.ts +0 -31
  117. package/dist/delivery/possible-responses.js +0 -41
  118. package/dist/delivery/root.d.ts +0 -21
  119. package/dist/delivery/root.js +0 -278
  120. package/dist/delivery/static-html-span.d.ts +0 -14
  121. package/dist/delivery/static-html-span.js +0 -22
  122. package/dist/delivery/utils-correctness.d.ts +0 -10
  123. package/dist/delivery/utils-correctness.js +0 -43
  124. package/dist/index.d.ts +0 -1
  125. package/dist/index.iife.d.ts +0 -8
  126. package/dist/index.iife.js +0 -152
  127. package/dist/index.js +0 -2
  128. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  129. package/dist/runtime-support.d.ts +0 -12
  130. package/dist/runtime-support.js +0 -12
package/src/index.js ADDED
@@ -0,0 +1,245 @@
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { renderMath } from '@pie-lib/math-rendering';
4
+ import { EnableAudioAutoplayImage } from '@pie-lib/render-ui';
5
+ import { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';
6
+
7
+ import ImageClozeAssociationComponent from './root';
8
+
9
+ export default class ImageClozeAssociation extends HTMLElement {
10
+ constructor() {
11
+ super();
12
+ this._root = null;
13
+ }
14
+
15
+ set model(m) {
16
+ this._model = m;
17
+
18
+ this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isComplete(), !!this._model));
19
+ this._render();
20
+ }
21
+
22
+ isComplete() {
23
+ const {
24
+ autoplayAudioEnabled,
25
+ completeAudioEnabled,
26
+ completeResponses,
27
+ duplicateResponses,
28
+ hasUnplacedChoices,
29
+ maxResponsePerZone,
30
+ responseAreasToBeFilled,
31
+ } = this._model || {};
32
+ const elementContext = this;
33
+
34
+ // check audio completion if audio settings are enabled and audio actually exists
35
+ if (autoplayAudioEnabled && completeAudioEnabled && !this.audioComplete) {
36
+ if (elementContext) {
37
+ const audio = elementContext.querySelector('audio');
38
+ const isInsidePrompt = audio && audio.closest('#preview-prompt');
39
+
40
+ // only require audio completion if audio exists and is inside the prompt
41
+ if (audio && isInsidePrompt) {
42
+ return false;
43
+ }
44
+ }
45
+ }
46
+
47
+ if (!this._session || !this._session.answers) {
48
+ return false;
49
+ }
50
+
51
+ const { answers } = this._session;
52
+
53
+ if (!Array.isArray(answers)) {
54
+ return false;
55
+ }
56
+
57
+ // filter answers by containerIndex and count the ones with content
58
+ const filledResponseAreas = [...new Map(answers.map((item) => [item.containerIndex, item])).values()].length;
59
+ // check if an answer choice was added to at least as many response areas
60
+ // as the number of populated response areas in the correct answer
61
+ const areResponseAreasFilled = filledResponseAreas >= responseAreasToBeFilled;
62
+
63
+ if (maxResponsePerZone > 1) {
64
+ if (duplicateResponses) {
65
+ // an answer choice can be used multiple times
66
+ return areResponseAreasFilled;
67
+ }
68
+
69
+ // any correct answer have any unplaced answer choices (by the author)
70
+ if (hasUnplacedChoices) {
71
+ return areResponseAreasFilled;
72
+ }
73
+
74
+ const allAnswersValue = answers.map((answer) => answer.value);
75
+
76
+ // check if any correct answer have any unplaced answer choices (by the student)
77
+ const requiredAnswersPlaced = completeResponses.some((response) =>
78
+ response.every((val) => allAnswersValue.includes(val)),
79
+ );
80
+
81
+ // true - all choices (required for a correct response) were placed into a response area
82
+ return requiredAnswersPlaced;
83
+ }
84
+
85
+ return areResponseAreasFilled;
86
+ }
87
+
88
+ set session(s) {
89
+ if (s && !s.answers) {
90
+ s.answers = [];
91
+ }
92
+
93
+ this._session = s;
94
+ this._render();
95
+ }
96
+
97
+ get session() {
98
+ return this._session;
99
+ }
100
+
101
+ updateAnswer(data) {
102
+ this._session.answers = data;
103
+ this._session.selector = 'Mouse';
104
+
105
+ this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
106
+
107
+ this._render();
108
+ }
109
+
110
+ _createAudioInfoToast() {
111
+ const info = document.createElement('div');
112
+ info.id = 'play-audio-info';
113
+
114
+ Object.assign(info.style, {
115
+ position: 'absolute',
116
+ top: 0,
117
+ width: '100%',
118
+ height: '100%',
119
+ display: 'flex',
120
+ justifyContent: 'center',
121
+ alignItems: 'center',
122
+ background: 'white',
123
+ zIndex: '1000',
124
+ cursor: 'pointer',
125
+ });
126
+
127
+ const img = document.createElement('img');
128
+ img.src = EnableAudioAutoplayImage;
129
+ img.alt = 'Click anywhere to enable audio autoplay';
130
+ img.width = 500;
131
+ img.height = 300;
132
+
133
+ info.appendChild(img);
134
+ return info;
135
+ }
136
+
137
+ connectedCallback() {
138
+ this._render();
139
+
140
+ // Observation: audio in Chrome will have the autoplay attribute,
141
+ // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio
142
+ // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox
143
+ const observer = new MutationObserver((mutationsList, observer) => {
144
+ mutationsList.forEach((mutation) => {
145
+ if (mutation.type === 'childList') {
146
+ const audio = this.querySelector('audio');
147
+ const isInsidePrompt = audio && audio.closest('#preview-prompt');
148
+
149
+ if (!this._model) return;
150
+ if (!this._model.autoplayAudioEnabled) return;
151
+ if (audio && !isInsidePrompt) return;
152
+ if (!audio) return;
153
+
154
+ const info = this._createAudioInfoToast();
155
+ const container = this.querySelector('#main-container');
156
+ const enableAudio = () => {
157
+ if (this.querySelector('#play-audio-info')) {
158
+ audio.play();
159
+ container.removeChild(info);
160
+ }
161
+
162
+ document.removeEventListener('click', enableAudio);
163
+ };
164
+
165
+ // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play
166
+ // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked
167
+ setTimeout(() => {
168
+ if (audio.paused && !this.querySelector('#play-audio-info')) {
169
+ // add info message as a toast to enable audio playback
170
+ container.appendChild(info);
171
+ document.addEventListener('click', enableAudio);
172
+ } else {
173
+ document.removeEventListener('click', enableAudio);
174
+ }
175
+ }, 500);
176
+
177
+ // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering
178
+ const handlePlaying = () => {
179
+ const info = this.querySelector('#play-audio-info');
180
+
181
+ if (info) {
182
+ container.removeChild(info);
183
+ }
184
+
185
+ audio.removeEventListener('playing', handlePlaying);
186
+ };
187
+
188
+ audio.addEventListener('playing', handlePlaying);
189
+
190
+ // we need to listen for the ended event to update the isComplete state
191
+ const handleEnded = () => {
192
+ this.audioComplete = true;
193
+ this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isComplete()));
194
+
195
+ audio.removeEventListener('ended', handleEnded);
196
+ };
197
+
198
+ audio.addEventListener('ended', handleEnded);
199
+
200
+ // store references to remove later
201
+ this._audio = audio;
202
+ this._handlePlaying = handlePlaying;
203
+ this._handleEnded = handleEnded;
204
+ this._enableAudio = enableAudio;
205
+
206
+ observer.disconnect();
207
+ }
208
+ });
209
+ });
210
+
211
+ observer.observe(this, { childList: true, subtree: true });
212
+ }
213
+
214
+ disconnectedCallback() {
215
+ document.removeEventListener('click', this._enableAudio);
216
+
217
+ if (this._audio) {
218
+ this._audio.removeEventListener('playing', this._handlePlaying);
219
+ this._audio.removeEventListener('ended', this._handleEnded);
220
+ this._audio = null;
221
+ }
222
+
223
+ if (this._root) {
224
+ this._root.unmount();
225
+ }
226
+ }
227
+
228
+ _render() {
229
+ if (this._model && this._session) {
230
+ const el = React.createElement(ImageClozeAssociationComponent, {
231
+ model: this._model,
232
+ session: this._session,
233
+ updateAnswer: this.updateAnswer.bind(this),
234
+ });
235
+
236
+ if (!this._root) {
237
+ this._root = createRoot(this);
238
+ }
239
+ this._root.render(el);
240
+ queueMicrotask(() => {
241
+ renderMath(this);
242
+ });
243
+ }
244
+ }
245
+ }
@@ -0,0 +1,94 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { styled } from '@mui/material/styles';
4
+ import { color } from '@pie-lib/render-ui';
5
+
6
+ import EvaluationIcon from './evaluation-icon';
7
+
8
+ const StyledContainer = styled('div')(({ theme }) => ({
9
+ marginTop: theme.spacing(2),
10
+ display: 'flex',
11
+ width: 'fit-content',
12
+ '&.default': {
13
+ border: `1px solid ${color.disabled()}`,
14
+ },
15
+ '&.correct': {
16
+ border: `2px solid ${color.correct()}`,
17
+ },
18
+ '&.incorrect': {
19
+ border: `2px solid ${color.incorrect()}`,
20
+ },
21
+ }));
22
+
23
+ class InteractiveSection extends React.Component {
24
+ getClassname() {
25
+ const { responseCorrect } = this.props;
26
+ let styleProp;
27
+
28
+ switch (responseCorrect) {
29
+ case undefined:
30
+ styleProp = 'default';
31
+ break;
32
+ case true:
33
+ styleProp = 'correct';
34
+ break;
35
+ default:
36
+ styleProp = 'incorrect';
37
+ break;
38
+ }
39
+ return styleProp;
40
+ }
41
+
42
+ getPositionDirection(choicePosition) {
43
+ let flexDirection;
44
+
45
+ switch (choicePosition) {
46
+ case 'left':
47
+ flexDirection = 'row-reverse';
48
+ break;
49
+ case 'right':
50
+ flexDirection = 'row';
51
+ break;
52
+ case 'top':
53
+ flexDirection = 'column-reverse';
54
+ break;
55
+ default:
56
+ // bottom
57
+ flexDirection = 'column';
58
+ break;
59
+ }
60
+
61
+ return flexDirection;
62
+ }
63
+
64
+ render() {
65
+ const { children, responseCorrect, uiStyle } = this.props;
66
+ const classname = this.getClassname();
67
+ const { possibilityListPosition = 'bottom' } = uiStyle || {};
68
+ const style = { flexDirection: this.getPositionDirection(possibilityListPosition) };
69
+ const evaluationStyle = {
70
+ display: 'flex',
71
+ margin: '0 auto',
72
+ marginTop: -14,
73
+ };
74
+
75
+ return (
76
+ <StyledContainer className={classname} style={style}>
77
+ <EvaluationIcon containerStyle={evaluationStyle} filled isCorrect={responseCorrect} />
78
+ {children}
79
+ </StyledContainer>
80
+ );
81
+ }
82
+ }
83
+
84
+ InteractiveSection.propTypes = {
85
+ children: PropTypes.oneOfType([PropTypes.element, PropTypes.array]).isRequired,
86
+ responseCorrect: PropTypes.oneOfType([PropTypes.bool, PropTypes.number]),
87
+ uiStyle: PropTypes.object,
88
+ };
89
+
90
+ InteractiveSection.defaultProps = {
91
+ responseCorrect: undefined,
92
+ };
93
+
94
+ export default InteractiveSection;
@@ -0,0 +1,152 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import classNames from 'classnames';
4
+ import { styled } from '@mui/material/styles';
5
+ import { useDraggable } from '@dnd-kit/core';
6
+ import { color } from '@pie-lib/render-ui';
7
+
8
+ import EvaluationIcon from './evaluation-icon';
9
+ import StaticHTMLSpan from './static-html-span';
10
+
11
+ const BaseContainer = styled('div')(() => ({
12
+ position: 'relative',
13
+ backgroundColor: color.white(),
14
+ border: `1px solid ${color.borderDark()}`,
15
+ display: 'flex',
16
+ alignItems: 'center',
17
+ justifyContent: 'center',
18
+ minHeight: '28px',
19
+ width: 'fit-content',
20
+ '& span img': {
21
+ // Added for touch devices, for image content.
22
+ // This will prevent the context menu from appearing and not allowing other interactions with the image.
23
+ // If interactions with the image in the token will be requested we should handle only the context Menu.
24
+ pointerEvents: 'none',
25
+ },
26
+ '&.textAnswerChoiceStyle': {
27
+ padding: '0 10px',
28
+ margin: '4px 6px !important',
29
+ },
30
+ '&.answerChoiceTransparency': {
31
+ border: 'none',
32
+ backgroundColor: `${color.transparent()}`,
33
+ '&:hover': {
34
+ border: `1px solid ${color.borderDark()}`,
35
+ },
36
+ },
37
+ '&.baseCorrect': {
38
+ border: `2px solid ${color.correct()} !important`,
39
+ },
40
+ '&.baseIncorrect': {
41
+ border: `2px solid ${color.incorrect()} !important`,
42
+ },
43
+ }));
44
+
45
+ const StyledSpan = styled(StaticHTMLSpan)(() => ({
46
+ cursor: 'grab',
47
+ backgroundColor: color.background(),
48
+ '&.hiddenSpan': {
49
+ visibility: 'hidden',
50
+ },
51
+ }));
52
+
53
+ const PossibleResponse = ({ canDrag, containerStyle, data, onDragBegin, answerChoiceTransparency, isOverlay }) => {
54
+ const rootRef = useRef(null);
55
+ const longPressTimer = useRef(null);
56
+
57
+ const { setNodeRef, attributes, listeners, isDragging } = useDraggable({
58
+ id: `possible-response-${data.id}`,
59
+ data: {
60
+ id: data.id,
61
+ value: data.value,
62
+ containerIndex: data.containerIndex,
63
+ },
64
+ disabled: !canDrag,
65
+ });
66
+
67
+ const handleTouchEnd = () => {
68
+ clearTimeout(longPressTimer.current);
69
+ };
70
+
71
+ const handleTouchMove = () => {
72
+ clearTimeout(longPressTimer.current);
73
+ };
74
+
75
+ const handleTouchStart = (e) => {
76
+ e.preventDefault();
77
+ longPressTimer.current = setTimeout(() => {
78
+ if (canDrag && rootRef.current) {
79
+ onDragBegin(data);
80
+ }
81
+ }, 500); // start drag after 500ms (touch and hold duration) for chromebooks and other touch devices
82
+ };
83
+
84
+ useEffect(() => {
85
+ const node = rootRef.current;
86
+
87
+ if (!node) return;
88
+
89
+ node.addEventListener('touchstart', handleTouchStart, { passive: false });
90
+ node.addEventListener('touchend', handleTouchEnd);
91
+ node.addEventListener('touchmove', handleTouchMove, { passive: false });
92
+
93
+ return () => {
94
+ node.removeEventListener('touchstart', handleTouchStart);
95
+ node.removeEventListener('touchend', handleTouchEnd);
96
+ node.removeEventListener('touchmove', handleTouchMove);
97
+ };
98
+ }, [canDrag, data]);
99
+
100
+ const { isCorrect } = data || {};
101
+ const evaluationStyle = {
102
+ fontSize: 14,
103
+ position: 'absolute',
104
+ bottom: '3px',
105
+ right: '3px',
106
+ };
107
+ const correctnessClass = isCorrect === true ? 'baseCorrect' : isCorrect === false ? 'baseIncorrect' : undefined;
108
+
109
+ const imgRegex = /<img[^>]+src="([^">]+)"/;
110
+ const containsImage = imgRegex.test(data.value);
111
+
112
+ const containerClassNames = classNames({
113
+ answerChoiceTransparency: answerChoiceTransparency && !isDragging,
114
+ [correctnessClass]: !!correctnessClass,
115
+ textAnswerChoiceStyle: !containsImage && !isOverlay,
116
+ });
117
+
118
+ const promptClassNames = classNames({ hiddenSpan: data.hidden });
119
+
120
+ return (
121
+ <BaseContainer
122
+ className={containerClassNames}
123
+ style={containerStyle}
124
+ ref={(ref) => {
125
+ rootRef.current = ref;
126
+ setNodeRef(ref);
127
+ }}
128
+ {...listeners}
129
+ {...attributes}
130
+ >
131
+ <StyledSpan html={data.value} className={promptClassNames} />
132
+ <EvaluationIcon isCorrect={data.isCorrect} containerStyle={evaluationStyle} />
133
+ </BaseContainer>
134
+ );
135
+ };
136
+
137
+ PossibleResponse.propTypes = {
138
+ canDrag: PropTypes.bool.isRequired,
139
+ containerStyle: PropTypes.object,
140
+ data: PropTypes.object.isRequired,
141
+ onDragBegin: PropTypes.func.isRequired,
142
+ answerChoiceTransparency: PropTypes.bool,
143
+ isOverlay: PropTypes.bool,
144
+ };
145
+
146
+ PossibleResponse.defaultProps = {
147
+ containerStyle: {},
148
+ answerChoiceTransparency: false,
149
+ isOverlay: false,
150
+ };
151
+
152
+ export default PossibleResponse;
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { styled } from '@mui/material/styles';
4
+ import { color } from '@pie-lib/render-ui';
5
+ import { ICADroppablePlaceholder } from '@pie-lib/drag';
6
+
7
+ import PossibleResponse from './possible-response';
8
+
9
+ const BaseContainer = styled('div')(({ theme }) => ({
10
+ backgroundColor: color.background(),
11
+ margin: theme.spacing(2),
12
+ display: 'flex',
13
+ alignItems: 'center',
14
+ width: 'fit-content',
15
+ }));
16
+
17
+ const PossibleResponses = ({
18
+ canDrag,
19
+ data,
20
+ onDragBegin,
21
+ answerChoiceTransparency,
22
+ customStyle,
23
+ isVertical,
24
+ minHeight,
25
+ }) => (
26
+ <BaseContainer style={customStyle}>
27
+ <ICADroppablePlaceholder id="ica-board" disabled={!canDrag} isVerticalPool={isVertical} minHeight={minHeight}>
28
+ {(data || []).map((item) => (
29
+ <PossibleResponse
30
+ canDrag={canDrag}
31
+ key={item.id}
32
+ data={item}
33
+ onDragBegin={onDragBegin}
34
+ answerChoiceTransparency={answerChoiceTransparency}
35
+ containerStyle={{ margin: '4px' }}
36
+ />
37
+ ))}
38
+ </ICADroppablePlaceholder>
39
+ </BaseContainer>
40
+ );
41
+
42
+ PossibleResponses.propTypes = {
43
+ canDrag: PropTypes.bool.isRequired,
44
+ data: PropTypes.array.isRequired,
45
+ onDragBegin: PropTypes.func.isRequired,
46
+ answerChoiceTransparency: PropTypes.bool,
47
+ customStyle: PropTypes.object,
48
+ isVertical: PropTypes.bool,
49
+ minHeight: PropTypes.number,
50
+ };
51
+
52
+ export default PossibleResponses;