@pie-lib/mask-markup 3.0.4-next.33 → 3.0.4-next.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/CHANGELOG.json +17 -0
  2. package/CHANGELOG.md +1256 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/choices/choice.js +116 -0
  5. package/lib/choices/choice.js.map +1 -0
  6. package/lib/choices/index.js +103 -0
  7. package/lib/choices/index.js.map +1 -0
  8. package/lib/componentize.js +21 -0
  9. package/lib/componentize.js.map +1 -0
  10. package/lib/components/blank.js +371 -0
  11. package/lib/components/blank.js.map +1 -0
  12. package/lib/components/correct-input.js +94 -0
  13. package/lib/components/correct-input.js.map +1 -0
  14. package/lib/components/dropdown.js +483 -0
  15. package/lib/components/dropdown.js.map +1 -0
  16. package/lib/components/input.js +50 -0
  17. package/lib/components/input.js.map +1 -0
  18. package/lib/constructed-response.js +101 -0
  19. package/lib/constructed-response.js.map +1 -0
  20. package/lib/customizable.js +42 -0
  21. package/lib/customizable.js.map +1 -0
  22. package/lib/drag-in-the-blank.js +254 -0
  23. package/lib/drag-in-the-blank.js.map +1 -0
  24. package/lib/index.js +55 -0
  25. package/lib/index.js.map +1 -0
  26. package/lib/inline-dropdown.js +40 -0
  27. package/lib/inline-dropdown.js.map +1 -0
  28. package/lib/mask.js +198 -0
  29. package/lib/mask.js.map +1 -0
  30. package/lib/serialization.js +261 -0
  31. package/lib/serialization.js.map +1 -0
  32. package/lib/with-mask.js +97 -0
  33. package/lib/with-mask.js.map +1 -0
  34. package/package.json +20 -39
  35. package/src/__tests__/drag-in-the-blank.test.js +111 -0
  36. package/src/__tests__/index.test.js +38 -0
  37. package/src/__tests__/mask.test.js +381 -0
  38. package/src/__tests__/serialization.test.js +54 -0
  39. package/src/__tests__/utils.js +1 -0
  40. package/src/__tests__/with-mask.test.js +76 -0
  41. package/src/choices/__tests__/index.test.js +75 -0
  42. package/src/choices/choice.jsx +97 -0
  43. package/src/choices/index.jsx +64 -0
  44. package/src/componentize.js +13 -0
  45. package/src/components/__tests__/blank.test.js +199 -0
  46. package/src/components/__tests__/correct-input.test.js +90 -0
  47. package/src/components/__tests__/dropdown.test.js +129 -0
  48. package/src/components/__tests__/input.test.js +102 -0
  49. package/src/components/blank.jsx +386 -0
  50. package/src/components/correct-input.jsx +82 -0
  51. package/src/components/dropdown.jsx +423 -0
  52. package/src/components/input.jsx +48 -0
  53. package/src/constructed-response.jsx +87 -0
  54. package/src/customizable.jsx +34 -0
  55. package/src/drag-in-the-blank.jsx +241 -0
  56. package/src/index.js +16 -0
  57. package/src/inline-dropdown.jsx +29 -0
  58. package/src/mask.jsx +172 -0
  59. package/src/serialization.js +260 -0
  60. package/src/with-mask.jsx +75 -0
  61. package/dist/_virtual/_rolldown/runtime.js +0 -4
  62. package/dist/choices/choice.d.ts +0 -24
  63. package/dist/choices/choice.js +0 -77
  64. package/dist/choices/index.d.ts +0 -25
  65. package/dist/choices/index.js +0 -49
  66. package/dist/componentize.d.ts +0 -12
  67. package/dist/componentize.js +0 -4
  68. package/dist/components/blank.d.ts +0 -39
  69. package/dist/components/blank.js +0 -240
  70. package/dist/components/correct-input.d.ts +0 -11
  71. package/dist/components/dropdown.d.ts +0 -37
  72. package/dist/components/dropdown.js +0 -320
  73. package/dist/components/input.d.ts +0 -37
  74. package/dist/constructed-response.d.ts +0 -44
  75. package/dist/constructed-response.js +0 -55
  76. package/dist/customizable.d.ts +0 -43
  77. package/dist/customizable.js +0 -8
  78. package/dist/drag-in-the-blank.d.ts +0 -37
  79. package/dist/drag-in-the-blank.js +0 -164
  80. package/dist/index.d.ts +0 -15
  81. package/dist/index.js +0 -7
  82. package/dist/inline-dropdown.d.ts +0 -44
  83. package/dist/inline-dropdown.js +0 -24
  84. package/dist/mask.d.ts +0 -30
  85. package/dist/mask.js +0 -99
  86. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  87. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/index.js +0 -17
  88. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssPrefix.js +0 -9
  89. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/cssUnitless.js +0 -26
  90. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/hasOwn.js +0 -11
  91. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isFunction.js +0 -11
  92. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/isObject.js +0 -11
  93. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixInfo.js +0 -24
  94. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixProperties.js +0 -32
  95. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/prefixer.js +0 -29
  96. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/camelize.js +0 -14
  97. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenRe.js +0 -8
  98. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/hyphenate.js +0 -12
  99. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/separate.js +0 -11
  100. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toLowerFirst.js +0 -10
  101. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/stringUtils/toUpperFirst.js +0 -10
  102. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleObject.js +0 -55
  103. package/dist/node_modules/.bun/to-style@1.3.3/node_modules/to-style/src/toStyleString.js +0 -16
  104. package/dist/serialization.d.ts +0 -34
  105. package/dist/serialization.js +0 -132
  106. package/dist/with-mask.d.ts +0 -55
  107. package/dist/with-mask.js +0 -45
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blank.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_mathRendering","_debug","_core","_utilities","_styles","_Chip","_classnames","_renderUi","_colors","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ownKeys","keys","getOwnPropertySymbols","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","getOwnPropertyDescriptors","defineProperties","log","debug","StyledContent","styled","_ref","dragged","over","border","concat","color","primary","minWidth","touchAction","overflow","whiteSpace","opacity","StyledChip","Chip","backgroundColor","background","text","fontSize","maxWidth","position","borderRadius","grey","correct","incorrect","StyledChipLabel","pointerEvents","display","padding","marginTop","marginBottom","left","top","transform","BlankContent","_ref2","_dragItem$choice","_frozenRef$current","_frozenRef$current2","disabled","choice","isOver","isDragging","dragItem","emptyResponseAreaWidth","emptyResponseAreaHeight","rootRef","useRef","spanRef","frozenRef","_useState","useState","height","width","_useState2","_slicedToArray2","dimensions","setDimensions","handleImageLoad","updateDimensions","handleElements","_spanRef$current","imageElement","current","querySelector","onload","setTimeout","getMeasureNode","mjx","parentElement","img","style","offsetHeight","measureNode","node","rect","getBoundingClientRect","offsetWidth","Math","max","scrollHeight","widthWithPadding","heightWithPadding","responseAreaWidth","parseFloat","responseAreaHeight","adjustedWidth","adjustedHeight","prevState","getRootDimensions","isNaN","rootStyle","minHeight","useEffect","renderMath","value","draggedLabel","label","createElement","clickable","ref","component","Fragment","draggable","className","classnames","hidden","dangerouslySetInnerHTML","__html","parentOver","undefined","variant","defaultProps","propTypes","id","PropTypes","oneOfType","string","number","bool","duplicates","object","onChange","func","instanceId","DragDropBlank","_ref3","_dragItem$data","_useDraggable","useDraggable","data","fromChoice","type","dragAttributes","attributes","dragListeners","listeners","setDragNodeRef","setNodeRef","_useDroppable","useDroppable","accepts","setDropNodeRef","active","CSS","Translate","toString","_extends2","_default","exports"],"sources":["../../src/components/blank.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport debug from 'debug';\nimport { useDraggable, useDroppable } from '@dnd-kit/core';\nimport { CSS } from '@dnd-kit/utilities';\nimport { styled } from '@mui/material/styles';\nimport Chip from '@mui/material/Chip';\nimport classnames from 'classnames';\nimport { color } from '@pie-lib/render-ui';\nimport { grey } from '@mui/material/colors';\n\nconst log = debug('pie-lib:mask-markup:blank');\n\nconst StyledContent = styled('span')(({ dragged, over }) => ({\n border: `solid 0px ${color.primary()}`,\n minWidth: '200px',\n touchAction: 'none',\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n opacity: 1,\n ...(over && {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n }),\n ...(dragged && {\n opacity: 0.5,\n }),\n}));\n\nconst StyledChip = styled(Chip)(() => ({\n backgroundColor: color.background(),\n border: `2px dashed ${color.text()}`,\n touchAction: 'none',\n color: color.text(),\n fontSize: 'inherit',\n maxWidth: '374px',\n position: 'relative',\n borderRadius: '3px',\n '&.over': {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n },\n '&.parentOver': {\n border: `1px solid ${grey[500]}`,\n backgroundColor: `${grey[300]}`,\n },\n '&.correct': {\n border: `solid 1px ${color.correct()}`,\n },\n '&.incorrect': {\n border: `solid 1px ${color.incorrect()}`,\n },\n '&.Mui-disabled': {\n opacity: 1,\n },\n}));\n\nconst StyledChipLabel = styled('span')(() => ({\n whiteSpace: 'normal',\n // Added for touch devices, for image content.\n // This will prevent the context menu from appearing and not allowing other interactions with the image.\n // If interactions with the image in the token will be requested we should handle only the context Menu.\n pointerEvents: 'none',\n '& img': {\n display: 'block',\n padding: '2px 0',\n },\n // Remove default <p> margins to ensure consistent spacing across all wrapped content (p, span, div, math)\n // Padding for top and bottom will instead be controlled by the container for consistent layout\n // Ensures consistent behavior with pie-api-browser, where marginTop is already removed by a Bootstrap stylesheet\n '& p': {\n marginTop: '0',\n marginBottom: '0',\n },\n '& mjx-frac': {\n fontSize: '120% !important',\n },\n '&.over': {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n },\n '&.hidden': {\n color: 'transparent',\n opacity: 0,\n },\n '&.dragged': {\n position: 'absolute',\n left: 16,\n maxWidth: '60px',\n top: '50%',\n transform: 'translateY(-50%)',\n },\n}));\n\nfunction BlankContent({\n disabled,\n choice,\n isOver,\n isDragging,\n dragItem,\n correct,\n emptyResponseAreaWidth,\n emptyResponseAreaHeight,\n}) {\n const rootRef = useRef(null);\n const spanRef = useRef(null);\n const frozenRef = useRef(null); // to use during dragging to prevent flickering\n const [dimensions, setDimensions] = useState({ height: 0, width: 0 });\n\n const handleImageLoad = () => {\n updateDimensions();\n };\n\n const handleElements = () => {\n const imageElement = spanRef.current?.querySelector('img');\n if (imageElement) {\n imageElement.onload = handleImageLoad;\n } else {\n setTimeout(() => {\n updateDimensions();\n }, 300);\n }\n };\n\n const getMeasureNode = () => {\n if (!spanRef.current) return null;\n const mjx = spanRef.current.querySelector('mjx-container');\n if (mjx && spanRef.current.parentElement) return spanRef.current.parentElement;\n const img = spanRef.current.querySelector('img');\n if (img) return img;\n return spanRef.current;\n };\n\n const updateDimensions = () => {\n if (spanRef.current && rootRef.current) {\n // Temporarily set rootRef width to 'auto' for natural measurement\n rootRef.current.style.width = 'auto';\n rootRef.current.style.height = 'auto';\n rootRef.current.offsetHeight;\n\n const measureNode = getMeasureNode();\n const node = measureNode || spanRef.current;\n const rect = node.getBoundingClientRect();\n const width = rect.width || node.offsetWidth || 0;\n const height = Math.max(\n rect.height || 0,\n node.offsetHeight || 0,\n node.scrollHeight || 0,\n spanRef.current.scrollHeight || 0,\n );\n\n const widthWithPadding = width + 24; // 12px padding on each side\n const heightWithPadding = height + 24; // 12px padding on top and bottom\n\n const responseAreaWidth = parseFloat(emptyResponseAreaWidth) || 0;\n const responseAreaHeight = parseFloat(emptyResponseAreaHeight) || 0;\n\n const adjustedWidth = widthWithPadding <= responseAreaWidth ? responseAreaWidth : widthWithPadding;\n const adjustedHeight = heightWithPadding <= responseAreaHeight ? responseAreaHeight : heightWithPadding;\n\n setDimensions((prevState) => ({\n width: adjustedWidth > responseAreaWidth ? adjustedWidth : prevState.width,\n height: adjustedHeight > responseAreaHeight ? adjustedHeight : prevState.height,\n }));\n\n rootRef.current.style.width = `${adjustedWidth}px`;\n rootRef.current.style.height = `${adjustedHeight}px`;\n }\n };\n\n const getRootDimensions = () => {\n // Handle potential non-numeric values\n const responseAreaWidth = !isNaN(parseFloat(emptyResponseAreaWidth)) ? parseFloat(emptyResponseAreaWidth) : 0;\n const responseAreaHeight = !isNaN(parseFloat(emptyResponseAreaHeight)) ? parseFloat(emptyResponseAreaHeight) : 0;\n\n const rootStyle = {\n height: dimensions.height || responseAreaHeight,\n width: dimensions.width || responseAreaWidth,\n };\n\n // add minWidth, minHeight if width and height are not defined\n return {\n ...rootStyle,\n ...(responseAreaWidth ? {} : { minWidth: 90 }),\n ...(responseAreaHeight ? {} : { minHeight: 32 }),\n };\n };\n\n useEffect(() => {\n handleElements();\n }, []);\n\n // Render math for the placeholder/preview when dragging over\n useEffect(() => {\n if (rootRef.current) {\n renderMath(rootRef.current);\n }\n }, [correct, isOver, dragItem?.choice?.value]);\n\n useEffect(() => {\n if (!choice) {\n setDimensions({ height: 0, width: 0 });\n return;\n }\n handleElements();\n }, [choice]);\n\n useEffect(() => {\n if (!isOver && !isDragging) {\n frozenRef.current = {\n width: rootRef.current.offsetWidth,\n height: rootRef.current.offsetHeight,\n };\n }\n }, [choice, isOver, isDragging]);\n\n const draggedLabel = dragItem && isOver && dragItem.choice && dragItem.choice.value;\n const label = choice && choice.value;\n const style =\n isOver || isDragging\n ? {\n width: frozenRef.current?.width,\n height: frozenRef.current?.height,\n }\n : getRootDimensions();\n\n return (\n <StyledChip\n clickable={false}\n disabled={disabled}\n ref={rootRef}\n component=\"span\"\n label={\n <React.Fragment>\n <StyledChipLabel\n ref={spanRef}\n draggable={true}\n className={classnames({\n over: isOver,\n hidden: draggedLabel,\n })}\n dangerouslySetInnerHTML={{ __html: label || '' }}\n />\n {draggedLabel && (\n <StyledChipLabel\n draggable={true}\n className={classnames({\n over: isOver,\n dragged: true,\n })}\n dangerouslySetInnerHTML={{ __html: draggedLabel || '' }}\n />\n )}\n </React.Fragment>\n }\n className={classnames({\n over: isOver,\n parentOver: isOver,\n correct: correct !== undefined && correct,\n incorrect: correct !== undefined && !correct,\n })}\n variant={disabled ? 'outlined' : undefined}\n style={style}\n />\n );\n}\n\nBlankContent.defaultProps = {\n emptyResponseAreaWidth: 0,\n emptyResponseAreaHeight: 0,\n};\n\nBlankContent.propTypes = {\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n disabled: PropTypes.bool,\n duplicates: PropTypes.bool,\n choice: PropTypes.object,\n isOver: PropTypes.bool,\n dragItem: PropTypes.object,\n correct: PropTypes.bool,\n onChange: PropTypes.func,\n emptyResponseAreaWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n emptyResponseAreaHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n instanceId: PropTypes.string,\n};\n\n// New functional component using @dnd-kit hooks\nfunction DragDropBlank({\n id,\n disabled,\n duplicates,\n choice,\n correct,\n onChange,\n emptyResponseAreaWidth,\n emptyResponseAreaHeight,\n instanceId,\n}) {\n // Setup draggable functionality\n const {\n attributes: dragAttributes,\n listeners: dragListeners,\n setNodeRef: setDragNodeRef,\n transform,\n isDragging,\n } = useDraggable({\n id: `mask-blank-drag-${id}`,\n disabled: disabled || !choice,\n data: {\n id: id,\n choice: choice,\n instanceId: instanceId,\n fromChoice: false, // This is from a blank, not from choices\n type: 'MaskBlank',\n },\n });\n\n // Setup droppable functionality\n const {\n setNodeRef: setDropNodeRef,\n isOver,\n active: dragItem,\n } = useDroppable({\n id: `mask-blank-drop-${id}`,\n data: {\n id: id,\n accepts: ['MaskBlank'],\n instanceId: instanceId,\n },\n });\n\n // Combine refs for both drag and drop\n const setNodeRef = (node) => {\n setDragNodeRef(node);\n setDropNodeRef(node);\n };\n\n const style = {\n transform: CSS.Translate.toString(transform),\n };\n\n return (\n <StyledContent\n ref={setNodeRef}\n style={style}\n dragged={isDragging}\n over={isOver}\n {...dragAttributes}\n {...dragListeners}\n >\n <BlankContent\n id={id}\n disabled={disabled}\n duplicates={duplicates}\n choice={choice}\n isOver={isOver}\n dragItem={dragItem?.data?.current}\n correct={correct}\n onChange={onChange}\n emptyResponseAreaWidth={emptyResponseAreaWidth}\n emptyResponseAreaHeight={emptyResponseAreaHeight}\n instanceId={instanceId}\n />\n </StyledContent>\n );\n}\n\nDragDropBlank.defaultProps = {\n emptyResponseAreaWidth: 0,\n emptyResponseAreaHeight: 0,\n};\n\nDragDropBlank.propTypes = {\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n disabled: PropTypes.bool,\n duplicates: PropTypes.bool,\n choice: PropTypes.object,\n correct: PropTypes.bool,\n onChange: PropTypes.func,\n emptyResponseAreaWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n emptyResponseAreaHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n instanceId: PropTypes.string,\n};\n\nexport default DragDropBlank;\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAN,sBAAA,CAAAF,OAAA;AACA,IAAAS,WAAA,GAAAP,sBAAA,CAAAF,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AAA4C,SAAAD,wBAAAa,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,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QAAQ,EAAEA,QAAS;IACnB9E,sBAAsB,EAAEA,sBAAuB;IAC/CC,uBAAuB,EAAEA,uBAAwB;IACjD+E,UAAU,EAAEA;EAAW,CACxB,CACY,CAAC;AAEpB;AAEAC,aAAa,CAACb,YAAY,GAAG;EAC3BpE,sBAAsB,EAAE,CAAC;EACzBC,uBAAuB,EAAE;AAC3B,CAAC;AAEDgF,aAAa,CAACZ,SAAS,GAAG;EACxBC,EAAE,EAAEC,qBAAS,CAACC,SAAS,CAAC,CAACD,qBAAS,CAACE,MAAM,EAAEF,qBAAS,CAACG,MAAM,CAAC,CAAC;EAC7D/E,QAAQ,EAAE4E,qBAAS,CAACI,IAAI;EACxBC,UAAU,EAAEL,qBAAS,CAACI,IAAI;EAC1B/E,MAAM,EAAE2E,qBAAS,CAACM,MAAM;EACxBlG,OAAO,EAAE4F,qBAAS,CAACI,IAAI;EACvBG,QAAQ,EAAEP,qBAAS,CAACQ,IAAI;EACxB/E,sBAAsB,EAAEuE,qBAAS,CAACC,SAAS,CAAC,CAACD,qBAAS,CAACE,MAAM,EAAEF,qBAAS,CAACG,MAAM,CAAC,CAAC;EACjFzE,uBAAuB,EAAEsE,qBAAS,CAACC,SAAS,CAAC,CAACD,qBAAS,CAACE,MAAM,EAAEF,qBAAS,CAACG,MAAM,CAAC,CAAC;EAClFM,UAAU,EAAET,qBAAS,CAACE;AACxB,CAAC;AAAC,IAAA+B,QAAA,GAAAC,OAAA,cAEaxB,aAAa","ignoreList":[]}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _OutlinedInput = _interopRequireDefault(require("@mui/material/OutlinedInput"));
13
+ var _classnames2 = _interopRequireDefault(require("classnames"));
14
+ var _styles = require("@mui/material/styles");
15
+ var _renderUi = require("@pie-lib/render-ui");
16
+ var _excluded = ["correct", "charactersLimit", "disabled", "isBox", "isConstructedResponse", "width", "spellCheck"];
17
+ var StyledOutlinedInput = (0, _styles.styled)(_OutlinedInput["default"])(function () {
18
+ return {
19
+ padding: '2px',
20
+ borderRadius: '4px',
21
+ fontSize: 'inherit',
22
+ display: 'inline-block',
23
+ verticalAlign: 'middle',
24
+ '& fieldset': {
25
+ border: 0
26
+ },
27
+ '& .MuiOutlinedInput-input': {
28
+ color: _renderUi.color.text(),
29
+ backgroundColor: _renderUi.color.background(),
30
+ borderRadius: '4px !important',
31
+ borderWidth: '1px',
32
+ borderStyle: 'solid',
33
+ padding: '10px 20px 10px 10px',
34
+ '&:disabled': {
35
+ opacity: 0.8,
36
+ cursor: 'not-allowed !important'
37
+ },
38
+ '&:hover': {
39
+ borderColor: _renderUi.color.primary(),
40
+ '&:disabled': {
41
+ borderColor: 'initial'
42
+ }
43
+ },
44
+ '&.Mui-focused': {
45
+ borderColor: _renderUi.color.primaryDark()
46
+ },
47
+ '&.crInput': {
48
+ padding: '8px !important'
49
+ },
50
+ '&.correct': {
51
+ borderColor: "".concat(_renderUi.color.correct(), " !important")
52
+ },
53
+ '&.incorrect': {
54
+ borderColor: "".concat(_renderUi.color.incorrect(), " !important")
55
+ }
56
+ }
57
+ };
58
+ });
59
+ var CorrectInput = function CorrectInput(props) {
60
+ var correct = props.correct,
61
+ charactersLimit = props.charactersLimit,
62
+ disabled = props.disabled,
63
+ isBox = props.isBox,
64
+ isConstructedResponse = props.isConstructedResponse,
65
+ width = props.width,
66
+ spellCheck = props.spellCheck,
67
+ rest = (0, _objectWithoutProperties2["default"])(props, _excluded);
68
+ var label = typeof correct === 'boolean' ? correct ? 'correct' : 'incorrect' : undefined;
69
+ var inputProps = charactersLimit ? {
70
+ maxLength: charactersLimit,
71
+ 'aria-label': 'Enter answer'
72
+ } : {
73
+ 'aria-label': 'Enter answer'
74
+ };
75
+ if (width) {
76
+ inputProps.style = {
77
+ width: "".concat(width + Math.round(width / 10) + 1, "ch") // added some extra space for capital letters
78
+ };
79
+ }
80
+ return /*#__PURE__*/_react["default"].createElement(StyledOutlinedInput, (0, _extends2["default"])({
81
+ className: (0, _classnames2["default"])({
82
+ disabledInput: disabled,
83
+ box: isBox
84
+ }),
85
+ classes: {
86
+ input: (0, _classnames2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, label, label), "crInput", isConstructedResponse))
87
+ },
88
+ inputProps: inputProps,
89
+ disabled: disabled,
90
+ spellCheck: spellCheck
91
+ }, rest));
92
+ };
93
+ var _default = exports["default"] = CorrectInput;
94
+ //# sourceMappingURL=correct-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correct-input.js","names":["_react","_interopRequireDefault","require","_OutlinedInput","_classnames2","_styles","_renderUi","_excluded","StyledOutlinedInput","styled","OutlinedInput","padding","borderRadius","fontSize","display","verticalAlign","border","color","text","backgroundColor","background","borderWidth","borderStyle","opacity","cursor","borderColor","primary","primaryDark","concat","correct","incorrect","CorrectInput","props","charactersLimit","disabled","isBox","isConstructedResponse","width","spellCheck","rest","_objectWithoutProperties2","label","undefined","inputProps","maxLength","style","Math","round","createElement","_extends2","className","classnames","disabledInput","box","classes","input","_defineProperty2","_default","exports"],"sources":["../../src/components/correct-input.jsx"],"sourcesContent":["import React from 'react';\nimport OutlinedInput from '@mui/material/OutlinedInput';\nimport classnames from 'classnames';\nimport { styled } from '@mui/material/styles';\nimport { color } from '@pie-lib/render-ui';\n\nconst StyledOutlinedInput = styled(OutlinedInput)(() => ({\n padding: '2px',\n borderRadius: '4px',\n fontSize: 'inherit',\n display: 'inline-block',\n verticalAlign: 'middle',\n '& fieldset': {\n border: 0,\n },\n '& .MuiOutlinedInput-input': {\n color: color.text(),\n backgroundColor: color.background(),\n borderRadius: '4px !important',\n borderWidth: '1px',\n borderStyle: 'solid',\n padding: '10px 20px 10px 10px',\n '&:disabled': {\n opacity: 0.8,\n cursor: 'not-allowed !important',\n },\n '&:hover': {\n borderColor: color.primary(),\n '&:disabled': {\n borderColor: 'initial',\n },\n },\n '&.Mui-focused': {\n borderColor: color.primaryDark(),\n },\n '&.crInput': {\n padding: '8px !important',\n },\n '&.correct': {\n borderColor: `${color.correct()} !important`,\n },\n '&.incorrect': {\n borderColor: `${color.incorrect()} !important`,\n },\n },\n}));\n\nconst CorrectInput = (props) => {\n const { correct, charactersLimit, disabled, isBox, isConstructedResponse, width, spellCheck, ...rest } = props;\n\n const label = typeof correct === 'boolean' ? (correct ? 'correct' : 'incorrect') : undefined;\n const inputProps = charactersLimit\n ? { maxLength: charactersLimit, 'aria-label': 'Enter answer' }\n : { 'aria-label': 'Enter answer' };\n\n if (width) {\n inputProps.style = {\n width: `${width + Math.round(width / 10) + 1}ch`, // added some extra space for capital letters\n };\n }\n\n return (\n <StyledOutlinedInput\n className={classnames({\n disabledInput: disabled,\n box: isBox,\n })}\n classes={{\n input: classnames({\n [label]: label,\n crInput: isConstructedResponse,\n }),\n }}\n inputProps={inputProps}\n disabled={disabled}\n spellCheck={spellCheck}\n {...rest}\n />\n );\n};\n\nexport default CorrectInput;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAA2C,IAAAK,SAAA;AAE3C,IAAMC,mBAAmB,GAAG,IAAAC,cAAM,EAACC,yBAAa,CAAC,CAAC;EAAA,OAAO;IACvDC,OAAO,EAAE,KAAK;IACdC,YAAY,EAAE,KAAK;IACnBC,QA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AKC,IAAI,OAAAC,yBAAA,aAAKR,KAAK,EAAAzB,SAAA;EAE9G,IAAMkC,KAAK,GAAG,OAAOZ,OAAO,KAAK,SAAS,GAAIA,OAAO,GAAG,SAAS,GAAG,WAAW,GAAIa,SAAS;EAC5F,IAAMC,UAAU,GAAGV,eAAe,GAC9B;IAAEW,SAAS,EAAEX,eAAe;IAAE,YAAY,EAAE;EAAe,CAAC,GAC5D;IAAE,YAAY,EAAE;EAAe,CAAC;EAEpC,IAAII,KAAK,EAAE;IACTM,UAAU,CAACE,KAAK,GAAG;MACjBR,KAAK,KAAAT,MAAA,CAAKS,KAAK,GAAGS,IAAI,CAACC,KAAK,CAACV,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,OAAI,CAAE;IACpD,CAAC;EACH;EAEA,oBACErC,MAAA,YAAAgD,aAAA,CAACxC,mBAAmB,MAAAyC,SAAA;IAClBC,SAAS,EAAE,IAAAC,uBAAU,EAAC;MACpBC,aAAa,EAAElB,QAAQ;MACvBmB,GAAG,EAAElB;IACP,CAAC,CAAE;IACHmB,OAAO,EAAE;MACPC,KAAK,EAAE,IAAAJ,uBAAU,MAAAK,gBAAA,iBAAAA,gBAAA,iBACdf,KAAK,EAAGA,KAAK,cACLL,qBAAqB,CAC/B;IACH,CAAE;IACFO,UAAU,EAAEA,UAAW;IACvBT,QAAQ,EAAEA,QAAS;IACnBI,UAAU,EAAEA;EAAW,GACnBC,IAAI,CACT,CAAC;AAEN,CAAC;AAAC,IAAAkB,QAAA,GAAAC,OAAA,cAEa3B,YAAY","ignoreList":[]}
@@ -0,0 +1,483 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
11
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
14
+ var _react = _interopRequireDefault(require("react"));
15
+ var _propTypes = _interopRequireDefault(require("prop-types"));
16
+ var _Button = _interopRequireDefault(require("@mui/material/Button"));
17
+ var _InputLabel = _interopRequireDefault(require("@mui/material/InputLabel"));
18
+ var _Menu = _interopRequireDefault(require("@mui/material/Menu"));
19
+ var _MenuItem = _interopRequireDefault(require("@mui/material/MenuItem"));
20
+ var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
21
+ var _ArrowDropUp = _interopRequireDefault(require("@mui/icons-material/ArrowDropUp"));
22
+ var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
23
+ var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
24
+ var _styles = require("@mui/material/styles");
25
+ var _renderUi = require("@pie-lib/render-ui");
26
+ var _mathRendering = require("@pie-lib/math-rendering");
27
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
28
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
29
+ function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
30
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
31
+ var StyledButton = (0, _styles.styled)(_Button["default"])(function () {
32
+ return {
33
+ color: _renderUi.color.text(),
34
+ border: "1px solid ".concat(_renderUi.color.borderGray()),
35
+ borderRadius: '4px',
36
+ justifyContent: 'space-between',
37
+ backgroundColor: _renderUi.color.background(),
38
+ position: 'relative',
39
+ height: '45px',
40
+ width: 'fit-content',
41
+ margin: '2px',
42
+ textTransform: 'none',
43
+ '& span': {
44
+ paddingRight: '24px'
45
+ },
46
+ '& svg': {
47
+ position: 'absolute',
48
+ right: '4px',
49
+ top: 'calc(50% - 12px)',
50
+ pointerEvents: 'none',
51
+ color: _renderUi.color.text(),
52
+ marginLeft: '5px'
53
+ },
54
+ '&.Mui-focused': {
55
+ outline: "3px solid ".concat(_renderUi.color.tertiary()),
56
+ outlineOffset: '2px',
57
+ borderWidth: '3px'
58
+ },
59
+ '&.disabledCorrect': {
60
+ borderWidth: '2px',
61
+ borderColor: _renderUi.color.correct(),
62
+ color: "".concat(_renderUi.color.text(), " !important")
63
+ },
64
+ '&.disabledIncorrect': {
65
+ borderWidth: '2px',
66
+ borderColor: _renderUi.color.incorrectWithIcon(),
67
+ color: "".concat(_renderUi.color.text(), " !important")
68
+ }
69
+ };
70
+ });
71
+ var StyledMenu = (0, _styles.styled)(_Menu["default"])(function () {
72
+ return {
73
+ backgroundColor: _renderUi.color.background(),
74
+ border: "1px solid ".concat(_renderUi.color.correct(), " !important"),
75
+ '&:hover': {
76
+ border: "1px solid ".concat(_renderUi.color.text(), " "),
77
+ borderColor: 'initial'
78
+ },
79
+ '&:focus': {
80
+ border: "1px solid ".concat(_renderUi.color.text()),
81
+ borderColor: 'initial'
82
+ },
83
+ // remove default padding on the inner list
84
+ '& .MuiList-root': {
85
+ padding: 0
86
+ }
87
+ };
88
+ });
89
+ var StyledMenuItem = (0, _styles.styled)(_MenuItem["default"])(function () {
90
+ return {
91
+ // base text/layout styles (from old JSS - before mui v5 migration)
92
+ height: 24,
93
+ overflow: 'hidden',
94
+ fontSize: '1rem',
95
+ fontWeight: 400,
96
+ fontFamily: 'inherit',
97
+ lineHeight: '1.5em',
98
+ whiteSpace: 'nowrap',
99
+ // custom styles
100
+ color: _renderUi.color.text(),
101
+ backgroundColor: _renderUi.color.background(),
102
+ '&.Mui-focusVisible': {
103
+ outline: "3px solid ".concat(_renderUi.color.tertiary()),
104
+ outlineOffset: '-1px',
105
+ // keeps it inside the item
106
+ color: _renderUi.color.text(),
107
+ backgroundColor: _renderUi.color.background()
108
+ },
109
+ '&:hover': {
110
+ color: _renderUi.color.text(),
111
+ backgroundColor: _renderUi.color.dropdownBackground()
112
+ },
113
+ boxSizing: 'border-box',
114
+ padding: '16px 8px',
115
+ borderRadius: '4px',
116
+ '&.selected': {
117
+ color: "".concat(_renderUi.color.text(), " !important"),
118
+ backgroundColor: "".concat(_renderUi.color.background(), " !important"),
119
+ '&:hover': {
120
+ color: _renderUi.color.text(),
121
+ backgroundColor: "".concat(_renderUi.color.dropdownBackground(), " !important")
122
+ }
123
+ }
124
+ };
125
+ });
126
+ var StyledLabel = (0, _styles.styled)('span')(function () {
127
+ return {
128
+ fontSize: 'max(1rem, 14px)'
129
+ };
130
+ });
131
+ var StyledSelectedIndicator = (0, _styles.styled)('span')(function () {
132
+ return {
133
+ fontSize: 'max(1rem, 14px)',
134
+ flexShrink: 0,
135
+ paddingLeft: '8px'
136
+ };
137
+ });
138
+ var StyledInputLabel = (0, _styles.styled)(_InputLabel["default"])(function () {
139
+ return {
140
+ position: 'absolute',
141
+ left: '-10000px',
142
+ top: 'auto',
143
+ width: '1px',
144
+ height: '1px',
145
+ overflow: 'hidden'
146
+ };
147
+ });
148
+ var StyledCorrectnessIcon = (0, _styles.styled)(_Check["default"])(function () {
149
+ return {
150
+ color: "".concat(_renderUi.color.white(), " !important"),
151
+ position: 'absolute',
152
+ top: '-8px !important',
153
+ left: '-8px',
154
+ marginLeft: '0 !important',
155
+ borderRadius: '50%',
156
+ fontSize: '16px',
157
+ padding: '2px',
158
+ '&.correct': {
159
+ backgroundColor: _renderUi.color.correct()
160
+ },
161
+ '&.incorrect': {
162
+ backgroundColor: _renderUi.color.incorrectWithIcon()
163
+ }
164
+ };
165
+ });
166
+ var StyledIncorrectnessIcon = (0, _styles.styled)(_Close["default"])(function () {
167
+ return {
168
+ color: "".concat(_renderUi.color.white(), " !important"),
169
+ position: 'absolute',
170
+ top: '-8px !important',
171
+ left: '-8px',
172
+ marginLeft: '0 !important',
173
+ borderRadius: '50%',
174
+ fontSize: '16px',
175
+ padding: '2px',
176
+ '&.correct': {
177
+ backgroundColor: _renderUi.color.correct()
178
+ },
179
+ '&.incorrect': {
180
+ backgroundColor: _renderUi.color.incorrectWithIcon()
181
+ }
182
+ };
183
+ });
184
+ var Dropdown = /*#__PURE__*/function (_React$Component) {
185
+ function Dropdown(props) {
186
+ var _this;
187
+ (0, _classCallCheck2["default"])(this, Dropdown);
188
+ _this = _callSuper(this, Dropdown, [props]);
189
+ (0, _defineProperty2["default"])(_this, "handleClick", function (event) {
190
+ var _this$props = _this.props,
191
+ id = _this$props.id,
192
+ value = _this$props.value,
193
+ choices = _this$props.choices;
194
+ var highlightedOptionId = null;
195
+ if (value) {
196
+ var selectedIndex = (choices || []).findIndex(function (c) {
197
+ return c.value === value;
198
+ });
199
+ if (selectedIndex >= 0) {
200
+ highlightedOptionId = "dropdown-option-".concat(id, "-").concat(selectedIndex);
201
+ }
202
+ }
203
+ _this.setState({
204
+ anchorEl: event.currentTarget,
205
+ highlightedOptionId: highlightedOptionId
206
+ });
207
+ });
208
+ (0, _defineProperty2["default"])(_this, "handleClose", function () {
209
+ var value = _this.props.value;
210
+ _this.setState({
211
+ anchorEl: null,
212
+ previewValue: null,
213
+ highlightedOptionId: null
214
+ });
215
+ // clear displayed preview if no selection
216
+ if (!value && _this.previewRef.current) {
217
+ _this.previewRef.current.innerHTML = '';
218
+ }
219
+ });
220
+ (0, _defineProperty2["default"])(_this, "handleHighlight", function (index) {
221
+ var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index);
222
+
223
+ // preview on hover if nothing selected
224
+ var stateUpdate = {
225
+ highlightedOptionId: highlightedOptionId
226
+ };
227
+ if (!_this.props.value) {
228
+ stateUpdate.previewValue = _this.props.choices[index].value;
229
+ }
230
+ _this.setState(stateUpdate);
231
+ });
232
+ (0, _defineProperty2["default"])(_this, "handleSelect", function (value, index) {
233
+ _this.props.onChange(_this.props.id, value);
234
+ _this.handleHighlight(index);
235
+ _this.handleClose();
236
+ });
237
+ (0, _defineProperty2["default"])(_this, "handleHover", function (index) {
238
+ var selectedValue = _this.props.value;
239
+ if (selectedValue) return;
240
+ var highlightedOptionId = "dropdown-option-".concat(_this.props.id, "-").concat(index);
241
+ var previewValue = _this.state.previewValue;
242
+ _this.setState({
243
+ highlightedOptionId: highlightedOptionId,
244
+ previewValue: previewValue
245
+ }, function () {
246
+ // On hover, preview the math-rendered content inside the button if no value is selected.
247
+ var ref = _this.elementRefs[index];
248
+ var preview = _this.previewRef.current;
249
+ if (ref && preview) {
250
+ preview.innerHTML = ref.innerHTML;
251
+ }
252
+ });
253
+ });
254
+ _this.state = {
255
+ anchorEl: null,
256
+ highlightedOptionId: null,
257
+ menuWidth: null,
258
+ previewValue: null
259
+ };
260
+ _this.hiddenRef = /*#__PURE__*/_react["default"].createRef();
261
+ _this.buttonRef = /*#__PURE__*/_react["default"].createRef();
262
+ _this.previewRef = /*#__PURE__*/_react["default"].createRef();
263
+ _this.elementRefs = [];
264
+ return _this;
265
+ }
266
+ (0, _inherits2["default"])(Dropdown, _React$Component);
267
+ return (0, _createClass2["default"])(Dropdown, [{
268
+ key: "componentDidMount",
269
+ value: function componentDidMount() {
270
+ // measure hidden menu width once
271
+ if (this.hiddenRef.current && this.state.menuWidth === null) {
272
+ this.setState({
273
+ menuWidth: this.hiddenRef.current.clientWidth
274
+ });
275
+ }
276
+ }
277
+ }, {
278
+ key: "componentDidUpdate",
279
+ value: function componentDidUpdate(prevProps, prevState) {
280
+ var hiddenEl = this.hiddenRef.current;
281
+ var dropdownJustOpened = !prevState.anchorEl && this.state.anchorEl;
282
+ if (dropdownJustOpened) {
283
+ this.elementRefs.forEach(function (ref) {
284
+ if (!ref) return;
285
+ var containsLatex = ref.querySelector('[data-latex], [data-raw]');
286
+ var hasMathJax = ref.querySelector('mjx-container');
287
+ var mathHandled = ref.querySelector('[data-math-handled="true"]');
288
+ if (containsLatex && (!mathHandled || !hasMathJax)) {
289
+ (0, _mathRendering.renderMath)(ref);
290
+ }
291
+ });
292
+ }
293
+ if (hiddenEl) {
294
+ var newWidth = hiddenEl.clientWidth;
295
+ if (newWidth !== this.state.menuWidth) {
296
+ this.elementRefs.forEach(function (ref) {
297
+ if (ref) (0, _mathRendering.renderMath)(ref);
298
+ });
299
+ (0, _mathRendering.renderMath)(hiddenEl);
300
+ this.setState({
301
+ menuWidth: newWidth
302
+ });
303
+ }
304
+ }
305
+ }
306
+ }, {
307
+ key: "getLabel",
308
+ value: function getLabel(choices, value) {
309
+ var found = (choices || []).find(function (choice) {
310
+ return choice.value === value;
311
+ });
312
+ return found ? found.label.trim() : undefined;
313
+ }
314
+ }, {
315
+ key: "render",
316
+ value: function render() {
317
+ var _this2 = this;
318
+ var _this$props2 = this.props,
319
+ id = _this$props2.id,
320
+ correct = _this$props2.correct,
321
+ disabled = _this$props2.disabled,
322
+ value = _this$props2.value,
323
+ choices = _this$props2.choices,
324
+ showCorrectAnswer = _this$props2.showCorrectAnswer,
325
+ singleQuery = _this$props2.singleQuery,
326
+ correctValue = _this$props2.correctValue;
327
+ var anchorEl = this.state.anchorEl;
328
+ var open = Boolean(anchorEl);
329
+ var buttonId = "dropdown-button-".concat(id);
330
+ var menuId = "dropdown-menu-".concat(id);
331
+ var valueDisplayId = "dropdown-value-".concat(id);
332
+
333
+ // Determine the class for disabled state, view mode and evaluate mode
334
+ var disabledClass;
335
+ // Reset elementRefs before each render to avoid stale references
336
+ this.elementRefs = [];
337
+ if (disabled && correct !== undefined) {
338
+ disabledClass = correct || showCorrectAnswer ? 'disabledCorrect' : 'disabledIncorrect';
339
+ }
340
+
341
+ // Create distinct, visually hidden labels for each dropdown
342
+ var incrementedId = parseInt(id, 10) + 1;
343
+ var labelId = singleQuery ? 'Query-label' : "Query-label-".concat(incrementedId);
344
+ var labelText = singleQuery ? 'Query' : "Query ".concat(incrementedId);
345
+
346
+ // Changed from Select to Button for dropdown to enhance accessibility. This modification offers explicit control over aria attributes and focuses management, ensuring the dropdown is compliant with accessibility standards. The use of Button and Menu components allows for better handling of keyboard interactions and provides accessible labels and menus, aligning with WCAG guidelines and improving usability for assistive technology users.
347
+ var correctnessIcon = null;
348
+ if (disabled && correct !== undefined) {
349
+ correctnessIcon = correct || showCorrectAnswer ? /*#__PURE__*/_react["default"].createElement(StyledCorrectnessIcon, {
350
+ className: "correct"
351
+ }) : /*#__PURE__*/_react["default"].createElement(StyledIncorrectnessIcon, {
352
+ className: "incorrect"
353
+ });
354
+ }
355
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
356
+ ref: this.hiddenRef,
357
+ style: {
358
+ position: 'absolute',
359
+ visibility: 'hidden',
360
+ top: 0,
361
+ left: 0
362
+ },
363
+ tabIndex: -1,
364
+ "aria-hidden": "true"
365
+ }, (choices || []).map(function (c, index) {
366
+ return /*#__PURE__*/_react["default"].createElement(StyledMenuItem, {
367
+ key: index,
368
+ tabIndex: -1,
369
+ "aria-hidden": "true"
370
+ }, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
371
+ dangerouslySetInnerHTML: {
372
+ __html: c.label
373
+ }
374
+ }));
375
+ })), /*#__PURE__*/_react["default"].createElement(StyledInputLabel, {
376
+ id: labelId,
377
+ tabIndex: -1,
378
+ "aria-hidden": "true"
379
+ }, labelText), /*#__PURE__*/_react["default"].createElement(StyledButton, {
380
+ ref: this.buttonRef,
381
+ style: _objectSpread(_objectSpread({}, this.state.menuWidth && {
382
+ minWidth: "calc(".concat(this.state.menuWidth, "px + 8px)")
383
+ }), {}, {
384
+ borderWidth: open ? '2px' : '1px',
385
+ transition: 'border-width 0.2s ease-in-out'
386
+ }),
387
+ "aria-controls": open ? menuId : undefined,
388
+ "aria-haspopup": "listbox",
389
+ "aria-expanded": open ? 'true' : undefined,
390
+ "aria-activedescendant": this.state.highlightedOptionId,
391
+ onClick: this.handleClick,
392
+ className: disabledClass,
393
+ disabled: disabled,
394
+ id: buttonId,
395
+ role: "combobox",
396
+ "aria-label": "Select an option for ".concat(labelText),
397
+ "aria-labelledby": valueDisplayId
398
+ }, correctnessIcon, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
399
+ id: valueDisplayId,
400
+ ref: this.previewRef,
401
+ dangerouslySetInnerHTML: {
402
+ __html: correctValue ? correctValue : open && this.state.previewValue ? this.getLabel(choices, this.state.previewValue) : this.getLabel(choices, value) || ''
403
+ }
404
+ }), open ? /*#__PURE__*/_react["default"].createElement(_ArrowDropUp["default"], null) : /*#__PURE__*/_react["default"].createElement(_ArrowDropDown["default"], null)), /*#__PURE__*/_react["default"].createElement(StyledMenu, {
405
+ id: menuId,
406
+ anchorEl: anchorEl,
407
+ keepMounted: true,
408
+ open: open,
409
+ onClose: this.handleClose,
410
+ getContentAnchorEl: null,
411
+ anchorOrigin: {
412
+ vertical: 'bottom',
413
+ horizontal: 'left'
414
+ },
415
+ transformOrigin: {
416
+ vertical: 'top',
417
+ horizontal: 'left'
418
+ },
419
+ transitionDuration: {
420
+ enter: 225,
421
+ exit: 195
422
+ },
423
+ slotProps: {
424
+ paper: this.state.menuWidth ? {
425
+ style: {
426
+ minWidth: this.state.menuWidth,
427
+ padding: '4px'
428
+ }
429
+ } : undefined,
430
+ list: {
431
+ 'aria-labelledby': buttonId,
432
+ role: 'listbox',
433
+ disablePadding: true
434
+ }
435
+ }
436
+ }, (choices || []).map(function (c, index) {
437
+ var optionId = "dropdown-option-".concat(id, "-").concat(index);
438
+ return /*#__PURE__*/_react["default"].createElement(StyledMenuItem, {
439
+ id: optionId,
440
+ className: c.value === value ? 'selected' : '',
441
+ selected: c.value === value,
442
+ key: "".concat(c.label, "-").concat(index),
443
+ value: c.value,
444
+ onClick: function onClick() {
445
+ return _this2.handleSelect(c.value, index);
446
+ },
447
+ role: "option",
448
+ "aria-selected": _this2.state.highlightedOptionId === optionId ? 'true' : undefined,
449
+ onMouseOver: function onMouseOver() {
450
+ return _this2.handleHover(index);
451
+ }
452
+ }, /*#__PURE__*/_react["default"].createElement(StyledLabel, {
453
+ ref: function ref(_ref) {
454
+ return _this2.elementRefs[index] = _ref;
455
+ },
456
+ dangerouslySetInnerHTML: {
457
+ __html: c.label
458
+ }
459
+ }), /*#__PURE__*/_react["default"].createElement(StyledSelectedIndicator, {
460
+ dangerouslySetInnerHTML: {
461
+ __html: c.value === value ? ' &check;' : ''
462
+ }
463
+ }));
464
+ })));
465
+ }
466
+ }]);
467
+ }(_react["default"].Component);
468
+ (0, _defineProperty2["default"])(Dropdown, "propTypes", {
469
+ id: _propTypes["default"].string,
470
+ value: _propTypes["default"].string,
471
+ disabled: _propTypes["default"].bool,
472
+ onChange: _propTypes["default"].func,
473
+ correct: _propTypes["default"].bool,
474
+ choices: _propTypes["default"].arrayOf(_propTypes["default"].shape({
475
+ value: _propTypes["default"].string,
476
+ label: _propTypes["default"].string
477
+ })),
478
+ showCorrectAnswer: _propTypes["default"].bool,
479
+ singleQuery: _propTypes["default"].bool,
480
+ correctValue: _propTypes["default"].string
481
+ });
482
+ var _default = exports["default"] = Dropdown;
483
+ //# sourceMappingURL=dropdown.js.map