@patternfly/react-core 4.207.0 → 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 +27 -0
- package/dist/esm/components/Divider/Divider.d.ts +10 -1
- package/dist/esm/components/Divider/Divider.d.ts.map +1 -1
- package/dist/esm/components/Divider/Divider.js +2 -2
- package/dist/esm/components/Divider/Divider.js.map +1 -1
- package/dist/js/components/Divider/Divider.d.ts +10 -1
- package/dist/js/components/Divider/Divider.d.ts.map +1 -1
- package/dist/js/components/Divider/Divider.js +2 -2
- package/dist/js/components/Divider/Divider.js.map +1 -1
- package/dist/umd/react-core.css +77 -69
- package/dist/umd/react-core.js +2 -2
- package/dist/umd/react-core.min.css +77 -69
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +6 -6
- package/src/components/Divider/Divider.tsx +12 -1
- package/src/components/Divider/__tests__/Divider.test.tsx +5 -1
- package/src/components/Divider/examples/Divider.md +6 -0
- package/src/components/Divider/examples/DividerOrientationVariousBreakpoints.tsx +19 -0
- package/src/components/Divider/examples/DividerVerticalFlex.tsx +5 -1
- package/src/components/Divider/examples/DividerVerticalFlexInsetMedium.tsx +6 -1
- package/src/components/Divider/examples/DividerVerticalFlexInsetVariousBreakpoints.tsx +4 -2
- package/src/components/DragDrop/examples/DragDrop.md +22 -154
- package/src/components/DragDrop/examples/DragDropBasic.tsx +53 -0
- package/src/components/DragDrop/examples/DragDropMultipleLists.tsx +98 -0
- package/src/components/Page/examples/Page.md +17 -7
- package/src/demos/CardDemos.md +108 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
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,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
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",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.192.
|
|
46
|
+
"@patternfly/patternfly": "4.192.4",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -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
|
}
|
|
@@ -14,7 +14,7 @@ export interface DividerProps extends React.HTMLProps<HTMLElement> {
|
|
|
14
14
|
className?: string;
|
|
15
15
|
/** The component type to use */
|
|
16
16
|
component?: 'hr' | 'li' | 'div';
|
|
17
|
-
/** Flag to indicate the divider is vertical (must be in a flex layout) */
|
|
17
|
+
/** @deprecated Use `orientation` instead. Flag to indicate the divider is vertical (must be in a flex layout) */
|
|
18
18
|
isVertical?: boolean;
|
|
19
19
|
/** Insets at various breakpoints. */
|
|
20
20
|
inset?: {
|
|
@@ -25,6 +25,15 @@ export interface DividerProps extends React.HTMLProps<HTMLElement> {
|
|
|
25
25
|
xl?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
|
|
26
26
|
'2xl'?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
|
|
27
27
|
};
|
|
28
|
+
/** Indicates how the divider will display at various breakpoints. Vertical divider must be in a flex layout. */
|
|
29
|
+
orientation?: {
|
|
30
|
+
default?: 'vertical' | 'horizontal';
|
|
31
|
+
sm?: 'vertical' | 'horizontal';
|
|
32
|
+
md?: 'vertical' | 'horizontal';
|
|
33
|
+
lg?: 'vertical' | 'horizontal';
|
|
34
|
+
xl?: 'vertical' | 'horizontal';
|
|
35
|
+
'2xl'?: 'vertical' | 'horizontal';
|
|
36
|
+
};
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
export const Divider: React.FunctionComponent<DividerProps> = ({
|
|
@@ -32,6 +41,7 @@ export const Divider: React.FunctionComponent<DividerProps> = ({
|
|
|
32
41
|
component = DividerVariant.hr,
|
|
33
42
|
isVertical = false,
|
|
34
43
|
inset,
|
|
44
|
+
orientation,
|
|
35
45
|
...props
|
|
36
46
|
}: DividerProps) => {
|
|
37
47
|
const Component: any = component;
|
|
@@ -42,6 +52,7 @@ export const Divider: React.FunctionComponent<DividerProps> = ({
|
|
|
42
52
|
styles.divider,
|
|
43
53
|
isVertical && styles.modifiers.vertical,
|
|
44
54
|
formatBreakpointMods(inset, styles),
|
|
55
|
+
formatBreakpointMods(orientation, styles),
|
|
45
56
|
className
|
|
46
57
|
)}
|
|
47
58
|
{...(component !== 'hr' && { role: 'separator' })}
|
|
@@ -22,7 +22,11 @@ test('vertical divider', () => {
|
|
|
22
22
|
const { asFragment } = render(
|
|
23
23
|
<Flex>
|
|
24
24
|
<FlexItem>first item</FlexItem>
|
|
25
|
-
<Divider
|
|
25
|
+
<Divider
|
|
26
|
+
orientation={{
|
|
27
|
+
default: 'vertical'
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
26
30
|
<FlexItem>second item</FlexItem>
|
|
27
31
|
</Flex>
|
|
28
32
|
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Divider, Flex, FlexItem } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DividerOrientationVariousBreakpoints: React.FunctionComponent = () => (
|
|
5
|
+
<Flex>
|
|
6
|
+
<FlexItem>first item</FlexItem>
|
|
7
|
+
<Divider
|
|
8
|
+
orientation={{
|
|
9
|
+
default: 'vertical',
|
|
10
|
+
sm: 'horizontal',
|
|
11
|
+
md: 'vertical',
|
|
12
|
+
lg: 'horizontal',
|
|
13
|
+
xl: 'vertical',
|
|
14
|
+
'2xl': 'horizontal'
|
|
15
|
+
}}
|
|
16
|
+
/>
|
|
17
|
+
<FlexItem>second item</FlexItem>
|
|
18
|
+
</Flex>
|
|
19
|
+
);
|
|
@@ -4,7 +4,11 @@ import { Divider, Flex, FlexItem } from '@patternfly/react-core';
|
|
|
4
4
|
export const DividerVerticalFlex: React.FunctionComponent = () => (
|
|
5
5
|
<Flex>
|
|
6
6
|
<FlexItem>first item</FlexItem>
|
|
7
|
-
<Divider
|
|
7
|
+
<Divider
|
|
8
|
+
orientation={{
|
|
9
|
+
default: 'vertical'
|
|
10
|
+
}}
|
|
11
|
+
/>
|
|
8
12
|
<FlexItem>second item</FlexItem>
|
|
9
13
|
</Flex>
|
|
10
14
|
);
|
|
@@ -4,7 +4,12 @@ import { Divider, Flex, FlexItem } from '@patternfly/react-core';
|
|
|
4
4
|
export const DividerVerticalFlexInsetMedium: React.FunctionComponent = () => (
|
|
5
5
|
<Flex>
|
|
6
6
|
<FlexItem>first item</FlexItem>
|
|
7
|
-
<Divider
|
|
7
|
+
<Divider
|
|
8
|
+
orientation={{
|
|
9
|
+
default: 'vertical'
|
|
10
|
+
}}
|
|
11
|
+
inset={{ default: 'insetMd' }}
|
|
12
|
+
/>
|
|
8
13
|
<FlexItem>second item</FlexItem>
|
|
9
14
|
</Flex>
|
|
10
15
|
);
|
|
@@ -5,7 +5,9 @@ export const DividerVerticalFlexInsetVariousBreakpoints: React.FunctionComponent
|
|
|
5
5
|
<Flex>
|
|
6
6
|
<FlexItem>first item</FlexItem>
|
|
7
7
|
<Divider
|
|
8
|
-
|
|
8
|
+
orientation={{
|
|
9
|
+
default: 'vertical'
|
|
10
|
+
}}
|
|
9
11
|
inset={{
|
|
10
12
|
default: 'insetMd',
|
|
11
13
|
md: 'insetNone',
|
|
@@ -13,6 +15,6 @@ export const DividerVerticalFlexInsetVariousBreakpoints: React.FunctionComponent
|
|
|
13
15
|
xl: 'insetXs'
|
|
14
16
|
}}
|
|
15
17
|
/>
|
|
16
|
-
<FlexItem>
|
|
18
|
+
<FlexItem>second item</FlexItem>
|
|
17
19
|
</Flex>
|
|
18
20
|
);
|
|
@@ -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
|
+
};
|
|
@@ -264,11 +264,10 @@ class FillPage extends React.Component {
|
|
|
264
264
|
return (
|
|
265
265
|
<Page header={Header} sidebar={Sidebar}>
|
|
266
266
|
<PageSection>A default page section</PageSection>
|
|
267
|
-
<PageSection isFilled={true}>
|
|
268
|
-
This section fills the available space.
|
|
269
|
-
</PageSection>
|
|
267
|
+
<PageSection isFilled={true}>This section fills the available space.</PageSection>
|
|
270
268
|
<PageSection isFilled={false}>
|
|
271
|
-
This section is set to not fill the available space, since the last page section is set to fill the available
|
|
269
|
+
This section is set to not fill the available space, since the last page section is set to fill the available
|
|
270
|
+
space by default.
|
|
272
271
|
</PageSection>
|
|
273
272
|
</Page>
|
|
274
273
|
);
|
|
@@ -590,7 +589,7 @@ class VerticalPage extends React.Component {
|
|
|
590
589
|
}
|
|
591
590
|
```
|
|
592
591
|
|
|
593
|
-
### Centered
|
|
592
|
+
### Centered section
|
|
594
593
|
|
|
595
594
|
```js
|
|
596
595
|
import React from 'react';
|
|
@@ -607,7 +606,9 @@ import {
|
|
|
607
606
|
PageToggleButton,
|
|
608
607
|
Toolbar,
|
|
609
608
|
ToolbarContent,
|
|
610
|
-
ToolbarItem
|
|
609
|
+
ToolbarItem,
|
|
610
|
+
Card,
|
|
611
|
+
CardBody
|
|
611
612
|
} from '@patternfly/react-core';
|
|
612
613
|
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
613
614
|
|
|
@@ -639,7 +640,16 @@ CenterAlignedPageSection = () => {
|
|
|
639
640
|
return (
|
|
640
641
|
<Page header={Header}>
|
|
641
642
|
<PageSection isWidthLimited isCenterAligned>
|
|
642
|
-
|
|
643
|
+
<Card>
|
|
644
|
+
<CardBody>
|
|
645
|
+
When a width limited page section is wider than the value of
|
|
646
|
+
<code>--pf-c-page--section--m-limit-width--MaxWidth</code>, the section will be centered in the main section.
|
|
647
|
+
<br />
|
|
648
|
+
<br />
|
|
649
|
+
The content in this example is placed in a card to better illustrate how the section behaves when it is
|
|
650
|
+
centered. A card is not required to center a page section.
|
|
651
|
+
</CardBody>
|
|
652
|
+
</Card>
|
|
643
653
|
</PageSection>
|
|
644
654
|
</Page>
|
|
645
655
|
);
|