@pie-lib/drag 2.34.0-mui-update.0 → 3.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -107
- package/lib/drag-provider.js +6 -3
- package/lib/drag-provider.js.map +1 -1
- package/lib/draggable-choice.js +6 -3
- package/lib/draggable-choice.js.map +1 -1
- package/package.json +12 -4
- package/src/__tests__/placeholder.test.jsx +84 -25
- package/src/__tests__/uid-context.test.jsx +49 -16
- package/src/drag-provider.jsx +3 -1
- package/src/draggable-choice.jsx +3 -1
- package/src/__tests__/__snapshots__/placeholder.test.jsx.snap +0 -68
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
-
# [
|
|
6
|
+
# [3.0.0-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.22.3-next.0...@pie-lib/drag@3.0.0-next.0) (2026-01-19)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @pie-lib/drag
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
## [2.22.3-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.36.0-mui-update.0...@pie-lib/drag@2.22.3-next.0) (2026-01-19)
|
|
15
15
|
|
|
16
16
|
**Note:** Version bump only for package @pie-lib/drag
|
|
17
17
|
|
|
@@ -19,186 +19,87 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
# [2.32.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.31.0-mui-update.0...@pie-lib/drag@2.32.0-mui-update.0) (2025-12-11)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* drag changes for ditb ([fc79ecd](https://github.com/pie-framework/pie-lib/commit/fc79ecdacb5693f1b5dcf19c7114f9cd4bed83ba))
|
|
28
|
-
* updates for drag-in-the-blank ([0c096d8](https://github.com/pie-framework/pie-lib/commit/0c096d887f97edecd2dac68cda136b2d265dc7d5))
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
# [2.31.0-mui-update.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.30.0-mui-update.0...@pie-lib/drag@2.31.0-mui-update.0) (2025-12-02)
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
### Bug Fixes
|
|
38
|
-
|
|
39
|
-
* drag components ([bea5eaa](https://github.com/pie-framework/pie-lib/commit/bea5eaaa54fc9060ac83bb7d6383b4c9e2491574))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### Features
|
|
43
|
-
|
|
44
|
-
* add drag provider onDragStart prop ([0879247](https://github.com/pie-framework/pie-lib/commit/087924747b02ceed710e971e8dbe0291071396af))
|
|
45
|
-
* sync latest changes from dev ([c936e9c](https://github.com/pie-framework/pie-lib/commit/c936e9c7f9e095e7d9b9805ac2bf72bd271e05f1))
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
22
|
## [2.22.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.22.1...@pie-lib/drag@2.22.2) (2025-11-27)
|
|
52
23
|
|
|
53
24
|
**Note:** Version bump only for package @pie-lib/drag
|
|
54
25
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
26
|
## [2.22.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.18.2...@pie-lib/drag@2.22.1) (2025-10-22)
|
|
60
27
|
|
|
61
28
|
**Note:** Version bump only for package @pie-lib/drag
|
|
62
29
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
30
|
# [2.22.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.21.0...@pie-lib/drag@2.22.0) (2025-10-16)
|
|
68
31
|
|
|
69
32
|
**Note:** Version bump only for package @pie-lib/drag
|
|
70
33
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
34
|
# [2.21.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.18.0...@pie-lib/drag@2.21.0) (2025-10-16)
|
|
76
35
|
|
|
77
36
|
**Note:** Version bump only for package @pie-lib/drag
|
|
78
37
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
38
|
# [2.20.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.18.0...@pie-lib/drag@2.20.0) (2025-10-16)
|
|
84
39
|
|
|
85
40
|
**Note:** Version bump only for package @pie-lib/drag
|
|
86
41
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
42
|
# [2.19.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.18.0...@pie-lib/drag@2.19.0) (2025-10-16)
|
|
92
43
|
|
|
93
44
|
**Note:** Version bump only for package @pie-lib/drag
|
|
94
45
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
46
|
## [2.18.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.18.1...@pie-lib/drag@2.18.2) (2025-10-14)
|
|
100
47
|
|
|
101
48
|
**Note:** Version bump only for package @pie-lib/drag
|
|
102
49
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
50
|
## [2.18.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.18.0...@pie-lib/drag@2.18.1) (2025-10-09)
|
|
108
51
|
|
|
109
52
|
**Note:** Version bump only for package @pie-lib/drag
|
|
110
53
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
54
|
# [2.18.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.18.0) (2025-09-25)
|
|
116
55
|
|
|
117
|
-
|
|
118
56
|
### Bug Fixes
|
|
119
57
|
|
|
120
|
-
|
|
121
|
-
|
|
58
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
122
59
|
|
|
123
60
|
### Features
|
|
124
61
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
62
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
130
63
|
|
|
131
64
|
# [2.17.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.16.0...@pie-lib/drag@2.17.0) (2025-09-18)
|
|
132
65
|
|
|
133
66
|
**Note:** Version bump only for package @pie-lib/drag
|
|
134
67
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
68
|
# [2.16.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.15.0...@pie-lib/drag@2.16.0) (2025-09-18)
|
|
140
69
|
|
|
141
70
|
**Note:** Version bump only for package @pie-lib/drag
|
|
142
71
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
72
|
# [2.15.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.15.0) (2025-09-18)
|
|
148
73
|
|
|
149
|
-
|
|
150
74
|
### Bug Fixes
|
|
151
75
|
|
|
152
|
-
|
|
153
|
-
|
|
76
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
154
77
|
|
|
155
78
|
### Features
|
|
156
79
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
80
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
162
81
|
|
|
163
82
|
# [2.14.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.13.0...@pie-lib/drag@2.14.0) (2025-09-17)
|
|
164
83
|
|
|
165
84
|
**Note:** Version bump only for package @pie-lib/drag
|
|
166
85
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
86
|
# [2.13.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.12.0...@pie-lib/drag@2.13.0) (2025-09-17)
|
|
172
87
|
|
|
173
88
|
**Note:** Version bump only for package @pie-lib/drag
|
|
174
89
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
90
|
# [2.12.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.11.1...@pie-lib/drag@2.12.0) (2025-09-17)
|
|
180
91
|
|
|
181
92
|
**Note:** Version bump only for package @pie-lib/drag
|
|
182
93
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
94
|
## [2.11.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.11.1) (2025-08-11)
|
|
188
95
|
|
|
189
|
-
|
|
190
96
|
### Bug Fixes
|
|
191
97
|
|
|
192
|
-
|
|
193
|
-
|
|
98
|
+
- fixed pie-lib/icons import [PD-5126](<[dcb506c](https://github.com/pie-framework/pie-lib/commit/dcb506c914a177f6d88bf73247a023bfe71dac1f)>)
|
|
194
99
|
|
|
195
100
|
### Features
|
|
196
101
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
102
|
+
- split pie-toolbox into multiple packages [PD-5126](<[7d55a25](https://github.com/pie-framework/pie-lib/commit/7d55a2552d084cd3d0d5c00dc77411b2ced2f5e2)>)
|
|
202
103
|
|
|
203
104
|
# [2.11.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/drag@2.2.9...@pie-lib/drag@2.11.0) (2025-08-07)
|
|
204
105
|
|
package/lib/drag-provider.js
CHANGED
|
@@ -17,7 +17,8 @@ function DragProvider(_ref) {
|
|
|
17
17
|
onDragEnd = _ref.onDragEnd,
|
|
18
18
|
onDragStart = _ref.onDragStart,
|
|
19
19
|
collisionDetection = _ref.collisionDetection,
|
|
20
|
-
modifiers = _ref.modifiers
|
|
20
|
+
modifiers = _ref.modifiers,
|
|
21
|
+
autoScroll = _ref.autoScroll;
|
|
21
22
|
var _useState = (0, _react.useState)(null),
|
|
22
23
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
23
24
|
activeId = _useState2[0],
|
|
@@ -44,7 +45,8 @@ function DragProvider(_ref) {
|
|
|
44
45
|
onDragStart: handleDragStart,
|
|
45
46
|
onDragEnd: handleDragEnd,
|
|
46
47
|
collisionDetection: collisionDetection,
|
|
47
|
-
modifiers: modifiers
|
|
48
|
+
modifiers: modifiers,
|
|
49
|
+
autoScroll: autoScroll
|
|
48
50
|
}, children);
|
|
49
51
|
}
|
|
50
52
|
DragProvider.propTypes = {
|
|
@@ -52,7 +54,8 @@ DragProvider.propTypes = {
|
|
|
52
54
|
onDragEnd: _propTypes["default"].func,
|
|
53
55
|
onDragStart: _propTypes["default"].func,
|
|
54
56
|
collisionDetection: _propTypes["default"].func,
|
|
55
|
-
modifiers: _propTypes["default"].arrayOf(_propTypes["default"].func)
|
|
57
|
+
modifiers: _propTypes["default"].arrayOf(_propTypes["default"].func),
|
|
58
|
+
autoScroll: _propTypes["default"].object
|
|
56
59
|
};
|
|
57
60
|
var _default = exports["default"] = DragProvider;
|
|
58
61
|
//# sourceMappingURL=drag-provider.js.map
|
package/lib/drag-provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drag-provider.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_core","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DragProvider","_ref","children","onDragEnd","onDragStart","collisionDetection","modifiers","_useState","useState","_useState2","_slicedToArray2","activeId","setActiveId","sensors","useSensors","useSensor","PointerSensor","activationConstraint","distance","KeyboardSensor","handleDragStart","event","active","id","handleDragEnd","createElement","DndContext","propTypes","PropTypes","node","isRequired","func","arrayOf","_default","exports"],"sources":["../src/drag-provider.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { DndContext, PointerSensor, KeyboardSensor, useSensor, useSensors } from '@dnd-kit/core';\n\nexport function DragProvider({ children, onDragEnd, onDragStart, collisionDetection, modifiers }) {\n const [activeId, setActiveId] = useState(null);\n \n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 8 }}),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart = (event) => {\n setActiveId(event.active.id);\n if (onDragStart) {\n onDragStart(event);\n }\n };\n\n const handleDragEnd = (event) => {\n setActiveId(null);\n if (onDragEnd) {\n onDragEnd(event);\n }\n };\n\n return (\n <DndContext \n sensors={sensors} \n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n collisionDetection={collisionDetection}\n modifiers={modifiers}\n >\n {children}\n </DndContext>\n );\n}\n\nDragProvider.propTypes = {\n children: PropTypes.node.isRequired,\n onDragEnd: PropTypes.func,\n onDragStart: PropTypes.func,\n collisionDetection: PropTypes.func,\n modifiers: PropTypes.arrayOf(PropTypes.func),\n};\n\nexport default DragProvider;"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAiG,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,OAAAP,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAM,EAAA,EAAAP,CAAA,IAAAC,CAAA,CAAAM,EAAA,IAAAd,CAAA,CAAAc,EAAA,WAAAN,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAE1F,SAASmB,YAAYA,CAAAC,IAAA,
|
|
1
|
+
{"version":3,"file":"drag-provider.js","names":["_react","_interopRequireWildcard","require","_propTypes","_interopRequireDefault","_core","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DragProvider","_ref","children","onDragEnd","onDragStart","collisionDetection","modifiers","autoScroll","_useState","useState","_useState2","_slicedToArray2","activeId","setActiveId","sensors","useSensors","useSensor","PointerSensor","activationConstraint","distance","KeyboardSensor","handleDragStart","event","active","id","handleDragEnd","createElement","DndContext","propTypes","PropTypes","node","isRequired","func","arrayOf","object","_default","exports"],"sources":["../src/drag-provider.jsx"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { DndContext, PointerSensor, KeyboardSensor, useSensor, useSensors } from '@dnd-kit/core';\n\nexport function DragProvider({ children, onDragEnd, onDragStart, collisionDetection, modifiers, autoScroll }) {\n const [activeId, setActiveId] = useState(null);\n \n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 8 }}),\n useSensor(KeyboardSensor)\n );\n\n const handleDragStart = (event) => {\n setActiveId(event.active.id);\n if (onDragStart) {\n onDragStart(event);\n }\n };\n\n const handleDragEnd = (event) => {\n setActiveId(null);\n if (onDragEnd) {\n onDragEnd(event);\n }\n };\n\n return (\n <DndContext \n sensors={sensors} \n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n collisionDetection={collisionDetection}\n modifiers={modifiers}\n autoScroll={autoScroll}\n >\n {children}\n </DndContext>\n );\n}\n\nDragProvider.propTypes = {\n children: PropTypes.node.isRequired,\n onDragEnd: PropTypes.func,\n onDragStart: PropTypes.func,\n collisionDetection: PropTypes.func,\n modifiers: PropTypes.arrayOf(PropTypes.func),\n autoScroll: PropTypes.object,\n};\n\nexport default DragProvider;"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAAiG,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAA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AAC,QAAA,GAAAC,OAAA,cAEapC,YAAY","ignoreList":[]}
|
package/lib/draggable-choice.js
CHANGED
|
@@ -38,9 +38,11 @@ function DraggableChoice(_ref2) {
|
|
|
38
38
|
alternateResponseIndex = _ref2.alternateResponseIndex,
|
|
39
39
|
choiceIndex = _ref2.choiceIndex,
|
|
40
40
|
onRemoveChoice = _ref2.onRemoveChoice,
|
|
41
|
-
type = _ref2.type
|
|
41
|
+
type = _ref2.type,
|
|
42
|
+
id = _ref2.id;
|
|
42
43
|
var _useDraggable = (0, _core.useDraggable)({
|
|
43
|
-
id: choice.id,
|
|
44
|
+
id: id || choice.id,
|
|
45
|
+
// id to be used for dnd-kit
|
|
44
46
|
disabled: disabled,
|
|
45
47
|
categoryId: category === null || category === void 0 ? void 0 : category.id,
|
|
46
48
|
alternateResponseIndex: alternateResponseIndex,
|
|
@@ -80,7 +82,8 @@ DraggableChoice.propTypes = {
|
|
|
80
82
|
alternateResponseIndex: _propTypes["default"].number,
|
|
81
83
|
choiceIndex: _propTypes["default"].number,
|
|
82
84
|
onRemoveChoice: _propTypes["default"].func,
|
|
83
|
-
type: _propTypes["default"].string
|
|
85
|
+
type: _propTypes["default"].string,
|
|
86
|
+
id: _propTypes["default"].string
|
|
84
87
|
};
|
|
85
88
|
var _default = exports["default"] = DraggableChoice;
|
|
86
89
|
//# sourceMappingURL=draggable-choice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggable-choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_core","_colors","DRAG_TYPE","exports","StyledChoice","styled","_ref","theme","backgroundColor","palette","background","paper","border","concat","grey","padding","spacing","minHeight","minWidth","maxWidth","cursor","DraggableChoice","_ref2","choice","children","className","disabled","category","alternateResponseIndex","choiceIndex","onRemoveChoice","type","
|
|
1
|
+
{"version":3,"file":"draggable-choice.js","names":["_react","_interopRequireDefault","require","_propTypes","_styles","_core","_colors","DRAG_TYPE","exports","StyledChoice","styled","_ref","theme","backgroundColor","palette","background","paper","border","concat","grey","padding","spacing","minHeight","minWidth","maxWidth","cursor","DraggableChoice","_ref2","choice","children","className","disabled","category","alternateResponseIndex","choiceIndex","onRemoveChoice","type","id","_useDraggable","useDraggable","categoryId","data","value","choiceId","from","attributes","listeners","setNodeRef","isDragging","createElement","_extends2","ref","propTypes","PropTypes","shape","oneOfType","string","number","isRequired","any","arrayOf","node","bool","func","_default"],"sources":["../src/draggable-choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { styled } from '@mui/material/styles';\nimport { useDraggable } from '@dnd-kit/core';\nimport { grey } from '@mui/material/colors';\n\nexport const DRAG_TYPE = 'CHOICE';\n\nconst StyledChoice = styled('div')(({ theme }) => ({\n backgroundColor: theme.palette.background.paper,\n border: `solid 1px ${grey[400]}`,\n padding: theme.spacing(1),\n minHeight: '30px',\n minWidth: theme.spacing(20),\n maxWidth: theme.spacing(75),\n cursor: 'grab',\n '&:active': {\n cursor: 'grabbing',\n },\n}));\n\nexport function DraggableChoice({\n choice,\n children,\n className,\n disabled,\n category,\n alternateResponseIndex,\n choiceIndex,\n onRemoveChoice,\n type,\n id\n}) {\n const {\n attributes,\n listeners,\n setNodeRef,\n isDragging\n } = useDraggable({\n id: id || choice.id, // id to be used for dnd-kit\n disabled: disabled,\n categoryId: category?.id,\n alternateResponseIndex,\n data: {\n id: choice.id,\n value: choice.value,\n choiceId: choice.id,\n from: category?.id,\n categoryId: category?.id,\n alternateResponseIndex,\n choiceIndex,\n onRemoveChoice,\n type\n }\n });\n\n return (\n <StyledChoice\n ref={setNodeRef}\n className={className}\n isDragging={isDragging}\n {...attributes}\n {...listeners}\n >\n {children}\n </StyledChoice>\n );\n}\n\nDraggableChoice.propTypes = {\n choice: PropTypes.shape({\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,\n value: PropTypes.any,\n }).isRequired,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n className: PropTypes.string,\n disabled: PropTypes.bool,\n category: PropTypes.shape({\n id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n alternateResponseIndex: PropTypes.number,\n choiceIndex: PropTypes.number,\n onRemoveChoice: PropTypes.func,\n type: PropTypes.string,\n id: PropTypes.string,\n};\n\nexport default DraggableChoice;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEO,IAAMK,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,QAAQ;AAEjC,IAAME,YAAY,GAAG,IAAAC,cAAM,EAAC,KAAK,CAAC,CAAC,UAAAC,IAAA;EAAA,IAAGC,KAAK,GAAAD,IAAA,CAALC,KAAK;EAAA,OAAQ;IACjDC,eAAe,EAAED,KAAK,CAACE,OAAO,CAACC,UAAU,CAACC,KAAK;IAC/CC,MAAM,eAAAC,MAAA,CAAeC,YAAI,CAAC,GAAG,CAAC,CAAE;IAChCC,OAAO,EAAER,KAAK,CAACS,OAAO,CAAC,CAAC,CAAC;IACzBC,SAAS,EAAE,MAAM;IACjBC,QAAQ,EAAEX,KAAK,CAACS,OAAO,CAAC,EAAE,CAAC;IAC3BG,QAAQ,EAAEZ,KAAK,CAACS,OAAO,CAAC,EAAE,CAAC;IAC3BI,MAAM,EAAE,MAAM;IACd,UAAU,EAAE;MACVA,MAAM,EAAE;IACV;EACF,CAAC;AAAA,CAAC,CAAC;AAEI,SAASC,eAAeA,CAAAC,KAAA,EAW5B;EAAA,IAVDC,MAAM,GAAAD,KAAA,CAANC,MAAM;IACNC,QAAQ,GAAAF,KAAA,CAARE,QAAQ;IACRC,SAAS,GAAAH,KAAA,CAATG,SAAS;IACTC,QAAQ,GAAAJ,KAAA,CAARI,QAAQ;IACRC,Q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AAC0B,SAAS,GAAG;EAC1BxB,MAAM,EAAEyB,qBAAS,CAACC,KAAK,CAAC;IACtBjB,EAAE,EAAEgB,qBAAS,CAACE,SAAS,CAAC,CAACF,qBAAS,CAACG,MAAM,EAAEH,qBAAS,CAACI,MAAM,CAAC,CAAC,CAACC,UAAU;IACxEhB,KAAK,EAAEW,qBAAS,CAACM;EACnB,CAAC,CAAC,CAACD,UAAU;EACb7B,QAAQ,EAAEwB,qBAAS,CAACE,SAAS,CAAC,CAACF,qBAAS,CAACO,OAAO,CAACP,qBAAS,CAACQ,IAAI,CAAC,EAAER,qBAAS,CAACQ,IAAI,CAAC,CAAC;EAClF/B,SAAS,EAAEuB,qBAAS,CAACG,MAAM;EAC3BzB,QAAQ,EAAEsB,qBAAS,CAACS,IAAI;EACxB9B,QAAQ,EAAEqB,qBAAS,CAACC,KAAK,CAAC;IACxBjB,EAAE,EAAEgB,qBAAS,CAACE,SAAS,CAAC,CAACF,qBAAS,CAACG,MAAM,EAAEH,qBAAS,CAACI,MAAM,CAAC;EAC9D,CAAC,CAAC;EACFxB,sBAAsB,EAAEoB,qBAAS,CAACI,MAAM;EACxCvB,WAAW,EAAEmB,qBAAS,CAACI,MAAM;EAC7BtB,cAAc,EAAEkB,qBAAS,CAACU,IAAI;EAC9B3B,IAAI,EAAEiB,qBAAS,CAACG,MAAM;EACtBnB,EAAE,EAAEgB,qBAAS,CAACG;AAChB,CAAC;AAAC,IAAAQ,QAAA,GAAAxD,OAAA,cAEakB,eAAe","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/drag",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"@emotion/style": "^0.8.0",
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
|
-
"@pie-lib/math-rendering": "3.
|
|
16
|
-
"@pie-lib/render-ui": "4.
|
|
15
|
+
"@pie-lib/math-rendering": "3.22.2-next.16",
|
|
16
|
+
"@pie-lib/render-ui": "4.35.3-next.15",
|
|
17
17
|
"classnames": "^2.2.6",
|
|
18
18
|
"lodash": "^4.17.11",
|
|
19
19
|
"prop-types": "^15.7.2",
|
|
@@ -25,5 +25,13 @@
|
|
|
25
25
|
"scripts": {},
|
|
26
26
|
"author": "",
|
|
27
27
|
"license": "ISC",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "e0f8f2250addd014938f4a631ab86cafe16b2730",
|
|
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
|
+
}
|
|
29
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
|
});
|
package/src/drag-provider.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { DndContext, PointerSensor, KeyboardSensor, useSensor, useSensors } from '@dnd-kit/core';
|
|
4
4
|
|
|
5
|
-
export function DragProvider({ children, onDragEnd, onDragStart, collisionDetection, modifiers }) {
|
|
5
|
+
export function DragProvider({ children, onDragEnd, onDragStart, collisionDetection, modifiers, autoScroll }) {
|
|
6
6
|
const [activeId, setActiveId] = useState(null);
|
|
7
7
|
|
|
8
8
|
const sensors = useSensors(
|
|
@@ -31,6 +31,7 @@ export function DragProvider({ children, onDragEnd, onDragStart, collisionDetect
|
|
|
31
31
|
onDragEnd={handleDragEnd}
|
|
32
32
|
collisionDetection={collisionDetection}
|
|
33
33
|
modifiers={modifiers}
|
|
34
|
+
autoScroll={autoScroll}
|
|
34
35
|
>
|
|
35
36
|
{children}
|
|
36
37
|
</DndContext>
|
|
@@ -43,6 +44,7 @@ DragProvider.propTypes = {
|
|
|
43
44
|
onDragStart: PropTypes.func,
|
|
44
45
|
collisionDetection: PropTypes.func,
|
|
45
46
|
modifiers: PropTypes.arrayOf(PropTypes.func),
|
|
47
|
+
autoScroll: PropTypes.object,
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
export default DragProvider;
|
package/src/draggable-choice.jsx
CHANGED
|
@@ -29,6 +29,7 @@ export function DraggableChoice({
|
|
|
29
29
|
choiceIndex,
|
|
30
30
|
onRemoveChoice,
|
|
31
31
|
type,
|
|
32
|
+
id
|
|
32
33
|
}) {
|
|
33
34
|
const {
|
|
34
35
|
attributes,
|
|
@@ -36,7 +37,7 @@ export function DraggableChoice({
|
|
|
36
37
|
setNodeRef,
|
|
37
38
|
isDragging
|
|
38
39
|
} = useDraggable({
|
|
39
|
-
id: choice.id,
|
|
40
|
+
id: id || choice.id, // id to be used for dnd-kit
|
|
40
41
|
disabled: disabled,
|
|
41
42
|
categoryId: category?.id,
|
|
42
43
|
alternateResponseIndex,
|
|
@@ -81,6 +82,7 @@ DraggableChoice.propTypes = {
|
|
|
81
82
|
choiceIndex: PropTypes.number,
|
|
82
83
|
onRemoveChoice: PropTypes.func,
|
|
83
84
|
type: PropTypes.string,
|
|
85
|
+
id: PropTypes.string,
|
|
84
86
|
};
|
|
85
87
|
|
|
86
88
|
export default DraggableChoice;
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
`;
|