@pie-element/drag-in-the-blank 10.2.0-beta.0 → 10.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,19 +3,84 @@
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
- # [10.2.0-beta.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.0...@pie-element/drag-in-the-blank@10.2.0-beta.0) (2026-08-07)
6
+ ## [10.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.2.0...@pie-element/drag-in-the-blank@10.2.1) (2026-08-26)
7
+
8
+ ### Bug Fixes
9
+
10
+ - PIE-518 ([f19ac71](https://github.com/pie-framework/pie-elements/commit/f19ac7145e5daf9dde0377ac6d634b44c9201973))
11
+
12
+ # [10.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.11...@pie-element/drag-in-the-blank@10.2.0) (2026-08-21)
13
+
14
+ ### Bug Fixes
15
+
16
+ - 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))
17
+ - read the prompt container by class, not by the id pie-lib removed PIE-927 ([aaaf6c2](https://github.com/pie-framework/pie-elements/commit/aaaf6c2f189de3b39f9de85969aeb2e50376c548))
18
+ - **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)
19
+
20
+ ### Features
21
+
22
+ - bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
23
+
24
+ ## [10.1.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.10...@pie-element/drag-in-the-blank@10.1.11) (2026-08-19)
25
+
26
+ ### Bug Fixes
27
+
28
+ - bump libs and shared modules PIE-681, PIE-708 ([08af8b5](https://github.com/pie-framework/pie-elements/commit/08af8b5802aecc8ee5454a1b6d60277d7ec94204))
29
+
30
+ ## [10.1.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.8...@pie-element/drag-in-the-blank@10.1.10) (2026-08-13)
31
+
32
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
33
+
34
+ ## [10.1.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.7...@pie-element/drag-in-the-blank@10.1.9) (2026-08-11)
35
+
36
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
37
+
38
+ ## [10.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.7...@pie-element/drag-in-the-blank@10.1.8) (2026-07-31)
39
+
40
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
41
+
42
+ ## [10.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.6...@pie-element/drag-in-the-blank@10.1.7) (2026-07-08)
7
43
 
8
44
  ### Bug Fixes
9
45
 
10
46
  - bump libs & shared modules PIE-706, PIE-702, PIE-679, PIE-698 ([5b1a8c4](https://github.com/pie-framework/pie-elements/commit/5b1a8c4c3eba2126fc43d78fd0187e7cd11d5424))
11
- - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
12
- - 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))
13
- - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
47
+
48
+ ## [10.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.5...@pie-element/drag-in-the-blank@10.1.6) (2026-07-02)
49
+
50
+ ### Bug Fixes
51
+
14
52
  - 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))
15
- - bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
53
+ - sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
54
+
55
+ ## [10.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.4...@pie-element/drag-in-the-blank@10.1.5) (2026-06-22)
56
+
57
+ ### Bug Fixes
58
+
59
+ - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
16
60
  - **drag-in-the-blank:** update onChoiceDone to pass latest value from editor PIE-701 ([40b5dc6](https://github.com/pie-framework/pie-elements/commit/40b5dc6dbdf659db2adcfdfb139c4dd4fa06a2f9))
17
61
  - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
18
- - sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
62
+
63
+ ## [10.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.3...@pie-element/drag-in-the-blank@10.1.4) (2026-06-17)
64
+
65
+ ### Bug Fixes
66
+
67
+ - 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))
68
+
69
+ ## [10.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.2...@pie-element/drag-in-the-blank@10.1.3) (2026-06-12)
70
+
71
+ ### Bug Fixes
72
+
73
+ - bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
74
+
75
+ ## [10.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.1...@pie-element/drag-in-the-blank@10.1.2) (2026-06-04)
76
+
77
+ ### Bug Fixes
78
+
79
+ - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
80
+
81
+ ## [10.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.0...@pie-element/drag-in-the-blank@10.1.1) (2026-05-21)
82
+
83
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank
19
84
 
20
85
  # [10.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank@10.1.0-next.1...@pie-element/drag-in-the-blank@10.1.0) (2026-05-21)
21
86
 
@@ -3,19 +3,81 @@
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
- # [9.2.0-beta.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.0...@pie-element/drag-in-the-blank-configure@9.2.0-beta.0) (2026-08-07)
6
+ ## [9.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.2.0...@pie-element/drag-in-the-blank-configure@9.2.1) (2026-08-26)
7
+
8
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
9
+
10
+ # [9.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.11...@pie-element/drag-in-the-blank-configure@9.2.0) (2026-08-21)
11
+
12
+ ### Bug Fixes
13
+
14
+ - 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))
15
+ - **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)
16
+
17
+ ### Features
18
+
19
+ - bump libs PIE-856, PIE-681, PIE-927 ([cb26d7a](https://github.com/pie-framework/pie-elements/commit/cb26d7afa6c99522533c321d5ff8ce3148a66e9e))
20
+
21
+ ## [9.1.11](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.10...@pie-element/drag-in-the-blank-configure@9.1.11) (2026-08-19)
22
+
23
+ ### Bug Fixes
24
+
25
+ - bump libs and shared modules PIE-681, PIE-708 ([08af8b5](https://github.com/pie-framework/pie-elements/commit/08af8b5802aecc8ee5454a1b6d60277d7ec94204))
26
+
27
+ ## [9.1.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.8...@pie-element/drag-in-the-blank-configure@9.1.10) (2026-08-13)
28
+
29
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
30
+
31
+ ## [9.1.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.7...@pie-element/drag-in-the-blank-configure@9.1.9) (2026-08-11)
32
+
33
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
34
+
35
+ ## [9.1.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.7...@pie-element/drag-in-the-blank-configure@9.1.8) (2026-07-31)
36
+
37
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
38
+
39
+ ## [9.1.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.6...@pie-element/drag-in-the-blank-configure@9.1.7) (2026-07-08)
7
40
 
8
41
  ### Bug Fixes
9
42
 
10
43
  - bump libs & shared modules PIE-706, PIE-702, PIE-679, PIE-698 ([5b1a8c4](https://github.com/pie-framework/pie-elements/commit/5b1a8c4c3eba2126fc43d78fd0187e7cd11d5424))
11
- - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
12
- - 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))
13
- - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
44
+
45
+ ## [9.1.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.5...@pie-element/drag-in-the-blank-configure@9.1.6) (2026-07-02)
46
+
47
+ ### Bug Fixes
48
+
14
49
  - 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))
15
- - bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
50
+ - sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
51
+
52
+ ## [9.1.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.4...@pie-element/drag-in-the-blank-configure@9.1.5) (2026-06-22)
53
+
54
+ ### Bug Fixes
55
+
56
+ - bump shared modules and libs PIE-674, PIE-662, PIE-705, PIE-674, PIE-963 ([78a3f64](https://github.com/pie-framework/pie-elements/commit/78a3f64652c9581c61bd4159f3210fc1e32d8bcf))
16
57
  - **drag-in-the-blank:** update onChoiceDone to pass latest value from editor PIE-701 ([40b5dc6](https://github.com/pie-framework/pie-elements/commit/40b5dc6dbdf659db2adcfdfb139c4dd4fa06a2f9))
17
58
  - handle webcomponent lifecycle on every element that misses it PIE-703 ([9d5923f](https://github.com/pie-framework/pie-elements/commit/9d5923f973f0471e1e8f69ad4309cfc63d980d93))
18
- - sync libs versions ([48b5be9](https://github.com/pie-framework/pie-elements/commit/48b5be9559eb5b5235ca05f51c5f0161032a7041))
59
+
60
+ ## [9.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.3...@pie-element/drag-in-the-blank-configure@9.1.4) (2026-06-17)
61
+
62
+ ### Bug Fixes
63
+
64
+ - 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))
65
+
66
+ ## [9.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.2...@pie-element/drag-in-the-blank-configure@9.1.3) (2026-06-12)
67
+
68
+ ### Bug Fixes
69
+
70
+ - bump shared modules and libsPIE-603, PIE-604, PIE-663, PIE-662, PIE-678 ([e61c7a7](https://github.com/pie-framework/pie-elements/commit/e61c7a7d23744586337dfbb17a18ebfc656c202f))
71
+
72
+ ## [9.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.1...@pie-element/drag-in-the-blank-configure@9.1.2) (2026-06-04)
73
+
74
+ ### Bug Fixes
75
+
76
+ - bump shared modules and libs PIE-600, PIE-602 ([ce99f6a](https://github.com/pie-framework/pie-elements/commit/ce99f6af50cb855b666a6df9340f9f5445fde4c4))
77
+
78
+ ## [9.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.0...@pie-element/drag-in-the-blank-configure@9.1.1) (2026-05-21)
79
+
80
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-configure
19
81
 
20
82
  # [9.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-configure@9.1.0-next.1...@pie-element/drag-in-the-blank-configure@9.1.0) (2026-05-21)
21
83
 
@@ -12,6 +12,7 @@ var _MoreVert = _interopRequireDefault(require("@mui/icons-material/MoreVert"));
12
12
  var _Delete = _interopRequireDefault(require("@mui/icons-material/Delete"));
13
13
  var _core = require("@dnd-kit/core");
14
14
  var _styles = require("@mui/material/styles");
15
+ var _renderUi = require("@pie-lib/render-ui");
15
16
  var _markupUtils = require("./markupUtils");
16
17
  const GripIcon = ({
17
18
  style
@@ -41,7 +42,7 @@ const StyledChoice = (0, _styles.styled)('div', {
41
42
  position: 'relative',
42
43
  padding: '8px 35px 8px 35px',
43
44
  cursor: 'grab',
44
- border: `1px solid ${error ? '#f44336' : '#C0C3CF'}`,
45
+ border: `1px solid ${error ? '#f44336' : _renderUi.color.border()}`,
45
46
  '& img': {
46
47
  display: 'flex'
47
48
  },
@@ -59,7 +60,7 @@ const StyledDeleteIcon = (0, _styles.styled)(_Delete.default)(({
59
60
  position: 'absolute',
60
61
  top: '6px',
61
62
  right: '0',
62
- color: theme.palette.grey[500],
63
+ color: _renderUi.color.text(),
63
64
  zIndex: 2,
64
65
  '&:hover': {
65
66
  cursor: 'pointer',
@@ -109,7 +110,7 @@ const BlankContent = props => {
109
110
  position: 'absolute',
110
111
  top: '6px',
111
112
  left: '15px',
112
- color: '#9e9e9e',
113
+ color: _renderUi.color.borderGray(),
113
114
  zIndex: 2
114
115
  }
115
116
  }), /*#__PURE__*/_react.default.createElement("span", {
@@ -1 +1 @@
1
- {"version":3,"file":"choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_MoreVert","_Delete","_core","_styles","_markupUtils","GripIcon","style","default","createElement","margin","propTypes","PropTypes","object","StyledChoice","styled","shouldForwardProp","prop","includes","theme","error","display","minWidth","minHeight","background","palette","common","white","boxSizing","borderRadius","overflow","position","padding","cursor","border","fontSize","StyledDeleteIcon","Delete","top","right","color","grey","zIndex","black","BlankContent","props","choice","onClick","onRemoveChoice","instanceId","disabled","attributes","listeners","setNodeRef","isDragging","useDraggable","id","data","type","value","choiceIsEmpty","handleDragStart","e","preventDefault","alert","_extends2","ref","onDragStart","left","dangerouslySetInnerHTML","__html","stopPropagation","exports","isRequired","func","bool","string","_default"],"sources":["../src/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport MoreVert from '@mui/icons-material/MoreVert';\nimport Delete from '@mui/icons-material/Delete';\nimport { useDraggable } from '@dnd-kit/core';\nimport { styled } from '@mui/material/styles';\nimport { choiceIsEmpty } from './markupUtils';\n\nconst GripIcon = ({ style }) => (\n <span style={style}>\n <MoreVert style={{ margin: '0 -16px' }} />\n <MoreVert />\n </span>\n);\n\nGripIcon.propTypes = {\n style: PropTypes.object,\n};\n\nconst StyledChoice = styled('div', {\n shouldForwardProp: (prop) => !['error', 'isDragging'].includes(prop),\n})(({ theme, error }) => ({\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n background: theme.palette.common.white,\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n position: 'relative',\n padding: '8px 35px 8px 35px',\n cursor: 'grab',\n border: `1px solid ${error ? '#f44336' : '#C0C3CF'}`,\n '& img': {\n display: 'flex',\n },\n // browser adds extra marrgin for p tags by default\n '& p': {\n margin: 0,\n },\n '& mjx-frac': {\n fontSize: '120% !important',\n },\n}));\n\nconst StyledDeleteIcon = styled(Delete)(({ theme }) => ({\n position: 'absolute',\n top: '6px',\n right: '0',\n color: theme.palette.grey[500],\n zIndex: 2,\n '&:hover': {\n cursor: 'pointer',\n color: theme.palette.common.black,\n },\n}));\n\nexport const BlankContent = (props) => {\n const { choice, onClick, onRemoveChoice, error, instanceId, disabled } = props;\n const { attributes, listeners, setNodeRef, isDragging } = useDraggable({\n id: `choice-${choice.id}-${instanceId || 'default'}`,\n data: {\n type: 'drag-in-the-blank-choice',\n id: choice.id,\n value: choice,\n instanceId: instanceId,\n },\n disabled: disabled || choiceIsEmpty(choice),\n });\n\n const handleDragStart = (e) => {\n if (choiceIsEmpty(choice)) {\n e.preventDefault();\n alert('You need to define a value for an answer choice before it can be associated with a response area.');\n return;\n }\n };\n\n return (\n <StyledChoice\n ref={setNodeRef}\n error={error}\n isDragging={isDragging}\n onClick={onClick}\n {...attributes}\n {...listeners}\n onDragStart={handleDragStart}\n >\n <GripIcon\n style={{\n position: 'absolute',\n top: '6px',\n left: '15px',\n color: '#9e9e9e',\n zIndex: 2,\n }}\n />\n\n <span dangerouslySetInnerHTML={{ __html: choice.value }} />\n\n <StyledDeleteIcon\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n\n onRemoveChoice(e);\n }}\n />\n </StyledChoice>\n );\n};\n\nBlankContent.propTypes = {\n choice: PropTypes.object.isRequired,\n onClick: PropTypes.func,\n onRemoveChoice: PropTypes.func.isRequired,\n error: PropTypes.bool,\n instanceId: PropTypes.string,\n disabled: PropTypes.bool,\n};\n\nexport default BlankContent;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAEA,MAAMO,QAAQ,GAAGA,CAAC;EAAEC;AAAM,CAAC,kBACzBV,MAAA,CAAAW,OAAA,CAAAC,aAAA;EAAMF,KAAK,EAAEA;AAAM,gBACjBV,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAACR,SAAA,CAAAO,OAAQ;EAACD,KAAK,EAAE;IAAEG,MAAM,EAAE;EAAU;AAAE,CAAE,CAAC,eAC1Cb,MAAA,CAAAW,OAAA,CAAAC,aAAA,CAACR,SAAA,CAAAO,OAAQ,MAAE,CACP,CACP;AAEDF,QAAQ,CAACK,SAAS,GAAG;EACnBJ,KAAK,EAAEK,kBAAS,CAACC;AACnB,CAAC;AAED,MAAMC,YAAY,GAAG,IAAAC,cAAM,EAAC,KAAK,EAAE;EACjCC,iBAAiB,EAAGC,IAAI,IAAK,CAAC,CAAC,OAAO,EAAE,YAAY,CAAC,CAACC,QAAQ,CAACD,IAAI;AACrE,CAAC,CAAC,CAAC,CAAC;EAAEE,KAAK;EAAEC;AAAM,CAAC,MAAM;EACxBC,OAAO,EAAE,aAAa;EACtBC,QAAQ,EAAE,OAAO;EACjBC,SAAS,EAAE,MAAM;EACjBC,UAAU,EAAEL,KAAK,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kBAAS,CAACC,MAAM,CAAC4D,UAAU;EACnC1B,OAAO,EAAEnC,kBAAS,CAAC8D,IAAI;EACvB1B,cAAc,EAAEpC,kBAAS,CAAC8D,IAAI,CAACD,UAAU;EACzCrD,KAAK,EAAER,kBAAS,CAAC+D,IAAI;EACrB1B,UAAU,EAAErC,kBAAS,CAACgE,MAAM;EAC5B1B,QAAQ,EAAEtC,kBAAS,CAAC+D;AACtB,CAAC;AAAC,IAAAE,QAAA,GAAAL,OAAA,CAAAhE,OAAA,GAEaoC,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_MoreVert","_Delete","_core","_styles","_renderUi","_markupUtils","GripIcon","style","default","createElement","margin","propTypes","PropTypes","object","StyledChoice","styled","shouldForwardProp","prop","includes","theme","error","display","minWidth","minHeight","background","palette","common","white","boxSizing","borderRadius","overflow","position","padding","cursor","border","color","fontSize","StyledDeleteIcon","Delete","top","right","text","zIndex","black","BlankContent","props","choice","onClick","onRemoveChoice","instanceId","disabled","attributes","listeners","setNodeRef","isDragging","useDraggable","id","data","type","value","choiceIsEmpty","handleDragStart","e","preventDefault","alert","_extends2","ref","onDragStart","left","borderGray","dangerouslySetInnerHTML","__html","stopPropagation","exports","isRequired","func","bool","string","_default"],"sources":["../src/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport MoreVert from '@mui/icons-material/MoreVert';\nimport Delete from '@mui/icons-material/Delete';\nimport { useDraggable } from '@dnd-kit/core';\nimport { styled } from '@mui/material/styles';\nimport { color } from '@pie-lib/render-ui';\nimport { choiceIsEmpty } from './markupUtils';\n\nconst GripIcon = ({ style }) => (\n <span style={style}>\n <MoreVert style={{ margin: '0 -16px' }} />\n <MoreVert />\n </span>\n);\n\nGripIcon.propTypes = {\n style: PropTypes.object,\n};\n\nconst StyledChoice = styled('div', {\n shouldForwardProp: (prop) => !['error', 'isDragging'].includes(prop),\n})(({ theme, error }) => ({\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n background: theme.palette.common.white,\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n position: 'relative',\n padding: '8px 35px 8px 35px',\n cursor: 'grab',\n border: `1px solid ${error ? '#f44336' : color.border()}`,\n '& img': {\n display: 'flex',\n },\n // browser adds extra marrgin for p tags by default\n '& p': {\n margin: 0,\n },\n '& mjx-frac': {\n fontSize: '120% !important',\n },\n}));\n\nconst StyledDeleteIcon = styled(Delete)(({ theme }) => ({\n position: 'absolute',\n top: '6px',\n right: '0',\n color: color.text(),\n zIndex: 2,\n '&:hover': {\n cursor: 'pointer',\n color: theme.palette.common.black,\n },\n}));\n\nexport const BlankContent = (props) => {\n const { choice, onClick, onRemoveChoice, error, instanceId, disabled } = props;\n const { attributes, listeners, setNodeRef, isDragging } = useDraggable({\n id: `choice-${choice.id}-${instanceId || 'default'}`,\n data: {\n type: 'drag-in-the-blank-choice',\n id: choice.id,\n value: choice,\n instanceId: instanceId,\n },\n disabled: disabled || choiceIsEmpty(choice),\n });\n\n const handleDragStart = (e) => {\n if (choiceIsEmpty(choice)) {\n e.preventDefault();\n alert('You need to define a value for an answer choice before it can be associated with a response area.');\n return;\n }\n };\n\n return (\n <StyledChoice\n ref={setNodeRef}\n error={error}\n isDragging={isDragging}\n onClick={onClick}\n {...attributes}\n {...listeners}\n onDragStart={handleDragStart}\n >\n <GripIcon\n style={{\n position: 'absolute',\n top: '6px',\n left: '15px',\n color: color.borderGray(),\n zIndex: 2,\n }}\n />\n\n <span dangerouslySetInnerHTML={{ __html: choice.value }} />\n\n <StyledDeleteIcon\n onClick={(e) => {\n e.preventDefault();\n e.stopPropagation();\n\n onRemoveChoice(e);\n }}\n />\n </StyledChoice>\n );\n};\n\nBlankContent.propTypes = {\n choice: PropTypes.object.isRequired,\n onClick: PropTypes.func,\n onRemoveChoice: PropTypes.func.isRequired,\n error: PropTypes.bool,\n instanceId: PropTypes.string,\n disabled: PropTypes.bool,\n};\n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,CAAC+D,IAAI,CAACD,UAAU;EACzCtD,KAAK,EAAER,kBAAS,CAACgE,IAAI;EACrB3B,UAAU,EAAErC,kBAAS,CAACiE,MAAM;EAC5B3B,QAAQ,EAAEtC,kBAAS,CAACgE;AACtB,CAAC;AAAC,IAAAE,QAAA,GAAAL,OAAA,CAAAjE,OAAA,GAEaoC,YAAY","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/drag-in-the-blank-configure",
3
- "version": "9.2.0-beta.0",
3
+ "version": "9.2.1",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -12,9 +12,9 @@
12
12
  "@mui/icons-material": "^7.3.4",
13
13
  "@mui/material": "^7.3.4",
14
14
  "@pie-framework/pie-configure-events": "^1.3.0",
15
- "@pie-lib/config-ui": "13.1.0-beta",
16
- "@pie-lib/drag": "4.0.6",
17
- "@pie-lib/editable-html-tip-tap": "2.2.0-beta",
15
+ "@pie-lib/config-ui": "13.0.17",
16
+ "@pie-lib/drag": "4.1.2",
17
+ "@pie-lib/editable-html-tip-tap": "2.1.15",
18
18
  "@pie-lib/math-rendering": "5.1.0",
19
19
  "debug": "^4.1.1",
20
20
  "lodash-es": "^4.17.23",
@@ -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
- # [9.2.0-beta.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-controller@9.1.0...@pie-element/drag-in-the-blank-controller@9.2.0-beta.0) (2026-08-07)
6
+ ## [9.1.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-controller@9.1.2...@pie-element/drag-in-the-blank-controller@9.1.4) (2026-08-13)
7
+
8
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-controller
9
+
10
+ ## [9.1.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-controller@9.1.2...@pie-element/drag-in-the-blank-controller@9.1.3) (2026-08-11)
11
+
12
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-controller
13
+
14
+ ## [9.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-controller@9.1.1...@pie-element/drag-in-the-blank-controller@9.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
+ ## [9.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-controller@9.1.0...@pie-element/drag-in-the-blank-controller@9.1.1) (2026-05-21)
21
+
22
+ **Note:** Version bump only for package @pie-element/drag-in-the-blank-controller
23
+
12
24
  # [9.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/drag-in-the-blank-controller@9.1.0-next.1...@pie-element/drag-in-the-blank-controller@9.1.0) (2026-05-21)
13
25
 
14
26
  ### Bug Fixes
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/drag-in-the-blank-controller",
3
3
  "private": true,
4
- "version": "9.2.0-beta.0",
4
+ "version": "9.1.4",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
package/lib/index.js CHANGED
@@ -21,7 +21,7 @@ const isComplete = (session, model, audioComplete, elementContext) => {
21
21
  if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {
22
22
  if (elementContext) {
23
23
  const audio = elementContext.querySelector('audio');
24
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
24
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
25
25
 
26
26
  // only require audio completion if audio exists and is inside the prompt
27
27
  if (audio && isInsidePrompt) {
@@ -116,7 +116,7 @@ class DragInTheBlank extends HTMLElement {
116
116
  if (mutation.type === 'childList') {
117
117
  if (this._audioInitialized) return;
118
118
  const audio = this.querySelector('audio');
119
- const isInsidePrompt = audio && audio.closest('#preview-prompt');
119
+ const isInsidePrompt = audio && audio.closest('.preview-prompt');
120
120
  if (!this._model) return;
121
121
  if (!this._model.autoplayAudioEnabled) return;
122
122
  if (audio && !isInsidePrompt) return;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_main","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","responseAreasToBeFilled","audio","querySelector","isInsidePrompt","closest","value","filledResponseAreas","Object","values","filter","val","length","exports","DragInTheBlank","HTMLElement","constructor","_defineProperty2","default","_model","_session","elem","React","createElement","Main","onChange","changeSession","_root","createRoot","render","setTimeout","renderMath","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","selector","dispatchChangedEvent","_render","_audioInitialized","m","ModelSetEvent","s","_createAudioInfoToast","info","document","id","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","paused","addEventListener","handlePlaying","audioStartTime","Date","getTime","handleEnded","audioEndTime","waitTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","disconnectedCallback","unmount"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport Main from './main';\n\nexport const isComplete = (session, model, audioComplete, elementContext) => {\n const { autoplayAudioEnabled, completeAudioEnabled, responseAreasToBeFilled } = model || {};\n\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const filledResponseAreas = Object.values(session.value || {}).filter((val) => !!val).length;\n\n return filledResponseAreas >= responseAreasToBeFilled;\n};\n\nexport default class DragInTheBlank extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._audioInitialized = false;\n this.audioComplete = false;\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n !!this._model,\n ),\n );\n // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio\n this._audioInitialized = false;\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n value: this._session.value,\n onChange: this.changeSession,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(elem);\n setTimeout(() => renderMath(this), 0);\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n ),\n );\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.session.selector = 'Mouse';\n\n this.dispatchChangedEvent();\n this._render();\n };\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._render();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('#preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n //timestamp when auto-played audio started playing\n this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n //timestamp when auto-played audio completed playing\n this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();\n\n let { audioStartTime, audioEndTime, waitTime } = this._session;\n if (!waitTime && audioStartTime && audioEndTime) {\n // waitTime is elapsed time the user waited for auto-played audio to finish\n this._session.waitTime = audioEndTime - audioStartTime;\n }\n\n this.audioComplete = true;\n this.dispatchChangedEvent();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEO,MAAMM,UAAU,GAAGA,CAACC,OAAO,EAAEC,KAAK,EAAEC,aAAa,EAAEC,cAAc,KAAK;EAC3E,MAAM;IAAEC,oBAAoB;IAAEC,oBAAoB;IAAEC;EAAwB,CAAC,GAAGL,KAAK,IAAI,CAAC,CAAC;EAE3F,IAAIG,oBAAoB,IAAIC,oBAAoB,IAAI,CAACH,aAAa,EAAE;IAClE,IAAIC,cAAc,EAAE;MAClB,MAAMI,KAAK,GAAGJ,cAAc,CAACK,aAAa,CAAC,OAAO,CAAC;MACnD,MAAMC,cAAc,GAAGF,KAAK,IAAIA,KAAK,CAACG,OAAO,CAAC,iBAAiB,CAAC;;MAEhE;MACA,IAAIH,KAAK,IAAIE,cAAc,EAAE;QAC3B,OAAO,KAAK;MACd;IACF;EACF;EAEA,IAAI,CAACT,OAAO,IAAI,CAACA,OAAO,CAACW,KAAK,EAAE;IAC9B,OAAO,KAAK;EACd;EAEA,MAAMC,mBAAmB,GA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,IAAI,CAACF,MAAM,GAAG,IAAI;IACpB;IAEA,IAAI,IAAI,CAAC1D,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACmE,OAAO,CAAC,CAAC;MACpB,IAAI,CAACnE,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAACd,OAAA,CAAAK,OAAA,GAAAJ,cAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_react","_interopRequireDefault","require","_client","_mathRendering","_renderUi","_piePlayerEvents","_main","isComplete","session","model","audioComplete","elementContext","autoplayAudioEnabled","completeAudioEnabled","responseAreasToBeFilled","audio","querySelector","isInsidePrompt","closest","value","filledResponseAreas","Object","values","filter","val","length","exports","DragInTheBlank","HTMLElement","constructor","_defineProperty2","default","_model","_session","elem","React","createElement","Main","onChange","changeSession","_root","createRoot","render","setTimeout","renderMath","dispatchEvent","SessionChangedEvent","tagName","toLowerCase","selector","dispatchChangedEvent","_render","_audioInitialized","m","ModelSetEvent","s","_createAudioInfoToast","info","document","id","assign","style","position","top","width","height","display","justifyContent","alignItems","background","zIndex","cursor","img","src","EnableAudioAutoplayImage","alt","appendChild","connectedCallback","observer","MutationObserver","mutationsList","forEach","mutation","type","container","enableAudio","play","removeChild","removeEventListener","paused","addEventListener","handlePlaying","audioStartTime","Date","getTime","handleEnded","audioEndTime","waitTime","_audio","_handlePlaying","_handleEnded","_enableAudio","disconnect","observe","childList","subtree","disconnectedCallback","unmount"],"sources":["../src/index.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { EnableAudioAutoplayImage } from '@pie-lib/render-ui';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport Main from './main';\n\nexport const isComplete = (session, model, audioComplete, elementContext) => {\n const { autoplayAudioEnabled, completeAudioEnabled, responseAreasToBeFilled } = model || {};\n\n if (autoplayAudioEnabled && completeAudioEnabled && !audioComplete) {\n if (elementContext) {\n const audio = elementContext.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('.preview-prompt');\n\n // only require audio completion if audio exists and is inside the prompt\n if (audio && isInsidePrompt) {\n return false;\n }\n }\n }\n\n if (!session || !session.value) {\n return false;\n }\n\n const filledResponseAreas = Object.values(session.value || {}).filter((val) => !!val).length;\n\n return filledResponseAreas >= responseAreasToBeFilled;\n};\n\nexport default class DragInTheBlank extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._audioInitialized = false;\n this.audioComplete = false;\n this._root = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n !!this._model,\n ),\n );\n // reset the audioInitialized to false since the model changed, and we might need to reinitialize the audio\n this._audioInitialized = false;\n this._render();\n }\n\n set session(s) {\n this._session = s;\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n _render = () => {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n value: this._session.value,\n onChange: this.changeSession,\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(elem);\n setTimeout(() => renderMath(this), 0);\n }\n };\n\n dispatchChangedEvent = () => {\n this.dispatchEvent(\n new SessionChangedEvent(\n this.tagName.toLowerCase(),\n isComplete(this._session, this._model, this.audioComplete, this),\n ),\n );\n };\n\n changeSession = (value) => {\n this.session.value = value;\n this.session.selector = 'Mouse';\n\n this.dispatchChangedEvent();\n this._render();\n };\n\n _createAudioInfoToast() {\n const info = document.createElement('div');\n info.id = 'play-audio-info';\n\n Object.assign(info.style, {\n position: 'absolute',\n top: 0,\n width: '100%',\n height: '100%',\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n background: 'white',\n zIndex: '1000',\n cursor: 'pointer',\n });\n\n const img = document.createElement('img');\n img.src = EnableAudioAutoplayImage;\n img.alt = 'Click anywhere to enable audio autoplay';\n img.width = 500;\n img.height = 300;\n\n info.appendChild(img);\n return info;\n }\n\n connectedCallback() {\n this._render();\n\n // Observation: audio in Chrome will have the autoplay attribute,\n // while other browsers will not have the autoplay attribute and will need a user interaction to play the audio\n // This workaround fixes the issue of audio being cached and played on any user interaction in Safari and Firefox\n const observer = new MutationObserver((mutationsList, observer) => {\n mutationsList.forEach((mutation) => {\n if (mutation.type === 'childList') {\n if (this._audioInitialized) return;\n const audio = this.querySelector('audio');\n const isInsidePrompt = audio && audio.closest('.preview-prompt');\n\n if (!this._model) return;\n if (!this._model.autoplayAudioEnabled) return;\n if (audio && !isInsidePrompt) return;\n if (!audio) return;\n\n const info = this._createAudioInfoToast();\n const container = this.querySelector('#main-container');\n const enableAudio = () => {\n if (this.querySelector('#play-audio-info')) {\n audio.play();\n container.removeChild(info);\n }\n\n document.removeEventListener('click', enableAudio);\n };\n\n // if the audio is paused, it means the user has not interacted with the page yet and the audio will not play\n // FIX FOR SAFARI: play with a slight delay to check if autoplay was blocked\n setTimeout(() => {\n if (audio.paused && !this.querySelector('#play-audio-info')) {\n // add info message as a toast to enable audio playback\n container.appendChild(info);\n document.addEventListener('click', enableAudio);\n } else {\n document.removeEventListener('click', enableAudio);\n }\n }, 500);\n\n // we need to listen for the playing event to remove the toast in case the audio plays because of re-rendering\n const handlePlaying = () => {\n //timestamp when auto-played audio started playing\n this._session.audioStartTime = this._session.audioStartTime || new Date().getTime();\n\n const info = this.querySelector('#play-audio-info');\n if (info) {\n container.removeChild(info);\n }\n\n audio.removeEventListener('playing', handlePlaying);\n };\n\n audio.addEventListener('playing', handlePlaying);\n\n // we need to listen for the ended event to update the isComplete state\n const handleEnded = () => {\n //timestamp when auto-played audio completed playing\n this._session.audioEndTime = this._session.audioEndTime || new Date().getTime();\n\n let { audioStartTime, audioEndTime, waitTime } = this._session;\n if (!waitTime && audioStartTime && audioEndTime) {\n // waitTime is elapsed time the user waited for auto-played audio to finish\n this._session.waitTime = audioEndTime - audioStartTime;\n }\n\n this.audioComplete = true;\n this.dispatchChangedEvent();\n audio.removeEventListener('ended', handleEnded);\n };\n\n audio.addEventListener('ended', handleEnded);\n\n // store references to remove later\n this._audio = audio;\n this._handlePlaying = handlePlaying;\n this._handleEnded = handleEnded;\n this._enableAudio = enableAudio;\n // set to true to prevent multiple initializations\n this._audioInitialized = true;\n\n observer.disconnect();\n }\n });\n });\n\n observer.observe(this, { childList: true, subtree: true });\n }\n\n disconnectedCallback() {\n document.removeEventListener('click', this._enableAudio);\n\n if (this._audio) {\n this._audio.removeEventListener('playing', this._handlePlaying);\n this._audio.removeEventListener('ended', this._handleEnded);\n this._audio = null;\n }\n\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEO,MAAMM,UAAU,GAAGA,CAACC,OAAO,EAAEC,KAAK,EAAEC,aAAa,EAAEC,cAAc,KAAK;EAC3E,MAAM;IAAEC,oBAAoB;IAAEC,oBAAoB;IAAEC;EAAwB,CAAC,GAAGL,KAAK,IAAI,CAAC,CAAC;EAE3F,IAAIG,oBAAoB,IAAIC,oBAAoB,IAAI,CAACH,aAAa,EAAE;IAClE,IAAIC,cAAc,EAAE;MAClB,MAAMI,KAAK,GAAGJ,cAAc,CAACK,aAAa,CAAC,OAAO,CAAC;MACnD,MAAMC,cAAc,GAAGF,KAAK,IAAIA,KAAK,CAACG,OAAO,CAAC,iBAAiB,CAAC;;MAEhE;MACA,IAAIH,KAAK,IAAIE,cAAc,EAAE;QAC3B,OAAO,KAAK;MACd;IACF;EACF;EAEA,IAAI,CAACT,OAAO,IAAI,CAACA,OAAO,CAACW,KAAK,EAAE;IAC9B,OAAO,KAAK;EACd;EAEA,MAAMC,mBAAmB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C3D,IAAI,CAACF,MAAM,GAAG,IAAI;IACpB;IAEA,IAAI,IAAI,CAAC1D,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACmE,OAAO,CAAC,CAAC;MACpB,IAAI,CAACnE,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAACd,OAAA,CAAAK,OAAA,GAAAJ,cAAA","ignoreList":[]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "10.2.0-beta.0",
7
+ "version": "10.2.1",
8
8
  "description": "",
9
9
  "scripts": {
10
10
  "postpublish": "../../scripts/postpublish"
@@ -15,11 +15,11 @@
15
15
  "@mui/icons-material": "^7.3.4",
16
16
  "@mui/material": "^7.3.4",
17
17
  "@pie-framework/pie-player-events": "^0.1.0",
18
- "@pie-lib/correct-answer-toggle": "4.0.5",
19
- "@pie-lib/drag": "4.0.6",
20
- "@pie-lib/mask-markup": "3.1.0-beta",
18
+ "@pie-lib/correct-answer-toggle": "4.0.7",
19
+ "@pie-lib/drag": "4.1.2",
20
+ "@pie-lib/mask-markup": "3.1.0",
21
21
  "@pie-lib/math-rendering": "5.1.0",
22
- "@pie-lib/render-ui": "6.1.3",
22
+ "@pie-lib/render-ui": "7.0.1",
23
23
  "lodash-es": "^4.17.23",
24
24
  "prop-types": "^15.8.1",
25
25
  "react": "18.3.1",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "author": "",
29
29
  "license": "ISC",
30
- "gitHead": "fe47b94dd1957aaae2617f391d9e29142fb11b82",
30
+ "gitHead": "5635523a84dd61f007275dcb853627b1ff0c6792",
31
31
  "main": "lib/index.js",
32
32
  "module": "src/index.js"
33
33
  }
@@ -1,114 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _react = _interopRequireDefault(require("react"));
5
- var _react2 = require("@testing-library/react");
6
- var _styles = require("@mui/material/styles");
7
- var _core = require("@dnd-kit/core");
8
- var _choice = require("../choice");
9
- // Mock @dnd-kit/core
10
- jest.mock('@dnd-kit/core', () => ({
11
- DndContext: ({
12
- children
13
- }) => /*#__PURE__*/_react.default.createElement("div", null, children),
14
- useDraggable: jest.fn(() => ({
15
- attributes: {},
16
- listeners: {},
17
- setNodeRef: jest.fn(),
18
- isDragging: false
19
- }))
20
- }));
21
- const theme = (0, _styles.createTheme)();
22
- describe('Choice', () => {
23
- let onClick;
24
- let onRemoveChoice;
25
- beforeEach(() => {
26
- onClick = jest.fn();
27
- onRemoveChoice = jest.fn();
28
- });
29
- const renderChoice = (extras = {}) => {
30
- const props = {
31
- key: '0',
32
- choice: {
33
- value: '<div>6</div>',
34
- id: '0'
35
- },
36
- onClick,
37
- onRemoveChoice,
38
- ...extras
39
- };
40
- return (0, _react2.render)(/*#__PURE__*/_react.default.createElement(_styles.ThemeProvider, {
41
- theme: theme
42
- }, /*#__PURE__*/_react.default.createElement(_core.DndContext, null, /*#__PURE__*/_react.default.createElement(_choice.BlankContent, props))));
43
- };
44
- describe('render', () => {
45
- it('renders without crashing', () => {
46
- const {
47
- container
48
- } = renderChoice();
49
- expect(container.firstChild).toBeInTheDocument();
50
- });
51
- it('displays the choice value', () => {
52
- const {
53
- container
54
- } = renderChoice();
55
- expect(container.innerHTML).toContain('<div>6</div>');
56
- });
57
- it('calls onClick when clicked on choice', () => {
58
- const {
59
- container
60
- } = renderChoice();
61
- const choiceElement = container.firstChild.firstChild;
62
- if (choiceElement) {
63
- _react2.fireEvent.click(choiceElement);
64
- expect(onClick).toHaveBeenCalled();
65
- }
66
- });
67
-
68
- // Note: The delete icon click behavior cannot be easily tested with RTL because:
69
- // 1. The onClick handler is on a styled MUI component with stopPropagation
70
- // 2. The actual DOM structure is complex with SVG elements
71
- // 3. Integration tests should verify this user interaction
72
- // Keeping the test but marking it as a known limitation
73
- it.skip('calls onRemoveChoice when delete icon is clicked', () => {
74
- const {
75
- container
76
- } = renderChoice();
77
- const svgs = container.querySelectorAll('svg');
78
- const deleteIcon = svgs[svgs.length - 1];
79
- if (deleteIcon) {
80
- const deleteButton = deleteIcon.closest('[class*="StyledDeleteIcon"]') || deleteIcon.parentElement;
81
- _react2.fireEvent.click(deleteButton);
82
- expect(onRemoveChoice).toHaveBeenCalled();
83
- }
84
- });
85
- });
86
- describe('drag behavior', () => {
87
- it('prevents drag when choice value is empty', () => {
88
- // Mock window.alert
89
- const jsdomAlert = window.alert;
90
- window.alert = jest.fn();
91
- const {
92
- container
93
- } = renderChoice({
94
- choice: {
95
- value: '',
96
- id: '0'
97
- }
98
- });
99
- const choiceElement = container.firstChild.firstChild;
100
- if (choiceElement) {
101
- const event = new Event('dragstart', {
102
- bubbles: true,
103
- cancelable: true
104
- });
105
- (0, _react2.fireEvent)(choiceElement, event);
106
-
107
- // The component should prevent the drag and show an alert
108
- // Note: The actual alert behavior is tested in integration tests
109
- }
110
- window.alert = jsdomAlert;
111
- });
112
- });
113
- });
114
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfcmVhY3QiLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwicmVxdWlyZSIsIl9yZWFjdDIiLCJfc3R5bGVzIiwiX2NvcmUiLCJfY2hvaWNlIiwiamVzdCIsIm1vY2siLCJEbmRDb250ZXh0IiwiY2hpbGRyZW4iLCJkZWZhdWx0IiwiY3JlYXRlRWxlbWVudCIsInVzZURyYWdnYWJsZSIsImZuIiwiYXR0cmlidXRlcyIsImxpc3RlbmVycyIsInNldE5vZGVSZWYiLCJpc0RyYWdnaW5nIiwidGhlbWUiLCJjcmVhdGVUaGVtZSIsImRlc2NyaWJlIiwib25DbGljayIsIm9uUmVtb3ZlQ2hvaWNlIiwiYmVmb3JlRWFjaCIsInJlbmRlckNob2ljZSIsImV4dHJhcyIsInByb3BzIiwia2V5IiwiY2hvaWNlIiwidmFsdWUiLCJpZCIsInJlbmRlciIsIlRoZW1lUHJvdmlkZXIiLCJ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