@patternfly/react-drag-drop 5.4.0-prerelease.4 → 5.4.0-prerelease.6
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 +10 -0
- package/dist/cjs.tsbuildinfo +1 -1
- package/dist/esm/next/components/DragDrop/DragDropSort.d.ts.map +1 -1
- package/dist/esm/next/components/DragDrop/DragDropSort.js +4 -1
- package/dist/esm/next/components/DragDrop/DragDropSort.js.map +1 -1
- package/dist/esm.tsbuildinfo +1 -1
- package/dist/js/next/components/DragDrop/DragDropSort.d.ts.map +1 -1
- package/dist/js/next/components/DragDrop/DragDropSort.js +4 -1
- package/dist/js/next/components/DragDrop/DragDropSort.js.map +1 -1
- package/package.json +3 -3
- package/src/next/components/DragDrop/DragDropSort.tsx +5 -1
- package/src/next/components/DragDrop/__tests__/DragDrop.test.tsx +5 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropSort.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DragDropSort.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DragDropSort.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DragDropSort.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAIL,eAAe,EAKf,YAAY,EACZ,cAAc,EACf,MAAM,eAAe,CAAC;AAavB,oBAAY,wBAAwB,GAAG,YAAY,CAAC;AACpD,oBAAY,0BAA0B,GAAG,cAAc,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,mEAAmE;IACnE,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD;iFAC6E;IAC7E,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC9B,wCAAwC;IACxC,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,kDAAkD;IAClD,MAAM,EAAE,CAAC,KAAK,EAAE,wBAAwB,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAClH,2DAA2D;IAC3D,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACvE;;;;;SAKK;IACL,OAAO,CAAC,EAAE,SAAS,GAAG,mBAAmB,GAAG,UAAU,GAAG,sBAAsB,GAAG,iBAAiB,CAAC;CACrG;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CA2HnE,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DragDropSort = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const React = tslib_1.__importStar(require("react"));
|
|
6
|
+
const ReactDOM = tslib_1.__importStar(require("react-dom"));
|
|
6
7
|
const react_styles_1 = require("@patternfly/react-styles");
|
|
7
8
|
const core_1 = require("@dnd-kit/core");
|
|
8
9
|
const sortable_1 = require("@dnd-kit/sortable");
|
|
@@ -10,6 +11,7 @@ const Draggable_1 = require("./Draggable");
|
|
|
10
11
|
const DraggableDataListItem_1 = require("./DraggableDataListItem");
|
|
11
12
|
const DraggableDualListSelectorListItem_1 = require("./DraggableDualListSelectorListItem");
|
|
12
13
|
const drag_drop_1 = tslib_1.__importDefault(require("@patternfly/react-styles/css/components/DragDrop/drag-drop"));
|
|
14
|
+
const react_core_1 = require("@patternfly/react-core");
|
|
13
15
|
const DragDropSort = (_a) => {
|
|
14
16
|
var { items, onDrop = () => { }, onDrag = () => { }, variant = 'default', children } = _a, props = tslib_1.__rest(_a, ["items", "onDrop", "onDrag", "variant", "children"]);
|
|
15
17
|
const [activeId, setActiveId] = React.useState(null);
|
|
@@ -50,6 +52,7 @@ const DragDropSort = (_a) => {
|
|
|
50
52
|
'--pf-v5-c-draggable--m-dragging--BackgroundColor': 'var(--pf-v5-global--BackgroundColor--100)'
|
|
51
53
|
} }, content));
|
|
52
54
|
};
|
|
55
|
+
const dragOverlay = React.createElement(core_1.DragOverlay, null, activeId && getDragOverlay());
|
|
53
56
|
const renderedChildren = (React.createElement(sortable_1.SortableContext, { items: itemIds, strategy: sortable_1.verticalListSortingStrategy, id: "droppable" },
|
|
54
57
|
items.map((item) => {
|
|
55
58
|
switch (variant) {
|
|
@@ -61,7 +64,7 @@ const DragDropSort = (_a) => {
|
|
|
61
64
|
return (React.createElement(Draggable_1.Draggable, Object.assign({ useDragButton: variant === 'defaultWithHandle', key: item.id, id: item.id }, item.props), item.content));
|
|
62
65
|
}
|
|
63
66
|
}),
|
|
64
|
-
|
|
67
|
+
react_core_1.canUseDOM ? ReactDOM.createPortal(dragOverlay, document.getElementById('root')) : dragOverlay));
|
|
65
68
|
return (React.createElement(core_1.DndContext, Object.assign({ sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, onDragStart: handleDragStart }, props),
|
|
66
69
|
children &&
|
|
67
70
|
React.cloneElement(children, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragDropSort.js","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DragDropSort.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,2DAA+C;AAC/C,wCAWuB;AACvB,gDAK2B;AAC3B,2CAAwC;AACxC,mEAAgE;AAChE,2FAAwF;AACxF,mHAAgF;
|
|
1
|
+
{"version":3,"file":"DragDropSort.js","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DragDropSort.tsx"],"names":[],"mappings":";;;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AAC;aACL;QACH,CAAC,CAAC;QACD,sBAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAC9E,CACnB,CAAC;IAEF,OAAO,CACL,oBAAC,iBAAU,kBACT,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,oBAAa,EACjC,SAAS,EAAE,aAAa,EACxB,WAAW,EAAE,eAAe,IACxB,KAAK;QAER,QAAQ;YACP,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE;gBAC3B,QAAQ,EAAE,gBAAgB;aAC3B,CAAC;QACH,CAAC,QAAQ,IAAI,iCAAM,gBAAgB,CAAO,CAChC,CACd,CAAC;AACJ,CAAC,CAAC;AA3HW,QAAA,YAAY,gBA2HvB;AACF,oBAAY,CAAC,WAAW,GAAG,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-drag-drop",
|
|
3
|
-
"version": "5.4.0-prerelease.
|
|
3
|
+
"version": "5.4.0-prerelease.6",
|
|
4
4
|
"description": "PatternFly drag and drop solution",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@dnd-kit/core": "^6.0.8",
|
|
33
33
|
"@dnd-kit/modifiers": "^6.0.1",
|
|
34
34
|
"@dnd-kit/sortable": "^7.0.2",
|
|
35
|
-
"@patternfly/react-core": "^5.4.0-prerelease.
|
|
35
|
+
"@patternfly/react-core": "^5.4.0-prerelease.5",
|
|
36
36
|
"@patternfly/react-icons": "^5.4.0-prerelease.1",
|
|
37
37
|
"@patternfly/react-styles": "^5.4.0-prerelease.1",
|
|
38
38
|
"memoize-one": "^5.1.0",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^4.7.4"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "883f1f6f6c1fa23015d974b80693715be897d0df"
|
|
49
49
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
2
3
|
import { css } from '@patternfly/react-styles';
|
|
3
4
|
import {
|
|
4
5
|
DndContext,
|
|
@@ -22,6 +23,7 @@ import { Draggable } from './Draggable';
|
|
|
22
23
|
import { DraggableDataListItem } from './DraggableDataListItem';
|
|
23
24
|
import { DraggableDualListSelectorListItem } from './DraggableDualListSelectorListItem';
|
|
24
25
|
import styles from '@patternfly/react-styles/css/components/DragDrop/drag-drop';
|
|
26
|
+
import { canUseDOM } from '@patternfly/react-core';
|
|
25
27
|
|
|
26
28
|
export type DragDropSortDragEndEvent = DragEndEvent;
|
|
27
29
|
export type DragDropSortDragStartEvent = DragStartEvent;
|
|
@@ -135,6 +137,8 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
|
|
|
135
137
|
);
|
|
136
138
|
};
|
|
137
139
|
|
|
140
|
+
const dragOverlay = <DragOverlay>{activeId && getDragOverlay()}</DragOverlay>;
|
|
141
|
+
|
|
138
142
|
const renderedChildren = (
|
|
139
143
|
<SortableContext items={itemIds} strategy={verticalListSortingStrategy} id="droppable">
|
|
140
144
|
{items.map((item: DraggableObject) => {
|
|
@@ -159,7 +163,7 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
|
|
|
159
163
|
);
|
|
160
164
|
}
|
|
161
165
|
})}
|
|
162
|
-
|
|
166
|
+
{canUseDOM ? ReactDOM.createPortal(dragOverlay, document.getElementById('root')) : dragOverlay}
|
|
163
167
|
</SortableContext>
|
|
164
168
|
);
|
|
165
169
|
|
|
@@ -2,6 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { DragDropSort } from '../';
|
|
4
4
|
|
|
5
|
+
jest.mock('react-dom', () => ({
|
|
6
|
+
...jest.requireActual('react-dom'),
|
|
7
|
+
createPortal: jest.fn((node) => node)
|
|
8
|
+
}));
|
|
9
|
+
|
|
5
10
|
test('renders some divs', () => {
|
|
6
11
|
const { asFragment } = render(
|
|
7
12
|
<div className="pf-c-droppable pf-m-dragging">
|