@pie-element/match-list 7.2.0-beta.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -4
- package/controller/CHANGELOG.md +13 -1
- package/controller/package.json +1 -1
- package/lib/answer-area.js +20 -7
- package/lib/answer-area.js.map +1 -1
- package/lib/answer.js +117 -26
- package/lib/answer.js.map +1 -1
- package/lib/arrow.js +8 -3
- package/lib/arrow.js.map +1 -1
- package/lib/choices-list.js +13 -4
- package/lib/choices-list.js.map +1 -1
- package/lib/droppable-placeholder.js +12 -1
- package/lib/droppable-placeholder.js.map +1 -1
- package/lib/keyboard-coordinates.js +147 -0
- package/lib/keyboard-coordinates.js.map +1 -0
- package/lib/main.js +223 -19
- package/lib/main.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,16 +3,65 @@
|
|
|
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
|
-
# [7.2.0
|
|
6
|
+
# [7.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.9...@pie-element/match-list@7.2.0) (2026-08-21)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- move [@pie-lib](https://github.com/pie-lib) deps back to latest, off next prereleases PIE-927 ([a53e012](https://github.com/pie-framework/pie-elements/commit/a53e0127eb4ac95ece54e1e2bd669ae4974f4251))
|
|
11
|
+
- **theming:** move the grey palette reads onto --pie-\* tokens PIE-856 ([d7d005b](https://github.com/pie-framework/pie-elements/commit/d7d005bf081843335b4b0377852f2ecd075cb62d)), closes [#000000](https://github.com/pie-framework/pie-elements/issues/000000) [#E0E1E6](https://github.com/pie-framework/pie-elements/issues/E0E1E6) [#646464](https://github.com/pie-framework/pie-elements/issues/646464) [#616161](https://github.com/pie-framework/pie-elements/issues/616161) [#E0E1E6](https://github.com/pie-framework/pie-elements/issues/E0E1E6) [#C0C3](https://github.com/pie-framework/pie-elements/issues/C0C3)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
|
|
16
|
+
|
|
17
|
+
## [7.1.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.8...@pie-element/match-list@7.1.9) (2026-08-19)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @pie-element/match-list
|
|
20
|
+
|
|
21
|
+
## [7.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.6...@pie-element/match-list@7.1.8) (2026-08-13)
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
- **match-list/placement-ordering:** scroll the interactive region horizontally when it does not fit PIE-766 & PIE-768 ([f0395a9](https://github.com/pie-framework/pie-elements/commit/f0395a91b16a803c5609d5ece6d3f87208dee1b2))
|
|
26
|
+
- **match-list:** improve keyboard drag-and-drop, collision detection and drop-zone visuals PIE-643 ([265b832](https://github.com/pie-framework/pie-elements/commit/265b8329b27b0226ce49ac83f3f3b944c18fc506))
|
|
27
|
+
|
|
28
|
+
## [7.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.6...@pie-element/match-list@7.1.7) (2026-08-11)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @pie-element/match-list
|
|
31
|
+
|
|
32
|
+
## [7.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.5...@pie-element/match-list@7.1.6) (2026-07-02)
|
|
7
33
|
|
|
8
34
|
### Bug Fixes
|
|
9
35
|
|
|
10
|
-
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
11
36
|
- bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
|
|
12
|
-
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
13
|
-
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
14
37
|
- sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
|
|
15
38
|
|
|
39
|
+
## [7.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.4...@pie-element/match-list@7.1.5) (2026-06-22)
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
- handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
|
|
44
|
+
|
|
45
|
+
## [7.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.3...@pie-element/match-list@7.1.4) (2026-06-17)
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
- bump shared modules and libs PIE-661 PIE-664 PIE-683 PIE-666 PIE-656 PIE-657 PIE-658 PIE-659 PIE-670 ([ebd6be4](https://github.com/pie-framework/pie-elements/commit/ebd6be4fd48fca41ad4c4908f606b25334731aed))
|
|
50
|
+
|
|
51
|
+
## [7.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.2...@pie-element/match-list@7.1.3) (2026-06-12)
|
|
52
|
+
|
|
53
|
+
### Bug Fixes
|
|
54
|
+
|
|
55
|
+
- bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
|
|
56
|
+
|
|
57
|
+
## [7.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.1...@pie-element/match-list@7.1.2) (2026-06-04)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @pie-element/match-list
|
|
60
|
+
|
|
61
|
+
## [7.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.0...@pie-element/match-list@7.1.1) (2026-05-21)
|
|
62
|
+
|
|
63
|
+
**Note:** Version bump only for package @pie-element/match-list
|
|
64
|
+
|
|
16
65
|
# [7.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list@7.1.0-next.1...@pie-element/match-list@7.1.0) (2026-05-21)
|
|
17
66
|
|
|
18
67
|
### Bug Fixes
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,24 @@
|
|
|
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
|
-
|
|
6
|
+
## [6.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list-controller@6.1.2...@pie-element/match-list-controller@6.1.4) (2026-08-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/match-list-controller
|
|
9
|
+
|
|
10
|
+
## [6.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list-controller@6.1.2...@pie-element/match-list-controller@6.1.3) (2026-08-11)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @pie-element/match-list-controller
|
|
13
|
+
|
|
14
|
+
## [6.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list-controller@6.1.1...@pie-element/match-list-controller@6.1.2) (2026-07-02)
|
|
7
15
|
|
|
8
16
|
### Bug Fixes
|
|
9
17
|
|
|
10
18
|
- bump shared modules and libs PIE-695, PIE-697, PIE-699, PIE-680, PIE-714, PIE-665, PIE-656 ([4b76ae7](https://github.com/pie-framework/pie-elements/commit/4b76ae75d1c5ea6d55f7c6fb53f299dfcbda2b1f))
|
|
11
19
|
|
|
20
|
+
## [6.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list-controller@6.1.0...@pie-element/match-list-controller@6.1.1) (2026-05-21)
|
|
21
|
+
|
|
22
|
+
**Note:** Version bump only for package @pie-element/match-list-controller
|
|
23
|
+
|
|
12
24
|
# [6.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/match-list-controller@6.1.0-next.1...@pie-element/match-list-controller@6.1.0) (2026-05-21)
|
|
13
25
|
|
|
14
26
|
### Bug Fixes
|
package/controller/package.json
CHANGED
package/lib/answer-area.js
CHANGED
|
@@ -12,9 +12,14 @@ var _styles = require("@mui/material/styles");
|
|
|
12
12
|
var _lodashEs = require("lodash-es");
|
|
13
13
|
var _arrow = _interopRequireDefault(require("./arrow"));
|
|
14
14
|
var _answer = _interopRequireDefault(require("./answer"));
|
|
15
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
16
|
+
// matches the min width of the answer entries (see AnswerContainer in ./answer), so the two columns
|
|
17
|
+
// give the row an intrinsic min width that the horizontal scroll container can overflow.
|
|
18
|
+
const MIN_COLUMN_WIDTH = 200;
|
|
15
19
|
const ArrowEntry = (0, _styles.styled)('div')({
|
|
16
20
|
alignItems: 'normal',
|
|
17
21
|
display: 'flex',
|
|
22
|
+
flexShrink: 0,
|
|
18
23
|
height: 40,
|
|
19
24
|
margin: '10px 20px'
|
|
20
25
|
});
|
|
@@ -29,14 +34,13 @@ const ItemList = (0, _styles.styled)('div')(({
|
|
|
29
34
|
marginTop: theme.spacing(2),
|
|
30
35
|
marginBottom: theme.spacing(2)
|
|
31
36
|
}));
|
|
32
|
-
const PromptEntry = (0, _styles.styled)('div')(({
|
|
33
|
-
|
|
34
|
-
}) => ({
|
|
35
|
-
border: `1px solid ${theme.palette.grey[400]}`,
|
|
37
|
+
const PromptEntry = (0, _styles.styled)('div')(() => ({
|
|
38
|
+
border: `1px solid ${_renderUi.color.border()}`,
|
|
36
39
|
boxSizing: 'border-box',
|
|
37
40
|
flex: 1,
|
|
38
41
|
margin: '10px 0',
|
|
39
42
|
minHeight: 40,
|
|
43
|
+
minWidth: MIN_COLUMN_WIDTH,
|
|
40
44
|
overflow: 'hidden',
|
|
41
45
|
padding: 10,
|
|
42
46
|
textAlign: 'center',
|
|
@@ -119,7 +123,10 @@ class AnswerArea extends _react.default.Component {
|
|
|
119
123
|
const {
|
|
120
124
|
disabled,
|
|
121
125
|
instanceId,
|
|
122
|
-
onRemoveAnswer
|
|
126
|
+
onRemoveAnswer,
|
|
127
|
+
selectedAnswer,
|
|
128
|
+
onChoiceClick,
|
|
129
|
+
onPlacementClick
|
|
123
130
|
} = this.props;
|
|
124
131
|
const rows = this.buildRows();
|
|
125
132
|
const correctnessMap = this.getCorrectOrIncorrectMap();
|
|
@@ -148,7 +155,10 @@ class AnswerArea extends _react.default.Component {
|
|
|
148
155
|
id: sessionAnswer.id,
|
|
149
156
|
title: sessionAnswer.title,
|
|
150
157
|
type: 'target',
|
|
151
|
-
onRemoveChoice: () => onRemoveAnswer(id)
|
|
158
|
+
onRemoveChoice: () => onRemoveAnswer(id),
|
|
159
|
+
selectedAnswer: selectedAnswer,
|
|
160
|
+
onSelectClick: onChoiceClick,
|
|
161
|
+
onPlacementClick: onPlacementClick
|
|
152
162
|
}));
|
|
153
163
|
}));
|
|
154
164
|
}
|
|
@@ -162,7 +172,10 @@ exports.AnswerArea = AnswerArea;
|
|
|
162
172
|
onRemoveAnswer: _propTypes.default.func,
|
|
163
173
|
instanceId: _propTypes.default.string.isRequired,
|
|
164
174
|
model: _propTypes.default.object.isRequired,
|
|
165
|
-
prompt: _propTypes.default.string
|
|
175
|
+
prompt: _propTypes.default.string,
|
|
176
|
+
selectedAnswer: _propTypes.default.object,
|
|
177
|
+
onChoiceClick: _propTypes.default.func,
|
|
178
|
+
onPlacementClick: _propTypes.default.func
|
|
166
179
|
});
|
|
167
180
|
var _default = exports.default = AnswerArea;
|
|
168
181
|
//# sourceMappingURL=answer-area.js.map
|
package/lib/answer-area.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer-area.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_lodashEs","_arrow","_answer","ArrowEntry","styled","alignItems","display","height","margin","ItemList","theme","flex","flexDirection","justifyContent","marginTop","spacing","marginBottom","PromptEntry","border","palette","grey","boxSizing","minHeight","overflow","padding","textAlign","width","wordBreak","Row","AnswerArea","React","Component","constructor","args","_defineProperty2","default","promptId","model","session","showCorrect","props","config","answerId","prompts","find","p","id","relatedAnswer","value","answer","answers","sessionValue","reduce","obj","prompt","undefined","mode","correctPromptMap","isUndefined","val","key","map","sessionAnswer","getAnswerFromSession","render","disabled","instanceId","onRemoveAnswer","rows","buildRows","correctnessMap","getCorrectOrIncorrectMap","createElement","title","index","dangerouslySetInnerHTML","__html","direction","className","correct","draggable","isEmpty","type","onRemoveChoice","exports","PropTypes","object","isRequired","bool","onSessionChange","func","string","_default"],"sources":["../src/answer-area.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { isEmpty, isUndefined, reduce } from 'lodash-es';\n\nimport Arrow from './arrow';\nimport DragAndDropAnswer from './answer';\n\nconst ArrowEntry = styled('div')({\n alignItems: 'normal',\n display: 'flex',\n height: 40,\n margin: '10px 20px',\n});\n\nconst ItemList = styled('div')(({ theme }) => ({\n alignItems: 'flex-start',\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n justifyContent: 'space-between',\n marginTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst PromptEntry = styled('div')(({ theme }) => ({\n border: `1px solid ${theme.palette.grey[400]}`,\n boxSizing: 'border-box',\n flex: 1,\n margin: '10px 0',\n minHeight: 40,\n overflow: 'hidden',\n padding: 10,\n textAlign: 'center',\n width: '100%',\n wordBreak: 'break-word',\n}));\n\nconst Row = styled('div')({\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n});\n\nexport class AnswerArea extends React.Component {\n static propTypes = {\n session: PropTypes.object.isRequired,\n showCorrect: PropTypes.bool.isRequired,\n disabled: PropTypes.bool.isRequired,\n onSessionChange: PropTypes.func,\n onRemoveAnswer: PropTypes.func,\n instanceId: PropTypes.string.isRequired,\n model: PropTypes.object.isRequired,\n prompt: PropTypes.string,\n };\n\n getAnswerFromSession = (promptId) => {\n const { model, session, showCorrect } = this.props;\n const { config } = model;\n const answerId = showCorrect\n ? config.prompts.find((p) => p.id === promptId).relatedAnswer\n : session.value && session.value[promptId];\n const answer = config.answers.find((answer) => answer.id === answerId);\n\n return answer || {};\n };\n\n getCorrectOrIncorrectMap = () => {\n const { model, session, showCorrect } = this.props;\n const { config } = model;\n const sessionValue =\n session.value ||\n config.prompts.reduce((obj, prompt) => {\n obj[prompt.id] = undefined;\n return obj;\n }, {});\n\n if (model.mode !== 'evaluate') {\n return {};\n }\n\n if (showCorrect) {\n return config.prompts.reduce((obj, prompt) => {\n obj[prompt.id] = true;\n\n return obj;\n }, {});\n }\n\n const correctPromptMap = config.prompts.reduce((obj, prompt) => {\n if (!isUndefined(prompt.relatedAnswer)) {\n obj[prompt.id] = prompt.relatedAnswer;\n }\n\n return obj;\n }, {});\n\n return reduce(\n sessionValue,\n (obj, val, key) => {\n obj[key] = correctPromptMap[key] === sessionValue[key];\n\n return obj;\n },\n {},\n );\n };\n\n buildRows = () => {\n const { model } = this.props;\n const { config } = model;\n const prompts = config.prompts || [];\n\n return prompts.map((prompt) => {\n const sessionAnswer = this.getAnswerFromSession(prompt.id);\n\n return {\n ...prompt,\n sessionAnswer,\n };\n });\n };\n\n render() {\n const { disabled, instanceId, onRemoveAnswer } = this.props;\n const rows = this.buildRows();\n const correctnessMap = this.getCorrectOrIncorrectMap();\n\n return (\n <ItemList>\n {rows.map(({ sessionAnswer, title, id }, index) => {\n return (\n <Row key={index}>\n <PromptEntry dangerouslySetInnerHTML={{ __html: title }} />\n\n <ArrowEntry>\n <Arrow direction=\"left\" />\n <Arrow />\n </ArrowEntry>\n\n <DragAndDropAnswer\n key={index}\n className=\"answer\"\n index={index}\n promptId={id}\n correct={correctnessMap[id]}\n draggable={!isEmpty(sessionAnswer)}\n disabled={disabled}\n instanceId={instanceId}\n id={sessionAnswer.id}\n title={sessionAnswer.title}\n type={'target'}\n onRemoveChoice={() => onRemoveAnswer(id)}\n />\n </Row>\n );\n })}\n </ItemList>\n );\n }\n}\n\nexport default AnswerArea;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAMM,UAAU,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC;EAC/BC,UAAU,EAAE,QAAQ;EACpBC,OAAO,EAAE,MAAM;EACfC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE;AACV,CAAC,CAAC;AAEF,MAAMC,QAAQ,GAAG,IAAAL,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEM;AAAM,CAAC,MAAM;EAC7CL,UAAU,EAAE,YAAY;EACxBC,OAAO,EAAE,MAAM;EACfK,IAAI,EAAE,CAAC;EACPC,aAAa,EAAE,QAAQ;EACvBC,cAAc,EAAE,eAAe;EAC/BC,SAAS,EAAEJ,KAAK,CAACK,OAAO,CAAC,CAAC,CAAC;EAC3BC,YAAY,EAAEN,KAAK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,QAAA,GAAAR,OAAA,CAAAjD,OAAA,GA4GYN,UAAU","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"answer-area.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_lodashEs","_arrow","_answer","_renderUi","MIN_COLUMN_WIDTH","ArrowEntry","styled","alignItems","display","flexShrink","height","margin","ItemList","theme","flex","flexDirection","justifyContent","marginTop","spacing","marginBottom","PromptEntry","border","color","boxSizing","minHeight","minWidth","overflow","padding","textAlign","width","wordBreak","Row","AnswerArea","React","Component","constructor","args","_defineProperty2","default","promptId","model","session","showCorrect","props","config","answerId","prompts","find","p","id","relatedAnswer","value","answer","answers","sessionValue","reduce","obj","prompt","undefined","mode","correctPromptMap","isUndefined","val","key","map","sessionAnswer","getAnswerFromSession","render","disabled","instanceId","onRemoveAnswer","selectedAnswer","onChoiceClick","onPlacementClick","rows","buildRows","correctnessMap","getCorrectOrIncorrectMap","createElement","title","index","dangerouslySetInnerHTML","__html","direction","className","correct","draggable","isEmpty","type","onRemoveChoice","onSelectClick","exports","PropTypes","object","isRequired","bool","onSessionChange","func","string","_default"],"sources":["../src/answer-area.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { isEmpty, isUndefined, reduce } from 'lodash-es';\n\nimport Arrow from './arrow';\nimport DragAndDropAnswer from './answer';\nimport { color } from '@pie-lib/render-ui';\n\n// matches the min width of the answer entries (see AnswerContainer in ./answer), so the two columns\n// give the row an intrinsic min width that the horizontal scroll container can overflow.\nconst MIN_COLUMN_WIDTH = 200;\n\nconst ArrowEntry = styled('div')({\n alignItems: 'normal',\n display: 'flex',\n flexShrink: 0,\n height: 40,\n margin: '10px 20px',\n});\n\nconst ItemList = styled('div')(({ theme }) => ({\n alignItems: 'flex-start',\n display: 'flex',\n flex: 1,\n flexDirection: 'column',\n justifyContent: 'space-between',\n marginTop: theme.spacing(2),\n marginBottom: theme.spacing(2),\n}));\n\nconst PromptEntry = styled('div')(() => ({\n border: `1px solid ${color.border()}`,\n boxSizing: 'border-box',\n flex: 1,\n margin: '10px 0',\n minHeight: 40,\n minWidth: MIN_COLUMN_WIDTH,\n overflow: 'hidden',\n padding: 10,\n textAlign: 'center',\n width: '100%',\n wordBreak: 'break-word',\n}));\n\nconst Row = styled('div')({\n alignItems: 'center',\n display: 'flex',\n justifyContent: 'space-between',\n width: '100%',\n});\n\nexport class AnswerArea extends React.Component {\n static propTypes = {\n session: PropTypes.object.isRequired,\n showCorrect: PropTypes.bool.isRequired,\n disabled: PropTypes.bool.isRequired,\n onSessionChange: PropTypes.func,\n onRemoveAnswer: PropTypes.func,\n instanceId: PropTypes.string.isRequired,\n model: PropTypes.object.isRequired,\n prompt: PropTypes.string,\n selectedAnswer: PropTypes.object,\n onChoiceClick: PropTypes.func,\n onPlacementClick: PropTypes.func,\n };\n\n getAnswerFromSession = (promptId) => {\n const { model, session, showCorrect } = this.props;\n const { config } = model;\n const answerId = showCorrect\n ? config.prompts.find((p) => p.id === promptId).relatedAnswer\n : session.value && session.value[promptId];\n const answer = config.answers.find((answer) => answer.id === answerId);\n\n return answer || {};\n };\n\n getCorrectOrIncorrectMap = () => {\n const { model, session, showCorrect } = this.props;\n const { config } = model;\n const sessionValue =\n session.value ||\n config.prompts.reduce((obj, prompt) => {\n obj[prompt.id] = undefined;\n return obj;\n }, {});\n\n if (model.mode !== 'evaluate') {\n return {};\n }\n\n if (showCorrect) {\n return config.prompts.reduce((obj, prompt) => {\n obj[prompt.id] = true;\n\n return obj;\n }, {});\n }\n\n const correctPromptMap = config.prompts.reduce((obj, prompt) => {\n if (!isUndefined(prompt.relatedAnswer)) {\n obj[prompt.id] = prompt.relatedAnswer;\n }\n\n return obj;\n }, {});\n\n return reduce(\n sessionValue,\n (obj, val, key) => {\n obj[key] = correctPromptMap[key] === sessionValue[key];\n\n return obj;\n },\n {},\n );\n };\n\n buildRows = () => {\n const { model } = this.props;\n const { config } = model;\n const prompts = config.prompts || [];\n\n return prompts.map((prompt) => {\n const sessionAnswer = this.getAnswerFromSession(prompt.id);\n\n return {\n ...prompt,\n sessionAnswer,\n };\n });\n };\n\n render() {\n const { disabled, instanceId, onRemoveAnswer, selectedAnswer, onChoiceClick, onPlacementClick } = this.props;\n const rows = this.buildRows();\n const correctnessMap = this.getCorrectOrIncorrectMap();\n\n return (\n <ItemList>\n {rows.map(({ sessionAnswer, title, id }, index) => {\n return (\n <Row key={index}>\n <PromptEntry dangerouslySetInnerHTML={{ __html: title }} />\n\n <ArrowEntry>\n <Arrow direction=\"left\" />\n <Arrow />\n </ArrowEntry>\n\n <DragAndDropAnswer\n key={index}\n className=\"answer\"\n index={index}\n promptId={id}\n correct={correctnessMap[id]}\n draggable={!isEmpty(sessionAnswer)}\n disabled={disabled}\n instanceId={instanceId}\n id={sessionAnswer.id}\n title={sessionAnswer.title}\n type={'target'}\n onRemoveChoice={() => onRemoveAnswer(id)}\n selectedAnswer={selectedAnswer}\n onSelectClick={onChoiceClick}\n onPlacementClick={onPlacementClick}\n />\n </Row>\n );\n })}\n </ItemList>\n );\n }\n}\n\nexport default AnswerArea;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEA;AACA;AACA,MAAMO,gBAAgB,GAAG,GAAG;AAE5B,MAAMC,UAAU,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC;EAC/BC,UAAU,EAAE,QAAQ;EACpBC,OAAO,EAAE,MAAM;EACfC,UAAU,EAAE,CAAC;EACbC,MAAM,EAAE,EAAE;EACVC,MAAM,EAAE;AACV,CAAC,CAAC;AA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AU,eACF;EACjBS,OAAO,EAAEmD,kBAAS,CAACC,MAAM,CAACC,UAAU;EACpCpD,WAAW,EAAEkD,kBAAS,CAACG,IAAI,CAACD,UAAU;EACtC1B,QAAQ,EAAEwB,kBAAS,CAACG,IAAI,CAACD,UAAU;EACnCE,eAAe,EAAEJ,kBAAS,CAACK,IAAI;EAC/B3B,cAAc,EAAEsB,kBAAS,CAACK,IAAI;EAC9B5B,UAAU,EAAEuB,kBAAS,CAACM,MAAM,CAACJ,UAAU;EACvCtD,KAAK,EAAEoD,kBAAS,CAACC,MAAM,CAACC,UAAU;EAClCrC,MAAM,EAAEmC,kBAAS,CAACM,MAAM;EACxB3B,cAAc,EAAEqB,kBAAS,CAACC,MAAM;EAChCrB,aAAa,EAAEoB,kBAAS,CAACK,IAAI;EAC7BxB,gBAAgB,EAAEmB,kBAAS,CAACK;AAC9B,CAAC;AAAA,IAAAE,QAAA,GAAAR,OAAA,CAAArD,OAAA,GA+GYN,UAAU","ignoreList":[]}
|
package/lib/answer.js
CHANGED
|
@@ -9,12 +9,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _core = require("@dnd-kit/core");
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _react =
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
13
|
var _debug = _interopRequireDefault(require("debug"));
|
|
14
14
|
var _styles = require("@mui/material/styles");
|
|
15
15
|
var _drag = require("@pie-lib/drag");
|
|
16
16
|
var _lodashEs = require("lodash-es");
|
|
17
17
|
var _renderUi = require("@pie-lib/render-ui");
|
|
18
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
19
|
const log = (0, _debug.default)('pie-elements:match-title:answer');
|
|
19
20
|
const HolderNumber = (0, _styles.styled)('div')(({
|
|
20
21
|
theme
|
|
@@ -48,15 +49,15 @@ Holder.propTypes = {
|
|
|
48
49
|
type: _propTypes.default.string
|
|
49
50
|
};
|
|
50
51
|
const AnswerContentContainer = (0, _styles.styled)('div')(({
|
|
51
|
-
theme,
|
|
52
52
|
isDragging,
|
|
53
|
+
isSelected,
|
|
53
54
|
isOver,
|
|
54
55
|
disabled,
|
|
55
56
|
outcome
|
|
56
57
|
}) => ({
|
|
57
58
|
color: _renderUi.color.text(),
|
|
58
59
|
backgroundColor: _renderUi.color.white(),
|
|
59
|
-
border: `1px solid ${outcome === 'correct' ? _renderUi.color.correct() : outcome === 'incorrect' ? _renderUi.color.incorrect() :
|
|
60
|
+
border: `1px solid ${outcome === 'correct' ? _renderUi.color.correct() : outcome === 'incorrect' ? _renderUi.color.incorrect() : _renderUi.color.border()}`,
|
|
60
61
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
61
62
|
width: '100%',
|
|
62
63
|
padding: '10px',
|
|
@@ -64,12 +65,13 @@ const AnswerContentContainer = (0, _styles.styled)('div')(({
|
|
|
64
65
|
overflow: 'hidden',
|
|
65
66
|
transition: 'opacity 200ms linear',
|
|
66
67
|
wordBreak: 'break-word',
|
|
67
|
-
opacity: isDragging && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,
|
|
68
|
+
opacity: (isDragging || isSelected) && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,
|
|
68
69
|
touchAction: 'none'
|
|
69
70
|
}));
|
|
70
71
|
const AnswerContent = props => {
|
|
71
72
|
const {
|
|
72
73
|
isDragging,
|
|
74
|
+
isSelected,
|
|
73
75
|
isOver,
|
|
74
76
|
title,
|
|
75
77
|
disabled,
|
|
@@ -88,6 +90,7 @@ const AnswerContent = props => {
|
|
|
88
90
|
} else {
|
|
89
91
|
return /*#__PURE__*/_react.default.createElement(AnswerContentContainer, {
|
|
90
92
|
isDragging: isDragging,
|
|
93
|
+
isSelected: isSelected,
|
|
91
94
|
isOver: isOver,
|
|
92
95
|
disabled: disabled,
|
|
93
96
|
outcome: outcome,
|
|
@@ -139,6 +142,7 @@ class Answer extends _react.default.Component {
|
|
|
139
142
|
id,
|
|
140
143
|
title,
|
|
141
144
|
isDragging = false,
|
|
145
|
+
isSelected = false,
|
|
142
146
|
className,
|
|
143
147
|
disabled,
|
|
144
148
|
isOver = false,
|
|
@@ -156,6 +160,7 @@ class Answer extends _react.default.Component {
|
|
|
156
160
|
isOver: isOver,
|
|
157
161
|
empty: (0, _lodashEs.isEmpty)(title),
|
|
158
162
|
isDragging: isDragging,
|
|
163
|
+
isSelected: isSelected,
|
|
159
164
|
disabled: disabled,
|
|
160
165
|
type: type
|
|
161
166
|
}));
|
|
@@ -165,6 +170,7 @@ exports.Answer = Answer;
|
|
|
165
170
|
(0, _defineProperty2.default)(Answer, "propTypes", {
|
|
166
171
|
className: _propTypes.default.string,
|
|
167
172
|
isDragging: _propTypes.default.bool,
|
|
173
|
+
isSelected: _propTypes.default.bool,
|
|
168
174
|
id: _propTypes.default.any,
|
|
169
175
|
title: _propTypes.default.string,
|
|
170
176
|
isOver: _propTypes.default.bool,
|
|
@@ -180,11 +186,29 @@ function DragAndDropAnswer(props) {
|
|
|
180
186
|
promptId,
|
|
181
187
|
draggable = true,
|
|
182
188
|
disabled = false,
|
|
183
|
-
type
|
|
189
|
+
type,
|
|
190
|
+
selectedAnswer,
|
|
191
|
+
onSelectClick,
|
|
192
|
+
onPlacementClick
|
|
184
193
|
} = props;
|
|
185
194
|
const dragId = `${type || 'answer'}-${id}`;
|
|
186
195
|
// droppable only if promptId exists
|
|
187
196
|
const dropId = promptId !== undefined && promptId !== null ? `drop-${promptId}` : undefined;
|
|
197
|
+
|
|
198
|
+
// Built once and reused for both dnd-kit's own data and the click handlers below, so
|
|
199
|
+
// a click carries exactly the same shape dnd-kit's onDragStart/onDragEnd would.
|
|
200
|
+
const activeData = {
|
|
201
|
+
type: type || 'answer',
|
|
202
|
+
id,
|
|
203
|
+
instanceId,
|
|
204
|
+
value: props.title,
|
|
205
|
+
promptId
|
|
206
|
+
};
|
|
207
|
+
const dropZoneData = dropId ? {
|
|
208
|
+
type: 'drop-zone',
|
|
209
|
+
promptId,
|
|
210
|
+
instanceId
|
|
211
|
+
} : undefined;
|
|
188
212
|
const {
|
|
189
213
|
attributes,
|
|
190
214
|
listeners,
|
|
@@ -194,63 +218,127 @@ function DragAndDropAnswer(props) {
|
|
|
194
218
|
isDragging
|
|
195
219
|
} = (0, _core.useDraggable)({
|
|
196
220
|
id: dragId,
|
|
197
|
-
data:
|
|
198
|
-
type: type || 'answer',
|
|
199
|
-
id,
|
|
200
|
-
instanceId,
|
|
201
|
-
value: props.title,
|
|
202
|
-
promptId
|
|
203
|
-
},
|
|
221
|
+
data: activeData,
|
|
204
222
|
disabled: !draggable || disabled
|
|
205
223
|
});
|
|
206
224
|
const droppable = (0, _core.useDroppable)({
|
|
207
225
|
id: dropId,
|
|
208
|
-
data:
|
|
209
|
-
type: 'drop-zone',
|
|
210
|
-
promptId,
|
|
211
|
-
instanceId
|
|
212
|
-
} : undefined,
|
|
226
|
+
data: dropZoneData,
|
|
213
227
|
disabled: disabled || !dropId
|
|
214
228
|
});
|
|
215
229
|
const setDropRef = droppable.setNodeRef;
|
|
216
230
|
const isOver = droppable.isOver;
|
|
217
231
|
|
|
232
|
+
// dnd-kit's own isOver only reflects real collision detection during an active drag,
|
|
233
|
+
// so it stays false while an answer is merely click-selected (no drag in progress).
|
|
234
|
+
// Track hovering locally and fold it into the same isOver signal used everywhere
|
|
235
|
+
// below, so hovering a response area while something is selected gets the exact same
|
|
236
|
+
// treatment as hovering it during a real drag — one code path, no duplicated CSS.
|
|
237
|
+
const [isHovered, setIsHovered] = (0, _react.useState)(false);
|
|
238
|
+
const hasSelection = !!selectedAnswer;
|
|
239
|
+
const showsHoverEffect = isOver || hasSelection && isHovered && !disabled;
|
|
240
|
+
const isSelected = !!selectedAnswer && selectedAnswer.type === activeData.type && selectedAnswer.id === activeData.id && selectedAnswer.promptId === activeData.promptId;
|
|
241
|
+
|
|
218
242
|
// compute style: apply transform to the element that actually moves
|
|
219
243
|
const transformStyle = transform ? `translate3d(${transform.x}px, ${transform.y}px, 0)` : undefined;
|
|
220
244
|
|
|
221
245
|
// If this item is a drop-zone (prompt slot), we render an outer droppable wrapper.
|
|
222
|
-
//
|
|
246
|
+
// The outer wrapper's rect is what dnd-kit measures for this slot's own droppable
|
|
247
|
+
// ("drop-{promptId}"), so it must stay untransformed — applying the drag transform
|
|
248
|
+
// there would make the slot's own droppable rect chase the dragged item during the
|
|
249
|
+
// drag, corrupting collision/keyboard-navigation results. The transform belongs on
|
|
250
|
+
// the inner draggable node instead.
|
|
223
251
|
if (dropId) {
|
|
252
|
+
const handleResponseAreaClick = () => {
|
|
253
|
+
if (disabled) return;
|
|
254
|
+
if (isSelected) {
|
|
255
|
+
// Clicking the already-selected placed answer again deselects it, same as
|
|
256
|
+
// for a choice in the pool.
|
|
257
|
+
onSelectClick?.(activeData);
|
|
258
|
+
} else if (selectedAnswer) {
|
|
259
|
+
// Something else is selected — place it here, same whether this area is
|
|
260
|
+
// currently empty or already occupied.
|
|
261
|
+
onPlacementClick?.(dropZoneData);
|
|
262
|
+
} else if (draggable) {
|
|
263
|
+
// Nothing selected yet, and this response area holds an answer — clicking it
|
|
264
|
+
// selects that answer for moving elsewhere, the same way Tab+Space/Enter does.
|
|
265
|
+
onSelectClick?.(activeData);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Empty response area clicked with nothing selected: nothing to place or select.
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
// An empty response area isn't draggable, so dnd-kit's own attributes (only
|
|
272
|
+
// applied to the inner node, and only when draggable) never make it tabbable —
|
|
273
|
+
// this outer wrapper needs its own focus/activation handling so "select a choice,
|
|
274
|
+
// then Tab to a response area and press Space/Enter" works even when the area is
|
|
275
|
+
// empty. This is independent of, and doesn't change, the existing in-drag
|
|
276
|
+
// Tab-cycling (that's driven by an active dnd-kit drag, not native focus).
|
|
277
|
+
//
|
|
278
|
+
// Only made a native Tab stop when NOT draggable (i.e. empty): when the target is
|
|
279
|
+
// filled, the inner node is already independently tabbable via dnd-kit's own
|
|
280
|
+
// attributes for the existing pick-up-to-move gesture, and adding a second,
|
|
281
|
+
// outer Tab stop for the same visual tile would add an extra stop to the existing
|
|
282
|
+
// Tab order. Placing into an occupied area is still fully reachable by mouse click
|
|
283
|
+
// here, or by the existing keyboard drag flow (Tab+Space/Enter on the choice,
|
|
284
|
+
// Tab-cycle to the occupied target, Space/Enter to swap).
|
|
285
|
+
const isNativeTabStop = !draggable && !disabled;
|
|
286
|
+
const handleResponseAreaKeyDown = e => {
|
|
287
|
+
if (e.code === 'Space' || e.code === 'Enter') {
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
handleResponseAreaClick();
|
|
290
|
+
}
|
|
291
|
+
};
|
|
224
292
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
225
293
|
ref: setDropRef,
|
|
294
|
+
role: "button",
|
|
295
|
+
tabIndex: isNativeTabStop ? 0 : -1,
|
|
296
|
+
onClick: handleResponseAreaClick,
|
|
297
|
+
onKeyDown: isNativeTabStop ? handleResponseAreaKeyDown : undefined,
|
|
298
|
+
onMouseEnter: () => setIsHovered(true),
|
|
299
|
+
onMouseLeave: () => setIsHovered(false),
|
|
226
300
|
style: {
|
|
227
301
|
flex: 1,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
backgroundColor: isOver ? 'rgba(0,0,0,0.05)' : 'transparent'
|
|
302
|
+
opacity: isDragging || isSelected ? 0.5 : 1,
|
|
303
|
+
backgroundColor: isDragging || isSelected || showsHoverEffect ? 'rgba(0,0,0,0.05)' : 'transparent',
|
|
304
|
+
cursor: hasSelection && !disabled ? 'pointer' : undefined
|
|
232
305
|
}
|
|
233
306
|
}, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
234
307
|
ref: setDragRef
|
|
235
|
-
}, listeners, attributes
|
|
308
|
+
}, listeners, attributes, {
|
|
309
|
+
style: {
|
|
310
|
+
transform: transformStyle,
|
|
311
|
+
transition
|
|
312
|
+
}
|
|
313
|
+
}), /*#__PURE__*/_react.default.createElement(Answer, (0, _extends2.default)({}, props, {
|
|
236
314
|
isDragging: isDragging,
|
|
237
|
-
|
|
315
|
+
isSelected: isSelected,
|
|
316
|
+
isOver: showsHoverEffect
|
|
238
317
|
}))));
|
|
239
318
|
}
|
|
319
|
+
const handleChoiceClick = e => {
|
|
320
|
+
if (disabled) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
e.stopPropagation();
|
|
324
|
+
onSelectClick?.(activeData);
|
|
325
|
+
};
|
|
240
326
|
|
|
241
327
|
// if there is NO dropId (this is a choice / draggable-only), render only draggable node and apply transform to it.
|
|
242
328
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
243
329
|
ref: setDragRef
|
|
244
330
|
}, listeners, attributes, {
|
|
331
|
+
onClick: handleChoiceClick,
|
|
245
332
|
style: {
|
|
246
333
|
transform: transformStyle,
|
|
247
334
|
transition,
|
|
248
335
|
cursor: disabled ? 'not-allowed' : 'grab',
|
|
249
|
-
opacity: isDragging ? 0.5 : 1,
|
|
336
|
+
opacity: isDragging || isSelected ? 0.5 : 1,
|
|
250
337
|
touchAction: draggable && !disabled ? 'none' : 'auto'
|
|
251
338
|
}
|
|
252
339
|
}), /*#__PURE__*/_react.default.createElement(Answer, (0, _extends2.default)({}, props, {
|
|
253
340
|
isDragging: isDragging,
|
|
341
|
+
isSelected: isSelected,
|
|
254
342
|
isOver: false
|
|
255
343
|
})));
|
|
256
344
|
}
|
|
@@ -261,7 +349,10 @@ DragAndDropAnswer.propTypes = {
|
|
|
261
349
|
title: _propTypes.default.string,
|
|
262
350
|
draggable: _propTypes.default.bool,
|
|
263
351
|
disabled: _propTypes.default.bool,
|
|
264
|
-
type: _propTypes.default.string
|
|
352
|
+
type: _propTypes.default.string,
|
|
353
|
+
selectedAnswer: _propTypes.default.object,
|
|
354
|
+
onSelectClick: _propTypes.default.func,
|
|
355
|
+
onPlacementClick: _propTypes.default.func
|
|
265
356
|
};
|
|
266
357
|
var _default = exports.default = DragAndDropAnswer;
|
|
267
358
|
//# sourceMappingURL=answer.js.map
|
package/lib/answer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answer.js","names":["_core","require","_propTypes","_interopRequireDefault","_react","_debug","_styles","_drag","_lodashEs","_renderUi","log","debug","HolderNumber","styled","theme","width","fontSize","textAlign","color","palette","common","black","Holder","index","isOver","disabled","type","default","createElement","PlaceHolder","extraStyles","display","padding","alignItems","justifyContent","height","undefined","propTypes","PropTypes","number","bool","string","AnswerContentContainer","isDragging","outcome","text","backgroundColor","white","border","correct","incorrect","grey","cursor","boxSizing","overflow","transition","wordBreak","opacity","touchAction","AnswerContent","props","title","empty","guideIndex","dangerouslySetInnerHTML","__html","AnswerContainer","minHeight","minWidth","margin","spacing","Answer","React","Component","constructor","args","_defineProperty2","e","componentDidMount","ref","addEventListener","handleTouchStart","passive","componentWillUnmount","removeEventListener","render","id","className","isEmpty","exports","any","DragAndDropAnswer","instanceId","promptId","draggable","dragId","dropId","attributes","listeners","setNodeRef","setDragRef","transform","useDraggable","data","value","droppable","useDroppable","setDropRef","transformStyle","x","y","style","flex","_extends2","_default"],"sources":["../src/answer.jsx"],"sourcesContent":["import { useDraggable, useDroppable } from '@dnd-kit/core';\nimport PropTypes from 'prop-types';\nimport React from 'react';\nimport debug from 'debug';\nimport { styled } from '@mui/material/styles';\nimport { PlaceHolder } from '@pie-lib/drag';\nimport { isEmpty } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nconst log = debug('pie-elements:match-title:answer');\n\nconst HolderNumber = styled('div')(({ theme }) => ({\n width: '100%',\n fontSize: '18px',\n textAlign: 'center',\n color: `rgba(${theme.palette.common.black}, 0.6)`,\n}));\n\nconst Holder = ({ index, isOver, disabled, type }) => (\n <PlaceHolder\n extraStyles={{\n display: 'flex',\n padding: '0',\n alignItems: 'center',\n justifyContent: 'center',\n height: '40px',\n }}\n disabled={disabled}\n isOver={isOver}\n type={type}\n >\n {index !== undefined && <HolderNumber>{index}</HolderNumber>}\n </PlaceHolder>\n);\n\nHolder.propTypes = {\n index: PropTypes.number,\n isOver: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n};\n\nconst AnswerContentContainer = styled('div')(({ theme, isDragging, isOver, disabled, outcome }) => ({\n color: color.text(),\n backgroundColor: color.white(),\n border: `1px solid ${outcome === 'correct' ? color.correct() :\n outcome === 'incorrect' ? color.incorrect() :\n theme.palette.grey[400]\n }`,\n cursor: disabled ? 'not-allowed' : 'pointer',\n width: '100%',\n padding: '10px',\n boxSizing: 'border-box',\n overflow: 'hidden',\n transition: 'opacity 200ms linear',\n wordBreak: 'break-word',\n opacity: isDragging && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,\n touchAction: 'none'\n}));\n\nconst AnswerContent = (props) => {\n const { isDragging, isOver, title, disabled, empty, outcome, guideIndex, type } = props;\n\n if (empty) {\n return <Holder\n index={guideIndex}\n isOver={isOver}\n disabled={disabled}\n type={type}\n\n />;\n } else {\n return (\n <AnswerContentContainer\n isDragging={isDragging}\n isOver={isOver}\n disabled={disabled}\n outcome={outcome}\n dangerouslySetInnerHTML={{ __html: title }}\n />\n );\n }\n};\n\nconst AnswerContainer = styled('div')(({ correct, theme }) => ({\n boxSizing: 'border-box',\n minHeight: 40,\n minWidth: '200px',\n overflow: 'hidden',\n margin: theme.spacing(0.5),\n padding: '0px',\n textAlign: 'center',\n height: 'initial',\n border: correct === true ? `1px solid var(--feedback-correct-bg-color, ${color.correct()})` :\n correct === false ? `1px solid var(--feedback-incorrect-bg-color, ${color.incorrect()})` :\n 'none',\n}));\n\nexport class Answer extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n isDragging: PropTypes.bool,\n id: PropTypes.any,\n title: PropTypes.string,\n isOver: PropTypes.bool,\n empty: PropTypes.bool,\n type: PropTypes.string,\n disabled: PropTypes.bool,\n correct: PropTypes.bool,\n };\n\n componentDidMount() {\n if (this.ref) {\n // NOTE: preventing default on touchstart can block dnd-kit pointer handling on some devices.\n // Consider removing this if you have issues on touch devices.\n this.ref.addEventListener('touchstart', this.handleTouchStart, { passive: true });\n }\n }\n\n componentWillUnmount() {\n if (this.ref) {\n this.ref.removeEventListener('touchstart', this.handleTouchStart);\n }\n }\n\n handleTouchStart = (e) => {\n // do NOT call e.preventDefault() here — it prevents pointer events necessary for dnd-kit.\n // Keep this handler empty or remove it if you don't need it.\n // e.preventDefault();\n };\n\n render() {\n const {\n id,\n title,\n isDragging = false,\n className,\n disabled,\n isOver = false,\n type,\n correct,\n } = this.props;\n\n log('[render], props: ', this.props);\n\n return (\n <AnswerContainer correct={correct} className={className} ref={(ref) => (this.ref = ref)}>\n <AnswerContent\n title={title}\n id={id}\n isOver={isOver}\n empty={isEmpty(title)}\n isDragging={isDragging}\n disabled={disabled}\n type={type}\n />\n </AnswerContainer>\n );\n }\n}\n\nfunction DragAndDropAnswer(props) {\n const { id, instanceId, promptId, draggable = true, disabled = false, type } = props;\n\n const dragId = `${type || 'answer'}-${id}`;\n // droppable only if promptId exists\n const dropId = promptId !== undefined && promptId !== null ? `drop-${promptId}` : undefined;\n\n const {\n attributes,\n listeners,\n setNodeRef: setDragRef,\n transform,\n transition,\n isDragging,\n } = useDraggable({\n id: dragId,\n data: {\n type: type || 'answer',\n id,\n instanceId,\n value: props.title,\n promptId,\n },\n disabled: !draggable || disabled,\n });\n\n const droppable = useDroppable({\n id: dropId,\n data: dropId ? { type: 'drop-zone', promptId, instanceId } : undefined,\n disabled: disabled || !dropId,\n });\n\n const setDropRef = droppable.setNodeRef;\n const isOver = droppable.isOver;\n\n // compute style: apply transform to the element that actually moves\n const transformStyle = transform\n ? `translate3d(${transform.x}px, ${transform.y}px, 0)`\n : undefined;\n\n // If this item is a drop-zone (prompt slot), we render an outer droppable wrapper.\n // For droppable wrapper we apply style to the outer wrapper\n if (dropId) {\n return (\n <div\n ref={setDropRef}\n style={{\n flex: 1,\n transform: transformStyle,\n transition,\n opacity: isDragging ? 0.5 : 1,\n backgroundColor: isOver ? 'rgba(0,0,0,0.05)' : 'transparent',\n }}\n >\n <div ref={setDragRef} {...listeners} {...attributes}>\n <Answer {...props} isDragging={isDragging} isOver={isOver} />\n </div>\n </div>\n );\n }\n\n // if there is NO dropId (this is a choice / draggable-only), render only draggable node and apply transform to it.\n return (\n <div\n ref={setDragRef}\n {...listeners}\n {...attributes}\n style={{\n transform: transformStyle,\n transition,\n cursor: disabled ? 'not-allowed' : 'grab',\n opacity: isDragging ? 0.5 : 1,\n touchAction: draggable && !disabled ? 'none' : 'auto',\n }}\n >\n <Answer {...props} isDragging={isDragging} isOver={false} />\n </div>\n );\n}\n\nDragAndDropAnswer.propTypes = {\n id: PropTypes.any,\n instanceId: PropTypes.string,\n promptId: PropTypes.any,\n title: PropTypes.string,\n draggable: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n};\n\nexport default DragAndDropAnswer;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,S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,kBAAS,CAACG,MAAM;EAC5BoD,QAAQ,EAAEvD,kBAAS,CAACoD,GAAG;EACvB7B,KAAK,EAAEvB,kBAAS,CAACG,MAAM;EACvBqD,SAAS,EAAExD,kBAAS,CAACE,IAAI;EACzBf,QAAQ,EAAEa,kBAAS,CAACE,IAAI;EACxBd,IAAI,EAAEY,kBAAS,CAACG;AAClB,CAAC;AAAC,IAAAyE,QAAA,GAAAzB,OAAA,CAAA9D,OAAA,GAEagE,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"answer.js","names":["_core","require","_propTypes","_interopRequireDefault","_react","_interopRequireWildcard","_debug","_styles","_drag","_lodashEs","_renderUi","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","log","debug","HolderNumber","styled","theme","width","fontSize","textAlign","color","palette","common","black","Holder","index","isOver","disabled","type","createElement","PlaceHolder","extraStyles","display","padding","alignItems","justifyContent","height","undefined","propTypes","PropTypes","number","bool","string","AnswerContentContainer","isDragging","isSelected","outcome","text","backgroundColor","white","border","correct","incorrect","cursor","boxSizing","overflow","transition","wordBreak","opacity","touchAction","AnswerContent","props","title","empty","guideIndex","dangerouslySetInnerHTML","__html","AnswerContainer","minHeight","minWidth","margin","spacing","Answer","React","Component","constructor","args","_defineProperty2","componentDidMount","ref","addEventListener","handleTouchStart","passive","componentWillUnmount","removeEventListener","render","id","className","isEmpty","exports","any","DragAndDropAnswer","instanceId","promptId","draggable","selectedAnswer","onSelectClick","onPlacementClick","dragId","dropId","activeData","value","dropZoneData","attributes","listeners","setNodeRef","setDragRef","transform","useDraggable","data","droppable","useDroppable","setDropRef","isHovered","setIsHovered","useState","hasSelection","showsHoverEffect","transformStyle","x","y","handleResponseAreaClick","isNativeTabStop","handleResponseAreaKeyDown","code","preventDefault","role","tabIndex","onClick","onKeyDown","onMouseEnter","onMouseLeave","style","flex","_extends2","handleChoiceClick","stopPropagation","object","func","_default"],"sources":["../src/answer.jsx"],"sourcesContent":["import { useDraggable, useDroppable } from '@dnd-kit/core';\nimport PropTypes from 'prop-types';\nimport React, { useState } from 'react';\nimport debug from 'debug';\nimport { styled } from '@mui/material/styles';\nimport { PlaceHolder } from '@pie-lib/drag';\nimport { isEmpty } from 'lodash-es';\nimport { color } from '@pie-lib/render-ui';\n\nconst log = debug('pie-elements:match-title:answer');\n\nconst HolderNumber = styled('div')(({ theme }) => ({\n width: '100%',\n fontSize: '18px',\n textAlign: 'center',\n color: `rgba(${theme.palette.common.black}, 0.6)`,\n}));\n\nconst Holder = ({ index, isOver, disabled, type }) => (\n <PlaceHolder\n extraStyles={{\n display: 'flex',\n padding: '0',\n alignItems: 'center',\n justifyContent: 'center',\n height: '40px',\n }}\n disabled={disabled}\n isOver={isOver}\n type={type}\n >\n {index !== undefined && <HolderNumber>{index}</HolderNumber>}\n </PlaceHolder>\n);\n\nHolder.propTypes = {\n index: PropTypes.number,\n isOver: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n};\n\nconst AnswerContentContainer = styled('div')(({ isDragging, isSelected, isOver, disabled, outcome }) => ({\n color: color.text(),\n backgroundColor: color.white(),\n border: `1px solid ${\n outcome === 'correct' ? color.correct() : outcome === 'incorrect' ? color.incorrect() : color.border()\n }`,\n cursor: disabled ? 'not-allowed' : 'pointer',\n width: '100%',\n padding: '10px',\n boxSizing: 'border-box',\n overflow: 'hidden',\n transition: 'opacity 200ms linear',\n wordBreak: 'break-word',\n opacity: (isDragging || isSelected) && !disabled ? 0.5 : isOver && !disabled ? 0.2 : 1,\n touchAction: 'none',\n}));\n\nconst AnswerContent = (props) => {\n const { isDragging, isSelected, isOver, title, disabled, empty, outcome, guideIndex, type } = props;\n\n if (empty) {\n return <Holder index={guideIndex} isOver={isOver} disabled={disabled} type={type} />;\n } else {\n return (\n <AnswerContentContainer\n isDragging={isDragging}\n isSelected={isSelected}\n isOver={isOver}\n disabled={disabled}\n outcome={outcome}\n dangerouslySetInnerHTML={{ __html: title }}\n />\n );\n }\n};\n\nconst AnswerContainer = styled('div')(({ correct, theme }) => ({\n boxSizing: 'border-box',\n minHeight: 40,\n minWidth: '200px',\n overflow: 'hidden',\n margin: theme.spacing(0.5),\n padding: '0px',\n textAlign: 'center',\n height: 'initial',\n border:\n correct === true\n ? `1px solid var(--feedback-correct-bg-color, ${color.correct()})`\n : correct === false\n ? `1px solid var(--feedback-incorrect-bg-color, ${color.incorrect()})`\n : 'none',\n}));\n\nexport class Answer extends React.Component {\n static propTypes = {\n className: PropTypes.string,\n isDragging: PropTypes.bool,\n isSelected: PropTypes.bool,\n id: PropTypes.any,\n title: PropTypes.string,\n isOver: PropTypes.bool,\n empty: PropTypes.bool,\n type: PropTypes.string,\n disabled: PropTypes.bool,\n correct: PropTypes.bool,\n };\n\n componentDidMount() {\n if (this.ref) {\n // NOTE: preventing default on touchstart can block dnd-kit pointer handling on some devices.\n // Consider removing this if you have issues on touch devices.\n this.ref.addEventListener('touchstart', this.handleTouchStart, { passive: true });\n }\n }\n\n componentWillUnmount() {\n if (this.ref) {\n this.ref.removeEventListener('touchstart', this.handleTouchStart);\n }\n }\n\n handleTouchStart = (e) => {\n // do NOT call e.preventDefault() here — it prevents pointer events necessary for dnd-kit.\n // Keep this handler empty or remove it if you don't need it.\n // e.preventDefault();\n };\n\n render() {\n const {\n id,\n title,\n isDragging = false,\n isSelected = false,\n className,\n disabled,\n isOver = false,\n type,\n correct,\n } = this.props;\n\n log('[render], props: ', this.props);\n\n return (\n <AnswerContainer correct={correct} className={className} ref={(ref) => (this.ref = ref)}>\n <AnswerContent\n title={title}\n id={id}\n isOver={isOver}\n empty={isEmpty(title)}\n isDragging={isDragging}\n isSelected={isSelected}\n disabled={disabled}\n type={type}\n />\n </AnswerContainer>\n );\n }\n}\n\nfunction DragAndDropAnswer(props) {\n const {\n id,\n instanceId,\n promptId,\n draggable = true,\n disabled = false,\n type,\n selectedAnswer,\n onSelectClick,\n onPlacementClick,\n } = props;\n\n const dragId = `${type || 'answer'}-${id}`;\n // droppable only if promptId exists\n const dropId = promptId !== undefined && promptId !== null ? `drop-${promptId}` : undefined;\n\n // Built once and reused for both dnd-kit's own data and the click handlers below, so\n // a click carries exactly the same shape dnd-kit's onDragStart/onDragEnd would.\n const activeData = {\n type: type || 'answer',\n id,\n instanceId,\n value: props.title,\n promptId,\n };\n const dropZoneData = dropId\n ? {\n type: 'drop-zone',\n promptId,\n instanceId,\n }\n : undefined;\n\n const {\n attributes,\n listeners,\n setNodeRef: setDragRef,\n transform,\n transition,\n isDragging,\n } = useDraggable({\n id: dragId,\n data: activeData,\n disabled: !draggable || disabled,\n });\n\n const droppable = useDroppable({\n id: dropId,\n data: dropZoneData,\n disabled: disabled || !dropId,\n });\n\n const setDropRef = droppable.setNodeRef;\n const isOver = droppable.isOver;\n\n // dnd-kit's own isOver only reflects real collision detection during an active drag,\n // so it stays false while an answer is merely click-selected (no drag in progress).\n // Track hovering locally and fold it into the same isOver signal used everywhere\n // below, so hovering a response area while something is selected gets the exact same\n // treatment as hovering it during a real drag — one code path, no duplicated CSS.\n const [isHovered, setIsHovered] = useState(false);\n const hasSelection = !!selectedAnswer;\n const showsHoverEffect = isOver || (hasSelection && isHovered && !disabled);\n\n const isSelected =\n !!selectedAnswer &&\n selectedAnswer.type === activeData.type &&\n selectedAnswer.id === activeData.id &&\n selectedAnswer.promptId === activeData.promptId;\n\n // compute style: apply transform to the element that actually moves\n const transformStyle = transform ? `translate3d(${transform.x}px, ${transform.y}px, 0)` : undefined;\n\n // If this item is a drop-zone (prompt slot), we render an outer droppable wrapper.\n // The outer wrapper's rect is what dnd-kit measures for this slot's own droppable\n // (\"drop-{promptId}\"), so it must stay untransformed — applying the drag transform\n // there would make the slot's own droppable rect chase the dragged item during the\n // drag, corrupting collision/keyboard-navigation results. The transform belongs on\n // the inner draggable node instead.\n if (dropId) {\n const handleResponseAreaClick = () => {\n if (disabled) return;\n\n if (isSelected) {\n // Clicking the already-selected placed answer again deselects it, same as\n // for a choice in the pool.\n onSelectClick?.(activeData);\n } else if (selectedAnswer) {\n // Something else is selected — place it here, same whether this area is\n // currently empty or already occupied.\n onPlacementClick?.(dropZoneData);\n } else if (draggable) {\n // Nothing selected yet, and this response area holds an answer — clicking it\n // selects that answer for moving elsewhere, the same way Tab+Space/Enter does.\n onSelectClick?.(activeData);\n }\n\n // Empty response area clicked with nothing selected: nothing to place or select.\n };\n\n // An empty response area isn't draggable, so dnd-kit's own attributes (only\n // applied to the inner node, and only when draggable) never make it tabbable —\n // this outer wrapper needs its own focus/activation handling so \"select a choice,\n // then Tab to a response area and press Space/Enter\" works even when the area is\n // empty. This is independent of, and doesn't change, the existing in-drag\n // Tab-cycling (that's driven by an active dnd-kit drag, not native focus).\n //\n // Only made a native Tab stop when NOT draggable (i.e. empty): when the target is\n // filled, the inner node is already independently tabbable via dnd-kit's own\n // attributes for the existing pick-up-to-move gesture, and adding a second,\n // outer Tab stop for the same visual tile would add an extra stop to the existing\n // Tab order. Placing into an occupied area is still fully reachable by mouse click\n // here, or by the existing keyboard drag flow (Tab+Space/Enter on the choice,\n // Tab-cycle to the occupied target, Space/Enter to swap).\n const isNativeTabStop = !draggable && !disabled;\n\n const handleResponseAreaKeyDown = (e) => {\n if (e.code === 'Space' || e.code === 'Enter') {\n e.preventDefault();\n handleResponseAreaClick();\n }\n };\n\n return (\n <div\n ref={setDropRef}\n role=\"button\"\n tabIndex={isNativeTabStop ? 0 : -1}\n onClick={handleResponseAreaClick}\n onKeyDown={isNativeTabStop ? handleResponseAreaKeyDown : undefined}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n style={{\n flex: 1,\n opacity: isDragging || isSelected ? 0.5 : 1,\n backgroundColor: isDragging || isSelected || showsHoverEffect ? 'rgba(0,0,0,0.05)' : 'transparent',\n cursor: hasSelection && !disabled ? 'pointer' : undefined,\n }}\n >\n <div ref={setDragRef} {...listeners} {...attributes} style={{ transform: transformStyle, transition }}>\n <Answer {...props} isDragging={isDragging} isSelected={isSelected} isOver={showsHoverEffect} />\n </div>\n </div>\n );\n }\n\n const handleChoiceClick = (e) => {\n if (disabled) {\n return;\n }\n\n e.stopPropagation();\n onSelectClick?.(activeData);\n };\n\n // if there is NO dropId (this is a choice / draggable-only), render only draggable node and apply transform to it.\n return (\n <div\n ref={setDragRef}\n {...listeners}\n {...attributes}\n onClick={handleChoiceClick}\n style={{\n transform: transformStyle,\n transition,\n cursor: disabled ? 'not-allowed' : 'grab',\n opacity: isDragging || isSelected ? 0.5 : 1,\n touchAction: draggable && !disabled ? 'none' : 'auto',\n }}\n >\n <Answer {...props} isDragging={isDragging} isSelected={isSelected} isOver={false} />\n </div>\n );\n}\n\nDragAndDropAnswer.propTypes = {\n id: PropTypes.any,\n instanceId: PropTypes.string,\n promptId: PropTypes.any,\n title: PropTypes.string,\n draggable: PropTypes.bool,\n disabled: PropTypes.bool,\n type: PropTypes.string,\n selectedAnswer: PropTypes.object,\n onSelectClick: PropTypes.func,\n onPlacementClick: PropTypes.func,\n};\n\nexport default DragAndDropAnswer;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,SAAA,GAAAT,OAAA;AAA2C,SAAAI,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,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0B,aAAA,CAAC2C,MAAM,MAAA8D,SAAA,CAAAnI,OAAA,MAAK0D,KAAK;IAAEjB,UAAU,EAAEA,UAAW;IAACC,UAAU,EAAEA,UAAW;IAACnB,MAAM,EAAE;EAAM,EAAE,CAChF,CAAC;AAEV;AAEAiE,iBAAiB,CAACrD,SAAS,GAAG;EAC5BgD,EAAE,EAAE/C,kBAAS,CAACmD,GAAG;EACjBE,UAAU,EAAErD,kBAAS,CAACG,MAAM;EAC5BmD,QAAQ,EAAEtD,kBAAS,CAACmD,GAAG;EACvB5B,KAAK,EAAEvB,kBAAS,CAACG,MAAM;EACvBoD,SAAS,EAAEvD,kBAAS,CAACE,IAAI;EACzBd,QAAQ,EAAEY,kBAAS,CAACE,IAAI;EACxBb,IAAI,EAAEW,kBAAS,CAACG,MAAM;EACtBqD,cAAc,EAAExD,kBAAS,CAACkG,MAAM;EAChCzC,aAAa,EAAEzD,kBAAS,CAACmG,IAAI;EAC7BzC,gBAAgB,EAAE1D,kBAAS,CAACmG;AAC9B,CAAC;AAAC,IAAAC,QAAA,GAAAlD,OAAA,CAAAtF,OAAA,GAEawF,iBAAiB","ignoreList":[]}
|
package/lib/arrow.js
CHANGED
|
@@ -10,16 +10,19 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
|
|
12
12
|
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
13
14
|
const ArrowContainer = (0, _styles.styled)('div')({
|
|
14
15
|
display: 'inline-block',
|
|
15
16
|
position: 'relative',
|
|
16
17
|
width: '100%'
|
|
17
18
|
});
|
|
19
|
+
|
|
20
|
+
// A 1px rule joining a prompt to its answer: it is the connector, so it needs to
|
|
21
|
+
// stay perceivable on every scheme's surface.
|
|
18
22
|
const Line = (0, _styles.styled)('span')(({
|
|
19
|
-
theme,
|
|
20
23
|
isRight
|
|
21
24
|
}) => ({
|
|
22
|
-
backgroundColor:
|
|
25
|
+
backgroundColor: _renderUi.color.border(),
|
|
23
26
|
bottom: isRight ? 20 : 19,
|
|
24
27
|
content: '""',
|
|
25
28
|
display: 'block',
|
|
@@ -41,7 +44,9 @@ class Arrow extends _react.default.Component {
|
|
|
41
44
|
}, /*#__PURE__*/_react.default.createElement(_ArrowDropDown.default, {
|
|
42
45
|
style: {
|
|
43
46
|
transform: 'rotate(90deg)',
|
|
44
|
-
|
|
47
|
+
// Pairs with Line above: head and shaft are one connector and have to
|
|
48
|
+
// step together, or the arrow loses its point on a dark scheme.
|
|
49
|
+
color: _renderUi.color.border(),
|
|
45
50
|
fontSize: 40
|
|
46
51
|
}
|
|
47
52
|
}), /*#__PURE__*/_react.default.createElement(Line, {
|