@patternfly/react-core 4.208.1 → 4.208.2
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
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## 4.208.2 (2022-05-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/react-core
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## 4.208.1 (2022-05-03)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @patternfly/react-core
|
package/dist/umd/react-core.css
CHANGED
|
@@ -22630,6 +22630,75 @@ svg.pf-c-spinner.pf-m-xl {
|
|
|
22630
22630
|
direction: ltr;
|
|
22631
22631
|
}
|
|
22632
22632
|
}
|
|
22633
|
+
.pf-l-gallery {
|
|
22634
|
+
--pf-l-gallery--m-gutter--GridGap: var(--pf-global--gutter);
|
|
22635
|
+
--pf-l-gallery--GridTemplateColumns--min: 250px;
|
|
22636
|
+
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min);
|
|
22637
|
+
--pf-l-gallery--GridTemplateColumns--max: 1fr;
|
|
22638
|
+
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max);
|
|
22639
|
+
--pf-l-gallery--GridTemplateColumns: repeat(auto-fill, minmax(var(--pf-l-gallery--GridTemplateColumns--minmax--min), var(--pf-l-gallery--GridTemplateColumns--minmax--max)));
|
|
22640
|
+
--pf-l-gallery--GridTemplateRows: auto;
|
|
22641
|
+
display: grid;
|
|
22642
|
+
grid-template-columns: var(--pf-l-gallery--GridTemplateColumns);
|
|
22643
|
+
grid-template-rows: var(--pf-l-gallery--GridTemplateRows);
|
|
22644
|
+
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min);
|
|
22645
|
+
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max);
|
|
22646
|
+
}
|
|
22647
|
+
|
|
22648
|
+
.pf-l-gallery.pf-m-gutter {
|
|
22649
|
+
grid-gap: var(--pf-l-gallery--m-gutter--GridGap);
|
|
22650
|
+
}
|
|
22651
|
+
|
|
22652
|
+
@media (min-width: 576px) {
|
|
22653
|
+
.pf-l-gallery {
|
|
22654
|
+
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min));
|
|
22655
|
+
}
|
|
22656
|
+
}
|
|
22657
|
+
@media (min-width: 768px) {
|
|
22658
|
+
.pf-l-gallery {
|
|
22659
|
+
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min)));
|
|
22660
|
+
}
|
|
22661
|
+
}
|
|
22662
|
+
@media (min-width: 992px) {
|
|
22663
|
+
.pf-l-gallery {
|
|
22664
|
+
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-lg, var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min))));
|
|
22665
|
+
}
|
|
22666
|
+
}
|
|
22667
|
+
@media (min-width: 1200px) {
|
|
22668
|
+
.pf-l-gallery {
|
|
22669
|
+
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-xl, var(--pf-l-gallery--GridTemplateColumns--min-on-lg, var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min)))));
|
|
22670
|
+
}
|
|
22671
|
+
}
|
|
22672
|
+
@media (min-width: 1450px) {
|
|
22673
|
+
.pf-l-gallery {
|
|
22674
|
+
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-2xl, var(--pf-l-gallery--GridTemplateColumns--min-on-xl, var(--pf-l-gallery--GridTemplateColumns--min-on-lg, var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min))))));
|
|
22675
|
+
}
|
|
22676
|
+
}
|
|
22677
|
+
@media (min-width: 576px) {
|
|
22678
|
+
.pf-l-gallery {
|
|
22679
|
+
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max));
|
|
22680
|
+
}
|
|
22681
|
+
}
|
|
22682
|
+
@media (min-width: 768px) {
|
|
22683
|
+
.pf-l-gallery {
|
|
22684
|
+
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max)));
|
|
22685
|
+
}
|
|
22686
|
+
}
|
|
22687
|
+
@media (min-width: 992px) {
|
|
22688
|
+
.pf-l-gallery {
|
|
22689
|
+
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-lg, var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max))));
|
|
22690
|
+
}
|
|
22691
|
+
}
|
|
22692
|
+
@media (min-width: 1200px) {
|
|
22693
|
+
.pf-l-gallery {
|
|
22694
|
+
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-xl, var(--pf-l-gallery--GridTemplateColumns--max-on-lg, var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max)))));
|
|
22695
|
+
}
|
|
22696
|
+
}
|
|
22697
|
+
@media (min-width: 1450px) {
|
|
22698
|
+
.pf-l-gallery {
|
|
22699
|
+
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-2xl, var(--pf-l-gallery--GridTemplateColumns--max-on-xl, var(--pf-l-gallery--GridTemplateColumns--max-on-lg, var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max))))));
|
|
22700
|
+
}
|
|
22701
|
+
}
|
|
22633
22702
|
.pf-l-flex {
|
|
22634
22703
|
--pf-l-flex--Display: flex;
|
|
22635
22704
|
--pf-l-flex--FlexWrap: wrap;
|
|
@@ -24706,75 +24775,6 @@ svg.pf-c-spinner.pf-m-xl {
|
|
|
24706
24775
|
--pf-l-flex--spacer: var(--pf-l-flex--spacer--4xl);
|
|
24707
24776
|
}
|
|
24708
24777
|
}
|
|
24709
|
-
.pf-l-gallery {
|
|
24710
|
-
--pf-l-gallery--m-gutter--GridGap: var(--pf-global--gutter);
|
|
24711
|
-
--pf-l-gallery--GridTemplateColumns--min: 250px;
|
|
24712
|
-
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min);
|
|
24713
|
-
--pf-l-gallery--GridTemplateColumns--max: 1fr;
|
|
24714
|
-
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max);
|
|
24715
|
-
--pf-l-gallery--GridTemplateColumns: repeat(auto-fill, minmax(var(--pf-l-gallery--GridTemplateColumns--minmax--min), var(--pf-l-gallery--GridTemplateColumns--minmax--max)));
|
|
24716
|
-
--pf-l-gallery--GridTemplateRows: auto;
|
|
24717
|
-
display: grid;
|
|
24718
|
-
grid-template-columns: var(--pf-l-gallery--GridTemplateColumns);
|
|
24719
|
-
grid-template-rows: var(--pf-l-gallery--GridTemplateRows);
|
|
24720
|
-
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min);
|
|
24721
|
-
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max);
|
|
24722
|
-
}
|
|
24723
|
-
|
|
24724
|
-
.pf-l-gallery.pf-m-gutter {
|
|
24725
|
-
grid-gap: var(--pf-l-gallery--m-gutter--GridGap);
|
|
24726
|
-
}
|
|
24727
|
-
|
|
24728
|
-
@media (min-width: 576px) {
|
|
24729
|
-
.pf-l-gallery {
|
|
24730
|
-
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min));
|
|
24731
|
-
}
|
|
24732
|
-
}
|
|
24733
|
-
@media (min-width: 768px) {
|
|
24734
|
-
.pf-l-gallery {
|
|
24735
|
-
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min)));
|
|
24736
|
-
}
|
|
24737
|
-
}
|
|
24738
|
-
@media (min-width: 992px) {
|
|
24739
|
-
.pf-l-gallery {
|
|
24740
|
-
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-lg, var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min))));
|
|
24741
|
-
}
|
|
24742
|
-
}
|
|
24743
|
-
@media (min-width: 1200px) {
|
|
24744
|
-
.pf-l-gallery {
|
|
24745
|
-
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-xl, var(--pf-l-gallery--GridTemplateColumns--min-on-lg, var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min)))));
|
|
24746
|
-
}
|
|
24747
|
-
}
|
|
24748
|
-
@media (min-width: 1450px) {
|
|
24749
|
-
.pf-l-gallery {
|
|
24750
|
-
--pf-l-gallery--GridTemplateColumns--minmax--min: var(--pf-l-gallery--GridTemplateColumns--min-on-2xl, var(--pf-l-gallery--GridTemplateColumns--min-on-xl, var(--pf-l-gallery--GridTemplateColumns--min-on-lg, var(--pf-l-gallery--GridTemplateColumns--min-on-md, var(--pf-l-gallery--GridTemplateColumns--min-on-sm, var(--pf-l-gallery--GridTemplateColumns--min))))));
|
|
24751
|
-
}
|
|
24752
|
-
}
|
|
24753
|
-
@media (min-width: 576px) {
|
|
24754
|
-
.pf-l-gallery {
|
|
24755
|
-
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max));
|
|
24756
|
-
}
|
|
24757
|
-
}
|
|
24758
|
-
@media (min-width: 768px) {
|
|
24759
|
-
.pf-l-gallery {
|
|
24760
|
-
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max)));
|
|
24761
|
-
}
|
|
24762
|
-
}
|
|
24763
|
-
@media (min-width: 992px) {
|
|
24764
|
-
.pf-l-gallery {
|
|
24765
|
-
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-lg, var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max))));
|
|
24766
|
-
}
|
|
24767
|
-
}
|
|
24768
|
-
@media (min-width: 1200px) {
|
|
24769
|
-
.pf-l-gallery {
|
|
24770
|
-
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-xl, var(--pf-l-gallery--GridTemplateColumns--max-on-lg, var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max)))));
|
|
24771
|
-
}
|
|
24772
|
-
}
|
|
24773
|
-
@media (min-width: 1450px) {
|
|
24774
|
-
.pf-l-gallery {
|
|
24775
|
-
--pf-l-gallery--GridTemplateColumns--minmax--max: var(--pf-l-gallery--GridTemplateColumns--max-on-2xl, var(--pf-l-gallery--GridTemplateColumns--max-on-xl, var(--pf-l-gallery--GridTemplateColumns--max-on-lg, var(--pf-l-gallery--GridTemplateColumns--max-on-md, var(--pf-l-gallery--GridTemplateColumns--max-on-sm, var(--pf-l-gallery--GridTemplateColumns--max))))));
|
|
24776
|
-
}
|
|
24777
|
-
}
|
|
24778
24778
|
.pf-l-grid {
|
|
24779
24779
|
--pf-l-grid--m-gutter--GridGap: var(--pf-global--gutter);
|
|
24780
24780
|
--pf-l-grid__item--GridColumnStart: auto;
|
|
@@ -26001,21 +26001,6 @@ svg.pf-c-spinner.pf-m-xl {
|
|
|
26001
26001
|
margin-right: var(--pf-l-level--m-gutter--MarginRight);
|
|
26002
26002
|
}
|
|
26003
26003
|
|
|
26004
|
-
.pf-l-stack {
|
|
26005
|
-
--pf-l-stack--m-gutter--MarginBottom: var(--pf-global--gutter);
|
|
26006
|
-
display: flex;
|
|
26007
|
-
flex-direction: column;
|
|
26008
|
-
height: 100%;
|
|
26009
|
-
}
|
|
26010
|
-
|
|
26011
|
-
.pf-l-stack__item.pf-m-fill {
|
|
26012
|
-
flex-grow: 1;
|
|
26013
|
-
}
|
|
26014
|
-
|
|
26015
|
-
.pf-l-stack.pf-m-gutter > *:not(:last-child) {
|
|
26016
|
-
margin-bottom: var(--pf-l-stack--m-gutter--MarginBottom);
|
|
26017
|
-
}
|
|
26018
|
-
|
|
26019
26004
|
.pf-l-split {
|
|
26020
26005
|
--pf-l-split--m-gutter--MarginRight: var(--pf-global--gutter);
|
|
26021
26006
|
display: flex;
|
|
@@ -26035,6 +26020,21 @@ svg.pf-c-spinner.pf-m-xl {
|
|
|
26035
26020
|
margin-right: var(--pf-l-split--m-gutter--MarginRight);
|
|
26036
26021
|
}
|
|
26037
26022
|
|
|
26023
|
+
.pf-l-stack {
|
|
26024
|
+
--pf-l-stack--m-gutter--MarginBottom: var(--pf-global--gutter);
|
|
26025
|
+
display: flex;
|
|
26026
|
+
flex-direction: column;
|
|
26027
|
+
height: 100%;
|
|
26028
|
+
}
|
|
26029
|
+
|
|
26030
|
+
.pf-l-stack__item.pf-m-fill {
|
|
26031
|
+
flex-grow: 1;
|
|
26032
|
+
}
|
|
26033
|
+
|
|
26034
|
+
.pf-l-stack.pf-m-gutter > *:not(:last-child) {
|
|
26035
|
+
margin-bottom: var(--pf-l-stack--m-gutter--MarginBottom);
|
|
26036
|
+
}
|
|
26037
|
+
|
|
26038
26038
|
.pf-c-alert-group {
|
|
26039
26039
|
--pf-c-alert-group__item--MarginTop: var(--pf-global--spacer--sm);
|
|
26040
26040
|
--pf-c-alert-group--m-toast--Top: var(--pf-global--spacer--2xl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.208.
|
|
3
|
+
"version": "4.208.2",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.59.
|
|
38
|
-
"@patternfly/react-styles": "^4.58.
|
|
39
|
-
"@patternfly/react-tokens": "^4.60.
|
|
37
|
+
"@patternfly/react-icons": "^4.59.2",
|
|
38
|
+
"@patternfly/react-styles": "^4.58.2",
|
|
39
|
+
"@patternfly/react-tokens": "^4.60.2",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "657b6120e44b7d79febe3164284e7444efd385be"
|
|
64
64
|
}
|
|
@@ -1,175 +1,43 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: Drag and drop
|
|
3
3
|
section: components
|
|
4
|
-
propComponents: [
|
|
5
|
-
DragDrop,
|
|
6
|
-
Draggable,
|
|
7
|
-
Droppable,
|
|
8
|
-
DraggableItemPosition
|
|
9
|
-
]
|
|
4
|
+
propComponents: [DragDrop, Draggable, Droppable, DraggableItemPosition]
|
|
10
5
|
beta: true
|
|
11
6
|
---
|
|
12
7
|
|
|
13
|
-
You can use `DragDrop` to move items in or between lists. `DragDrop`
|
|
8
|
+
You can use the `DragDrop` component to move items in or between lists. The `DragDrop` component should contain `Droppable` components which contain `Draggable` components.
|
|
14
9
|
|
|
15
|
-
```
|
|
10
|
+
```ts noLive
|
|
16
11
|
import React from 'react';
|
|
17
12
|
import { DragDrop, Draggable, Droppable } from '@patternfly/react-core';
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
You can have as many Draggables as you like
|
|
26
|
-
</
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</
|
|
14
|
+
const DragDropCodeSample: React.FunctionComponent = () => (
|
|
15
|
+
<DragDrop>
|
|
16
|
+
{' '}
|
|
17
|
+
{/* DragDrop houses the context for dragging and dropping */}
|
|
18
|
+
<Droppable>
|
|
19
|
+
<Draggable>You can put anything here! It will be wrapped in a styled div.</Draggable>
|
|
20
|
+
<Draggable>You can have as many Draggables as you like.</Draggable>
|
|
21
|
+
</Droppable>
|
|
22
|
+
<Droppable>
|
|
23
|
+
{' '}
|
|
24
|
+
{/* You can also have many droppables! */}
|
|
25
|
+
<Draggable />
|
|
26
|
+
</Droppable>
|
|
27
|
+
</DragDrop>
|
|
28
|
+
);
|
|
32
29
|
```
|
|
30
|
+
|
|
33
31
|
Note: Keyboard accessibility and screen reader accessibility are still in development.
|
|
34
32
|
|
|
35
33
|
## Examples
|
|
36
|
-
### Basic
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
import React from 'react';
|
|
40
|
-
import { DragDrop, Draggable, Droppable } from '@patternfly/react-core';
|
|
41
|
-
|
|
42
|
-
const getItems = count =>
|
|
43
|
-
Array.from({ length: count }, (v, k) => k).map(k => ({
|
|
44
|
-
id: `item-${k}`,
|
|
45
|
-
content: `item ${k} `.repeat(k === 4 ? 20 : 1)
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
const reorder = (list, startIndex, endIndex) => {
|
|
49
|
-
const result = Array.from(list);
|
|
50
|
-
const [removed] = result.splice(startIndex, 1);
|
|
51
|
-
result.splice(endIndex, 0, removed);
|
|
52
|
-
return result;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
Basic = () => {
|
|
56
|
-
const [items, setItems] = React.useState(getItems(10));
|
|
57
|
-
|
|
58
|
-
function onDrop(source, dest) {
|
|
59
|
-
if (dest) {
|
|
60
|
-
const newItems = reorder(
|
|
61
|
-
items,
|
|
62
|
-
source.index,
|
|
63
|
-
dest.index
|
|
64
|
-
);
|
|
65
|
-
setItems(newItems);
|
|
66
34
|
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
35
|
+
### Basic
|
|
71
36
|
|
|
72
|
-
|
|
73
|
-
<DragDrop onDrop={onDrop}>
|
|
74
|
-
<Droppable>
|
|
75
|
-
{items.map(({ id, content }, i) =>
|
|
76
|
-
<Draggable key={i} style={{ padding: '8px' }}>
|
|
77
|
-
{content}
|
|
78
|
-
</Draggable>
|
|
79
|
-
)}
|
|
80
|
-
</Droppable>
|
|
81
|
-
</DragDrop>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
37
|
+
```ts file="./DragDropBasic.tsx"
|
|
84
38
|
```
|
|
85
39
|
|
|
86
40
|
### Multiple lists
|
|
87
41
|
|
|
88
|
-
```
|
|
89
|
-
import React from 'react';
|
|
90
|
-
import { DragDrop, Draggable, Droppable, Split, SplitItem } from '@patternfly/react-core';
|
|
91
|
-
|
|
92
|
-
const getItems = (count, start) =>
|
|
93
|
-
Array.from({ length: count }, (v, k) => k).map(k => ({
|
|
94
|
-
id: `item-${k + start}`,
|
|
95
|
-
content: `item ${k + start} `.repeat(k === 4 ? 20 : 1)
|
|
96
|
-
}));
|
|
97
|
-
|
|
98
|
-
const reorder = (list, startIndex, endIndex) => {
|
|
99
|
-
const result = Array.from(list);
|
|
100
|
-
const [removed] = result.splice(startIndex, 1);
|
|
101
|
-
result.splice(endIndex, 0, removed);
|
|
102
|
-
return result;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const move = (source, destination, sourceIndex, destIndex) => {
|
|
106
|
-
const sourceClone = Array.from(source);
|
|
107
|
-
const destClone = Array.from(destination);
|
|
108
|
-
const [removed] = sourceClone.splice(sourceIndex, 1);
|
|
109
|
-
destClone.splice(destIndex, 0, removed);
|
|
110
|
-
return [sourceClone, destClone];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
MultiList = () => {
|
|
114
|
-
const [items, setItems] = React.useState({
|
|
115
|
-
items1: getItems(10, 0),
|
|
116
|
-
items2: getItems(5, 10)
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
function onDrop(source, dest) {
|
|
120
|
-
console.log(source, dest);
|
|
121
|
-
if (dest) {
|
|
122
|
-
if (source.droppableId === dest.droppableId) {
|
|
123
|
-
const newItems = reorder(
|
|
124
|
-
source.droppableId === 'items1' ? items.items1 : items.items2,
|
|
125
|
-
source.index,
|
|
126
|
-
dest.index
|
|
127
|
-
);
|
|
128
|
-
if (source.droppableId === 'items1') {
|
|
129
|
-
setItems({
|
|
130
|
-
items1: newItems,
|
|
131
|
-
items2: items.items2
|
|
132
|
-
});
|
|
133
|
-
} else {
|
|
134
|
-
setItems({
|
|
135
|
-
items1: items.items1,
|
|
136
|
-
items2: newItems
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
const [newItems1, newItems2] = move(
|
|
141
|
-
source.droppableId === 'items1' ? items.items1 : items.items2,
|
|
142
|
-
dest.droppableId === 'items1' ? items.items1 : items.items2,
|
|
143
|
-
source.index,
|
|
144
|
-
dest.index
|
|
145
|
-
);
|
|
146
|
-
setItems({
|
|
147
|
-
items1: source.droppableId === 'items1' ? newItems1 : newItems2,
|
|
148
|
-
items2: dest.droppableId === 'items1' ? newItems1 : newItems2
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<DragDrop onDrop={onDrop}>
|
|
158
|
-
<Split hasGutter>
|
|
159
|
-
{Object.entries(items).map(([key, subitems]) =>
|
|
160
|
-
<SplitItem key={key} style={{ flex: 1 }}>
|
|
161
|
-
<Droppable zone="multizone" droppableId={key}>
|
|
162
|
-
{subitems.map(({ id, content }, i) =>
|
|
163
|
-
<Draggable key={id} style={{ padding: '8px' }}>
|
|
164
|
-
{content}
|
|
165
|
-
</Draggable>
|
|
166
|
-
)}
|
|
167
|
-
</Droppable>
|
|
168
|
-
</SplitItem>
|
|
169
|
-
)}
|
|
170
|
-
</Split>
|
|
171
|
-
</DragDrop>
|
|
172
|
-
);
|
|
173
|
-
}
|
|
42
|
+
```ts file="./DragDropMultipleLists.tsx"
|
|
174
43
|
```
|
|
175
|
-
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DragDrop, Draggable, Droppable } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
interface ItemType {
|
|
5
|
+
id: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface SourceType {
|
|
10
|
+
droppableId: string;
|
|
11
|
+
index: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface DestinationType extends SourceType {}
|
|
15
|
+
|
|
16
|
+
const getItems = (count: number) =>
|
|
17
|
+
Array.from({ length: count }, (_, idx) => idx).map(idx => ({
|
|
18
|
+
id: `item-${idx}`,
|
|
19
|
+
content: `item ${idx} `.repeat(idx === 4 ? 20 : 1)
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const reorder = (list: ItemType[], startIndex: number, endIndex: number) => {
|
|
23
|
+
const result = list;
|
|
24
|
+
const [removed] = result.splice(startIndex, 1);
|
|
25
|
+
result.splice(endIndex, 0, removed);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const DragDropBasic: React.FunctionComponent = () => {
|
|
30
|
+
const [items, setItems] = React.useState(getItems(10));
|
|
31
|
+
|
|
32
|
+
function onDrop(source: SourceType, dest: DestinationType) {
|
|
33
|
+
if (dest) {
|
|
34
|
+
const newItems = reorder(items, source.index, dest.index);
|
|
35
|
+
setItems(newItems);
|
|
36
|
+
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<DragDrop onDrop={onDrop}>
|
|
44
|
+
<Droppable>
|
|
45
|
+
{items.map(({ content }, i) => (
|
|
46
|
+
<Draggable key={i} style={{ padding: '8px' }}>
|
|
47
|
+
{content}
|
|
48
|
+
</Draggable>
|
|
49
|
+
))}
|
|
50
|
+
</Droppable>
|
|
51
|
+
</DragDrop>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DragDrop, Draggable, Droppable, Split, SplitItem } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
interface ItemType {
|
|
5
|
+
id: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface SourceType {
|
|
10
|
+
droppableId: string;
|
|
11
|
+
index: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface DestinationType extends SourceType {}
|
|
15
|
+
|
|
16
|
+
const getItems = (count: number, startIndex: number) =>
|
|
17
|
+
Array.from({ length: count }, (_, idx) => idx + startIndex).map(idx => ({
|
|
18
|
+
id: `item-${idx}`,
|
|
19
|
+
content: `item ${idx} `.repeat(idx === 4 ? 20 : 1)
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const reorder = (list: ItemType[], startIndex: number, endIndex: number) => {
|
|
23
|
+
const result = list;
|
|
24
|
+
const [removed] = result.splice(startIndex, 1);
|
|
25
|
+
result.splice(endIndex, 0, removed);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const move = (source: ItemType[], destination: ItemType[], sourceIndex: number, destIndex: number) => {
|
|
30
|
+
const sourceClone = source;
|
|
31
|
+
const destClone = destination;
|
|
32
|
+
const [removed] = sourceClone.splice(sourceIndex, 1);
|
|
33
|
+
destClone.splice(destIndex, 0, removed);
|
|
34
|
+
return [sourceClone, destClone];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const DragDropMultipleLists: React.FunctionComponent = () => {
|
|
38
|
+
const [items, setItems] = React.useState({
|
|
39
|
+
items1: getItems(10, 0),
|
|
40
|
+
items2: getItems(5, 10)
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
function onDrop(source: SourceType, dest: DestinationType) {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.log(source, dest);
|
|
46
|
+
if (dest) {
|
|
47
|
+
if (source.droppableId === dest.droppableId) {
|
|
48
|
+
const newItems = reorder(
|
|
49
|
+
source.droppableId === 'items1' ? items.items1 : items.items2,
|
|
50
|
+
source.index,
|
|
51
|
+
dest.index
|
|
52
|
+
);
|
|
53
|
+
if (source.droppableId === 'items1') {
|
|
54
|
+
setItems({
|
|
55
|
+
items1: newItems,
|
|
56
|
+
items2: items.items2
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
setItems({
|
|
60
|
+
items1: items.items1,
|
|
61
|
+
items2: newItems
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
const [newItems1, newItems2] = move(
|
|
66
|
+
source.droppableId === 'items1' ? items.items1 : items.items2,
|
|
67
|
+
dest.droppableId === 'items1' ? items.items1 : items.items2,
|
|
68
|
+
source.index,
|
|
69
|
+
dest.index
|
|
70
|
+
);
|
|
71
|
+
setItems({
|
|
72
|
+
items1: source.droppableId === 'items1' ? newItems1 : newItems2,
|
|
73
|
+
items2: dest.droppableId === 'items1' ? newItems1 : newItems2
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<DragDrop onDrop={onDrop}>
|
|
83
|
+
<Split hasGutter>
|
|
84
|
+
{Object.entries(items).map(([key, subitems]) => (
|
|
85
|
+
<SplitItem key={key} style={{ flex: 1 }}>
|
|
86
|
+
<Droppable zone="multizone" droppableId={key}>
|
|
87
|
+
{subitems.map(({ id, content }) => (
|
|
88
|
+
<Draggable key={id} style={{ padding: '8px' }}>
|
|
89
|
+
{content}
|
|
90
|
+
</Draggable>
|
|
91
|
+
))}
|
|
92
|
+
</Droppable>
|
|
93
|
+
</SplitItem>
|
|
94
|
+
))}
|
|
95
|
+
</Split>
|
|
96
|
+
</DragDrop>
|
|
97
|
+
);
|
|
98
|
+
};
|