playbook_ui 13.29.0 → 13.30.0.pre.alpha.PBNTR353draggablev53136
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +1 -0
- data/app/pb_kits/playbook/index.js +1 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_horizontal.html.erb +58 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_horizontal.jsx +68 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_card/_card.scss +5 -0
- data/app/pb_kits/playbook/pb_card/_card.tsx +57 -9
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +9 -5
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +2 -6
- data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +2 -3
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +2 -4
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +70 -50
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +26 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +3 -2
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +2 -2
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.jsx +13 -8
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.jsx +23 -35
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.md +5 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.jsx +7 -7
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +7 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.jsx +11 -9
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.md +7 -0
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +143 -18
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +6 -5
- data/app/pb_kits/playbook/pb_list/_list.tsx +4 -4
- data/app/pb_kits/playbook/pb_list/_list_item.tsx +7 -3
- data/app/pb_kits/playbook/pb_overlay/_overlay.scss +72 -0
- data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +78 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.html.erb +24 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.jsx +40 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_default.md +7 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.html.erb +11 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.jsx +36 -0
- data/app/pb_kits/playbook/pb_overlay/docs/_overlay_multi_directional.md +5 -0
- data/app/pb_kits/playbook/pb_overlay/docs/example.yml +8 -0
- data/app/pb_kits/playbook/pb_overlay/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_overlay/overlay.html.erb +27 -0
- data/app/pb_kits/playbook/pb_overlay/overlay.rb +110 -0
- data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +66 -0
- data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_percentage.tsx +57 -0
- data/app/pb_kits/playbook/pb_overlay/subcomponents/_overlay_token.tsx +48 -0
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +43 -25
- data/app/pb_kits/playbook/pb_selectable_list/_item.tsx +7 -3
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.tsx +3 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column_rails.html.erb +32 -33
- data/app/pb_kits/playbook/pb_table/table_header.html.erb +0 -2
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +11 -10
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +8 -6
- data/app/pb_kits/playbook/playbook-doc.js +2 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +1 -0
- data/dist/menu.yml +5 -1
- data/dist/playbook-rails.js +6 -6
- data/lib/playbook/kit_base.rb +19 -0
- data/lib/playbook/version.rb +2 -2
- metadata +26 -5
@@ -18,7 +18,7 @@ const containers = ["To Do", "In Progress", "Done"];
|
|
18
18
|
// Initial items to be dragged
|
19
19
|
const data = [
|
20
20
|
{
|
21
|
-
id: "
|
21
|
+
id: "11",
|
22
22
|
container: "To Do",
|
23
23
|
title: "Task 1",
|
24
24
|
description: "Bug fixes",
|
@@ -26,7 +26,7 @@ const data = [
|
|
26
26
|
assignee_img: "https://randomuser.me/api/portraits/men/44.jpg",
|
27
27
|
},
|
28
28
|
{
|
29
|
-
id: "
|
29
|
+
id: "12",
|
30
30
|
container: "To Do",
|
31
31
|
title: "Task 2",
|
32
32
|
description: "Documentation",
|
@@ -34,7 +34,7 @@ const data = [
|
|
34
34
|
assignee_img: "https://randomuser.me/api/portraits/women/8.jpg",
|
35
35
|
},
|
36
36
|
{
|
37
|
-
id: "
|
37
|
+
id: "13",
|
38
38
|
container: "In Progress",
|
39
39
|
title: "Task 3",
|
40
40
|
description: "Add a variant",
|
@@ -42,7 +42,7 @@ const data = [
|
|
42
42
|
assignee_img: "https://randomuser.me/api/portraits/women/10.jpg",
|
43
43
|
},
|
44
44
|
{
|
45
|
-
id: "
|
45
|
+
id: "14",
|
46
46
|
container: "To Do",
|
47
47
|
title: "Task 4",
|
48
48
|
description: "Add jest tests",
|
@@ -50,7 +50,7 @@ const data = [
|
|
50
50
|
assignee_img: "https://randomuser.me/api/portraits/men/8.jpg",
|
51
51
|
},
|
52
52
|
{
|
53
|
-
id: "
|
53
|
+
id: "15",
|
54
54
|
container: "Done",
|
55
55
|
title: "Task 5",
|
56
56
|
description: "Alpha testing",
|
@@ -58,7 +58,7 @@ const data = [
|
|
58
58
|
assignee_img: "https://randomuser.me/api/portraits/men/18.jpg",
|
59
59
|
},
|
60
60
|
{
|
61
|
-
id: "
|
61
|
+
id: "16",
|
62
62
|
container: "In Progress",
|
63
63
|
title: "Task 6",
|
64
64
|
description: "Release",
|
@@ -83,7 +83,7 @@ const DraggableMultipleContainer = (props) => {
|
|
83
83
|
|
84
84
|
return (
|
85
85
|
<DraggableProvider initialItems={data}
|
86
|
-
|
86
|
+
onReorder={(items) => setInitialState(items)}
|
87
87
|
>
|
88
88
|
<Flex
|
89
89
|
justifyContent="center"
|
@@ -92,6 +92,7 @@ const DraggableMultipleContainer = (props) => {
|
|
92
92
|
{containers?.map((container) => (
|
93
93
|
<Draggable.Container
|
94
94
|
container={container}
|
95
|
+
htmlOptions={{style:{ width: "200px", height: "70vh"}}}
|
95
96
|
key={container}
|
96
97
|
padding="sm"
|
97
98
|
>
|
@@ -112,12 +113,13 @@ const DraggableMultipleContainer = (props) => {
|
|
112
113
|
}) => (
|
113
114
|
<Draggable.Item
|
114
115
|
container={container}
|
115
|
-
|
116
|
+
dragId={id}
|
116
117
|
key={id}
|
117
118
|
>
|
118
119
|
<Card
|
119
120
|
marginBottom="sm"
|
120
121
|
padding="sm"
|
122
|
+
{...props}
|
121
123
|
>
|
122
124
|
<Flex justify="between">
|
123
125
|
<FlexItem>
|
@@ -130,6 +132,7 @@ const DraggableMultipleContainer = (props) => {
|
|
130
132
|
<Title paddingLeft="xs"
|
131
133
|
size={4}
|
132
134
|
text={title}
|
135
|
+
{...props}
|
133
136
|
/>
|
134
137
|
</Flex>
|
135
138
|
</FlexItem>
|
@@ -138,10 +141,12 @@ const DraggableMultipleContainer = (props) => {
|
|
138
141
|
rounded
|
139
142
|
text={badgeProperties(container).text}
|
140
143
|
variant={badgeProperties(container).color}
|
144
|
+
{...props}
|
141
145
|
/>
|
142
146
|
</Flex>
|
143
147
|
<Body paddingTop="xs"
|
144
148
|
text={description}
|
149
|
+
{...props}
|
145
150
|
/>
|
146
151
|
</Card>
|
147
152
|
</Draggable.Item>
|
@@ -0,0 +1 @@
|
|
1
|
+
The Draggable kit can also be used to achieve more complex, multiple container functionality as shown here. This complex usage requires the full subcomponent structure.
|
@@ -13,15 +13,15 @@ import {
|
|
13
13
|
// Initial items to be dragged
|
14
14
|
const data = [
|
15
15
|
{
|
16
|
-
id: "
|
16
|
+
id: "21",
|
17
17
|
text: "Joe Black",
|
18
18
|
},
|
19
19
|
{
|
20
|
-
id: "
|
20
|
+
id: "22",
|
21
21
|
text: "Nancy White",
|
22
22
|
},
|
23
23
|
{
|
24
|
-
id: "
|
24
|
+
id: "23",
|
25
25
|
text: "Bill Green",
|
26
26
|
},
|
27
27
|
];
|
@@ -32,58 +32,44 @@ const DraggableWithCards = (props) => {
|
|
32
32
|
return (
|
33
33
|
<DraggableProvider
|
34
34
|
initialItems={data}
|
35
|
-
|
35
|
+
onReorder={(items) => setInitialState(items)}
|
36
36
|
>
|
37
37
|
<Draggable.Container {...props}>
|
38
38
|
{initialState.map(({ id, text }) => (
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
highlight={{ position: "side", color: "primary" }}
|
39
|
+
<Card dragId={id}
|
40
|
+
draggableItem
|
41
|
+
highlight={{ color: "primary", position: "side" }}
|
42
|
+
key={id}
|
44
43
|
marginBottom="xs"
|
44
|
+
padding="xs"
|
45
|
+
{...props}
|
45
46
|
>
|
46
47
|
<Flex alignItems="stretch"
|
47
48
|
flexDirection="column"
|
48
|
-
|
49
|
+
>
|
49
50
|
<Flex gap="xs">
|
50
51
|
<Title size={4}
|
51
|
-
text={text}
|
52
|
-
|
52
|
+
text={text}
|
53
|
+
{...props}
|
54
|
+
/>
|
53
55
|
<Badge
|
54
56
|
text="35-12345"
|
55
57
|
variant="primary"
|
56
|
-
|
58
|
+
{...props}
|
59
|
+
/>
|
57
60
|
</Flex>
|
58
|
-
|
59
|
-
<Flex
|
60
|
-
gap="sm"
|
61
|
-
spacing="between"
|
62
|
-
>
|
63
|
-
<Caption
|
64
|
-
size="xs"
|
65
|
-
text="8:00A"
|
66
|
-
/>
|
67
|
-
<Flex gap="xxs">
|
68
61
|
<Caption
|
69
62
|
size="xs"
|
70
|
-
text="Township Name"
|
71
|
-
|
72
|
-
<Caption size="xs"
|
73
|
-
text="•"
|
63
|
+
text="8:00A • Township Name • 90210"
|
64
|
+
{...props}
|
74
65
|
/>
|
75
|
-
<Caption size="xs"
|
76
|
-
text="90210"
|
77
|
-
/>
|
78
|
-
</Flex>
|
79
|
-
</Flex>
|
80
|
-
|
81
66
|
<Flex gap="xxs"
|
82
67
|
spacing="between"
|
83
68
|
>
|
84
69
|
<Flex gap="xxs">
|
85
70
|
<Caption color="error"
|
86
71
|
size="xs"
|
72
|
+
{...props}
|
87
73
|
>
|
88
74
|
<Icon icon="house-circle-exclamation" />
|
89
75
|
</Caption>
|
@@ -96,20 +82,22 @@ const DraggableWithCards = (props) => {
|
|
96
82
|
<Badge rounded
|
97
83
|
text="Schedule QA"
|
98
84
|
variant="warning"
|
85
|
+
{...props}
|
99
86
|
/>
|
100
87
|
<Badge rounded
|
101
88
|
text="Flex"
|
102
|
-
variant="primary"
|
89
|
+
variant="primary"
|
90
|
+
{...props}
|
103
91
|
/>
|
104
92
|
<Badge rounded
|
105
93
|
text="R99"
|
106
94
|
variant="primary"
|
95
|
+
{...props}
|
107
96
|
/>
|
108
97
|
</Flex>
|
109
98
|
</Flex>
|
110
99
|
</Flex>
|
111
100
|
</Card>
|
112
|
-
</Draggable.Item>
|
113
101
|
))}
|
114
102
|
</Draggable.Container>
|
115
103
|
</DraggableProvider>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
For a simplified version of the Draggable API for the Card kit, You can use the Card kit as the Draggable Item by using the `draggableItem` prop. The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the Card kit.
|
2
|
+
|
3
|
+
In addition to the above, `dragId` is a REQUIRED prop to be passed to the Card kit when implementing dragging.
|
4
|
+
|
5
|
+
The dev must manage state as shown.
|
@@ -4,19 +4,19 @@ import { DraggableProvider, List, ListItem } from "../../";
|
|
4
4
|
// Initial items to be dragged
|
5
5
|
const data = [
|
6
6
|
{
|
7
|
-
id: "
|
7
|
+
id: "31",
|
8
8
|
text: "Philadelphia",
|
9
9
|
},
|
10
10
|
{
|
11
|
-
id: "
|
11
|
+
id: "32",
|
12
12
|
text: "New Jersey",
|
13
13
|
},
|
14
14
|
{
|
15
|
-
id: "
|
15
|
+
id: "33",
|
16
16
|
text: "Maryland",
|
17
17
|
},
|
18
18
|
{
|
19
|
-
id: "
|
19
|
+
id: "34",
|
20
20
|
text: "Connecticut",
|
21
21
|
},
|
22
22
|
];
|
@@ -28,13 +28,13 @@ const DraggableWithList = (props) => {
|
|
28
28
|
return (
|
29
29
|
<>
|
30
30
|
<DraggableProvider initialItems={data}
|
31
|
-
|
31
|
+
onReorder={(items) => setInitialState(items)}
|
32
32
|
>
|
33
|
-
<List
|
33
|
+
<List enableDrag
|
34
34
|
{...props}
|
35
35
|
>
|
36
36
|
{initialState.map(({ id, text }) => (
|
37
|
-
<ListItem
|
37
|
+
<ListItem dragId={id}
|
38
38
|
key={id}
|
39
39
|
>
|
40
40
|
{text}
|
@@ -1 +1,7 @@
|
|
1
|
-
For a simplified version of the Draggable API
|
1
|
+
For a simplified version of the Draggable API for the List kit, use the DraggableProvider to wrap the List kit and use the `enableDrag` prop.
|
2
|
+
|
3
|
+
In addition to the above, `dragId` is a REQUIRED prop to be passed to the List kit when implementing dragging.
|
4
|
+
|
5
|
+
The dev must manage state as shown.
|
6
|
+
|
7
|
+
The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the List kit.
|
@@ -4,19 +4,19 @@ import { SelectableList, DraggableProvider } from "../../";
|
|
4
4
|
// Initial items to be dragged
|
5
5
|
const data = [
|
6
6
|
{
|
7
|
-
id: "
|
7
|
+
id: "41",
|
8
8
|
text: "Task 1",
|
9
9
|
},
|
10
10
|
{
|
11
|
-
id: "
|
11
|
+
id: "42",
|
12
12
|
text: "Task 2",
|
13
13
|
},
|
14
14
|
{
|
15
|
-
id: "
|
15
|
+
id: "43",
|
16
16
|
text: "Task 3",
|
17
17
|
},
|
18
18
|
{
|
19
|
-
id: "
|
19
|
+
id: "44",
|
20
20
|
text: "Task 4",
|
21
21
|
},
|
22
22
|
];
|
@@ -27,18 +27,20 @@ const DraggableWithSelectableList = (props) => {
|
|
27
27
|
return (
|
28
28
|
<>
|
29
29
|
<DraggableProvider initialItems={data}
|
30
|
-
|
30
|
+
onReorder={(items) => setInitialState(items)}
|
31
31
|
>
|
32
|
-
<SelectableList
|
33
|
-
variant="
|
32
|
+
<SelectableList enableDrag
|
33
|
+
variant="radio"
|
34
34
|
{...props}
|
35
35
|
>
|
36
36
|
{initialState.map(({ id, text }) => (
|
37
|
-
<SelectableList.Item
|
37
|
+
<SelectableList.Item
|
38
|
+
dragId={id}
|
38
39
|
key={id}
|
39
40
|
label={text}
|
40
|
-
name=
|
41
|
+
name="radio-test"
|
41
42
|
value={id}
|
43
|
+
{...props}
|
42
44
|
/>
|
43
45
|
))}
|
44
46
|
</SelectableList>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
For a simplified version of the Draggable API for the SelectableList kit, use the DraggableProvider to wrap the SelectableList kit and use the `enableDrag` prop.
|
2
|
+
|
3
|
+
In addition to the above, `dragId` is a REQUIRED prop to be passed to the SelectableList kit when implementing dragging.
|
4
|
+
|
5
|
+
The dev must manage state as shown.
|
6
|
+
|
7
|
+
The dragHandle is added by default but this can be opted out of by setting `dragHandle` to false on the SelectableList kit.
|
@@ -1,9 +1,16 @@
|
|
1
|
-
import React, {useState} from "react"
|
2
|
-
import { render, screen } from "../utilities/test-utils"
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { render, screen } from "../utilities/test-utils";
|
3
3
|
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
Draggable,
|
6
|
+
DraggableProvider,
|
7
|
+
SelectableList,
|
8
|
+
List,
|
9
|
+
ListItem,
|
10
|
+
Card,
|
11
|
+
} from "../";
|
5
12
|
|
6
|
-
const testId =
|
13
|
+
const testId = "draggable";
|
7
14
|
|
8
15
|
const data = [
|
9
16
|
{
|
@@ -24,24 +31,19 @@ const data = [
|
|
24
31
|
},
|
25
32
|
];
|
26
33
|
|
27
|
-
|
28
34
|
const DefaultDraggableKit = () => {
|
29
35
|
const [initialState, setInitialState] = useState(data);
|
30
36
|
|
31
37
|
return (
|
32
38
|
<DraggableProvider
|
33
39
|
initialItems={data}
|
34
|
-
|
40
|
+
onReorder={(items) => setInitialState(items)}
|
35
41
|
>
|
36
|
-
<Draggable
|
37
|
-
data={{ testid: testId }}
|
38
|
-
draggableItems={data}
|
39
|
-
onDragChange={(items) => setInitialItems(items)}
|
40
|
-
>
|
42
|
+
<Draggable data={{ testid: testId }}>
|
41
43
|
<Draggable.Container>
|
42
44
|
<SelectableList variant="checkbox">
|
43
45
|
{initialState.map(({ id, text }) => (
|
44
|
-
<Draggable.Item
|
46
|
+
<Draggable.Item dragId={id}
|
45
47
|
key={id}
|
46
48
|
>
|
47
49
|
<SelectableList.Item label={text}
|
@@ -57,9 +59,132 @@ const DefaultDraggableKit = () => {
|
|
57
59
|
);
|
58
60
|
};
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
62
|
+
const DraggableKitWithList = () => {
|
63
|
+
const [initialState, setInitialState] = useState(data);
|
64
|
+
return (
|
65
|
+
<div data-testid="draggable">
|
66
|
+
<DraggableProvider
|
67
|
+
initialItems={data}
|
68
|
+
onReorder={(items) => setInitialState(items)}
|
69
|
+
>
|
70
|
+
<List enableDrag>
|
71
|
+
{initialState.map(({ id, text }) => (
|
72
|
+
<ListItem dragId={id}
|
73
|
+
key={id}
|
74
|
+
>
|
75
|
+
{text}
|
76
|
+
</ListItem>
|
77
|
+
))}
|
78
|
+
</List>
|
79
|
+
</DraggableProvider>
|
80
|
+
</div>
|
81
|
+
);
|
82
|
+
};
|
83
|
+
|
84
|
+
const DraggableKitWithSelectableList = () => {
|
85
|
+
const [initialState, setInitialState] = useState(data);
|
86
|
+
return (
|
87
|
+
<div data-testid="draggable">
|
88
|
+
<DraggableProvider
|
89
|
+
initialItems={data}
|
90
|
+
onReorder={(items) => setInitialState(items)}
|
91
|
+
>
|
92
|
+
<SelectableList enableDrag>
|
93
|
+
{initialState.map(({ id, text }) => (
|
94
|
+
<SelectableList.Item
|
95
|
+
dragId={id}
|
96
|
+
key={id}
|
97
|
+
label={text}
|
98
|
+
name={id}
|
99
|
+
value={id}
|
100
|
+
/>
|
101
|
+
))}
|
102
|
+
</SelectableList>
|
103
|
+
</DraggableProvider>
|
104
|
+
</div>
|
105
|
+
);
|
106
|
+
};
|
107
|
+
|
108
|
+
const DraggableKitWithCard = () => {
|
109
|
+
const [initialState, setInitialState] = useState(data);
|
110
|
+
return (
|
111
|
+
<div data-testid="draggable">
|
112
|
+
<DraggableProvider
|
113
|
+
initialItems={data}
|
114
|
+
onReorder={(items) => setInitialState(items)}
|
115
|
+
>
|
116
|
+
<Draggable.Container>
|
117
|
+
{initialState.map(({ id, text }) => (
|
118
|
+
<Card dragId={id}
|
119
|
+
draggableItem
|
120
|
+
key={id}
|
121
|
+
>
|
122
|
+
{text}
|
123
|
+
</Card>
|
124
|
+
))}
|
125
|
+
</Draggable.Container>
|
126
|
+
</DraggableProvider>
|
127
|
+
</div>
|
128
|
+
);
|
129
|
+
};
|
130
|
+
|
131
|
+
test("generated default kit and classname", () => {
|
132
|
+
render(<DefaultDraggableKit />);
|
133
|
+
const kit = screen.getByTestId(testId);
|
134
|
+
expect(kit).toBeInTheDocument();
|
135
|
+
expect(kit).toHaveClass("pb_draggable");
|
136
|
+
});
|
137
|
+
|
138
|
+
test("generated Draggable Container", () => {
|
139
|
+
render(<DefaultDraggableKit />);
|
140
|
+
const kit = screen.getByTestId(testId);
|
141
|
+
|
142
|
+
const container = kit.querySelector(".pb_draggable_container");
|
143
|
+
expect(container).toBeInTheDocument();
|
144
|
+
});
|
145
|
+
|
146
|
+
test("generated Draggable Item", () => {
|
147
|
+
render(<DefaultDraggableKit />);
|
148
|
+
const kit = screen.getByTestId(testId);
|
149
|
+
|
150
|
+
const item = kit.querySelector(".pb_draggable_item");
|
151
|
+
expect(item).toBeInTheDocument();
|
152
|
+
});
|
153
|
+
|
154
|
+
test("Attached draggable HTML attributes", () => {
|
155
|
+
render(<DefaultDraggableKit />);
|
156
|
+
const kit = screen.getByTestId(testId);
|
157
|
+
|
158
|
+
const item = kit.querySelector(".pb_draggable_item");
|
159
|
+
expect(item).toHaveAttribute("draggable");
|
160
|
+
});
|
161
|
+
|
162
|
+
test("generated dragHandle with List", () => {
|
163
|
+
render(<DraggableKitWithList />);
|
164
|
+
const kit = screen.getByTestId(testId);
|
165
|
+
|
166
|
+
const list = kit.querySelector(".pb_list_kit");
|
167
|
+
expect(list).toBeInTheDocument();
|
168
|
+
const dragHandle = list.querySelector(".fa-grip-dots-vertical");
|
169
|
+
expect(dragHandle).toBeInTheDocument();
|
170
|
+
});
|
171
|
+
|
172
|
+
test("generated dragHandle with SelectableList", () => {
|
173
|
+
render(<DraggableKitWithSelectableList />);
|
174
|
+
const kit = screen.getByTestId(testId);
|
175
|
+
|
176
|
+
const selectabellist = kit.querySelector(".pb_selectable_list_kit");
|
177
|
+
expect(selectabellist).toBeInTheDocument();
|
178
|
+
const dragHandle = selectabellist.querySelector(".fa-grip-dots-vertical");
|
179
|
+
expect(dragHandle).toBeInTheDocument();
|
180
|
+
});
|
181
|
+
|
182
|
+
test("generated dragHandle with Card", () => {
|
183
|
+
render(<DraggableKitWithCard />);
|
184
|
+
const kit = screen.getByTestId(testId);
|
185
|
+
|
186
|
+
const card = kit.querySelector(".pb_card_kit_deselected_border_radius_md");
|
187
|
+
expect(card).toBeInTheDocument();
|
188
|
+
const dragHandle = card.querySelector(".fa-grip-dots-vertical");
|
189
|
+
expect(dragHandle).toBeInTheDocument();
|
190
|
+
});
|
@@ -17,10 +17,11 @@ type DraggableItemProps = {
|
|
17
17
|
data?: { [key: string]: string };
|
18
18
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
19
19
|
id?: string;
|
20
|
+
dragId?: string;
|
20
21
|
};
|
21
22
|
|
22
23
|
const DraggableItem = (props: DraggableItemProps) => {
|
23
|
-
const { aria = {}, children, className, container, data = {}, htmlOptions = {}, id } = props;
|
24
|
+
const { aria = {}, children, className, container, data = {}, htmlOptions = {}, id, dragId } = props;
|
24
25
|
|
25
26
|
const { isDragging, handleDragStart, handleDragEnter, handleDragEnd } =
|
26
27
|
DraggableContext();
|
@@ -31,7 +32,7 @@ const DraggableItem = (props: DraggableItemProps) => {
|
|
31
32
|
|
32
33
|
const classes = classnames(
|
33
34
|
buildCss("pb_draggable_item"),
|
34
|
-
`${isDragging ===
|
35
|
+
`${isDragging === dragId ? "is_dragging" : ""}`,
|
35
36
|
globalProps(props),
|
36
37
|
className
|
37
38
|
);
|
@@ -44,10 +45,10 @@ const DraggableItem = (props: DraggableItemProps) => {
|
|
44
45
|
className={classes}
|
45
46
|
draggable
|
46
47
|
id={id}
|
47
|
-
key={
|
48
|
+
key={dragId}
|
48
49
|
onDragEnd={() => handleDragEnd()}
|
49
|
-
onDragEnter={() => handleDragEnter(
|
50
|
-
onDragStart={() => handleDragStart(
|
50
|
+
onDragEnter={() => handleDragEnter(dragId, container)}
|
51
|
+
onDragStart={() => handleDragStart(dragId, container)}
|
51
52
|
>
|
52
53
|
{children}
|
53
54
|
</div>
|
@@ -10,7 +10,7 @@ type ListProps = {
|
|
10
10
|
className?: string;
|
11
11
|
children: React.ReactNode[] | React.ReactNode;
|
12
12
|
dark?: boolean;
|
13
|
-
|
13
|
+
enableDrag?: boolean;
|
14
14
|
data?: Record<string, unknown>;
|
15
15
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
16
16
|
id?: string;
|
@@ -32,7 +32,7 @@ const List = (props: ListProps) => {
|
|
32
32
|
className,
|
33
33
|
dark = false,
|
34
34
|
data = {},
|
35
|
-
|
35
|
+
enableDrag = false,
|
36
36
|
htmlOptions = {},
|
37
37
|
id,
|
38
38
|
layout = "",
|
@@ -54,7 +54,7 @@ const List = (props: ListProps) => {
|
|
54
54
|
const childrenWithProps = React.Children.map(
|
55
55
|
children,
|
56
56
|
(child: React.ReactElement) => {
|
57
|
-
return React.cloneElement(child, { text, variant,
|
57
|
+
return React.cloneElement(child, { text, variant, enableDrag });
|
58
58
|
}
|
59
59
|
);
|
60
60
|
const ariaProps = buildAriaProps(aria);
|
@@ -74,7 +74,7 @@ const List = (props: ListProps) => {
|
|
74
74
|
return (
|
75
75
|
<>
|
76
76
|
{
|
77
|
-
|
77
|
+
enableDrag ? (
|
78
78
|
<Draggable.Container>
|
79
79
|
<div className={classes}>
|
80
80
|
{ordered ? (
|
@@ -11,6 +11,7 @@ type ListItemProps = {
|
|
11
11
|
children: React.ReactNode[] | React.ReactNode,
|
12
12
|
className?: string,
|
13
13
|
data?: Record<string, unknown>,
|
14
|
+
dragId?: string,
|
14
15
|
dragHandle?: boolean,
|
15
16
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
16
17
|
id?: string,
|
@@ -23,7 +24,8 @@ const ListItem = (props: ListItemProps) => {
|
|
23
24
|
children,
|
24
25
|
className,
|
25
26
|
data = {},
|
26
|
-
|
27
|
+
enableDrag,
|
28
|
+
dragId,
|
27
29
|
dragHandle = true,
|
28
30
|
htmlOptions = {},
|
29
31
|
id,
|
@@ -42,8 +44,10 @@ const ListItem = (props: ListItemProps) => {
|
|
42
44
|
return (
|
43
45
|
<>
|
44
46
|
{
|
45
|
-
|
46
|
-
<Draggable.Item
|
47
|
+
enableDrag ? (
|
48
|
+
<Draggable.Item
|
49
|
+
dragId={dragId}
|
50
|
+
>
|
47
51
|
<li
|
48
52
|
{...ariaProps}
|
49
53
|
{...dataProps}
|