@pie-lib/drag 2.22.1 → 2.23.0-mui-update.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -11
- package/lib/drag-in-the-blank-dp.js +28 -24
- package/lib/drag-in-the-blank-dp.js.map +1 -1
- package/lib/drag-provider.js +47 -0
- package/lib/drag-provider.js.map +1 -0
- package/lib/drag-type.js +2 -3
- package/lib/drag-type.js.map +1 -1
- package/lib/draggable-choice.js +87 -0
- package/lib/draggable-choice.js.map +1 -0
- package/lib/droppable-placeholder.js +33 -65
- package/lib/droppable-placeholder.js.map +1 -1
- package/lib/ica-dp.js +38 -26
- package/lib/ica-dp.js.map +1 -1
- package/lib/index.js +7 -35
- package/lib/index.js.map +1 -1
- package/lib/match-list-dp.js +38 -26
- package/lib/match-list-dp.js.map +1 -1
- package/lib/placeholder.js +77 -102
- package/lib/placeholder.js.map +1 -1
- package/lib/preview-component.js +67 -107
- package/lib/preview-component.js.map +1 -1
- package/lib/swap.js +1 -7
- package/lib/swap.js.map +1 -1
- package/lib/uid-context.js +4 -18
- package/lib/uid-context.js.map +1 -1
- package/package.json +12 -10
- package/src/drag-in-the-blank-dp.jsx +32 -15
- package/src/drag-provider.jsx +40 -0
- package/src/drag-type.js +1 -1
- package/src/draggable-choice.jsx +87 -0
- package/src/droppable-placeholder.jsx +38 -28
- package/src/ica-dp.jsx +41 -18
- package/src/index.js +4 -8
- package/src/match-list-dp.jsx +41 -18
- package/src/placeholder.jsx +64 -71
- package/src/preview-component.jsx +62 -70
- package/lib/choice.js +0 -129
- package/lib/choice.js.map +0 -1
- package/lib/with-drag-context.js +0 -59
- package/lib/with-drag-context.js.map +0 -1
- package/src/choice.jsx +0 -76
- package/src/with-drag-context.js +0 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preview-component.jsx"],"names":["styles","maskBlank","backgroundColor","color","white","border","text","alignItems","display","height","minHeight","fontSize","whiteSpace","maxWidth","borderRadius","padding","ica","background","borderDark","justifyContent","marginLeft","marginTop","width","categorize","matchList","boxSizing","placementOrdering","getPrompt","itemType","item","choice","value","undefined","getCustomStyle","touchPosition","style","transform","x","y","top","left","position","PreviewComponent","preview","setTouchPosition","zoomLevel","setZoomLevel","handleTouchMove","event","touches","length","touch","touchOffset","clientX","clientY","root","current","zoomAffectedElement","document","querySelector","body","parseFloat","getComputedStyle","zoom","touchMoveListener","window","addEventListener","removeEventListener","customStyle","prompt"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG;AACbC,EAAAA,SAAS,EAAE;AACT;AACA;AACAC,IAAAA,eAAe,EAAEC,gBAAMC,KAAN,EAHR;AAITC,IAAAA,MAAM,sBAAeF,gBAAMG,IAAN,EAAf,CAJG;AAKTH,IAAAA,KAAK,EAAEA,gBAAMG,IAAN,EALE;AAMTC,IAAAA,UAAU,EAAE,QANH;AAOTC,IAAAA,OAAO,EAAE,aAPA;AAQTC,IAAAA,MAAM,EAAE,SARC;AASTC,IAAAA,SAAS,EAAE,MATF;AAUTC,IAAAA,QAAQ,EAAE,SAVD;AAWTC,IAAAA,UAAU,EAAE,UAXH;AAYTC,IAAAA,QAAQ,EAAE,OAZD;AAaTC,IAAAA,YAAY,EAAE,KAbL;AAcTC,IAAAA,OAAO,EAAE;AAdA,GADE;AAiBbC,EAAAA,GAAG,EAAE;AACHd,IAAAA,eAAe,EAAEC,gBAAMc,UAAN,EADd;AAEHZ,IAAAA,MAAM,sBAAeF,gBAAMe,UAAN,EAAf,CAFH;AAGHV,IAAAA,OAAO,EAAE,MAHN;AAIHD,IAAAA,UAAU,EAAE,QAJT;AAKHY,IAAAA,cAAc,EAAE,QALb;AAMHT,IAAAA,SAAS,EAAE,MANR;AAOHK,IAAAA,OAAO,EAAE,OAPN;AAQHK,IAAAA,UAAU,EAAE,CART;AASHC,IAAAA,SAAS,EAAE,CATR;AAUHC,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AAgB,CAACL,mBAAD,CAAhB,CAAsCM,IAAvC,CAAV,IAA0D,CAA3D,CAAZ;AACD;AACF,GATD,EASG,CAACvD,OAAD,EAAUqB,IAAV,aAAUA,IAAV,wCAAUA,IAAI,CAAEC,MAAhB,kDAAU,cAAcC,KAAxB,EAA+BF,IAA/B,aAA+BA,IAA/B,uBAA+BA,IAAI,CAAEE,KAArC,EAA4CH,QAA5C,EAAsDC,IAAtD,CATH;AAWA,wBAAU,YAAM;AACd,QAAMmC,iBAAiB,GAAG,SAApBA,iBAAoB,CAAChB,KAAD;AAAA,aAAWD,eAAe,CAACC,KAAD,CAA1B;AAAA,KAA1B;;AACA,QAAIxC,OAAJ,EAAa;AACXyD,MAAAA,MAAM,CAACC,gBAAP,CAAwB,WAAxB,EAAqCF,iBAArC;AACD;;AACD,WAAO,YAAM;AACXC,MAAAA,MAAM,CAACE,mBAAP,CAA2B,WAA3B,EAAwCH,iBAAxC;AACD,KAFD;AAGD,GARD,EAQG,CAACxD,OAAD,EAAUuC,eAAV,CARH;;AAUA,MAAI,CAACvC,OAAL,EAAc;AACZ,WAAO,IAAP;AACD;;AAED,MAAM4D,WAAW,GAAGnC,cAAc,CAACL,QAAD,EAAWC,IAAX,EAAiBK,aAAjB,EAAgCC,KAAhC,CAAlC;AAEA,MAAMkC,MAAM,GAAG1C,SAAS,CAACC,QAAD,EAAWC,IAAX,CAAxB;AAEA,sBACE;AAAK,IAAA,GAAG,EAAE0B,IAAV;AAAgB,IAAA,KAAK,EAAEa;AAAvB,kBACE,gCAAC,uBAAD;AAAe,IAAA,SAAS,EAAC,OAAzB;AAAiC,IAAA,MAAM,EAAEC,MAAzC;AAAiD,IAAA,OAAO,EAAC;AAAzD,IADF,CADF;AAKD,CAxDD;;eA0De3B,gB","sourcesContent":["import React, { useEffect, useRef, useState, useCallback } from 'react';\nimport { usePreview } from 'react-dnd-multi-backend';\nimport { PreviewPrompt, color } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nconst styles = {\n maskBlank: {\n // this style is applied only on small screens and for touch devices when dragging, for drag-in-the-blank.\n // It is styled to be identical to the drag-in-the-blank chip\n backgroundColor: color.white(),\n border: `1px solid ${color.text()}`,\n color: color.text(),\n alignItems: 'center',\n display: 'inline-flex',\n height: 'initial',\n minHeight: '32px',\n fontSize: 'inherit',\n whiteSpace: 'pre-wrap',\n maxWidth: '374px',\n borderRadius: '3px',\n padding: '12px',\n },\n ica: {\n backgroundColor: color.background(),\n border: `1px solid ${color.borderDark()}`,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '28px',\n padding: '0 3px',\n marginLeft: 2,\n marginTop: 2,\n width: 'fit-content',\n },\n categorize: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '16px',\n borderRadius: '4px',\n border: '1px solid',\n },\n matchList: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n },\n placementOrdering: {\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n backgroundColor: color.background(),\n },\n};\n\nconst getPrompt = (itemType, item) => {\n switch (itemType) {\n // DRAG-IN-THE-BLANK\n case 'MaskBlank':\n return item?.choice?.value;\n // IMAGE-CLOZE-ASSOCIATION\n case 'react-dnd-response':\n return item?.value;\n // MATCH-LIST\n case 'Answer':\n return item?.value;\n // PLACEMENT-ORDERING\n case 'Tile':\n return item?.value;\n default:\n return item?.itemType === 'categorize' ? item?.value : undefined;\n }\n};\n\nconst getCustomStyle = (itemType, item, touchPosition, style) => {\n const transform = `translate(${touchPosition.x}px, ${touchPosition.y}px)`;\n const top = style?.top || 0;\n const left = style?.left || 0;\n const position = style?.position || 'fixed';\n\n return {\n position,\n top,\n left,\n transform,\n ...(itemType === 'MaskBlank' ? styles.maskBlank : {}),\n ...(item?.itemType === 'categorize' ? styles.categorize : {}),\n ...(itemType === 'Answer' ? styles.matchList : {}),\n ...(itemType === 'Tile' ? styles.placementOrdering : {}),\n ...(itemType === 'react-dnd-response' ? styles.ica : {}),\n };\n};\n\nconst PreviewComponent = () => {\n const preview = usePreview();\n const { itemType, item, style, display } = preview;\n const [touchPosition, setTouchPosition] = useState({ x: 0, y: 0 });\n const [zoomLevel, setZoomLevel] = useState(1);\n\n const handleTouchMove = useCallback(\n (event) => {\n if (event.touches.length > 0) {\n const touch = event.touches[0];\n const touchOffset = 1;\n setTouchPosition({\n x: (touch.clientX + touchOffset) / zoomLevel,\n y: (touch.clientY + touchOffset) / zoomLevel,\n });\n }\n },\n [zoomLevel],\n );\n\n const root = useRef(null);\n\n useEffect(() => {\n if (display && root.current) {\n renderMath(root.current);\n\n // Adjusted for precise zoom level calculation in Online Testing, targeting the specific class pattern .asmt-zoomable.asmt-zoom-NR .asmt-question .padding\n const zoomAffectedElement = document.querySelector('.padding') || document.body;\n\n setZoomLevel(parseFloat(getComputedStyle(zoomAffectedElement).zoom) || 1);\n }\n }, [display, item?.choice?.value, item?.value, itemType, item]);\n\n useEffect(() => {\n const touchMoveListener = (event) => handleTouchMove(event);\n if (display) {\n window.addEventListener('touchmove', touchMoveListener);\n }\n return () => {\n window.removeEventListener('touchmove', touchMoveListener);\n };\n }, [display, handleTouchMove]);\n\n if (!display) {\n return null;\n }\n\n const customStyle = getCustomStyle(itemType, item, touchPosition, style);\n\n const prompt = getPrompt(itemType, item);\n\n return (\n <div ref={root} style={customStyle}>\n <PreviewPrompt className=\"label\" prompt={prompt} tagName=\"span\" />\n </div>\n );\n};\n\nexport default PreviewComponent;\n"],"file":"preview-component.js"}
|
|
1
|
+
{"version":3,"file":"preview-component.js","names":["_react","_interopRequireWildcard","require","_core","_renderUi","_mathRendering","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","styles","maskBlank","backgroundColor","color","white","border","concat","text","alignItems","display","height","minHeight","fontSize","whiteSpace","maxWidth","borderRadius","padding","ica","background","borderDark","justifyContent","marginLeft","marginTop","width","categorize","matchList","boxSizing","placementOrdering","getPrompt","dragData","_dragData$choice","undefined","choiceId","value","itemType","choice","getCustomStyle","baseStyle","cursor","opacity","transform","PreviewComponent","_active$data","_useDndContext","useDndContext","active","_useState","useState","_useState2","_slicedToArray2","zoomLevel","setZoomLevel","root","useRef","data","current","isActive","useEffect","renderMath","zoomAffectedElement","document","querySelector","body","parseFloat","getComputedStyle","zoom","customStyle","prompt","createElement","DragOverlay","ref","style","PreviewPrompt","className","tagName","_default","exports"],"sources":["../src/preview-component.jsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { DragOverlay, useDndContext } from '@dnd-kit/core';\nimport { PreviewPrompt, color } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nconst styles = {\n maskBlank: {\n // this style is applied only on small screens and for touch devices when dragging, for drag-in-the-blank.\n // It is styled to be identical to the drag-in-the-blank chip\n backgroundColor: color.white(),\n border: `1px solid ${color.text()}`,\n color: color.text(),\n alignItems: 'center',\n display: 'inline-flex',\n height: 'initial',\n minHeight: '32px',\n fontSize: 'inherit',\n whiteSpace: 'pre-wrap',\n maxWidth: '374px',\n borderRadius: '3px',\n padding: '12px',\n },\n ica: {\n backgroundColor: color.background(),\n border: `1px solid ${color.borderDark()}`,\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: '28px',\n padding: '0 3px',\n marginLeft: 2,\n marginTop: 2,\n width: 'fit-content',\n },\n categorize: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '16px',\n borderRadius: '4px',\n border: '1px solid',\n },\n matchList: {\n color: color.text(),\n backgroundColor: color.background(),\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n },\n placementOrdering: {\n padding: '10px',\n boxSizing: 'border-box',\n border: '1px solid #D1D1D1',\n backgroundColor: color.background(),\n },\n};\n\nconst getPrompt = (dragData) => {\n if (!dragData) return undefined;\n\n // Handle different drag data structures based on the component type\n if (dragData.choiceId) {\n // DraggableChoice format\n return dragData.value;\n }\n \n // Legacy format support\n switch (dragData.itemType) {\n case 'MaskBlank':\n return dragData.choice?.value;\n case 'dnd-kit-response':\n return dragData.value;\n case 'Answer':\n return dragData.value;\n case 'Tile':\n return dragData.value;\n case 'categorize':\n return dragData.value;\n default:\n return dragData.value;\n }\n};\n\nconst getCustomStyle = (dragData) => {\n if (!dragData) return {};\n\n const baseStyle = {\n cursor: 'grabbing',\n opacity: 0.8,\n transform: 'rotate(5deg)', // Slight rotation for visual feedback\n };\n\n // Apply specific styles based on item type\n if (dragData.itemType === 'MaskBlank') {\n return { ...baseStyle, ...styles.maskBlank };\n }\n if (dragData.itemType === 'categorize') {\n return { ...baseStyle, ...styles.categorize };\n }\n if (dragData.itemType === 'Answer') {\n return { ...baseStyle, ...styles.matchList };\n }\n if (dragData.itemType === 'Tile') {\n return { ...baseStyle, ...styles.placementOrdering };\n }\n if (dragData.itemType === 'dnd-kit-response') {\n return { ...baseStyle, ...styles.ica };\n }\n\n // Default style for choice items\n return { ...baseStyle, ...styles.categorize };\n};\n\nconst PreviewComponent = () => {\n const { active } = useDndContext();\n const [zoomLevel, setZoomLevel] = useState(1);\n const root = useRef(null);\n\n const dragData = active?.data?.current;\n const isActive = !!active;\n\n useEffect(() => {\n if (isActive && root.current) {\n renderMath(root.current);\n\n // Adjusted for precise zoom level calculation in Online Testing, targeting the specific class pattern .asmt-zoomable.asmt-zoom-NR .asmt-question .padding\n const zoomAffectedElement = document.querySelector('.padding') || document.body;\n setZoomLevel(parseFloat(getComputedStyle(zoomAffectedElement).zoom) || 1);\n }\n }, [isActive, dragData]);\n\n const customStyle = getCustomStyle(dragData);\n const prompt = getPrompt(dragData);\n\n return (\n <DragOverlay>\n {isActive && prompt && (\n <div ref={root} style={customStyle}>\n <PreviewPrompt className=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,CAAC,CAAC;EAExB,IAAMqC,WAAW,GAAG9B,cAAc,CAACP,QAAQ,CAAC;EAC5C,IAAMsC,MAAM,GAAGvC,SAAS,CAACC,QAAQ,CAAC;EAElC,oBACErE,MAAA,YAAA4G,aAAA,CAACzG,KAAA,CAAA0G,WAAW,QACTb,QAAQ,IAAIW,MAAM,iBACjB3G,MAAA,YAAA4G,aAAA;IAAKE,GAAG,EAAElB,IAAK;IAACmB,KAAK,EAAEL;EAAY,gBACjC1G,MAAA,YAAA4G,aAAA,CAACxG,SAAA,CAAA4G,aAAa;IAACC,SAAS,EAAC,OAAO;IAACN,MAAM,EAAEA,MAAO;IAACO,OAAO,EAAC;EAAM,CAAE,CAC9D,CAEI,CAAC;AAElB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,cAEanC,gBAAgB","ignoreList":[]}
|
package/lib/swap.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
11
|
-
|
|
12
|
-
var _default = function _default(arr, fromIndex, toIndex) {
|
|
9
|
+
var _default = exports["default"] = function _default(arr, fromIndex, toIndex) {
|
|
13
10
|
if (!arr || arr.length <= 1 || fromIndex === undefined || toIndex === undefined) {
|
|
14
11
|
throw new Error("swap requires a non-empty array, fromIndex, toIndex: ".concat(arr, ", ").concat(fromIndex, " ").concat(toIndex));
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
var update = (0, _cloneDeep["default"])(arr);
|
|
18
14
|
var tmp = arr[toIndex];
|
|
19
15
|
update[toIndex] = update[fromIndex];
|
|
20
16
|
update[fromIndex] = tmp;
|
|
21
17
|
return update;
|
|
22
18
|
};
|
|
23
|
-
|
|
24
|
-
exports["default"] = _default;
|
|
25
19
|
//# sourceMappingURL=swap.js.map
|
package/lib/swap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"swap.js","names":["_cloneDeep","_interopRequireDefault","require","_default","exports","arr","fromIndex","toIndex","length","undefined","Error","concat","update","cloneDeep","tmp"],"sources":["../src/swap.js"],"sourcesContent":["import cloneDeep from 'lodash/cloneDeep';\n\nexport default (arr, fromIndex, toIndex) => {\n if (!arr || arr.length <= 1 || fromIndex === undefined || toIndex === undefined) {\n throw new Error(`swap requires a non-empty array, fromIndex, toIndex: ${arr}, ${fromIndex} ${toIndex}`);\n }\n\n const update = cloneDeep(arr);\n const tmp = arr[toIndex];\n update[toIndex] = update[fromIndex];\n update[fromIndex] = tmp;\n\n return update;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyC,IAAAC,QAAA,GAAAC,OAAA,cAE1B,SAAAD,SAACE,GAAG,EAAEC,SAAS,EAAEC,OAAO,EAAK;EAC1C,IAAI,CAACF,GAAG,IAAIA,GAAG,CAACG,MAAM,IAAI,CAAC,IAAIF,SAAS,KAAKG,SAAS,IAAIF,OAAO,KAAKE,SAAS,EAAE;IAC/E,MAAM,IAAIC,KAAK,yDAAAC,MAAA,CAAyDN,GAAG,QAAAM,MAAA,CAAKL,SAAS,OAAAK,MAAA,CAAIJ,OAAO,CAAE,CAAC;EACzG;EAEA,IAAMK,MAAM,GAAG,IAAAC,qBAAS,EAACR,GAAG,CAAC;EAC7B,IAAMS,GAAG,GAAGT,GAAG,CAACE,OAAO,CAAC;EACxBK,MAAM,CAACL,OAAO,CAAC,GAAGK,MAAM,CAACN,SAAS,CAAC;EACnCM,MAAM,CAACN,SAAS,CAAC,GAAGQ,GAAG;EAEvB,OAAOF,MAAM;AACf,CAAC","ignoreList":[]}
|
package/lib/uid-context.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.withUid = exports.generateId = exports.Provider = exports.Consumer = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
10
|
var _React$createContext = /*#__PURE__*/_react["default"].createContext(-1),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
exports.Provider = Provider;
|
|
19
|
-
exports.Consumer = Consumer;
|
|
20
|
-
|
|
21
|
-
var generateId = function generateId() {
|
|
11
|
+
Consumer = exports.Consumer = _React$createContext.Consumer,
|
|
12
|
+
Provider = exports.Provider = _React$createContext.Provider;
|
|
13
|
+
var generateId = exports.generateId = function generateId() {
|
|
22
14
|
return (Math.random() * 1000001).toFixed(0);
|
|
23
15
|
};
|
|
24
|
-
|
|
25
|
-
exports.generateId = generateId;
|
|
26
|
-
|
|
27
|
-
var withUid = function withUid(Component) {
|
|
16
|
+
var withUid = exports.withUid = function withUid(Component) {
|
|
28
17
|
var Wrapped = function Wrapped(props) {
|
|
29
18
|
return /*#__PURE__*/_react["default"].createElement(Consumer, null, function (uid) {
|
|
30
19
|
return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, props, {
|
|
@@ -32,9 +21,6 @@ var withUid = function withUid(Component) {
|
|
|
32
21
|
}));
|
|
33
22
|
});
|
|
34
23
|
};
|
|
35
|
-
|
|
36
24
|
return Wrapped;
|
|
37
25
|
};
|
|
38
|
-
|
|
39
|
-
exports.withUid = withUid;
|
|
40
26
|
//# sourceMappingURL=uid-context.js.map
|
package/lib/uid-context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"uid-context.js","names":["_react","_interopRequireDefault","require","_React$createContext","React","createContext","Consumer","exports","Provider","generateId","Math","random","toFixed","withUid","Component","Wrapped","props","createElement","uid","_extends2"],"sources":["../src/uid-context.js"],"sourcesContent":["import React from 'react';\n\nconst { Consumer, Provider } = React.createContext(-1);\n\nexport { Provider, Consumer };\n\nexport const generateId = () => (Math.random() * 1000001).toFixed(0);\n\nexport const withUid = (Component) => {\n const Wrapped = (props) => <Consumer>{(uid) => <Component {...props} uid={uid} />}</Consumer>;\n\n return Wrapped;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,oBAAA,gBAA+BC,iBAAK,CAACC,aAAa,CAAC,CAAC,CAAC,CAAC;EAA9CC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAAH,oBAAA,CAARG,QAAQ;EAAEE,QAAQ,GAAAD,OAAA,CAAAC,QAAA,GAAAL,oBAAA,CAARK,QAAQ;AAInB,IAAMC,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,SAAbA,UAAUA,CAAA;EAAA,OAAS,CAACC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,OAAO,EAAEC,OAAO,CAAC,CAAC,CAAC;AAAA;AAE7D,IAAMC,OAAO,GAAAN,OAAA,CAAAM,OAAA,GAAG,SAAVA,OAAOA,CAAIC,SAAS,EAAK;EACpC,IAAMC,OAAO,GAAG,SAAVA,OAAOA,CAAIC,KAAK;IAAA,oBAAKhB,MAAA,YAAAiB,aAAA,CAACX,QAAQ,QAAE,UAACY,GAAG;MAAA,oBAAKlB,MAAA,YAAAiB,aAAA,CAACH,SAAS,MAAAK,SAAA,iBAAKH,KAAK;QAAEE,GAAG,EAAEA;MAAI,EAAE,CAAC;IAAA,CAAW,CAAC;EAAA;EAE7F,OAAOH,OAAO;AAChB,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/drag",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0-mui-update.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@
|
|
9
|
-
"@
|
|
10
|
-
"@
|
|
8
|
+
"@dnd-kit/core": "6.1.0",
|
|
9
|
+
"@dnd-kit/sortable": "8.0.0",
|
|
10
|
+
"@dnd-kit/utilities": "3.2.2",
|
|
11
|
+
"@emotion/react": "^11.14.0",
|
|
12
|
+
"@emotion/style": "^0.8.0",
|
|
13
|
+
"@mui/icons-material": "^7.3.4",
|
|
14
|
+
"@mui/material": "^7.3.4",
|
|
15
|
+
"@pie-lib/math-rendering": "^3.27.0-mui-update.0",
|
|
16
|
+
"@pie-lib/render-ui": "^4.36.0-mui-update.0",
|
|
11
17
|
"classnames": "^2.2.6",
|
|
12
18
|
"lodash": "^4.17.11",
|
|
13
19
|
"prop-types": "^15.7.2",
|
|
14
|
-
"react": "^
|
|
15
|
-
"react-dnd": "^14.0.5",
|
|
16
|
-
"react-dnd-html5-backend": "^14.0.2",
|
|
17
|
-
"react-dnd-multi-backend": "^6.0.2",
|
|
18
|
-
"react-dnd-touch-backend": "^12.0.0"
|
|
20
|
+
"react": "^18.2.0"
|
|
19
21
|
},
|
|
20
22
|
"publishConfig": {
|
|
21
23
|
"access": "public"
|
|
@@ -23,5 +25,5 @@
|
|
|
23
25
|
"scripts": {},
|
|
24
26
|
"author": "",
|
|
25
27
|
"license": "ISC",
|
|
26
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "2e0222bda045f46b504640a972d43787e68288c4"
|
|
27
29
|
}
|
|
@@ -1,19 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import { DroppablePlaceholder } from './droppable-placeholder';
|
|
3
|
-
import dragType from './drag-type';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
// With @dnd-kit, the drop logic is handled in the DragProvider's onDragEnd callback
|
|
6
|
+
// This component now just wraps DroppablePlaceholder with drag-in-the-blank specific logic
|
|
7
|
+
|
|
8
|
+
export function DragInTheBlankDroppable({
|
|
9
|
+
id,
|
|
10
|
+
children,
|
|
11
|
+
disabled,
|
|
12
|
+
onDrop,
|
|
13
|
+
...rest
|
|
14
|
+
}) {
|
|
15
|
+
// The actual drop handling will be managed by the parent component
|
|
16
|
+
// through the DragProvider's onDragEnd callback
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<DroppablePlaceholder
|
|
20
|
+
id={id}
|
|
21
|
+
disabled={disabled}
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</DroppablePlaceholder>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
29
|
+
DragInTheBlankDroppable.propTypes = {
|
|
30
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
31
|
+
children: PropTypes.node,
|
|
32
|
+
disabled: PropTypes.bool,
|
|
33
|
+
onDrop: PropTypes.func,
|
|
34
|
+
};
|
|
18
35
|
|
|
19
|
-
export default
|
|
36
|
+
export default DragInTheBlankDroppable;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { DndContext, PointerSensor, KeyboardSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
4
|
+
|
|
5
|
+
export function DragProvider({ children, onDragEnd }) {
|
|
6
|
+
const [activeId, setActiveId] = useState(null);
|
|
7
|
+
|
|
8
|
+
const sensors = useSensors(
|
|
9
|
+
useSensor(PointerSensor, { activationConstraint: { distance: 8 }}),
|
|
10
|
+
useSensor(KeyboardSensor)
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const handleDragStart = (event) => {
|
|
14
|
+
setActiveId(event.active.id);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const handleDragEnd = (event) => {
|
|
18
|
+
setActiveId(null);
|
|
19
|
+
if (onDragEnd) {
|
|
20
|
+
onDragEnd(event);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<DndContext
|
|
26
|
+
sensors={sensors}
|
|
27
|
+
onDragStart={handleDragStart}
|
|
28
|
+
onDragEnd={handleDragEnd}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</DndContext>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
DragProvider.propTypes = {
|
|
36
|
+
children: PropTypes.node.isRequired,
|
|
37
|
+
onDragEnd: PropTypes.func,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default DragProvider;
|
package/src/drag-type.js
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { useDraggable } from '@dnd-kit/core';
|
|
5
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
6
|
+
import { grey } from '@mui/material/colors';
|
|
7
|
+
|
|
8
|
+
export const DRAG_TYPE = 'CHOICE';
|
|
9
|
+
|
|
10
|
+
const StyledChoice = styled('div')(({ theme, isDragging }) => ({
|
|
11
|
+
backgroundColor: theme.palette.background.paper,
|
|
12
|
+
border: `solid 1px ${grey[400]}`,
|
|
13
|
+
padding: theme.spacing(1),
|
|
14
|
+
minHeight: '30px',
|
|
15
|
+
minWidth: theme.spacing(20),
|
|
16
|
+
maxWidth: theme.spacing(75),
|
|
17
|
+
cursor: 'grab',
|
|
18
|
+
opacity: isDragging ? 0.5 : 1,
|
|
19
|
+
'&:active': {
|
|
20
|
+
cursor: 'grabbing',
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
export function DraggableChoice({
|
|
25
|
+
choice,
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
disabled,
|
|
29
|
+
category,
|
|
30
|
+
alternateResponseIndex,
|
|
31
|
+
choiceIndex,
|
|
32
|
+
onRemoveChoice
|
|
33
|
+
}) {
|
|
34
|
+
const {
|
|
35
|
+
attributes,
|
|
36
|
+
listeners,
|
|
37
|
+
setNodeRef,
|
|
38
|
+
transform,
|
|
39
|
+
isDragging
|
|
40
|
+
} = useDraggable({
|
|
41
|
+
id: choice.id,
|
|
42
|
+
disabled: disabled,
|
|
43
|
+
data: {
|
|
44
|
+
value: choice.value,
|
|
45
|
+
choiceId: choice.id,
|
|
46
|
+
from: category?.id,
|
|
47
|
+
alternateResponseIndex,
|
|
48
|
+
choiceIndex,
|
|
49
|
+
onRemoveChoice
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const style = {
|
|
54
|
+
transform: CSS.Translate.toString(transform),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<StyledChoice
|
|
59
|
+
ref={setNodeRef}
|
|
60
|
+
style={style}
|
|
61
|
+
className={className}
|
|
62
|
+
isDragging={isDragging}
|
|
63
|
+
{...attributes}
|
|
64
|
+
{...listeners}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</StyledChoice>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
DraggableChoice.propTypes = {
|
|
72
|
+
choice: PropTypes.shape({
|
|
73
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
74
|
+
value: PropTypes.any,
|
|
75
|
+
}).isRequired,
|
|
76
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
77
|
+
className: PropTypes.string,
|
|
78
|
+
disabled: PropTypes.bool,
|
|
79
|
+
category: PropTypes.shape({
|
|
80
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
81
|
+
}),
|
|
82
|
+
alternateResponseIndex: PropTypes.number,
|
|
83
|
+
choiceIndex: PropTypes.number,
|
|
84
|
+
onRemoveChoice: PropTypes.func,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default DraggableChoice;
|
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PlaceHolder from './placeholder';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
4
5
|
|
|
5
6
|
const preventInteractionStyle = {
|
|
6
7
|
flex: 1,
|
|
7
8
|
};
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
export function DroppablePlaceholder({
|
|
11
|
+
id,
|
|
12
|
+
children,
|
|
13
|
+
disabled,
|
|
14
|
+
classes,
|
|
15
|
+
isVerticalPool,
|
|
16
|
+
minHeight
|
|
17
|
+
}) {
|
|
18
|
+
const { setNodeRef, isOver } = useDroppable({
|
|
19
|
+
id,
|
|
20
|
+
disabled
|
|
21
|
+
});
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</PlaceHolder>
|
|
35
|
-
</div>,
|
|
36
|
-
);
|
|
37
|
-
}
|
|
23
|
+
return (
|
|
24
|
+
<div ref={setNodeRef} style={preventInteractionStyle}>
|
|
25
|
+
<PlaceHolder
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
isOver={isOver}
|
|
28
|
+
choiceBoard={true}
|
|
29
|
+
className={classes}
|
|
30
|
+
isVerticalPool={isVerticalPool}
|
|
31
|
+
minHeight={minHeight}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</PlaceHolder>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
38
37
|
}
|
|
38
|
+
|
|
39
|
+
DroppablePlaceholder.propTypes = {
|
|
40
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
41
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
42
|
+
disabled: PropTypes.bool,
|
|
43
|
+
classes: PropTypes.object,
|
|
44
|
+
isVerticalPool: PropTypes.bool,
|
|
45
|
+
minHeight: PropTypes.number,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default DroppablePlaceholder;
|
package/src/ica-dp.jsx
CHANGED
|
@@ -1,23 +1,46 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import { DroppablePlaceholder } from './droppable-placeholder';
|
|
3
|
-
import dragType from './drag-type';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return !props.disabled;
|
|
8
|
-
},
|
|
9
|
-
drop: (props, monitor) => {
|
|
10
|
-
const item = monitor.getItem();
|
|
5
|
+
// With @dnd-kit, the drop logic is handled in the DragProvider's onDragEnd callback
|
|
6
|
+
// This component now just wraps DroppablePlaceholder with ICA specific logic
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export function ICADroppable({
|
|
9
|
+
id,
|
|
10
|
+
children,
|
|
11
|
+
disabled,
|
|
12
|
+
onRemoveAnswer,
|
|
13
|
+
...rest
|
|
14
|
+
}) {
|
|
15
|
+
// The actual drop handling will be managed by the parent component
|
|
16
|
+
// through the DragProvider's onDragEnd callback
|
|
17
|
+
// The onRemoveAnswer logic should be handled in the parent's onDragEnd:
|
|
18
|
+
//
|
|
19
|
+
// const handleDragEnd = (event) => {
|
|
20
|
+
// if (event.over && event.active) {
|
|
21
|
+
// const item = event.active.data.current;
|
|
22
|
+
// if (onRemoveAnswer) {
|
|
23
|
+
// onRemoveAnswer(item);
|
|
24
|
+
// }
|
|
25
|
+
// }
|
|
26
|
+
// };
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<DroppablePlaceholder
|
|
30
|
+
id={id}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
{...rest}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</DroppablePlaceholder>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
17
38
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
ICADroppable.propTypes = {
|
|
40
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
41
|
+
children: PropTypes.node,
|
|
42
|
+
disabled: PropTypes.bool,
|
|
43
|
+
onRemoveAnswer: PropTypes.func,
|
|
44
|
+
};
|
|
22
45
|
|
|
23
|
-
export default
|
|
46
|
+
export default ICADroppable;
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { DragSource, DropTarget } from 'react-dnd';
|
|
2
|
-
|
|
3
1
|
import PlaceHolder from './placeholder';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import DraggableChoice from './draggable-choice';
|
|
3
|
+
import DragProvider from './drag-provider';
|
|
6
4
|
import swap from './swap';
|
|
7
5
|
import * as uid from './uid-context';
|
|
8
6
|
import MatchDroppablePlaceholder from './match-list-dp';
|
|
@@ -14,10 +12,8 @@ export {
|
|
|
14
12
|
MatchDroppablePlaceholder,
|
|
15
13
|
DragDroppablePlaceholder,
|
|
16
14
|
ICADroppablePlaceholder,
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
DragProvider,
|
|
16
|
+
DraggableChoice,
|
|
19
17
|
swap,
|
|
20
18
|
uid,
|
|
21
|
-
DragSource,
|
|
22
|
-
DropTarget,
|
|
23
19
|
};
|
package/src/match-list-dp.jsx
CHANGED
|
@@ -1,23 +1,46 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
2
3
|
import { DroppablePlaceholder } from './droppable-placeholder';
|
|
3
|
-
import dragType from './drag-type';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return !props.disabled;
|
|
8
|
-
},
|
|
9
|
-
drop: (props, monitor) => {
|
|
10
|
-
const item = monitor.getItem();
|
|
5
|
+
// With @dnd-kit, the drop logic is handled in the DragProvider's onDragEnd callback
|
|
6
|
+
// This component now just wraps DroppablePlaceholder with match-list specific logic
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
export function MatchListDroppable({
|
|
9
|
+
id,
|
|
10
|
+
children,
|
|
11
|
+
disabled,
|
|
12
|
+
onRemoveAnswer,
|
|
13
|
+
...rest
|
|
14
|
+
}) {
|
|
15
|
+
// The actual drop handling will be managed by the parent component
|
|
16
|
+
// through the DragProvider's onDragEnd callback
|
|
17
|
+
// The onRemoveAnswer logic should be handled in the parent's onDragEnd:
|
|
18
|
+
//
|
|
19
|
+
// const handleDragEnd = (event) => {
|
|
20
|
+
// if (event.over && event.active) {
|
|
21
|
+
// const item = event.active.data.current;
|
|
22
|
+
// if (onRemoveAnswer) {
|
|
23
|
+
// onRemoveAnswer(item.promptId);
|
|
24
|
+
// }
|
|
25
|
+
// }
|
|
26
|
+
// };
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<DroppablePlaceholder
|
|
30
|
+
id={id}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
{...rest}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</DroppablePlaceholder>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
17
38
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
MatchListDroppable.propTypes = {
|
|
40
|
+
id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
|
|
41
|
+
children: PropTypes.node,
|
|
42
|
+
disabled: PropTypes.bool,
|
|
43
|
+
onRemoveAnswer: PropTypes.func,
|
|
44
|
+
};
|
|
22
45
|
|
|
23
|
-
export default
|
|
46
|
+
export default MatchListDroppable;
|