@pie-lib/drag 2.22.2 → 2.22.3-next.155
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 +6 -76
- package/esm/package.json +3 -0
- package/lib/drag-in-the-blank-dp.js +57 -26
- package/lib/drag-in-the-blank-dp.js.map +1 -1
- package/lib/drag-provider.js +61 -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 +89 -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 +26 -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 -99
- 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 +20 -10
- package/src/__tests__/placeholder.test.jsx +84 -25
- package/src/__tests__/uid-context.test.jsx +49 -16
- package/src/drag-in-the-blank-dp.jsx +62 -16
- package/src/drag-provider.jsx +50 -0
- package/src/drag-type.js +1 -1
- package/src/draggable-choice.jsx +88 -0
- package/src/droppable-placeholder.jsx +38 -28
- package/src/ica-dp.jsx +20 -18
- package/src/index.js +4 -8
- package/src/match-list-dp.jsx +41 -18
- package/src/placeholder.jsx +68 -72
- 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/__tests__/__snapshots__/placeholder.test.jsx.snap +0 -68
- package/src/choice.jsx +0 -76
- package/src/with-drag-context.js +0 -32
package/lib/preview-component.js
CHANGED
|
@@ -1,34 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
|
|
14
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
|
-
var _reactDndMultiBackend = require("react-dnd-multi-backend");
|
|
19
|
-
|
|
12
|
+
var _core = require("@dnd-kit/core");
|
|
20
13
|
var _renderUi = require("@pie-lib/render-ui");
|
|
21
|
-
|
|
22
14
|
var _mathRendering = require("@pie-lib/math-rendering");
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
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
|
-
|
|
28
|
-
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; }
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
18
|
var styles = {
|
|
33
19
|
maskBlank: {
|
|
34
20
|
// this style is applied only on small screens and for touch devices when dragging, for drag-in-the-blank.
|
|
@@ -79,116 +65,90 @@ var styles = {
|
|
|
79
65
|
backgroundColor: _renderUi.color.background()
|
|
80
66
|
}
|
|
81
67
|
};
|
|
68
|
+
var getPrompt = function getPrompt(dragData) {
|
|
69
|
+
var _dragData$choice;
|
|
70
|
+
if (!dragData) return undefined;
|
|
71
|
+
|
|
72
|
+
// Handle different drag data structures based on the component type
|
|
73
|
+
if (dragData.choiceId) {
|
|
74
|
+
// DraggableChoice format
|
|
75
|
+
return dragData.value;
|
|
76
|
+
}
|
|
82
77
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
switch (itemType) {
|
|
87
|
-
// DRAG-IN-THE-BLANK
|
|
78
|
+
// Legacy format support
|
|
79
|
+
switch (dragData.itemType) {
|
|
88
80
|
case 'MaskBlank':
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
case 'react-dnd-response':
|
|
93
|
-
return item === null || item === void 0 ? void 0 : item.value;
|
|
94
|
-
// MATCH-LIST
|
|
95
|
-
|
|
81
|
+
return (_dragData$choice = dragData.choice) === null || _dragData$choice === void 0 ? void 0 : _dragData$choice.value;
|
|
82
|
+
case 'dnd-kit-response':
|
|
83
|
+
return dragData.value;
|
|
96
84
|
case 'Answer':
|
|
97
|
-
return
|
|
98
|
-
// PLACEMENT-ORDERING
|
|
99
|
-
|
|
85
|
+
return dragData.value;
|
|
100
86
|
case 'Tile':
|
|
101
|
-
return
|
|
102
|
-
|
|
87
|
+
return dragData.value;
|
|
88
|
+
case 'categorize':
|
|
89
|
+
return dragData.value;
|
|
103
90
|
default:
|
|
104
|
-
return
|
|
91
|
+
return dragData.value;
|
|
105
92
|
}
|
|
106
93
|
};
|
|
94
|
+
var getCustomStyle = function getCustomStyle(dragData) {
|
|
95
|
+
if (!dragData) return {};
|
|
96
|
+
var baseStyle = {
|
|
97
|
+
cursor: 'grabbing',
|
|
98
|
+
opacity: 0.8,
|
|
99
|
+
transform: 'rotate(5deg)' // Slight rotation for visual feedback
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Apply specific styles based on item type
|
|
103
|
+
if (dragData.itemType === 'MaskBlank') {
|
|
104
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.maskBlank);
|
|
105
|
+
}
|
|
106
|
+
if (dragData.itemType === 'categorize') {
|
|
107
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.categorize);
|
|
108
|
+
}
|
|
109
|
+
if (dragData.itemType === 'Answer') {
|
|
110
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.matchList);
|
|
111
|
+
}
|
|
112
|
+
if (dragData.itemType === 'Tile') {
|
|
113
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.placementOrdering);
|
|
114
|
+
}
|
|
115
|
+
if (dragData.itemType === 'dnd-kit-response') {
|
|
116
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.ica);
|
|
117
|
+
}
|
|
107
118
|
|
|
108
|
-
|
|
109
|
-
|
|
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 : {});
|
|
119
|
+
// Default style for choice items
|
|
120
|
+
return _objectSpread(_objectSpread({}, baseStyle), styles.categorize);
|
|
119
121
|
};
|
|
120
|
-
|
|
121
122
|
var PreviewComponent = function PreviewComponent() {
|
|
122
|
-
var
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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]);
|
|
123
|
+
var _active$data;
|
|
124
|
+
var _useDndContext = (0, _core.useDndContext)(),
|
|
125
|
+
active = _useDndContext.active;
|
|
126
|
+
var _useState = (0, _react.useState)(1),
|
|
127
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
128
|
+
zoomLevel = _useState2[0],
|
|
129
|
+
setZoomLevel = _useState2[1];
|
|
153
130
|
var root = (0, _react.useRef)(null);
|
|
131
|
+
var dragData = active === null || active === void 0 || (_active$data = active.data) === null || _active$data === void 0 ? void 0 : _active$data.current;
|
|
132
|
+
var isActive = !!active;
|
|
154
133
|
(0, _react.useEffect)(function () {
|
|
155
|
-
if (
|
|
156
|
-
(0, _mathRendering.renderMath)(root.current);
|
|
134
|
+
if (isActive && root.current) {
|
|
135
|
+
(0, _mathRendering.renderMath)(root.current);
|
|
157
136
|
|
|
137
|
+
// Adjusted for precise zoom level calculation in Online Testing, targeting the specific class pattern .asmt-zoomable.asmt-zoom-NR .asmt-question .padding
|
|
158
138
|
var zoomAffectedElement = document.querySelector('.padding') || document.body;
|
|
159
139
|
setZoomLevel(parseFloat(getComputedStyle(zoomAffectedElement).zoom) || 1);
|
|
160
140
|
}
|
|
161
|
-
}, [
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
if (display) {
|
|
168
|
-
window.addEventListener('touchmove', touchMoveListener);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return function () {
|
|
172
|
-
window.removeEventListener('touchmove', touchMoveListener);
|
|
173
|
-
};
|
|
174
|
-
}, [display, handleTouchMove]);
|
|
175
|
-
|
|
176
|
-
if (!display) {
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
var customStyle = getCustomStyle(itemType, item, touchPosition, style);
|
|
181
|
-
var prompt = getPrompt(itemType, item);
|
|
182
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
141
|
+
}, [isActive, dragData]);
|
|
142
|
+
var customStyle = getCustomStyle(dragData);
|
|
143
|
+
var prompt = getPrompt(dragData);
|
|
144
|
+
return /*#__PURE__*/_react["default"].createElement(_core.DragOverlay, null, isActive && prompt && /*#__PURE__*/_react["default"].createElement("div", {
|
|
183
145
|
ref: root,
|
|
184
146
|
style: customStyle
|
|
185
147
|
}, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
|
|
186
148
|
className: "label",
|
|
187
149
|
prompt: prompt,
|
|
188
150
|
tagName: "span"
|
|
189
|
-
}));
|
|
151
|
+
})));
|
|
190
152
|
};
|
|
191
|
-
|
|
192
|
-
var _default = PreviewComponent;
|
|
193
|
-
exports["default"] = _default;
|
|
153
|
+
var _default = exports["default"] = PreviewComponent;
|
|
194
154
|
//# sourceMappingURL=preview-component.js.map
|
|
@@ -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,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C,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=\"label\" prompt={prompt} tagName=\"span\" />\n </div>\n )}\n </DragOverlay>\n );\n};\n\nexport default PreviewComponent;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAAqD,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,wBAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAA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AAMI,mBAAmB,GAAGC,QAAQ,CAACC,aAAa,CAAC,UAAU,CAAC,IAAID,QAAQ,CAACE,IAAI;MAC/EX,YAAY,CAACY,UAAU,CAACC,gBAAgB,CAACL,mBAAmB,CAAC,CAACM,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E;EACF,CAAC,EAAE,CAACT,QAAQ,EAAE3B,QAAQ,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.22.
|
|
3
|
+
"version": "2.22.3-next.155+09821f09",
|
|
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.40.0-mui-update.0",
|
|
16
|
+
"@pie-lib/render-ui": "4.49.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,13 @@
|
|
|
23
25
|
"scripts": {},
|
|
24
26
|
"author": "",
|
|
25
27
|
"license": "ISC",
|
|
26
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "09821f09cfcaee178971c57f4134645350be2222",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"require": "./lib/index.js",
|
|
32
|
+
"import": "./src/index.js",
|
|
33
|
+
"default": "./lib/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./esm": "./esm/index.js"
|
|
36
|
+
}
|
|
27
37
|
}
|
|
@@ -1,48 +1,107 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { PlaceHolder } from '../placeholder';
|
|
4
4
|
|
|
5
5
|
describe('placeholder', () => {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
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>);
|
|
6
|
+
const renderComponent = (extras = {}) => {
|
|
7
|
+
const props = { ...extras };
|
|
8
|
+
return render(<PlaceHolder {...props}>Foo</PlaceHolder>);
|
|
17
9
|
};
|
|
18
10
|
|
|
19
|
-
describe('
|
|
20
|
-
it('
|
|
21
|
-
|
|
22
|
-
expect(
|
|
11
|
+
describe('rendering', () => {
|
|
12
|
+
it('renders children content', () => {
|
|
13
|
+
renderComponent();
|
|
14
|
+
expect(screen.getByText('Foo')).toBeInTheDocument();
|
|
23
15
|
});
|
|
24
16
|
|
|
25
|
-
it('
|
|
26
|
-
|
|
17
|
+
it('renders with regular placeholder class', () => {
|
|
18
|
+
const { container } = renderComponent();
|
|
19
|
+
const placeholder = container.firstChild;
|
|
20
|
+
expect(placeholder).toHaveClass('placeholder');
|
|
27
21
|
});
|
|
28
22
|
|
|
29
|
-
it('
|
|
30
|
-
|
|
23
|
+
it('applies over class when isOver is true', () => {
|
|
24
|
+
const { container } = renderComponent({ isOver: true });
|
|
25
|
+
const placeholder = container.firstChild;
|
|
26
|
+
expect(placeholder).toHaveClass('over');
|
|
31
27
|
});
|
|
32
28
|
|
|
33
|
-
it('
|
|
34
|
-
|
|
29
|
+
it('applies disabled class when disabled is true', () => {
|
|
30
|
+
const { container } = renderComponent({ disabled: true });
|
|
31
|
+
const placeholder = container.firstChild;
|
|
32
|
+
expect(placeholder).toHaveClass('disabled');
|
|
35
33
|
});
|
|
36
34
|
|
|
37
|
-
it('
|
|
38
|
-
const
|
|
35
|
+
it('applies custom className', () => {
|
|
36
|
+
const { container } = renderComponent({ className: 'bar' });
|
|
37
|
+
const placeholder = container.firstChild;
|
|
38
|
+
expect(placeholder).toHaveClass('bar');
|
|
39
|
+
expect(placeholder).toHaveClass('placeholder');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('applies choice type class', () => {
|
|
43
|
+
const { container } = renderComponent({ type: 'choice' });
|
|
44
|
+
const placeholder = container.firstChild;
|
|
45
|
+
expect(placeholder).toHaveClass('choice');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('applies board class when choiceBoard is true', () => {
|
|
49
|
+
const { container } = renderComponent({ choiceBoard: true });
|
|
50
|
+
const placeholder = container.firstChild;
|
|
51
|
+
expect(placeholder).toHaveClass('board');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('applies categorizeBoard class when choiceBoard and isCategorize are true', () => {
|
|
55
|
+
const { container } = renderComponent({ choiceBoard: true, isCategorize: true });
|
|
56
|
+
const placeholder = container.firstChild;
|
|
57
|
+
expect(placeholder).toHaveClass('categorizeBoard');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('applies verticalPool class when isVerticalPool is true', () => {
|
|
61
|
+
const { container } = renderComponent({ isVerticalPool: true });
|
|
62
|
+
const placeholder = container.firstChild;
|
|
63
|
+
expect(placeholder).toHaveClass('verticalPool');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('grid styles', () => {
|
|
68
|
+
it('applies grid column styles', () => {
|
|
69
|
+
const { container } = renderComponent({
|
|
70
|
+
grid: { columns: 3 },
|
|
71
|
+
});
|
|
72
|
+
const placeholder = container.firstChild;
|
|
73
|
+
expect(placeholder).toHaveStyle({ gridTemplateColumns: 'repeat(3, 1fr)' });
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('applies grid row styles with default value', () => {
|
|
77
|
+
const { container } = renderComponent({
|
|
78
|
+
grid: { rows: 2 },
|
|
79
|
+
});
|
|
80
|
+
const placeholder = container.firstChild;
|
|
81
|
+
expect(placeholder).toHaveStyle({ gridTemplateRows: 'repeat(2, 1fr)' });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('applies grid row styles with custom rowsRepeatValue', () => {
|
|
85
|
+
const { container } = renderComponent({
|
|
39
86
|
grid: {
|
|
40
87
|
rows: 2,
|
|
41
88
|
columns: 1,
|
|
42
89
|
rowsRepeatValue: 'min-content',
|
|
43
90
|
},
|
|
44
91
|
});
|
|
45
|
-
|
|
92
|
+
const placeholder = container.firstChild;
|
|
93
|
+
expect(placeholder).toHaveStyle({
|
|
94
|
+
gridTemplateRows: 'repeat(2, min-content)',
|
|
95
|
+
gridTemplateColumns: 'repeat(1, 1fr)',
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe('min height', () => {
|
|
101
|
+
it('applies minHeight style when provided', () => {
|
|
102
|
+
const { container } = renderComponent({ minHeight: 200 });
|
|
103
|
+
const placeholder = container.firstChild;
|
|
104
|
+
expect(placeholder).toHaveStyle({ minHeight: '200px' });
|
|
46
105
|
});
|
|
47
106
|
});
|
|
48
107
|
});
|
|
@@ -1,21 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
createContext: jest.fn().mockReturnValue({
|
|
7
|
-
Consumer: jest.fn((fn) => fn),
|
|
8
|
-
Provider: jest.fn(),
|
|
9
|
-
}),
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
describe('id-context', () => {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { withUid, Provider as UidProvider } from '../uid-context';
|
|
4
|
+
|
|
5
|
+
describe('uid-context', () => {
|
|
13
6
|
describe('withUid', () => {
|
|
14
|
-
it('
|
|
15
|
-
const
|
|
7
|
+
it('provides uid to wrapped component', () => {
|
|
8
|
+
const TestComponent = ({ uid }) => <div data-testid="test-uid">{uid}</div>;
|
|
9
|
+
const WrappedComponent = withUid(TestComponent);
|
|
10
|
+
|
|
11
|
+
render(
|
|
12
|
+
<UidProvider value="test-uid-123">
|
|
13
|
+
<WrappedComponent />
|
|
14
|
+
</UidProvider>,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
expect(screen.getByTestId('test-uid')).toHaveTextContent('test-uid-123');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('passes through other props to wrapped component', () => {
|
|
21
|
+
const TestComponent = ({ uid, customProp }) => (
|
|
22
|
+
<div>
|
|
23
|
+
<span data-testid="uid">{uid}</span>
|
|
24
|
+
<span data-testid="custom">{customProp}</span>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
const WrappedComponent = withUid(TestComponent);
|
|
28
|
+
|
|
29
|
+
render(
|
|
30
|
+
<UidProvider value="test-uid">
|
|
31
|
+
<WrappedComponent customProp="custom-value" />
|
|
32
|
+
</UidProvider>,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(screen.getByTestId('uid')).toHaveTextContent('test-uid');
|
|
36
|
+
expect(screen.getByTestId('custom')).toHaveTextContent('custom-value');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('UidProvider', () => {
|
|
41
|
+
it('provides uid context to children', () => {
|
|
42
|
+
const TestComponent = ({ uid }) => <div data-testid="uid-value">{uid}</div>;
|
|
43
|
+
const WrappedComponent = withUid(TestComponent);
|
|
44
|
+
|
|
45
|
+
render(
|
|
46
|
+
<UidProvider value="provider-uid">
|
|
47
|
+
<WrappedComponent />
|
|
48
|
+
</UidProvider>,
|
|
49
|
+
);
|
|
16
50
|
|
|
17
|
-
|
|
18
|
-
expect(createElement).toBeCalledWith(expect.any(Function), null, expect.anything());
|
|
51
|
+
expect(screen.getByTestId('uid-value')).toHaveTextContent('provider-uid');
|
|
19
52
|
});
|
|
20
53
|
});
|
|
21
54
|
});
|