@patternfly/react-drag-drop 5.4.0-prerelease.2 → 5.4.0-prerelease.20
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 +81 -0
- package/dist/cjs.tsbuildinfo +1 -1
- package/dist/esm/next/components/DragDrop/DragDropSort.d.ts +2 -2
- package/dist/esm/next/components/DragDrop/DragDropSort.d.ts.map +1 -1
- package/dist/esm/next/components/DragDrop/DragDropSort.js +6 -3
- package/dist/esm/next/components/DragDrop/DragDropSort.js.map +1 -1
- package/dist/esm/next/components/DragDrop/DraggableDualListSelectorListItem.js.map +1 -1
- package/dist/esm.tsbuildinfo +1 -1
- package/dist/js/next/components/DragDrop/DragButton.js.map +1 -1
- package/dist/js/next/components/DragDrop/DragDropSort.d.ts +2 -2
- package/dist/js/next/components/DragDrop/DragDropSort.d.ts.map +1 -1
- package/dist/js/next/components/DragDrop/DragDropSort.js +6 -3
- package/dist/js/next/components/DragDrop/DragDropSort.js.map +1 -1
- package/dist/js/next/components/DragDrop/DraggableDualListSelectorListItem.js.map +1 -1
- package/package.json +6 -10
- package/src/next/components/DragDrop/DragDropSort.tsx +17 -3
- package/src/next/components/DragDrop/__tests__/DragDrop.test.tsx +5 -0
- package/src/next/components/DragDrop/__tests__/__snapshots__/DragDrop.test.tsx.snap +81 -15
- package/src/next/components/DragDrop/examples/BasicSortingWithDragButton.tsx +0 -1
- package/src/next/components/DragDrop/examples/DragDrop.md +0 -6
- package/src/next/components/DragDrop/examples/BasicSorting.tsx +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragButton.js","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DragButton.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,2DAA+C;AAC/C,mHAA0F;AAC1F,2GAAiF
|
|
1
|
+
{"version":3,"file":"DragButton.js","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DragButton.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,2DAA+C;AAC/C,mHAA0F;AAC1F,2GAAiF;;AAY1E,MAAM,UAAU,GAA6C,CAAC,EAAwC,EAAE,EAAE;QAA5C,EAAE,SAAS,OAA6B,EAAxB,KAAK,sBAArB,aAAuB,CAAF;IAAwB,OAAA,CAChH,8CACE,SAAS,EAAE,IAAA,kBAAG,EAAC,SAAS,EAAE,gBAAY,CAAC,MAAM,EAAE,gBAAY,CAAC,SAAS,CAAC,KAAK,CAAC,gBACjE,aAAa,IACpB,KAAK;QAET,8BAAM,SAAS,EAAE,IAAA,kBAAG,EAAC,mBAAgB,CAAC,yBAAyB,CAAC;YAC9D,oBAAC,4BAAgB,OAAG,CACf,CACA,CACV,CAAA;CAAA,CAAC;AAVW,QAAA,UAAU,cAUrB;AACF,kBAAU,CAAC,WAAW,GAAG,YAAY,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { DndContextProps, DragEndEvent, DragStartEvent } from '@dnd-kit/core';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type DragDropSortDragEndEvent = DragEndEvent;
|
|
4
|
+
export type DragDropSortDragStartEvent = DragStartEvent;
|
|
5
5
|
export interface DraggableObject {
|
|
6
6
|
/** Unique id of the draggable object */
|
|
7
7
|
id: string;
|
|
@@ -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,MAAM,MAAM,wBAAwB,GAAG,YAAY,CAAC;AACpD,MAAM,MAAM,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,CAqInE,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);
|
|
@@ -44,12 +46,13 @@ const DragDropSort = (_a) => {
|
|
|
44
46
|
content = (React.createElement(DraggableDataListItem_1.DraggableDataListItem, Object.assign({ key: item.id, id: item.id }, item.props), item.content));
|
|
45
47
|
break;
|
|
46
48
|
default:
|
|
47
|
-
content = (React.createElement(Draggable_1.Draggable, Object.assign({ useDragButton: variant === 'defaultWithHandle', key: item.id, id: item.id }, item.props), item.content));
|
|
49
|
+
content = (React.createElement(Draggable_1.Draggable, Object.assign({ useDragButton: variant === 'defaultWithHandle' || variant === 'default', key: item.id, id: item.id }, item.props), item.content));
|
|
48
50
|
}
|
|
49
51
|
return (React.createElement("div", { className: (0, react_styles_1.css)(drag_drop_1.default.draggable, drag_drop_1.default.modifiers.dragging), style: {
|
|
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) {
|
|
@@ -58,10 +61,10 @@ const DragDropSort = (_a) => {
|
|
|
58
61
|
case 'DataList':
|
|
59
62
|
return (React.createElement(DraggableDataListItem_1.DraggableDataListItem, Object.assign({ key: item.id, id: item.id }, item.props), item.content));
|
|
60
63
|
default:
|
|
61
|
-
return (React.createElement(Draggable_1.Draggable, Object.assign({ useDragButton: variant === 'defaultWithHandle', key: item.id, id: item.id }, item.props), item.content));
|
|
64
|
+
return (React.createElement(Draggable_1.Draggable, Object.assign({ useDragButton: variant === 'defaultWithHandle' || variant === 'default', 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":";;;;AAAA,qDAA+B;AAC/B,4DAAsC;AACtC,2DAA+C;AAC/C,wCAWuB;AACvB,gDAK2B;AAC3B,2CAAwC;AACxC,mEAAgE;AAChE,2FAAwF;AACxF,mHAAgF;AAChF,uDAAmD;AAoC5C,MAAM,YAAY,GAA+C,CAAC,EAOrD,EAAE,EAAE;QAPiD,EACvE,KAAK,EACL,MAAM,GAAG,GAAG,EAAE,GAAE,CAAC,EACjB,MAAM,GAAG,GAAG,EAAE,GAA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ACT,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;AArIW,QAAA,YAAY,gBAqIvB;AACF,oBAAY,CAAC,WAAW,GAAG,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DraggableDualListSelectorListItem.js","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DraggableDualListSelectorListItem.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,gDAAgD;AAChD,kDAAyC;AACzC,2DAA+C;AAC/C,6IAAiG;AACjG,mHAAoF;AACpF,6CAA0C
|
|
1
|
+
{"version":3,"file":"DraggableDualListSelectorListItem.js","sourceRoot":"","sources":["../../../../../src/next/components/DragDrop/DraggableDualListSelectorListItem.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAC/B,gDAAgD;AAChD,kDAAyC;AACzC,2DAA+C;AAC/C,6IAAiG;AACjG,mHAAoF;AACpF,6CAA0C;;AAwBnC,MAAM,iCAAiC,GAAoE,CAAC,EAQ1E,EAAE,EAAE;QARsE,EACjH,QAAQ,EACR,EAAE,EACF,SAAS,EACT,UAAU,EACV,UAAU,EACV,cAAc,OAEyB,EADpC,KAAK,sBAPyG,6EAQlH,CADS;IAER,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAA,sBAAW,EAAC;QAC3F,EAAE;QACF,oBAAoB,EAAE,GAAG,EAAE,CAAC,KAAK;KAClC,CAAC,CAAC;IAEH,MAAM,EAAE,gBAAgB,EAAE,GAAG,K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,CAAC,CAAC;gBAEZ,8BAAM,SAAS,EAAE,IAAA,kBAAG,EAAC,4BAAM,CAAC,wBAAwB,CAAC;oBACnD,8BAAM,SAAS,EAAE,IAAA,kBAAG,EAAC,4BAAM,CAAC,wBAAwB,CAAC,IAAG,QAAQ,CAAQ,CACnE,CACF,CACH,CACH,CACN,CAAC;AACJ,CAAC,CAAC;AA7DW,QAAA,iCAAiC,qCA6D5C;AACF,yCAAiC,CAAC,WAAW,GAAG,mCAAmC,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.20",
|
|
4
4
|
"description": "PatternFly drag and drop solution",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -29,21 +29,17 @@
|
|
|
29
29
|
"clean": "rimraf dist"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@dnd-kit/core": "^6.0
|
|
32
|
+
"@dnd-kit/core": "^6.1.0",
|
|
33
33
|
"@dnd-kit/modifiers": "^6.0.1",
|
|
34
34
|
"@dnd-kit/sortable": "^7.0.2",
|
|
35
|
-
"@patternfly/react-core": "^5.4.0-prerelease.
|
|
36
|
-
"@patternfly/react-icons": "^5.4.0-prerelease.
|
|
37
|
-
"@patternfly/react-styles": "^5.4.0-prerelease.
|
|
38
|
-
"memoize-one": "^5.1.0",
|
|
35
|
+
"@patternfly/react-core": "^5.4.0-prerelease.19",
|
|
36
|
+
"@patternfly/react-icons": "^5.4.0-prerelease.8",
|
|
37
|
+
"@patternfly/react-styles": "^5.4.0-prerelease.9",
|
|
39
38
|
"resize-observer-polyfill": "^1.5.1"
|
|
40
39
|
},
|
|
41
40
|
"peerDependencies": {
|
|
42
41
|
"react": "^17 || ^18",
|
|
43
42
|
"react-dom": "^17 || ^18"
|
|
44
43
|
},
|
|
45
|
-
"
|
|
46
|
-
"typescript": "^4.7.4"
|
|
47
|
-
},
|
|
48
|
-
"gitHead": "340cea48ffda0cf75fee98ff10fff75d8e03f19d"
|
|
44
|
+
"gitHead": "aa10cf4bb299dcedc7e75492b7c9990a216731a9"
|
|
49
45
|
}
|
|
@@ -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;
|
|
@@ -115,7 +117,12 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
|
|
|
115
117
|
break;
|
|
116
118
|
default:
|
|
117
119
|
content = (
|
|
118
|
-
<Draggable
|
|
120
|
+
<Draggable
|
|
121
|
+
useDragButton={variant === 'defaultWithHandle' || variant === 'default'}
|
|
122
|
+
key={item.id}
|
|
123
|
+
id={item.id}
|
|
124
|
+
{...item.props}
|
|
125
|
+
>
|
|
119
126
|
{item.content}
|
|
120
127
|
</Draggable>
|
|
121
128
|
);
|
|
@@ -135,6 +142,8 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
|
|
|
135
142
|
);
|
|
136
143
|
};
|
|
137
144
|
|
|
145
|
+
const dragOverlay = <DragOverlay>{activeId && getDragOverlay()}</DragOverlay>;
|
|
146
|
+
|
|
138
147
|
const renderedChildren = (
|
|
139
148
|
<SortableContext items={itemIds} strategy={verticalListSortingStrategy} id="droppable">
|
|
140
149
|
{items.map((item: DraggableObject) => {
|
|
@@ -153,13 +162,18 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
|
|
|
153
162
|
);
|
|
154
163
|
default:
|
|
155
164
|
return (
|
|
156
|
-
<Draggable
|
|
165
|
+
<Draggable
|
|
166
|
+
useDragButton={variant === 'defaultWithHandle' || variant === 'default'}
|
|
167
|
+
key={item.id}
|
|
168
|
+
id={item.id}
|
|
169
|
+
{...item.props}
|
|
170
|
+
>
|
|
157
171
|
{item.content}
|
|
158
172
|
</Draggable>
|
|
159
173
|
);
|
|
160
174
|
}
|
|
161
175
|
})}
|
|
162
|
-
|
|
176
|
+
{canUseDOM ? ReactDOM.createPortal(dragOverlay, document.getElementById('root')) : dragOverlay}
|
|
163
177
|
</SortableContext>
|
|
164
178
|
);
|
|
165
179
|
|
|
@@ -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">
|
|
@@ -7,33 +7,99 @@ exports[`renders some divs 1`] = `
|
|
|
7
7
|
>
|
|
8
8
|
<div>
|
|
9
9
|
<div
|
|
10
|
-
aria-describedby="DndDescribedBy-0"
|
|
11
|
-
aria-disabled="false"
|
|
12
|
-
aria-roledescription="sortable"
|
|
13
10
|
class=""
|
|
14
|
-
role="button"
|
|
15
|
-
tabindex="0"
|
|
16
11
|
>
|
|
12
|
+
<button
|
|
13
|
+
aria-describedby="DndDescribedBy-0"
|
|
14
|
+
aria-disabled="false"
|
|
15
|
+
aria-label="Drag button"
|
|
16
|
+
aria-roledescription="sortable"
|
|
17
|
+
class="pf-v5-c-button pf-m-plain"
|
|
18
|
+
role="button"
|
|
19
|
+
tabindex="0"
|
|
20
|
+
>
|
|
21
|
+
<span
|
|
22
|
+
class="pf-v5-c-data-list__item-draggable-icon"
|
|
23
|
+
>
|
|
24
|
+
<svg
|
|
25
|
+
aria-hidden="true"
|
|
26
|
+
class="pf-v5-svg"
|
|
27
|
+
fill="currentColor"
|
|
28
|
+
height="1em"
|
|
29
|
+
role="img"
|
|
30
|
+
viewBox="0 0 320 512"
|
|
31
|
+
width="1em"
|
|
32
|
+
>
|
|
33
|
+
<path
|
|
34
|
+
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
|
|
35
|
+
/>
|
|
36
|
+
</svg>
|
|
37
|
+
</span>
|
|
38
|
+
</button>
|
|
17
39
|
one
|
|
18
40
|
</div>
|
|
19
41
|
<div
|
|
20
|
-
aria-describedby="DndDescribedBy-0"
|
|
21
|
-
aria-disabled="false"
|
|
22
|
-
aria-roledescription="sortable"
|
|
23
42
|
class=""
|
|
24
|
-
role="button"
|
|
25
|
-
tabindex="0"
|
|
26
43
|
>
|
|
44
|
+
<button
|
|
45
|
+
aria-describedby="DndDescribedBy-0"
|
|
46
|
+
aria-disabled="false"
|
|
47
|
+
aria-label="Drag button"
|
|
48
|
+
aria-roledescription="sortable"
|
|
49
|
+
class="pf-v5-c-button pf-m-plain"
|
|
50
|
+
role="button"
|
|
51
|
+
tabindex="0"
|
|
52
|
+
>
|
|
53
|
+
<span
|
|
54
|
+
class="pf-v5-c-data-list__item-draggable-icon"
|
|
55
|
+
>
|
|
56
|
+
<svg
|
|
57
|
+
aria-hidden="true"
|
|
58
|
+
class="pf-v5-svg"
|
|
59
|
+
fill="currentColor"
|
|
60
|
+
height="1em"
|
|
61
|
+
role="img"
|
|
62
|
+
viewBox="0 0 320 512"
|
|
63
|
+
width="1em"
|
|
64
|
+
>
|
|
65
|
+
<path
|
|
66
|
+
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
|
|
67
|
+
/>
|
|
68
|
+
</svg>
|
|
69
|
+
</span>
|
|
70
|
+
</button>
|
|
27
71
|
two
|
|
28
72
|
</div>
|
|
29
73
|
<div
|
|
30
|
-
aria-describedby="DndDescribedBy-0"
|
|
31
|
-
aria-disabled="false"
|
|
32
|
-
aria-roledescription="sortable"
|
|
33
74
|
class=""
|
|
34
|
-
role="button"
|
|
35
|
-
tabindex="0"
|
|
36
75
|
>
|
|
76
|
+
<button
|
|
77
|
+
aria-describedby="DndDescribedBy-0"
|
|
78
|
+
aria-disabled="false"
|
|
79
|
+
aria-label="Drag button"
|
|
80
|
+
aria-roledescription="sortable"
|
|
81
|
+
class="pf-v5-c-button pf-m-plain"
|
|
82
|
+
role="button"
|
|
83
|
+
tabindex="0"
|
|
84
|
+
>
|
|
85
|
+
<span
|
|
86
|
+
class="pf-v5-c-data-list__item-draggable-icon"
|
|
87
|
+
>
|
|
88
|
+
<svg
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
class="pf-v5-svg"
|
|
91
|
+
fill="currentColor"
|
|
92
|
+
height="1em"
|
|
93
|
+
role="img"
|
|
94
|
+
viewBox="0 0 320 512"
|
|
95
|
+
width="1em"
|
|
96
|
+
>
|
|
97
|
+
<path
|
|
98
|
+
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
|
|
99
|
+
/>
|
|
100
|
+
</svg>
|
|
101
|
+
</span>
|
|
102
|
+
</button>
|
|
37
103
|
three
|
|
38
104
|
</div>
|
|
39
105
|
</div>
|
|
@@ -21,12 +21,6 @@ import { DragDropSort } from '@patternfly/react-drag-drop';
|
|
|
21
21
|
|
|
22
22
|
### Basic drag and drop sorting
|
|
23
23
|
|
|
24
|
-
```ts file="./BasicSorting.tsx"
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Basic drag and drop sorting with drag button
|
|
29
|
-
|
|
30
24
|
```ts file="./BasicSortingWithDragButton.tsx"
|
|
31
25
|
|
|
32
26
|
```
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { DragDropSort, DraggableObject } from '@patternfly/react-drag-drop';
|
|
3
|
-
|
|
4
|
-
export const BasicSorting: React.FunctionComponent = () => {
|
|
5
|
-
const [items, setItems] = React.useState<DraggableObject[]>([
|
|
6
|
-
{ id: 'basic-1', content: 'one' },
|
|
7
|
-
{ id: 'basic-2', content: 'two' },
|
|
8
|
-
{ id: 'basic-3', content: 'three' }
|
|
9
|
-
]);
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<DragDropSort
|
|
13
|
-
items={items}
|
|
14
|
-
onDrop={(_, newItems) => {
|
|
15
|
-
setItems(newItems);
|
|
16
|
-
}}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
};
|