@pie-lib/drag 2.2.10-next.1 → 2.3.0-beta.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 +18 -34
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/drag-in-the-blank-dp.js +1 -1
- package/lib/drag-in-the-blank-dp.js.map +1 -1
- package/lib/droppable-placeholder.js +10 -10
- package/lib/droppable-placeholder.js.map +1 -1
- package/lib/placeholder.js +59 -10
- package/lib/placeholder.js.map +1 -1
- package/lib/preview-component.js +68 -16
- package/lib/preview-component.js.map +1 -1
- package/lib/with-drag-context.js +9 -4
- package/lib/with-drag-context.js.map +1 -1
- package/package.json +6 -4
- package/src/__tests__/__snapshots__/placeholder.test.jsx.snap +68 -0
- package/src/__tests__/placeholder.test.jsx +48 -0
- package/src/__tests__/uid-context.test.jsx +21 -0
- package/src/drag-in-the-blank-dp.jsx +1 -1
- package/src/droppable-placeholder.jsx +11 -8
- package/src/placeholder.jsx +65 -6
- package/src/preview-component.jsx +58 -19
- package/src/with-drag-context.js +15 -8
- package/README.md +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,18 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
# [2.3.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.3.0-beta.1) (2025-07-20)
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* revert to pie-lib/math-rendering that what working ([25660ea](https://github.com/pie-framework/pie-lib/commit/25660ea6595e800a71c5494bd3bb9eecd3609a5a))
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/drag
|
|
12
9
|
|
|
13
10
|
|
|
14
11
|
|
|
15
12
|
|
|
16
13
|
|
|
17
|
-
|
|
14
|
+
# [2.3.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.3.0-beta.0) (2025-07-20)
|
|
18
15
|
|
|
19
16
|
**Note:** Version bump only for package @pie-lib/drag
|
|
20
17
|
|
|
@@ -22,71 +19,58 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
22
19
|
|
|
23
20
|
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
# [2.4.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.4.0-beta.0) (2025-07-15)
|
|
26
23
|
|
|
27
24
|
**Note:** Version bump only for package @pie-lib/drag
|
|
28
25
|
|
|
26
|
+
# [2.3.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.3.0-beta.0) (2025-07-15)
|
|
29
27
|
|
|
28
|
+
**Note:** Version bump only for package @pie-lib/drag
|
|
29
|
+
|
|
30
|
+
## [2.2.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.8...@pie-lib/drag@2.2.9) (2023-10-03)
|
|
30
31
|
|
|
32
|
+
### Bug Fixes
|
|
31
33
|
|
|
34
|
+
- revert to pie-lib/math-rendering that what working ([25660ea](https://github.com/pie-framework/pie-lib/commit/25660ea6595e800a71c5494bd3bb9eecd3609a5a))
|
|
32
35
|
|
|
33
|
-
## [2.2.
|
|
36
|
+
## [2.2.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.7...@pie-lib/drag@2.2.8) (2023-10-01)
|
|
34
37
|
|
|
35
38
|
**Note:** Version bump only for package @pie-lib/drag
|
|
36
39
|
|
|
40
|
+
## [2.2.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.6...@pie-lib/drag@2.2.7) (2023-09-27)
|
|
37
41
|
|
|
42
|
+
**Note:** Version bump only for package @pie-lib/drag
|
|
38
43
|
|
|
44
|
+
## [2.2.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.5...@pie-lib/drag@2.2.6) (2023-09-27)
|
|
39
45
|
|
|
46
|
+
**Note:** Version bump only for package @pie-lib/drag
|
|
40
47
|
|
|
41
48
|
## [2.2.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.4...@pie-lib/drag@2.2.5) (2023-09-27)
|
|
42
49
|
|
|
43
|
-
|
|
44
50
|
### Bug Fixes
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
- add required packages ([b0b6855](https://github.com/pie-framework/pie-lib/commit/b0b6855418a988ed6ea911c97425b89fbab2794d))
|
|
51
53
|
|
|
52
54
|
## [2.2.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.3...@pie-lib/drag@2.2.4) (2023-08-07)
|
|
53
55
|
|
|
54
|
-
|
|
55
56
|
### Bug Fixes
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
- **drag:** create droppablePlaceholder for ICA PD-3050 ([b2e595e](https://github.com/pie-framework/pie-lib/commit/b2e595e66b331147064c6b72fa44ba756078f159))
|
|
62
59
|
|
|
63
60
|
## [2.2.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.2...@pie-lib/drag@2.2.3) (2023-07-31)
|
|
64
61
|
|
|
65
62
|
**Note:** Version bump only for package @pie-lib/drag
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
64
|
## [2.2.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.1...@pie-lib/drag@2.2.2) (2023-07-24)
|
|
72
65
|
|
|
73
|
-
|
|
74
66
|
### Bug Fixes
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
68
|
+
- **drag-in-the-blank:** add preview for draged items on touch backend, wip ([4e4bab6](https://github.com/pie-framework/pie-lib/commit/4e4bab63fb69e53d4cdff303d5bfd4fc18a5c7a0))
|
|
81
69
|
|
|
82
70
|
## [2.2.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.0...@pie-lib/drag@2.2.1) (2023-06-24)
|
|
83
71
|
|
|
84
72
|
**Note:** Version bump only for package @pie-lib/drag
|
|
85
73
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
74
|
# [2.2.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.1.19...@pie-lib/drag@2.2.0) (2023-06-12)
|
|
91
75
|
|
|
92
76
|
### Features
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -9,7 +9,7 @@ exports.spec = exports["default"] = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _reactDnd = require("react-dnd");
|
|
11
11
|
|
|
12
|
-
var _droppablePlaceholder = require("
|
|
12
|
+
var _droppablePlaceholder = require("./droppable-placeholder");
|
|
13
13
|
|
|
14
14
|
var _dragType = _interopRequireDefault(require("./drag-type"));
|
|
15
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/drag-in-the-blank-dp.jsx"],"names":["spec","canDrop","props","disabled","drop","dropped","WithTarget","dragType","types","db","connect","monitor","connectDropTarget","dropTarget","isOver","DroppablePlaceholder"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,IAAMA,IAAI,GAAG;AAClBC,EAAAA,OAAO,EAAE,iBAACC,KAAD,EAAW;AAClB,WAAO,CAACA,KAAK,CAACC,QAAd;AACD,GAHiB;AAIlBC,EAAAA,IAAI,EAAE;AAAA,WAAO;AACXC,MAAAA,OAAO,EAAE;AADE,KAAP;AAAA;AAJY,CAAb;;AASP,IAAMC,UAAU,GAAG,0BAAWC,qBAASC,KAAT,CAAeC,EAA1B,EAA8BT,IAA9B,EAAoC,UAACU,OAAD,EAAUC,OAAV;AAAA,SAAuB;AAC5EC,IAAAA,iBAAiB,EAAEF,OAAO,CAACG,UAAR,EADyD;AAE5EC,IAAAA,MAAM,EAAEH,OAAO,CAACG,MAAR;AAFoE,GAAvB;AAAA,CAApC,EAGfC,0CAHe,CAAnB;eAKeT,U","sourcesContent":["import { DropTarget } from 'react-dnd';\nimport { DroppablePlaceholder } from '
|
|
1
|
+
{"version":3,"sources":["../src/drag-in-the-blank-dp.jsx"],"names":["spec","canDrop","props","disabled","drop","dropped","WithTarget","dragType","types","db","connect","monitor","connectDropTarget","dropTarget","isOver","DroppablePlaceholder"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,IAAMA,IAAI,GAAG;AAClBC,EAAAA,OAAO,EAAE,iBAACC,KAAD,EAAW;AAClB,WAAO,CAACA,KAAK,CAACC,QAAd;AACD,GAHiB;AAIlBC,EAAAA,IAAI,EAAE;AAAA,WAAO;AACXC,MAAAA,OAAO,EAAE;AADE,KAAP;AAAA;AAJY,CAAb;;AASP,IAAMC,UAAU,GAAG,0BAAWC,qBAASC,KAAT,CAAeC,EAA1B,EAA8BT,IAA9B,EAAoC,UAACU,OAAD,EAAUC,OAAV;AAAA,SAAuB;AAC5EC,IAAAA,iBAAiB,EAAEF,OAAO,CAACG,UAAR,EADyD;AAE5EC,IAAAA,MAAM,EAAEH,OAAO,CAACG,MAAR;AAFoE,GAAvB;AAAA,CAApC,EAGfC,0CAHe,CAAnB;eAKeT,U","sourcesContent":["import { DropTarget } from 'react-dnd';\nimport { DroppablePlaceholder } from './droppable-placeholder';\nimport dragType from './drag-type';\n\nexport const spec = {\n canDrop: (props) => {\n return !props.disabled;\n },\n drop: () => ({\n dropped: true,\n }),\n};\n\nconst WithTarget = DropTarget(dragType.types.db, spec, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n}))(DroppablePlaceholder);\n\nexport default WithTarget;\n"],"file":"drag-in-the-blank-dp.js"}
|
|
@@ -30,13 +30,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
30
30
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
31
|
|
|
32
32
|
var preventInteractionStyle = {
|
|
33
|
-
flex: 1
|
|
34
|
-
WebkitTouchCallout: 'none',
|
|
35
|
-
WebkitUserSelect: 'none',
|
|
36
|
-
KhtmlUserSelect: 'none',
|
|
37
|
-
MozUserSelect: 'none',
|
|
38
|
-
MsUserSelect: 'none',
|
|
39
|
-
UserSelect: 'none'
|
|
33
|
+
flex: 1
|
|
40
34
|
};
|
|
41
35
|
|
|
42
36
|
var DroppablePlaceholder = /*#__PURE__*/function (_React$Component) {
|
|
@@ -57,14 +51,18 @@ var DroppablePlaceholder = /*#__PURE__*/function (_React$Component) {
|
|
|
57
51
|
connectDropTarget = _this$props.connectDropTarget,
|
|
58
52
|
isOver = _this$props.isOver,
|
|
59
53
|
disabled = _this$props.disabled,
|
|
60
|
-
classes = _this$props.classes
|
|
54
|
+
classes = _this$props.classes,
|
|
55
|
+
isVerticalPool = _this$props.isVerticalPool,
|
|
56
|
+
minHeight = _this$props.minHeight;
|
|
61
57
|
return connectDropTarget( /*#__PURE__*/_react["default"].createElement("div", {
|
|
62
58
|
style: preventInteractionStyle
|
|
63
59
|
}, /*#__PURE__*/_react["default"].createElement(_placeholder["default"], {
|
|
64
60
|
disabled: disabled,
|
|
65
61
|
isOver: isOver,
|
|
66
62
|
choiceBoard: true,
|
|
67
|
-
className: classes
|
|
63
|
+
className: classes,
|
|
64
|
+
isVerticalPool: isVerticalPool,
|
|
65
|
+
minHeight: minHeight
|
|
68
66
|
}, children)));
|
|
69
67
|
}
|
|
70
68
|
}]);
|
|
@@ -77,6 +75,8 @@ exports.DroppablePlaceholder = DroppablePlaceholder;
|
|
|
77
75
|
connectDropTarget: _propTypes["default"].func.isRequired,
|
|
78
76
|
isOver: _propTypes["default"].bool,
|
|
79
77
|
children: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].node), _propTypes["default"].node]).isRequired,
|
|
80
|
-
disabled: _propTypes["default"].bool
|
|
78
|
+
disabled: _propTypes["default"].bool,
|
|
79
|
+
isVerticalPool: _propTypes["default"].bool,
|
|
80
|
+
minHeight: _propTypes["default"].number
|
|
81
81
|
});
|
|
82
82
|
//# sourceMappingURL=droppable-placeholder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/droppable-placeholder.jsx"],"names":["preventInteractionStyle","flex","
|
|
1
|
+
{"version":3,"sources":["../src/droppable-placeholder.jsx"],"names":["preventInteractionStyle","flex","DroppablePlaceholder","props","children","connectDropTarget","isOver","disabled","classes","isVerticalPool","minHeight","React","Component","PropTypes","object","func","isRequired","bool","oneOfType","arrayOf","node","number"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAEA,IAAMA,uBAAuB,GAAG;AAC9BC,EAAAA,IAAI,EAAE;AADwB,CAAhC;;IAIaC,oB;;;;;;;;;;;;WAWX,kBAAS;AACP,wBAA8F,KAAKC,KAAnG;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,iBAAlB,eAAkBA,iBAAlB;AAAA,UAAqCC,MAArC,eAAqCA,MAArC;AAAA,UAA6CC,QAA7C,eAA6CA,QAA7C;AAAA,UAAuDC,OAAvD,eAAuDA,OAAvD;AAAA,UAAgEC,cAAhE,eAAgEA,cAAhE;AAAA,UAAgFC,SAAhF,eAAgFA,SAAhF;AAEA,aAAOL,iBAAiB,eACtB;AAAK,QAAA,KAAK,EAAEL;AAAZ,sBACE,gCAAC,uBAAD;AACE,QAAA,QAAQ,EAAEO,QADZ;AAEE,QAAA,MAAM,EAAED,MAFV;AAGE,QAAA,WAAW,EAAE,IAHf;AAIE,QAAA,SAAS,EAAEE,OAJb;AAKE,QAAA,cAAc,EAAEC,cALlB;AAME,QAAA,SAAS,EAAEC;AANb,SAQGN,QARH,CADF,CADsB,CAAxB;AAcD;;;EA5BuCO,kBAAMC,S;;;iCAAnCV,oB,eACQ;AACjBM,EAAAA,OAAO,EAAEK,sBAAUC,MADF;AAEjBT,EAAAA,iBAAiB,EAAEQ,sBAAUE,IAAV,CAAeC,UAFjB;AAGjBV,EAAAA,MAAM,EAAEO,sBAAUI,IAHD;AAIjBb,EAAAA,QAAQ,EAAES,sBAAUK,SAAV,CAAoB,CAACL,sBAAUM,OAAV,CAAkBN,sBAAUO,IAA5B,CAAD,EAAoCP,sBAAUO,IAA9C,CAApB,EAAyEJ,UAJlE;AAKjBT,EAAAA,QAAQ,EAAEM,sBAAUI,IALH;AAMjBR,EAAAA,cAAc,EAAEI,sBAAUI,IANT;AAOjBP,EAAAA,SAAS,EAAEG,sBAAUQ;AAPJ,C","sourcesContent":["import React from 'react';\nimport PlaceHolder from './placeholder';\nimport PropTypes from 'prop-types';\n\nconst preventInteractionStyle = {\n flex: 1,\n};\n\nexport class DroppablePlaceholder extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n connectDropTarget: PropTypes.func.isRequired,\n isOver: PropTypes.bool,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n disabled: PropTypes.bool,\n isVerticalPool: PropTypes.bool,\n minHeight: PropTypes.number,\n };\n\n render() {\n const { children, connectDropTarget, isOver, disabled, classes, isVerticalPool, minHeight } = this.props;\n\n return connectDropTarget(\n <div style={preventInteractionStyle}>\n <PlaceHolder\n disabled={disabled}\n isOver={isOver}\n choiceBoard={true}\n className={classes}\n isVerticalPool={isVerticalPool}\n minHeight={minHeight}\n >\n {children}\n </PlaceHolder>\n </div>,\n );\n }\n}\n"],"file":"droppable-placeholder.js"}
|
package/lib/placeholder.js
CHANGED
|
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = exports.PlaceHolder = void 0;
|
|
9
9
|
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
10
12
|
var _react = _interopRequireDefault(require("react"));
|
|
11
13
|
|
|
12
14
|
var _styles = require("@material-ui/core/styles");
|
|
@@ -17,6 +19,12 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
17
19
|
|
|
18
20
|
var _grey = _interopRequireDefault(require("@material-ui/core/colors/grey"));
|
|
19
21
|
|
|
22
|
+
var _renderUi = require("@pie-lib/render-ui");
|
|
23
|
+
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
20
28
|
var PlaceHolder = function PlaceHolder(props) {
|
|
21
29
|
var children = props.children,
|
|
22
30
|
classes = props.classes,
|
|
@@ -25,7 +33,10 @@ var PlaceHolder = function PlaceHolder(props) {
|
|
|
25
33
|
type = props.type,
|
|
26
34
|
grid = props.grid,
|
|
27
35
|
disabled = props.disabled,
|
|
28
|
-
choiceBoard = props.choiceBoard
|
|
36
|
+
choiceBoard = props.choiceBoard,
|
|
37
|
+
isCategorize = props.isCategorize,
|
|
38
|
+
isVerticalPool = props.isVerticalPool,
|
|
39
|
+
minHeight = props.minHeight;
|
|
29
40
|
var names = (0, _classnames["default"])(classes.placeholder, disabled && classes.disabled, isOver && classes.over, classes[type], className);
|
|
30
41
|
var style = {};
|
|
31
42
|
|
|
@@ -36,11 +47,23 @@ var PlaceHolder = function PlaceHolder(props) {
|
|
|
36
47
|
if (grid && grid.rows) {
|
|
37
48
|
var repeatValue = grid.rowsRepeatValue || '1fr';
|
|
38
49
|
style.gridTemplateRows = "repeat(".concat(grid.rows, ", ").concat(repeatValue, ")");
|
|
50
|
+
} // The "type" is only sent through placement-ordering / placeholder
|
|
51
|
+
// It can be "choice" or "target"
|
|
52
|
+
// We apply a different style for the "choice" type
|
|
53
|
+
// For any other type, use a dashed black border and a white fill
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if (type === 'choice') {
|
|
57
|
+
style.border = "1px solid ".concat(_renderUi.color.borderLight());
|
|
58
|
+
style.background = _renderUi.color.backgroundDark();
|
|
39
59
|
}
|
|
40
60
|
|
|
61
|
+
var boardStyle = isCategorize ? classes.categorizeBoard : classes.board;
|
|
41
62
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
42
|
-
style: style,
|
|
43
|
-
|
|
63
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
64
|
+
minHeight: minHeight
|
|
65
|
+
}),
|
|
66
|
+
className: (0, _classnames["default"])(classes.noSelectStyles, choiceBoard ? boardStyle : names, isVerticalPool && classes.verticalPool)
|
|
44
67
|
}, children);
|
|
45
68
|
};
|
|
46
69
|
|
|
@@ -59,22 +82,33 @@ PlaceHolder.propTypes = {
|
|
|
59
82
|
isOver: _propTypes["default"].bool,
|
|
60
83
|
index: _propTypes["default"].number,
|
|
61
84
|
type: _propTypes["default"].string,
|
|
62
|
-
disabled: _propTypes["default"].bool
|
|
85
|
+
disabled: _propTypes["default"].bool,
|
|
86
|
+
isCategorize: _propTypes["default"].bool,
|
|
87
|
+
isVerticalPool: _propTypes["default"].bool,
|
|
88
|
+
minHeight: _propTypes["default"].number
|
|
63
89
|
};
|
|
64
90
|
|
|
65
91
|
var styles = function styles(theme) {
|
|
66
92
|
return {
|
|
93
|
+
noSelectStyles: {
|
|
94
|
+
WebkitTouchCallout: 'none',
|
|
95
|
+
WebkitUserSelect: 'none',
|
|
96
|
+
KhtmlUserSelect: 'none',
|
|
97
|
+
MozUserSelect: 'none',
|
|
98
|
+
MsUserSelect: 'none',
|
|
99
|
+
userSelect: 'none'
|
|
100
|
+
},
|
|
67
101
|
placeholder: {
|
|
68
102
|
width: '100%',
|
|
69
103
|
height: '100%',
|
|
70
|
-
background:
|
|
71
|
-
border: '1px solid #D1D1D1',
|
|
104
|
+
background: _renderUi.color.white(),
|
|
72
105
|
transition: 'background-color 200ms linear, border-color 200ms linear',
|
|
73
106
|
boxSizing: 'border-box',
|
|
74
107
|
display: 'grid',
|
|
75
108
|
gridRowGap: "".concat(theme.spacing.unit, "px"),
|
|
76
109
|
gridColumnGap: "".concat(theme.spacing.unit, "px"),
|
|
77
|
-
padding: theme.spacing.unit * 1
|
|
110
|
+
padding: theme.spacing.unit * 1,
|
|
111
|
+
border: "2px dashed ".concat(_renderUi.color.black())
|
|
78
112
|
},
|
|
79
113
|
disabled: {
|
|
80
114
|
boxShadow: 'none',
|
|
@@ -85,15 +119,30 @@ var styles = function styles(theme) {
|
|
|
85
119
|
backgroundColor: "".concat(_grey["default"][300])
|
|
86
120
|
},
|
|
87
121
|
board: {
|
|
88
|
-
border: '1px solid #D1D1D1',
|
|
89
122
|
padding: theme.spacing.unit,
|
|
90
123
|
display: 'flex',
|
|
91
124
|
flexWrap: 'wrap',
|
|
92
125
|
alignItems: 'center',
|
|
93
|
-
minHeight: '
|
|
126
|
+
minHeight: '100px',
|
|
94
127
|
justifyContent: 'center',
|
|
95
128
|
overflow: 'hidden',
|
|
96
|
-
touchAction: 'none'
|
|
129
|
+
touchAction: 'none',
|
|
130
|
+
backgroundColor: _renderUi.color.backgroundDark()
|
|
131
|
+
},
|
|
132
|
+
categorizeBoard: {
|
|
133
|
+
padding: theme.spacing.unit / 2,
|
|
134
|
+
display: 'flex',
|
|
135
|
+
flexWrap: 'wrap',
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
minHeight: '100px',
|
|
138
|
+
justifyContent: 'center',
|
|
139
|
+
overflow: 'hidden',
|
|
140
|
+
touchAction: 'none',
|
|
141
|
+
backgroundColor: _renderUi.color.backgroundDark()
|
|
142
|
+
},
|
|
143
|
+
verticalPool: {
|
|
144
|
+
display: 'flex',
|
|
145
|
+
flexFlow: 'column wrap'
|
|
97
146
|
}
|
|
98
147
|
};
|
|
99
148
|
};
|
package/lib/placeholder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/placeholder.jsx"],"names":["PlaceHolder","props","children","classes","className","isOver","type","grid","disabled","choiceBoard","names","placeholder","over","style","columns","gridTemplateColumns","rows","repeatValue","rowsRepeatValue","gridTemplateRows","board","propTypes","PropTypes","object","isRequired","bool","shape","number","string","oneOfType","arrayOf","node","index","styles","theme","
|
|
1
|
+
{"version":3,"sources":["../src/placeholder.jsx"],"names":["PlaceHolder","props","children","classes","className","isOver","type","grid","disabled","choiceBoard","isCategorize","isVerticalPool","minHeight","names","placeholder","over","style","columns","gridTemplateColumns","rows","repeatValue","rowsRepeatValue","gridTemplateRows","border","color","borderLight","background","backgroundDark","boardStyle","categorizeBoard","board","noSelectStyles","verticalPool","propTypes","PropTypes","object","isRequired","bool","shape","number","string","oneOfType","arrayOf","node","index","styles","theme","WebkitTouchCallout","WebkitUserSelect","KhtmlUserSelect","MozUserSelect","MsUserSelect","userSelect","width","height","white","transition","boxSizing","display","gridRowGap","spacing","unit","gridColumnGap","padding","black","boxShadow","palette","paper","grey","backgroundColor","flexWrap","alignItems","justifyContent","overflow","touchAction","flexFlow"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEO,IAAMA,WAAW,GAAG,SAAdA,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A,QAAQ,EAAE,MAHL;AAILC,MAAAA,UAAU,EAAE,QAJP;AAKL3D,MAAAA,SAAS,EAAE,OALN;AAML4D,MAAAA,cAAc,EAAE,QANX;AAOLC,MAAAA,QAAQ,EAAE,QAPL;AAQLC,MAAAA,WAAW,EAAE,MARR;AASLL,MAAAA,eAAe,EAAE7C,gBAAMG,cAAN;AATZ,KA7BkB;AAwCzBE,IAAAA,eAAe,EAAE;AACfkC,MAAAA,OAAO,EAAEjB,KAAK,CAACc,OAAN,CAAcC,IAAd,GAAqB,CADf;AAEfH,MAAAA,OAAO,EAAE,MAFM;AAGfY,MAAAA,QAAQ,EAAE,MAHK;AAIfC,MAAAA,UAAU,EAAE,QAJG;AAKf3D,MAAAA,SAAS,EAAE,OALI;AAMf4D,MAAAA,cAAc,EAAE,QAND;AAOfC,MAAAA,QAAQ,EAAE,QAPK;AAQfC,MAAAA,WAAW,EAAE,MARE;AASfL,MAAAA,eAAe,EAAE7C,gBAAMG,cAAN;AATF,KAxCQ;AAmDzBK,IAAAA,YAAY,EAAE;AACZ0B,MAAAA,OAAO,EAAE,MADG;AAEZiB,MAAAA,QAAQ,EAAE;AAFE;AAnDW,GAAZ;AAAA,CAAf;;eAyDe,wBAAW9B,MAAX,EAAmB7C,WAAnB,C","sourcesContent":["import React from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport grey from '@material-ui/core/colors/grey';\nimport { color } from '@pie-lib/render-ui';\n\nexport const PlaceHolder = (props) => {\n const {\n children,\n classes,\n className,\n isOver,\n type,\n grid,\n disabled,\n choiceBoard,\n isCategorize,\n isVerticalPool,\n minHeight,\n } = props;\n\n const names = classNames(\n classes.placeholder,\n disabled && classes.disabled,\n isOver && classes.over,\n classes[type],\n className,\n );\n\n const style = {};\n\n if (grid && grid.columns) {\n style.gridTemplateColumns = `repeat(${grid.columns}, 1fr)`;\n }\n\n if (grid && grid.rows) {\n const repeatValue = grid.rowsRepeatValue || '1fr';\n\n style.gridTemplateRows = `repeat(${grid.rows}, ${repeatValue})`;\n }\n\n // The \"type\" is only sent through placement-ordering / placeholder\n // It can be \"choice\" or \"target\"\n // We apply a different style for the \"choice\" type\n // For any other type, use a dashed black border and a white fill\n if (type === 'choice') {\n style.border = `1px solid ${color.borderLight()}`;\n style.background = color.backgroundDark();\n }\n\n const boardStyle = isCategorize ? classes.categorizeBoard : classes.board;\n\n return (\n <div\n style={{ ...style, minHeight: minHeight }}\n className={classNames(\n classes.noSelectStyles,\n choiceBoard ? boardStyle : names,\n isVerticalPool && classes.verticalPool,\n )}\n >\n {children}\n </div>\n );\n};\n\nPlaceHolder.propTypes = {\n classes: PropTypes.object.isRequired,\n choiceBoard: PropTypes.bool,\n grid: PropTypes.shape({\n columns: PropTypes.number,\n rows: PropTypes.number,\n // if a different value then 1fr is wanted\n rowsRepeatValue: PropTypes.string,\n }),\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n className: PropTypes.string,\n isOver: PropTypes.bool,\n index: PropTypes.number,\n type: PropTypes.string,\n disabled: PropTypes.bool,\n isCategorize: PropTypes.bool,\n isVerticalPool: PropTypes.bool,\n minHeight: PropTypes.number,\n};\n\nconst styles = (theme) => ({\n noSelectStyles: {\n WebkitTouchCallout: 'none',\n WebkitUserSelect: 'none',\n KhtmlUserSelect: 'none',\n MozUserSelect: 'none',\n MsUserSelect: 'none',\n userSelect: 'none',\n },\n placeholder: {\n width: '100%',\n height: '100%',\n background: color.white(),\n transition: 'background-color 200ms linear, border-color 200ms linear',\n boxSizing: 'border-box',\n display: 'grid',\n gridRowGap: `${theme.spacing.unit}px`,\n gridColumnGap: `${theme.spacing.unit}px`,\n padding: theme.spacing.unit * 1,\n border: `2px dashed ${color.black()}`,\n },\n disabled: {\n boxShadow: 'none',\n background: theme.palette.background.paper,\n },\n over: {\n border: `1px solid ${grey[500]}`,\n backgroundColor: `${grey[300]}`,\n },\n board: {\n padding: theme.spacing.unit,\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'center',\n minHeight: '100px',\n justifyContent: 'center',\n overflow: 'hidden',\n touchAction: 'none',\n backgroundColor: color.backgroundDark(),\n },\n categorizeBoard: {\n padding: theme.spacing.unit / 2,\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'center',\n minHeight: '100px',\n justifyContent: 'center',\n overflow: 'hidden',\n touchAction: 'none',\n backgroundColor: color.backgroundDark(),\n },\n verticalPool: {\n display: 'flex',\n flexFlow: 'column wrap',\n },\n});\n\nexport default withStyles(styles)(PlaceHolder);\n"],"file":"placeholder.js"}
|
package/lib/preview-component.js
CHANGED
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
12
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
15
|
|
|
14
16
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -29,21 +31,24 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
29
31
|
|
|
30
32
|
var styles = {
|
|
31
33
|
maskBlank: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
// this style is applied only on small screens and for touch devices when dragging, for drag-in-the-blank.
|
|
35
|
+
// It is styled to be identical to the drag-in-the-blank chip
|
|
36
|
+
backgroundColor: _renderUi.color.white(),
|
|
37
|
+
border: "1px solid ".concat(_renderUi.color.text()),
|
|
38
|
+
color: _renderUi.color.text(),
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
display: 'inline-flex',
|
|
41
|
+
height: 'initial',
|
|
35
42
|
minHeight: '32px',
|
|
36
|
-
|
|
43
|
+
fontSize: 'inherit',
|
|
44
|
+
whiteSpace: 'pre-wrap',
|
|
37
45
|
maxWidth: '374px',
|
|
38
|
-
|
|
39
|
-
padding: '
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
justifyContent: 'center',
|
|
42
|
-
borderRadius: '16px'
|
|
46
|
+
borderRadius: '3px',
|
|
47
|
+
padding: '12px'
|
|
43
48
|
},
|
|
44
49
|
ica: {
|
|
45
50
|
backgroundColor: _renderUi.color.background(),
|
|
46
|
-
border: "1px solid ".concat(_renderUi.color.
|
|
51
|
+
border: "1px solid ".concat(_renderUi.color.borderDark()),
|
|
47
52
|
display: 'flex',
|
|
48
53
|
alignItems: 'center',
|
|
49
54
|
justifyContent: 'center',
|
|
@@ -100,10 +105,17 @@ var getPrompt = function getPrompt(itemType, item) {
|
|
|
100
105
|
}
|
|
101
106
|
};
|
|
102
107
|
|
|
103
|
-
var getCustomStyle = function getCustomStyle(itemType, item, style) {
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
var getCustomStyle = function getCustomStyle(itemType, item, touchPosition, style) {
|
|
109
|
+
var transform = "translate(".concat(touchPosition.x, "px, ").concat(touchPosition.y, "px)");
|
|
110
|
+
var top = (style === null || style === void 0 ? void 0 : style.top) || 0;
|
|
111
|
+
var left = (style === null || style === void 0 ? void 0 : style.left) || 0;
|
|
112
|
+
var position = (style === null || style === void 0 ? void 0 : style.position) || 'fixed';
|
|
113
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
114
|
+
position: position,
|
|
115
|
+
top: top,
|
|
116
|
+
left: left,
|
|
117
|
+
transform: transform
|
|
118
|
+
}, itemType === 'MaskBlank' ? styles.maskBlank : {}), (item === null || item === void 0 ? void 0 : item.itemType) === 'categorize' ? styles.categorize : {}), itemType === 'Answer' ? styles.matchList : {}), itemType === 'Tile' ? styles.placementOrdering : {}), itemType === 'react-dnd-response' ? styles.ica : {});
|
|
107
119
|
};
|
|
108
120
|
|
|
109
121
|
var PreviewComponent = function PreviewComponent() {
|
|
@@ -114,18 +126,58 @@ var PreviewComponent = function PreviewComponent() {
|
|
|
114
126
|
item = preview.item,
|
|
115
127
|
style = preview.style,
|
|
116
128
|
display = preview.display;
|
|
129
|
+
|
|
130
|
+
var _useState = (0, _react.useState)({
|
|
131
|
+
x: 0,
|
|
132
|
+
y: 0
|
|
133
|
+
}),
|
|
134
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
135
|
+
touchPosition = _useState2[0],
|
|
136
|
+
setTouchPosition = _useState2[1];
|
|
137
|
+
|
|
138
|
+
var _useState3 = (0, _react.useState)(1),
|
|
139
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
140
|
+
zoomLevel = _useState4[0],
|
|
141
|
+
setZoomLevel = _useState4[1];
|
|
142
|
+
|
|
143
|
+
var handleTouchMove = (0, _react.useCallback)(function (event) {
|
|
144
|
+
if (event.touches.length > 0) {
|
|
145
|
+
var touch = event.touches[0];
|
|
146
|
+
var touchOffset = 1;
|
|
147
|
+
setTouchPosition({
|
|
148
|
+
x: (touch.clientX + touchOffset) / zoomLevel,
|
|
149
|
+
y: (touch.clientY + touchOffset) / zoomLevel
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}, [zoomLevel]);
|
|
117
153
|
var root = (0, _react.useRef)(null);
|
|
118
154
|
(0, _react.useEffect)(function () {
|
|
119
155
|
if (display && root.current) {
|
|
120
|
-
(0, _mathRendering.renderMath)(root.current);
|
|
156
|
+
(0, _mathRendering.renderMath)(root.current); // Adjusted for precise zoom level calculation in Online Testing, targeting the specific class pattern .asmt-zoomable.asmt-zoom-NR .asmt-question .padding
|
|
157
|
+
|
|
158
|
+
var zoomAffectedElement = document.querySelector('.padding') || document.body;
|
|
159
|
+
setZoomLevel(parseFloat(getComputedStyle(zoomAffectedElement).zoom) || 1);
|
|
121
160
|
}
|
|
122
161
|
}, [display, item === null || item === void 0 ? void 0 : (_item$choice2 = item.choice) === null || _item$choice2 === void 0 ? void 0 : _item$choice2.value, item === null || item === void 0 ? void 0 : item.value, itemType, item]);
|
|
162
|
+
(0, _react.useEffect)(function () {
|
|
163
|
+
var touchMoveListener = function touchMoveListener(event) {
|
|
164
|
+
return handleTouchMove(event);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
if (display) {
|
|
168
|
+
window.addEventListener('touchmove', touchMoveListener);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return function () {
|
|
172
|
+
window.removeEventListener('touchmove', touchMoveListener);
|
|
173
|
+
};
|
|
174
|
+
}, [display, handleTouchMove]);
|
|
123
175
|
|
|
124
176
|
if (!display) {
|
|
125
177
|
return null;
|
|
126
178
|
}
|
|
127
179
|
|
|
128
|
-
var customStyle = getCustomStyle(itemType, item, style);
|
|
180
|
+
var customStyle = getCustomStyle(itemType, item, touchPosition, style);
|
|
129
181
|
var prompt = getPrompt(itemType, item);
|
|
130
182
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
131
183
|
ref: root,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preview-component.jsx"],"names":["styles","maskBlank","border","color","minWidth","minHeight","height","maxWidth","display","padding","alignItems","justifyContent","borderRadius","ica","backgroundColor","background","primary","marginLeft","marginTop","width","categorize","text","matchList","boxSizing","placementOrdering","getPrompt","itemType","item","choice","value","undefined","getCustomStyle","style","baseStyle","PreviewComponent","preview","root","current","customStyle","prompt"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,MAAM,GAAG;AACbC,EAAAA,SAAS,EAAE;AACTC,IAAAA,MAAM,EAAE,iBADC;AAETC,IAAAA,KAAK,EAAE,OAFE;AAGTC,IAAAA,QAAQ,EAAE,MAHD;AAITC,IAAAA,SAAS,EAAE,MAJF;AAKTC,IAAAA,MAAM,EAAE,MALC;AAMTC,IAAAA,QAAQ,EAAE,OAND;AAOTC,IAAAA,OAAO,EAAE,MAPA;AAQTC,IAAAA,OAAO,EAAE,KARA;AASTC,IAAAA,UAAU,EAAE,QATH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AR;AAAA,MAAkBC,IAAlB,GAA2CQ,OAA3C,CAAkBR,IAAlB;AAAA,MAAwBK,KAAxB,GAA2CG,OAA3C,CAAwBH,KAAxB;AAAA,MAA+BxB,OAA/B,GAA2C2B,OAA3C,CAA+B3B,OAA/B;AAEA,MAAM4B,IAAI,GAAG,mBAAO,IAAP,CAAb;AAEA,wBAAU,YAAM;AACd,QAAI5B,OAAO,IAAI4B,IAAI,CAACC,OAApB,EAA6B;AAC3B,qCAAWD,IAAI,CAACC,OAAhB;AACD;AACF,GAJD,EAIG,CAAC7B,OAAD,EAAUmB,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,CAJH;;AAMA,MAAI,CAACnB,OAAL,EAAc;AACZ,WAAO,IAAP;AACD;;AAED,MAAM8B,WAAW,GAAGP,cAAc,CAACL,QAAD,EAAWC,IAAX,EAAiBK,KAAjB,CAAlC;AAEA,MAAMO,MAAM,GAAGd,SAAS,CAACC,QAAD,EAAWC,IAAX,CAAxB;AAEA,sBACE;AAAK,IAAA,GAAG,EAAES,IAAV;AAAgB,IAAA,KAAK,EAAEE;AAAvB,kBACE,gCAAC,uBAAD;AAAe,IAAA,SAAS,EAAC,OAAzB;AAAiC,IAAA,MAAM,EAAEC,MAAzC;AAAiD,IAAA,OAAO,EAAC;AAAzD,IADF,CADF;AAKD,CAzBD;;eA2BeL,gB","sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { usePreview } from 'react-dnd-multi-backend';\nimport { PreviewPrompt } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { color } from '@pie-lib/render-ui';\n\nconst styles = {\n maskBlank: {\n border: '1px solid black',\n color: 'black',\n minWidth: '90px',\n minHeight: '32px',\n height: 'auto',\n maxWidth: '374px',\n display: 'flex',\n padding: '4px',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '16px',\n },\n ica: {\n backgroundColor: color.background(),\n border: `1px solid ${color.primary()}`,\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, style) => {\n const baseStyle = {\n ...style,\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 return baseStyle;\n};\n\nconst PreviewComponent = () => {\n const preview = usePreview();\n const { itemType, item, style, display } = preview;\n\n const root = useRef(null);\n\n useEffect(() => {\n if (display && root.current) {\n renderMath(root.current);\n }\n }, [display, item?.choice?.value, item?.value, itemType, item]);\n\n if (!display) {\n return null;\n }\n\n const customStyle = getCustomStyle(itemType, item, 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,"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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zD,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"}
|
package/lib/with-drag-context.js
CHANGED
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports["default"] = void 0;
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _react = _interopRequireDefault(require("react"));
|
|
13
15
|
|
|
14
16
|
var _reactDndMultiBackend = _interopRequireWildcard(require("react-dnd-multi-backend"));
|
|
@@ -26,7 +28,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
26
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
29
|
|
|
28
30
|
var backends = [{
|
|
29
|
-
backend: _reactDndHtml5Backend.HTML5Backend
|
|
31
|
+
backend: _reactDndHtml5Backend.HTML5Backend,
|
|
32
|
+
transition: _reactDndMultiBackend.MouseTransition
|
|
30
33
|
}, {
|
|
31
34
|
backend: _reactDndTouchBackend.TouchBackend,
|
|
32
35
|
options: {
|
|
@@ -40,13 +43,15 @@ var backends = [{
|
|
|
40
43
|
|
|
41
44
|
var _default = function _default(Component) {
|
|
42
45
|
return function (props) {
|
|
43
|
-
|
|
46
|
+
var isClient = typeof window !== 'undefined';
|
|
47
|
+
return /*#__PURE__*/_react["default"].createElement(_reactDnd.DndProvider, (0, _extends2["default"])({
|
|
44
48
|
backend: _reactDndMultiBackend["default"],
|
|
45
49
|
options: {
|
|
46
50
|
backends: backends
|
|
47
|
-
}
|
|
51
|
+
}
|
|
52
|
+
}, isClient && {
|
|
48
53
|
context: window
|
|
49
|
-
}, /*#__PURE__*/_react["default"].createElement(Component, props), /*#__PURE__*/_react["default"].createElement(_previewComponent["default"], null));
|
|
54
|
+
}), /*#__PURE__*/_react["default"].createElement(Component, props), /*#__PURE__*/_react["default"].createElement(_previewComponent["default"], null));
|
|
50
55
|
};
|
|
51
56
|
};
|
|
52
57
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/with-drag-context.js"],"names":["backends","backend","HTML5Backend","TouchBackend","options","enableMouseEvents","enableTouchEvents","preview","
|
|
1
|
+
{"version":3,"sources":["../src/with-drag-context.js"],"names":["backends","backend","HTML5Backend","transition","MouseTransition","TouchBackend","options","enableMouseEvents","enableTouchEvents","preview","TouchTransition","skipDispatchOnTransition","Component","props","isClient","window","MultiBackend","context"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAEA,IAAMA,QAAQ,GAAG,CACf;AACEC,EAAAA,OAAO,EAAEC,kCADX;AAEEC,EAAAA,UAAU,EAAEC;AAFd,CADe,EAKf;AACEH,EAAAA,OAAO,EAAEI,kCADX;AAEEC,EAAAA,OAAO,EAAE;AAAEC,IAAAA,iBAAiB,EAAE,IAArB;AAA2BC,IAAAA,iBAAiB,EAAE;AAA9C,GAFX;AAGEC,EAAAA,OAAO,EAAE,IAHX;AAIEN,EAAAA,UAAU,EAAEO,qCAJd;AAKEC,EAAAA,wBAAwB,EAAE;AAL5B,CALe,CAAjB;;eAce,kBAACC,SAAD;AAAA,SAAe,UAACC,KAAD,EAAW;AACvC,QAAMC,QAAQ,GAAG,OAAOC,MAAP,KAAkB,WAAnC;AAEA,wBACE,gCAAC,qBAAD;AAAa,MAAA,OAAO,EAAEC,gCAAtB;AAAoC,MAAA,OAAO,EAAE;AAAEhB,QAAAA,QAAQ,EAARA;AAAF;AAA7C,OAAgEc,QAAQ,IAAI;AAAEG,MAAAA,OAAO,EAAEF;AAAX,KAA5E,gBACE,gCAAC,SAAD,EAAeF,KAAf,CADF,eAEE,gCAAC,4BAAD,OAFF,CADF;AAMD,GATc;AAAA,C","sourcesContent":["import React from 'react';\nimport MultiBackend, { TouchTransition, MouseTransition } from 'react-dnd-multi-backend';\nimport { DndProvider } from 'react-dnd';\nimport { TouchBackend } from 'react-dnd-touch-backend';\nimport { HTML5Backend } from 'react-dnd-html5-backend';\n\nimport PreviewComponent from './preview-component';\n\nconst backends = [\n {\n backend: HTML5Backend,\n transition: MouseTransition,\n },\n {\n backend: TouchBackend,\n options: { enableMouseEvents: true, enableTouchEvents: true },\n preview: true,\n transition: TouchTransition,\n skipDispatchOnTransition: true,\n },\n];\n\nexport default (Component) => (props) => {\n const isClient = typeof window !== 'undefined';\n\n return (\n <DndProvider backend={MultiBackend} options={{ backends }} {...(isClient && { context: window })}>\n <Component {...props} />\n <PreviewComponent />\n </DndProvider>\n );\n};\n"],"file":"with-drag-context.js"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/drag",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@material-ui/core": "^3.8.3",
|
|
9
|
-
"@pie-lib/math-rendering": "
|
|
10
|
-
"@pie-lib/render-ui": "
|
|
9
|
+
"@pie-lib/math-rendering": "latest",
|
|
10
|
+
"@pie-lib/render-ui": "latest",
|
|
11
11
|
"classnames": "^2.2.6",
|
|
12
12
|
"lodash": "^4.17.11",
|
|
13
|
+
"prop-types": "^15.7.2",
|
|
14
|
+
"react": "^16.8.1",
|
|
13
15
|
"react-dnd": "^14.0.5",
|
|
14
16
|
"react-dnd-html5-backend": "^14.0.2",
|
|
15
17
|
"react-dnd-multi-backend": "^6.0.2",
|
|
@@ -21,5 +23,5 @@
|
|
|
21
23
|
"scripts": {},
|
|
22
24
|
"author": "",
|
|
23
25
|
"license": "ISC",
|
|
24
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "e2aa3ddac60f49bcb8c2562370f496323642f453"
|
|
25
27
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`placeholder snapshot className 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="placeholder bar"
|
|
6
|
+
style={
|
|
7
|
+
Object {
|
|
8
|
+
"minHeight": undefined,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
>
|
|
12
|
+
Foo
|
|
13
|
+
</div>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`placeholder snapshot disabled: true 1`] = `
|
|
17
|
+
<div
|
|
18
|
+
className="placeholder disabled"
|
|
19
|
+
style={
|
|
20
|
+
Object {
|
|
21
|
+
"minHeight": undefined,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
>
|
|
25
|
+
Foo
|
|
26
|
+
</div>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`placeholder snapshot isOver: true 1`] = `
|
|
30
|
+
<div
|
|
31
|
+
className="placeholder over"
|
|
32
|
+
style={
|
|
33
|
+
Object {
|
|
34
|
+
"minHeight": undefined,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
Foo
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
exports[`placeholder snapshot reqular 1`] = `
|
|
43
|
+
<div
|
|
44
|
+
className="placeholder"
|
|
45
|
+
style={
|
|
46
|
+
Object {
|
|
47
|
+
"minHeight": undefined,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
Foo
|
|
52
|
+
</div>
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
exports[`placeholder snapshot specific grid rowsRepeatValue 1`] = `
|
|
56
|
+
<div
|
|
57
|
+
className="placeholder"
|
|
58
|
+
style={
|
|
59
|
+
Object {
|
|
60
|
+
"gridTemplateColumns": "repeat(1, 1fr)",
|
|
61
|
+
"gridTemplateRows": "repeat(2, min-content)",
|
|
62
|
+
"minHeight": undefined,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
>
|
|
66
|
+
Foo
|
|
67
|
+
</div>
|
|
68
|
+
`;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { shallow } from 'enzyme';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { PlaceHolder } from '../placeholder';
|
|
4
|
+
|
|
5
|
+
describe('placeholder', () => {
|
|
6
|
+
const wrapper = (extras) => {
|
|
7
|
+
const defaults = {
|
|
8
|
+
classes: {
|
|
9
|
+
placeholder: 'placeholder',
|
|
10
|
+
disabled: 'disabled',
|
|
11
|
+
over: 'over',
|
|
12
|
+
number: 'number',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const props = { ...defaults, ...extras };
|
|
16
|
+
return shallow(<PlaceHolder {...props}> Foo </PlaceHolder>);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
describe('snapshot', () => {
|
|
20
|
+
it('reqular', () => {
|
|
21
|
+
const w = wrapper();
|
|
22
|
+
expect(w).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('isOver: true', () => {
|
|
26
|
+
expect(wrapper({ isOver: true })).toMatchSnapshot();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('disabled: true', () => {
|
|
30
|
+
expect(wrapper({ disabled: true })).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('className', () => {
|
|
34
|
+
expect(wrapper({ className: 'bar' })).toMatchSnapshot();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('specific grid rowsRepeatValue', () => {
|
|
38
|
+
const w = wrapper({
|
|
39
|
+
grid: {
|
|
40
|
+
rows: 2,
|
|
41
|
+
columns: 1,
|
|
42
|
+
rowsRepeatValue: 'min-content',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
expect(w).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createContext, createElement } from 'react';
|
|
2
|
+
import { withUid } from '../uid-context';
|
|
3
|
+
|
|
4
|
+
jest.mock('react', () => ({
|
|
5
|
+
createElement: jest.fn((c) => c),
|
|
6
|
+
createContext: jest.fn().mockReturnValue({
|
|
7
|
+
Consumer: jest.fn((fn) => fn),
|
|
8
|
+
Provider: jest.fn(),
|
|
9
|
+
}),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
describe('id-context', () => {
|
|
13
|
+
describe('withUid', () => {
|
|
14
|
+
it('calls createElement', () => {
|
|
15
|
+
const Wrapped = withUid(() => ({}));
|
|
16
|
+
|
|
17
|
+
const Consumer = Wrapped({});
|
|
18
|
+
expect(createElement).toBeCalledWith(expect.any(Function), null, expect.anything());
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -4,12 +4,6 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
|
|
5
5
|
const preventInteractionStyle = {
|
|
6
6
|
flex: 1,
|
|
7
|
-
WebkitTouchCallout: 'none',
|
|
8
|
-
WebkitUserSelect: 'none',
|
|
9
|
-
KhtmlUserSelect: 'none',
|
|
10
|
-
MozUserSelect: 'none',
|
|
11
|
-
MsUserSelect: 'none',
|
|
12
|
-
UserSelect: 'none',
|
|
13
7
|
};
|
|
14
8
|
|
|
15
9
|
export class DroppablePlaceholder extends React.Component {
|
|
@@ -19,14 +13,23 @@ export class DroppablePlaceholder extends React.Component {
|
|
|
19
13
|
isOver: PropTypes.bool,
|
|
20
14
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
|
21
15
|
disabled: PropTypes.bool,
|
|
16
|
+
isVerticalPool: PropTypes.bool,
|
|
17
|
+
minHeight: PropTypes.number,
|
|
22
18
|
};
|
|
23
19
|
|
|
24
20
|
render() {
|
|
25
|
-
const { children, connectDropTarget, isOver, disabled, classes } = this.props;
|
|
21
|
+
const { children, connectDropTarget, isOver, disabled, classes, isVerticalPool, minHeight } = this.props;
|
|
26
22
|
|
|
27
23
|
return connectDropTarget(
|
|
28
24
|
<div style={preventInteractionStyle}>
|
|
29
|
-
<PlaceHolder
|
|
25
|
+
<PlaceHolder
|
|
26
|
+
disabled={disabled}
|
|
27
|
+
isOver={isOver}
|
|
28
|
+
choiceBoard={true}
|
|
29
|
+
className={classes}
|
|
30
|
+
isVerticalPool={isVerticalPool}
|
|
31
|
+
minHeight={minHeight}
|
|
32
|
+
>
|
|
30
33
|
{children}
|
|
31
34
|
</PlaceHolder>
|
|
32
35
|
</div>,
|
package/src/placeholder.jsx
CHANGED
|
@@ -3,9 +3,23 @@ import { withStyles } from '@material-ui/core/styles';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import grey from '@material-ui/core/colors/grey';
|
|
6
|
+
import { color } from '@pie-lib/render-ui';
|
|
6
7
|
|
|
7
8
|
export const PlaceHolder = (props) => {
|
|
8
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
children,
|
|
11
|
+
classes,
|
|
12
|
+
className,
|
|
13
|
+
isOver,
|
|
14
|
+
type,
|
|
15
|
+
grid,
|
|
16
|
+
disabled,
|
|
17
|
+
choiceBoard,
|
|
18
|
+
isCategorize,
|
|
19
|
+
isVerticalPool,
|
|
20
|
+
minHeight,
|
|
21
|
+
} = props;
|
|
22
|
+
|
|
9
23
|
const names = classNames(
|
|
10
24
|
classes.placeholder,
|
|
11
25
|
disabled && classes.disabled,
|
|
@@ -19,14 +33,33 @@ export const PlaceHolder = (props) => {
|
|
|
19
33
|
if (grid && grid.columns) {
|
|
20
34
|
style.gridTemplateColumns = `repeat(${grid.columns}, 1fr)`;
|
|
21
35
|
}
|
|
36
|
+
|
|
22
37
|
if (grid && grid.rows) {
|
|
23
38
|
const repeatValue = grid.rowsRepeatValue || '1fr';
|
|
24
39
|
|
|
25
40
|
style.gridTemplateRows = `repeat(${grid.rows}, ${repeatValue})`;
|
|
26
41
|
}
|
|
27
42
|
|
|
43
|
+
// The "type" is only sent through placement-ordering / placeholder
|
|
44
|
+
// It can be "choice" or "target"
|
|
45
|
+
// We apply a different style for the "choice" type
|
|
46
|
+
// For any other type, use a dashed black border and a white fill
|
|
47
|
+
if (type === 'choice') {
|
|
48
|
+
style.border = `1px solid ${color.borderLight()}`;
|
|
49
|
+
style.background = color.backgroundDark();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const boardStyle = isCategorize ? classes.categorizeBoard : classes.board;
|
|
53
|
+
|
|
28
54
|
return (
|
|
29
|
-
<div
|
|
55
|
+
<div
|
|
56
|
+
style={{ ...style, minHeight: minHeight }}
|
|
57
|
+
className={classNames(
|
|
58
|
+
classes.noSelectStyles,
|
|
59
|
+
choiceBoard ? boardStyle : names,
|
|
60
|
+
isVerticalPool && classes.verticalPool,
|
|
61
|
+
)}
|
|
62
|
+
>
|
|
30
63
|
{children}
|
|
31
64
|
</div>
|
|
32
65
|
);
|
|
@@ -47,20 +80,31 @@ PlaceHolder.propTypes = {
|
|
|
47
80
|
index: PropTypes.number,
|
|
48
81
|
type: PropTypes.string,
|
|
49
82
|
disabled: PropTypes.bool,
|
|
83
|
+
isCategorize: PropTypes.bool,
|
|
84
|
+
isVerticalPool: PropTypes.bool,
|
|
85
|
+
minHeight: PropTypes.number,
|
|
50
86
|
};
|
|
51
87
|
|
|
52
88
|
const styles = (theme) => ({
|
|
89
|
+
noSelectStyles: {
|
|
90
|
+
WebkitTouchCallout: 'none',
|
|
91
|
+
WebkitUserSelect: 'none',
|
|
92
|
+
KhtmlUserSelect: 'none',
|
|
93
|
+
MozUserSelect: 'none',
|
|
94
|
+
MsUserSelect: 'none',
|
|
95
|
+
userSelect: 'none',
|
|
96
|
+
},
|
|
53
97
|
placeholder: {
|
|
54
98
|
width: '100%',
|
|
55
99
|
height: '100%',
|
|
56
|
-
background:
|
|
57
|
-
border: '1px solid #D1D1D1',
|
|
100
|
+
background: color.white(),
|
|
58
101
|
transition: 'background-color 200ms linear, border-color 200ms linear',
|
|
59
102
|
boxSizing: 'border-box',
|
|
60
103
|
display: 'grid',
|
|
61
104
|
gridRowGap: `${theme.spacing.unit}px`,
|
|
62
105
|
gridColumnGap: `${theme.spacing.unit}px`,
|
|
63
106
|
padding: theme.spacing.unit * 1,
|
|
107
|
+
border: `2px dashed ${color.black()}`,
|
|
64
108
|
},
|
|
65
109
|
disabled: {
|
|
66
110
|
boxShadow: 'none',
|
|
@@ -71,15 +115,30 @@ const styles = (theme) => ({
|
|
|
71
115
|
backgroundColor: `${grey[300]}`,
|
|
72
116
|
},
|
|
73
117
|
board: {
|
|
74
|
-
border: '1px solid #D1D1D1',
|
|
75
118
|
padding: theme.spacing.unit,
|
|
76
119
|
display: 'flex',
|
|
77
120
|
flexWrap: 'wrap',
|
|
78
121
|
alignItems: 'center',
|
|
79
|
-
minHeight: '
|
|
122
|
+
minHeight: '100px',
|
|
123
|
+
justifyContent: 'center',
|
|
124
|
+
overflow: 'hidden',
|
|
125
|
+
touchAction: 'none',
|
|
126
|
+
backgroundColor: color.backgroundDark(),
|
|
127
|
+
},
|
|
128
|
+
categorizeBoard: {
|
|
129
|
+
padding: theme.spacing.unit / 2,
|
|
130
|
+
display: 'flex',
|
|
131
|
+
flexWrap: 'wrap',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
minHeight: '100px',
|
|
80
134
|
justifyContent: 'center',
|
|
81
135
|
overflow: 'hidden',
|
|
82
136
|
touchAction: 'none',
|
|
137
|
+
backgroundColor: color.backgroundDark(),
|
|
138
|
+
},
|
|
139
|
+
verticalPool: {
|
|
140
|
+
display: 'flex',
|
|
141
|
+
flexFlow: 'column wrap',
|
|
83
142
|
},
|
|
84
143
|
});
|
|
85
144
|
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
|
2
2
|
import { usePreview } from 'react-dnd-multi-backend';
|
|
3
|
-
import { PreviewPrompt } from '@pie-lib/render-ui';
|
|
3
|
+
import { PreviewPrompt, color } from '@pie-lib/render-ui';
|
|
4
4
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
5
|
-
import { color } from '@pie-lib/render-ui';
|
|
6
5
|
|
|
7
6
|
const styles = {
|
|
8
7
|
maskBlank: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
// this style is applied only on small screens and for touch devices when dragging, for drag-in-the-blank.
|
|
9
|
+
// It is styled to be identical to the drag-in-the-blank chip
|
|
10
|
+
backgroundColor: color.white(),
|
|
11
|
+
border: `1px solid ${color.text()}`,
|
|
12
|
+
color: color.text(),
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
display: 'inline-flex',
|
|
15
|
+
height: 'initial',
|
|
12
16
|
minHeight: '32px',
|
|
13
|
-
|
|
17
|
+
fontSize: 'inherit',
|
|
18
|
+
whiteSpace: 'pre-wrap',
|
|
14
19
|
maxWidth: '374px',
|
|
15
|
-
|
|
16
|
-
padding: '
|
|
17
|
-
alignItems: 'center',
|
|
18
|
-
justifyContent: 'center',
|
|
19
|
-
borderRadius: '16px',
|
|
20
|
+
borderRadius: '3px',
|
|
21
|
+
padding: '12px',
|
|
20
22
|
},
|
|
21
23
|
ica: {
|
|
22
24
|
backgroundColor: color.background(),
|
|
23
|
-
border: `1px solid ${color.
|
|
25
|
+
border: `1px solid ${color.borderDark()}`,
|
|
24
26
|
display: 'flex',
|
|
25
27
|
alignItems: 'center',
|
|
26
28
|
justifyContent: 'center',
|
|
@@ -71,36 +73,73 @@ const getPrompt = (itemType, item) => {
|
|
|
71
73
|
}
|
|
72
74
|
};
|
|
73
75
|
|
|
74
|
-
const getCustomStyle = (itemType, item, style) => {
|
|
75
|
-
const
|
|
76
|
-
|
|
76
|
+
const getCustomStyle = (itemType, item, touchPosition, style) => {
|
|
77
|
+
const transform = `translate(${touchPosition.x}px, ${touchPosition.y}px)`;
|
|
78
|
+
const top = style?.top || 0;
|
|
79
|
+
const left = style?.left || 0;
|
|
80
|
+
const position = style?.position || 'fixed';
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
position,
|
|
84
|
+
top,
|
|
85
|
+
left,
|
|
86
|
+
transform,
|
|
77
87
|
...(itemType === 'MaskBlank' ? styles.maskBlank : {}),
|
|
78
88
|
...(item?.itemType === 'categorize' ? styles.categorize : {}),
|
|
79
89
|
...(itemType === 'Answer' ? styles.matchList : {}),
|
|
80
90
|
...(itemType === 'Tile' ? styles.placementOrdering : {}),
|
|
81
91
|
...(itemType === 'react-dnd-response' ? styles.ica : {}),
|
|
82
92
|
};
|
|
83
|
-
|
|
84
|
-
return baseStyle;
|
|
85
93
|
};
|
|
86
94
|
|
|
87
95
|
const PreviewComponent = () => {
|
|
88
96
|
const preview = usePreview();
|
|
89
97
|
const { itemType, item, style, display } = preview;
|
|
98
|
+
const [touchPosition, setTouchPosition] = useState({ x: 0, y: 0 });
|
|
99
|
+
const [zoomLevel, setZoomLevel] = useState(1);
|
|
100
|
+
|
|
101
|
+
const handleTouchMove = useCallback(
|
|
102
|
+
(event) => {
|
|
103
|
+
if (event.touches.length > 0) {
|
|
104
|
+
const touch = event.touches[0];
|
|
105
|
+
const touchOffset = 1;
|
|
106
|
+
setTouchPosition({
|
|
107
|
+
x: (touch.clientX + touchOffset) / zoomLevel,
|
|
108
|
+
y: (touch.clientY + touchOffset) / zoomLevel,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[zoomLevel],
|
|
113
|
+
);
|
|
90
114
|
|
|
91
115
|
const root = useRef(null);
|
|
92
116
|
|
|
93
117
|
useEffect(() => {
|
|
94
118
|
if (display && root.current) {
|
|
95
119
|
renderMath(root.current);
|
|
120
|
+
|
|
121
|
+
// Adjusted for precise zoom level calculation in Online Testing, targeting the specific class pattern .asmt-zoomable.asmt-zoom-NR .asmt-question .padding
|
|
122
|
+
const zoomAffectedElement = document.querySelector('.padding') || document.body;
|
|
123
|
+
|
|
124
|
+
setZoomLevel(parseFloat(getComputedStyle(zoomAffectedElement).zoom) || 1);
|
|
96
125
|
}
|
|
97
126
|
}, [display, item?.choice?.value, item?.value, itemType, item]);
|
|
98
127
|
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
const touchMoveListener = (event) => handleTouchMove(event);
|
|
130
|
+
if (display) {
|
|
131
|
+
window.addEventListener('touchmove', touchMoveListener);
|
|
132
|
+
}
|
|
133
|
+
return () => {
|
|
134
|
+
window.removeEventListener('touchmove', touchMoveListener);
|
|
135
|
+
};
|
|
136
|
+
}, [display, handleTouchMove]);
|
|
137
|
+
|
|
99
138
|
if (!display) {
|
|
100
139
|
return null;
|
|
101
140
|
}
|
|
102
141
|
|
|
103
|
-
const customStyle = getCustomStyle(itemType, item, style);
|
|
142
|
+
const customStyle = getCustomStyle(itemType, item, touchPosition, style);
|
|
104
143
|
|
|
105
144
|
const prompt = getPrompt(itemType, item);
|
|
106
145
|
|
package/src/with-drag-context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import MultiBackend, { TouchTransition } from 'react-dnd-multi-backend';
|
|
2
|
+
import MultiBackend, { TouchTransition, MouseTransition } from 'react-dnd-multi-backend';
|
|
3
3
|
import { DndProvider } from 'react-dnd';
|
|
4
4
|
import { TouchBackend } from 'react-dnd-touch-backend';
|
|
5
5
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
@@ -7,7 +7,10 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
|
7
7
|
import PreviewComponent from './preview-component';
|
|
8
8
|
|
|
9
9
|
const backends = [
|
|
10
|
-
{
|
|
10
|
+
{
|
|
11
|
+
backend: HTML5Backend,
|
|
12
|
+
transition: MouseTransition,
|
|
13
|
+
},
|
|
11
14
|
{
|
|
12
15
|
backend: TouchBackend,
|
|
13
16
|
options: { enableMouseEvents: true, enableTouchEvents: true },
|
|
@@ -17,9 +20,13 @@ const backends = [
|
|
|
17
20
|
},
|
|
18
21
|
];
|
|
19
22
|
|
|
20
|
-
export default (Component) => (props) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
export default (Component) => (props) => {
|
|
24
|
+
const isClient = typeof window !== 'undefined';
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<DndProvider backend={MultiBackend} options={{ backends }} {...(isClient && { context: window })}>
|
|
28
|
+
<Component {...props} />
|
|
29
|
+
<PreviewComponent />
|
|
30
|
+
</DndProvider>
|
|
31
|
+
);
|
|
32
|
+
};
|
package/README.md
DELETED