playbook_ui 13.28.0.pre.alpha.play829selectablecardalignment2978 → 13.29.0.pre.alpha.testingcollapsibleissue3052
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/_playbook.scss +2 -3
- data/app/pb_kits/playbook/index.js +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx +4 -1
- data/app/pb_kits/playbook/pb_bar_graph/barGraph.test.js +31 -0
- data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +16 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom.md +2 -1
- data/app/pb_kits/playbook/pb_bar_graph/docs/{_bar_graph_custom.html.erb → _bar_graph_custom_rails.html.erb} +3 -3
- data/app/pb_kits/playbook/pb_bar_graph/docs/_bar_graph_custom_rails.md +2 -0
- data/app/pb_kits/playbook/pb_bar_graph/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.tsx +9 -3
- data/app/pb_kits/playbook/pb_circle_chart/circleChart.test.js +45 -0
- data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +24 -1
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +53 -0
- data/app/pb_kits/playbook/pb_collapsible/_collapsible.tsx +15 -13
- data/app/pb_kits/playbook/pb_collapsible/collapsible.test.js +24 -0
- data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.ts +7 -1
- data/app/pb_kits/playbook/pb_dashboard/pbChartsLightTheme.ts +9 -1
- data/app/pb_kits/playbook/pb_draggable/_draggable.scss +13 -0
- data/app/pb_kits/playbook/pb_draggable/_draggable.tsx +53 -0
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +92 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.jsx +53 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_default.md +4 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers.jsx +158 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_cards.jsx +119 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.jsx +50 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list.md +1 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list.jsx +51 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +11 -0
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +5 -0
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +65 -0
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableContainer.tsx +54 -0
- data/app/pb_kits/playbook/pb_draggable/subcomponents/DraggableItem.tsx +57 -0
- data/app/pb_kits/playbook/pb_form_group/_form_group.scss +2 -2
- data/app/pb_kits/playbook/pb_gauge/_gauge.tsx +4 -1
- data/app/pb_kits/playbook/pb_gauge/gauge.rb +6 -1
- data/app/pb_kits/playbook/pb_gauge/gauge.test.js +35 -0
- data/app/pb_kits/playbook/pb_icon/icon.rb +3 -2
- data/app/pb_kits/playbook/pb_line_graph/_line_graph.tsx +8 -2
- data/app/pb_kits/playbook/pb_line_graph/lineGraph.test.js +52 -0
- data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +22 -1
- data/app/pb_kits/playbook/pb_list/_list.tsx +43 -2
- data/app/pb_kits/playbook/pb_list/_list_item.tsx +46 -10
- data/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss +1 -1
- data/app/pb_kits/playbook/pb_selectable_list/_item.tsx +35 -28
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.tsx +5 -1
- data/app/pb_kits/playbook/pb_table/_table.tsx +5 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column.jsx +33 -32
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_column_rails.md +2 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row.jsx +33 -33
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row_rails.html.erb +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_row_rails.md +2 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data.jsx +51 -50
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data.md +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data_rails.html.erb +54 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data_rails.md +2 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row.jsx +37 -38
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row_rails.html.erb +53 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row_rails.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/{_table_alignment_row.html.erb → _table_outer_padding.html.erb} +7 -7
- data/app/pb_kits/playbook/pb_table/docs/_table_outer_padding.jsx +76 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_outer_padding.md +1 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +9 -9
- data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_all.scss +1 -0
- data/app/pb_kits/playbook/pb_table/styles/_outer_padding.scss +21 -0
- data/app/pb_kits/playbook/pb_table/table.rb +14 -1
- data/app/pb_kits/playbook/pb_table/table.test.js +5 -1
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +12 -9
- data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +61 -0
- data/app/pb_kits/playbook/pb_treemap_chart/treemap_chart.rb +6 -1
- data/app/pb_kits/playbook/playbook-doc.js +2 -0
- data/app/pb_kits/playbook/tokens/_vertical_align.scss +18 -0
- data/app/pb_kits/playbook/utilities/_vertical_align.scss +16 -0
- data/app/pb_kits/playbook/utilities/globalProps.ts +12 -1
- data/dist/menu.yml +5 -2
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/classnames.rb +1 -0
- data/lib/playbook/kit_base.rb +2 -0
- data/lib/playbook/version.rb +2 -2
- data/lib/playbook/vertical_align.rb +37 -0
- metadata +41 -7
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_data.html.erb +0 -63
- data/app/pb_kits/playbook/pb_table/docs/_table_alignment_shift_row.html.erb +0 -52
- /data/app/pb_kits/playbook/pb_table/docs/{_table_alignment_column.html.erb → _table_alignment_column_rails.html.erb} +0 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { SelectableList, Draggable, DraggableProvider } from "../../";
|
3
|
+
|
4
|
+
// Initial items to be dragged
|
5
|
+
const data = [
|
6
|
+
{
|
7
|
+
id: "1",
|
8
|
+
text: "Task 1",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
id: "2",
|
12
|
+
text: "Task 2",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
id: "3",
|
16
|
+
text: "Task 3",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
id: "4",
|
20
|
+
text: "Task 4",
|
21
|
+
},
|
22
|
+
];
|
23
|
+
|
24
|
+
const DraggableDefault = (props) => {
|
25
|
+
const [initialState, setInitialState] = useState(data);
|
26
|
+
|
27
|
+
return (
|
28
|
+
<>
|
29
|
+
<DraggableProvider initialItems={data}
|
30
|
+
onChange={(items) => setInitialState(items)}
|
31
|
+
>
|
32
|
+
<Draggable.Container {...props}>
|
33
|
+
<SelectableList variant="checkbox">
|
34
|
+
{initialState.map(({ id, text }) => (
|
35
|
+
<Draggable.Item id={id}
|
36
|
+
key={id}
|
37
|
+
>
|
38
|
+
<SelectableList.Item
|
39
|
+
label={text}
|
40
|
+
name={id}
|
41
|
+
value={id}
|
42
|
+
/>
|
43
|
+
</Draggable.Item>
|
44
|
+
))}
|
45
|
+
</SelectableList>
|
46
|
+
</Draggable.Container>
|
47
|
+
</DraggableProvider>
|
48
|
+
</>
|
49
|
+
|
50
|
+
);
|
51
|
+
};
|
52
|
+
|
53
|
+
export default DraggableDefault;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
To use the Draggable kit, you must use the DraggableProvider and pass in `initialItems`. The `onChange` is a function that returns the data as it changes as items are reordered. Use this to manage state as shown.
|
2
|
+
|
3
|
+
The `Draggable.Container` specifies the container within which items can be dropped.
|
4
|
+
The `Draggable.Item` specifies the items that can be dragged and dropped. `Draggable.Item` requires `id` to be passed in as shown.
|
@@ -0,0 +1,158 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import {
|
3
|
+
Flex,
|
4
|
+
Caption,
|
5
|
+
Card,
|
6
|
+
FlexItem,
|
7
|
+
Badge,
|
8
|
+
Avatar,
|
9
|
+
Title,
|
10
|
+
Body,
|
11
|
+
Draggable,
|
12
|
+
DraggableProvider,
|
13
|
+
} from "../../";
|
14
|
+
|
15
|
+
// Initial groups to drag between
|
16
|
+
const containers = ["To Do", "In Progress", "Done"];
|
17
|
+
|
18
|
+
// Initial items to be dragged
|
19
|
+
const data = [
|
20
|
+
{
|
21
|
+
id: "1",
|
22
|
+
container: "To Do",
|
23
|
+
title: "Task 1",
|
24
|
+
description: "Bug fixes",
|
25
|
+
assignee_name: "Terry Miles",
|
26
|
+
assignee_img: "https://randomuser.me/api/portraits/men/44.jpg",
|
27
|
+
},
|
28
|
+
{
|
29
|
+
id: "2",
|
30
|
+
container: "To Do",
|
31
|
+
title: "Task 2",
|
32
|
+
description: "Documentation",
|
33
|
+
assignee_name: "Sophia Miles",
|
34
|
+
assignee_img: "https://randomuser.me/api/portraits/women/8.jpg",
|
35
|
+
},
|
36
|
+
{
|
37
|
+
id: "3",
|
38
|
+
container: "In Progress",
|
39
|
+
title: "Task 3",
|
40
|
+
description: "Add a variant",
|
41
|
+
assignee_name: "Alice Jones",
|
42
|
+
assignee_img: "https://randomuser.me/api/portraits/women/10.jpg",
|
43
|
+
},
|
44
|
+
{
|
45
|
+
id: "4",
|
46
|
+
container: "To Do",
|
47
|
+
title: "Task 4",
|
48
|
+
description: "Add jest tests",
|
49
|
+
assignee_name: "Mike James",
|
50
|
+
assignee_img: "https://randomuser.me/api/portraits/men/8.jpg",
|
51
|
+
},
|
52
|
+
{
|
53
|
+
id: "5",
|
54
|
+
container: "Done",
|
55
|
+
title: "Task 5",
|
56
|
+
description: "Alpha testing",
|
57
|
+
assignee_name: "James Guy",
|
58
|
+
assignee_img: "https://randomuser.me/api/portraits/men/18.jpg",
|
59
|
+
},
|
60
|
+
{
|
61
|
+
id: "6",
|
62
|
+
container: "In Progress",
|
63
|
+
title: "Task 6",
|
64
|
+
description: "Release",
|
65
|
+
assignee_name: "Sally Jones",
|
66
|
+
assignee_img: "https://randomuser.me/api/portraits/women/28.jpg",
|
67
|
+
},
|
68
|
+
];
|
69
|
+
|
70
|
+
const DraggableMultipleContainer = (props) => {
|
71
|
+
const [initialState, setInitialState] = useState(data);
|
72
|
+
|
73
|
+
const badgeProperties = (container) => {
|
74
|
+
switch (container) {
|
75
|
+
case "To Do":
|
76
|
+
return { text: "queue", color: "warning" };
|
77
|
+
case "In Progress":
|
78
|
+
return { text: "progress", color: "primary" };
|
79
|
+
default:
|
80
|
+
return { text: "done", color: "success" };
|
81
|
+
}
|
82
|
+
};
|
83
|
+
|
84
|
+
return (
|
85
|
+
<DraggableProvider initialItems={data}
|
86
|
+
onChange={(items) => setInitialState(items)}
|
87
|
+
>
|
88
|
+
<Flex
|
89
|
+
justifyContent="center"
|
90
|
+
{...props}
|
91
|
+
>
|
92
|
+
{containers?.map((container) => (
|
93
|
+
<Draggable.Container
|
94
|
+
container={container}
|
95
|
+
key={container}
|
96
|
+
padding="sm"
|
97
|
+
>
|
98
|
+
<Caption textAlign="center">{container}</Caption>
|
99
|
+
<Flex
|
100
|
+
alignItems="stretch"
|
101
|
+
orientation="column"
|
102
|
+
>
|
103
|
+
{initialState
|
104
|
+
.filter((item) => item.container === container)
|
105
|
+
.map(
|
106
|
+
({
|
107
|
+
assignee_img,
|
108
|
+
assignee_name,
|
109
|
+
description,
|
110
|
+
id,
|
111
|
+
title,
|
112
|
+
}) => (
|
113
|
+
<Draggable.Item
|
114
|
+
container={container}
|
115
|
+
id={id}
|
116
|
+
key={id}
|
117
|
+
>
|
118
|
+
<Card
|
119
|
+
marginBottom="sm"
|
120
|
+
padding="sm"
|
121
|
+
>
|
122
|
+
<Flex justify="between">
|
123
|
+
<FlexItem>
|
124
|
+
<Flex>
|
125
|
+
<Avatar
|
126
|
+
imageUrl={assignee_img}
|
127
|
+
name={assignee_name}
|
128
|
+
size="xxs"
|
129
|
+
/>
|
130
|
+
<Title paddingLeft="xs"
|
131
|
+
size={4}
|
132
|
+
text={title}
|
133
|
+
/>
|
134
|
+
</Flex>
|
135
|
+
</FlexItem>
|
136
|
+
<Badge
|
137
|
+
marginLeft="sm"
|
138
|
+
rounded
|
139
|
+
text={badgeProperties(container).text}
|
140
|
+
variant={badgeProperties(container).color}
|
141
|
+
/>
|
142
|
+
</Flex>
|
143
|
+
<Body paddingTop="xs"
|
144
|
+
text={description}
|
145
|
+
/>
|
146
|
+
</Card>
|
147
|
+
</Draggable.Item>
|
148
|
+
)
|
149
|
+
)}
|
150
|
+
</Flex>
|
151
|
+
</Draggable.Container>
|
152
|
+
))}
|
153
|
+
</Flex>
|
154
|
+
</DraggableProvider>
|
155
|
+
);
|
156
|
+
};
|
157
|
+
|
158
|
+
export default DraggableMultipleContainer;
|
@@ -0,0 +1,119 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import {
|
3
|
+
Flex,
|
4
|
+
Badge,
|
5
|
+
Title,
|
6
|
+
Icon,
|
7
|
+
Draggable,
|
8
|
+
DraggableProvider,
|
9
|
+
Card,
|
10
|
+
Caption,
|
11
|
+
} from "../../";
|
12
|
+
|
13
|
+
// Initial items to be dragged
|
14
|
+
const data = [
|
15
|
+
{
|
16
|
+
id: "1",
|
17
|
+
text: "Joe Black",
|
18
|
+
},
|
19
|
+
{
|
20
|
+
id: "2",
|
21
|
+
text: "Nancy White",
|
22
|
+
},
|
23
|
+
{
|
24
|
+
id: "3",
|
25
|
+
text: "Bill Green",
|
26
|
+
},
|
27
|
+
];
|
28
|
+
|
29
|
+
const DraggableWithCards = (props) => {
|
30
|
+
const [initialState, setInitialState] = useState(data);
|
31
|
+
|
32
|
+
return (
|
33
|
+
<DraggableProvider
|
34
|
+
initialItems={data}
|
35
|
+
onChange={(items) => setInitialState(items)}
|
36
|
+
>
|
37
|
+
<Draggable.Container {...props}>
|
38
|
+
{initialState.map(({ id, text }) => (
|
39
|
+
<Draggable.Item id={id}
|
40
|
+
key={id}
|
41
|
+
>
|
42
|
+
<Card
|
43
|
+
highlight={{ position: "side", color: "primary" }}
|
44
|
+
marginBottom="xs"
|
45
|
+
>
|
46
|
+
<Flex alignItems="stretch"
|
47
|
+
flexDirection="column"
|
48
|
+
>
|
49
|
+
<Flex gap="xs">
|
50
|
+
<Title size={4}
|
51
|
+
text={text}
|
52
|
+
/>
|
53
|
+
<Badge
|
54
|
+
text="35-12345"
|
55
|
+
variant="primary"
|
56
|
+
/>
|
57
|
+
</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
|
+
<Caption
|
69
|
+
size="xs"
|
70
|
+
text="Township Name"
|
71
|
+
/>
|
72
|
+
<Caption size="xs"
|
73
|
+
text="•"
|
74
|
+
/>
|
75
|
+
<Caption size="xs"
|
76
|
+
text="90210"
|
77
|
+
/>
|
78
|
+
</Flex>
|
79
|
+
</Flex>
|
80
|
+
|
81
|
+
<Flex gap="xxs"
|
82
|
+
spacing="between"
|
83
|
+
>
|
84
|
+
<Flex gap="xxs">
|
85
|
+
<Caption color="error"
|
86
|
+
size="xs"
|
87
|
+
>
|
88
|
+
<Icon icon="house-circle-exclamation" />
|
89
|
+
</Caption>
|
90
|
+
<Caption color="success"
|
91
|
+
size="xs">
|
92
|
+
<Icon icon="file-circle-check" />
|
93
|
+
</Caption>
|
94
|
+
</Flex>
|
95
|
+
<Flex>
|
96
|
+
<Badge rounded
|
97
|
+
text="Schedule QA"
|
98
|
+
variant="warning"
|
99
|
+
/>
|
100
|
+
<Badge rounded
|
101
|
+
text="Flex"
|
102
|
+
variant="primary"
|
103
|
+
/>
|
104
|
+
<Badge rounded
|
105
|
+
text="R99"
|
106
|
+
variant="primary"
|
107
|
+
/>
|
108
|
+
</Flex>
|
109
|
+
</Flex>
|
110
|
+
</Flex>
|
111
|
+
</Card>
|
112
|
+
</Draggable.Item>
|
113
|
+
))}
|
114
|
+
</Draggable.Container>
|
115
|
+
</DraggableProvider>
|
116
|
+
);
|
117
|
+
};
|
118
|
+
|
119
|
+
export default DraggableWithCards;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { DraggableProvider, List, ListItem } from "../../";
|
3
|
+
|
4
|
+
// Initial items to be dragged
|
5
|
+
const data = [
|
6
|
+
{
|
7
|
+
id: "1",
|
8
|
+
text: "Philadelphia",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
id: "2",
|
12
|
+
text: "New Jersey",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
id: "3",
|
16
|
+
text: "Maryland",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
id: "4",
|
20
|
+
text: "Connecticut",
|
21
|
+
},
|
22
|
+
];
|
23
|
+
|
24
|
+
const DraggableWithList = (props) => {
|
25
|
+
const [initialState, setInitialState] = useState(data);
|
26
|
+
|
27
|
+
|
28
|
+
return (
|
29
|
+
<>
|
30
|
+
<DraggableProvider initialItems={data}
|
31
|
+
onChange={(items) => setInitialState(items)}
|
32
|
+
>
|
33
|
+
<List draggable
|
34
|
+
{...props}
|
35
|
+
>
|
36
|
+
{initialState.map(({ id, text }) => (
|
37
|
+
<ListItem id={id}
|
38
|
+
key={id}
|
39
|
+
>
|
40
|
+
{text}
|
41
|
+
</ListItem>
|
42
|
+
))}
|
43
|
+
</List>
|
44
|
+
</DraggableProvider>
|
45
|
+
</>
|
46
|
+
|
47
|
+
);
|
48
|
+
};
|
49
|
+
|
50
|
+
export default DraggableWithList;
|
@@ -0,0 +1 @@
|
|
1
|
+
For a simplified version of the Draggable API fro the List kit, use the DraggableProvider to wrap the List use the `draggable` prop on List. The dev must manage state as shown and pass in id to the ListItem.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { SelectableList, DraggableProvider } from "../../";
|
3
|
+
|
4
|
+
// Initial items to be dragged
|
5
|
+
const data = [
|
6
|
+
{
|
7
|
+
id: "1",
|
8
|
+
text: "Task 1",
|
9
|
+
},
|
10
|
+
{
|
11
|
+
id: "2",
|
12
|
+
text: "Task 2",
|
13
|
+
},
|
14
|
+
{
|
15
|
+
id: "3",
|
16
|
+
text: "Task 3",
|
17
|
+
},
|
18
|
+
{
|
19
|
+
id: "4",
|
20
|
+
text: "Task 4",
|
21
|
+
},
|
22
|
+
];
|
23
|
+
|
24
|
+
const DraggableWithSelectableList = (props) => {
|
25
|
+
const [initialState, setInitialState] = useState(data);
|
26
|
+
|
27
|
+
return (
|
28
|
+
<>
|
29
|
+
<DraggableProvider initialItems={data}
|
30
|
+
onChange={(items) => setInitialState(items)}
|
31
|
+
>
|
32
|
+
<SelectableList draggable
|
33
|
+
variant="checkbox"
|
34
|
+
{...props}
|
35
|
+
>
|
36
|
+
{initialState.map(({ id, text }) => (
|
37
|
+
<SelectableList.Item id={id}
|
38
|
+
key={id}
|
39
|
+
label={text}
|
40
|
+
name={id}
|
41
|
+
value={id}
|
42
|
+
/>
|
43
|
+
))}
|
44
|
+
</SelectableList>
|
45
|
+
</DraggableProvider>
|
46
|
+
</>
|
47
|
+
|
48
|
+
);
|
49
|
+
};
|
50
|
+
|
51
|
+
export default DraggableWithSelectableList
|
@@ -0,0 +1,11 @@
|
|
1
|
+
examples:
|
2
|
+
|
3
|
+
|
4
|
+
react:
|
5
|
+
- draggable_default: Default
|
6
|
+
- draggable_with_list: Draggable with List Kit
|
7
|
+
- draggable_with_selectable_list: Draggable with SelectableList Kit
|
8
|
+
- draggable_with_cards: Draggable with Cards
|
9
|
+
- draggable_multiple_containers: Dragging Across Multiple Containers
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,5 @@
|
|
1
|
+
export { default as DraggableDefault } from './_draggable_default.jsx'
|
2
|
+
export { default as DraggableWithCards } from './_draggable_with_cards.jsx'
|
3
|
+
export { default as DraggableWithList } from './_draggable_with_list.jsx'
|
4
|
+
export { default as DraggableWithSelectableList } from './_draggable_with_selectable_list.jsx'
|
5
|
+
export { default as DraggableMultipleContainers } from './_draggable_multiple_containers.jsx'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React, {useState} from "react"
|
2
|
+
import { render, screen } from "../utilities/test-utils"
|
3
|
+
|
4
|
+
import { Draggable, DraggableProvider, SelectableList } from '../'
|
5
|
+
|
6
|
+
const testId = 'draggable'
|
7
|
+
|
8
|
+
const data = [
|
9
|
+
{
|
10
|
+
id: "1",
|
11
|
+
text: "Task 1",
|
12
|
+
},
|
13
|
+
{
|
14
|
+
id: "2",
|
15
|
+
text: "Task 2",
|
16
|
+
},
|
17
|
+
{
|
18
|
+
id: "3",
|
19
|
+
text: "Task 3",
|
20
|
+
},
|
21
|
+
{
|
22
|
+
id: "4",
|
23
|
+
text: "Task 4",
|
24
|
+
},
|
25
|
+
];
|
26
|
+
|
27
|
+
|
28
|
+
const DefaultDraggableKit = () => {
|
29
|
+
const [initialState, setInitialState] = useState(data);
|
30
|
+
|
31
|
+
return (
|
32
|
+
<DraggableProvider
|
33
|
+
initialItems={data}
|
34
|
+
onChange={(items) => setInitialState(items)}
|
35
|
+
>
|
36
|
+
<Draggable
|
37
|
+
data={{ testid: testId }}
|
38
|
+
draggableItems={data}
|
39
|
+
onDragChange={(items) => setInitialItems(items)}
|
40
|
+
>
|
41
|
+
<Draggable.Container>
|
42
|
+
<SelectableList variant="checkbox">
|
43
|
+
{initialState.map(({ id, text }) => (
|
44
|
+
<Draggable.Item id={id}
|
45
|
+
key={id}
|
46
|
+
>
|
47
|
+
<SelectableList.Item label={text}
|
48
|
+
name={id}
|
49
|
+
value={id}
|
50
|
+
/>
|
51
|
+
</Draggable.Item>
|
52
|
+
))}
|
53
|
+
</SelectableList>
|
54
|
+
</Draggable.Container>
|
55
|
+
</Draggable>
|
56
|
+
</DraggableProvider>
|
57
|
+
);
|
58
|
+
};
|
59
|
+
|
60
|
+
test('generated default kit and classname', () => {
|
61
|
+
render(<DefaultDraggableKit/>)
|
62
|
+
const kit = screen.getByTestId(testId)
|
63
|
+
expect(kit).toBeInTheDocument()
|
64
|
+
expect(kit).toHaveClass('pb_draggable')
|
65
|
+
})
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import {
|
4
|
+
buildAriaProps,
|
5
|
+
buildCss,
|
6
|
+
buildDataProps,
|
7
|
+
buildHtmlProps
|
8
|
+
} from "../../utilities/props";
|
9
|
+
import { globalProps } from "../../utilities/globalProps";
|
10
|
+
import { DraggableContext } from "../context";
|
11
|
+
|
12
|
+
type DraggableContainerProps = {
|
13
|
+
aria?: { [key: string]: string };
|
14
|
+
children?: React.ReactNode;
|
15
|
+
className?: string;
|
16
|
+
container?: any;
|
17
|
+
data?: { [key: string]: string };
|
18
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
19
|
+
id?: string;
|
20
|
+
};
|
21
|
+
|
22
|
+
const DraggableContainer = (props: DraggableContainerProps) => {
|
23
|
+
const { aria = {}, children, className, container, data = {}, htmlOptions = {}, id } = props;
|
24
|
+
|
25
|
+
const { handleDragOver, handleDrop, activeContainer } = DraggableContext();
|
26
|
+
|
27
|
+
const ariaProps = buildAriaProps(aria);
|
28
|
+
const dataProps = buildDataProps(data);
|
29
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
30
|
+
|
31
|
+
const classes = classnames(
|
32
|
+
buildCss("pb_draggable_container"),
|
33
|
+
`${activeContainer === container ? "active" : ""}`,
|
34
|
+
globalProps(props),
|
35
|
+
className
|
36
|
+
);
|
37
|
+
|
38
|
+
return (
|
39
|
+
<div
|
40
|
+
{...ariaProps}
|
41
|
+
{...dataProps}
|
42
|
+
{...htmlProps}
|
43
|
+
className={classes}
|
44
|
+
id={id}
|
45
|
+
key={container}
|
46
|
+
onDragOver={(e) => handleDragOver(e, container)}
|
47
|
+
onDrop={() => handleDrop(container)}
|
48
|
+
>
|
49
|
+
{children}
|
50
|
+
</div>
|
51
|
+
);
|
52
|
+
};
|
53
|
+
|
54
|
+
export default DraggableContainer;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import classnames from "classnames";
|
3
|
+
import {
|
4
|
+
buildAriaProps,
|
5
|
+
buildCss,
|
6
|
+
buildDataProps,
|
7
|
+
buildHtmlProps
|
8
|
+
} from "../../utilities/props";
|
9
|
+
import { globalProps } from "../../utilities/globalProps";
|
10
|
+
import { DraggableContext } from "../context";
|
11
|
+
|
12
|
+
type DraggableItemProps = {
|
13
|
+
aria?: { [key: string]: string };
|
14
|
+
children?: React.ReactNode;
|
15
|
+
className?: string;
|
16
|
+
container?: any;
|
17
|
+
data?: { [key: string]: string };
|
18
|
+
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
19
|
+
id?: string;
|
20
|
+
};
|
21
|
+
|
22
|
+
const DraggableItem = (props: DraggableItemProps) => {
|
23
|
+
const { aria = {}, children, className, container, data = {}, htmlOptions = {}, id } = props;
|
24
|
+
|
25
|
+
const { isDragging, handleDragStart, handleDragEnter, handleDragEnd } =
|
26
|
+
DraggableContext();
|
27
|
+
|
28
|
+
const ariaProps = buildAriaProps(aria);
|
29
|
+
const dataProps = buildDataProps(data);
|
30
|
+
const htmlProps = buildHtmlProps(htmlOptions);
|
31
|
+
|
32
|
+
const classes = classnames(
|
33
|
+
buildCss("pb_draggable_item"),
|
34
|
+
`${isDragging === id ? "is_dragging" : ""}`,
|
35
|
+
globalProps(props),
|
36
|
+
className
|
37
|
+
);
|
38
|
+
|
39
|
+
return (
|
40
|
+
<div
|
41
|
+
{...ariaProps}
|
42
|
+
{...dataProps}
|
43
|
+
{...htmlProps}
|
44
|
+
className={classes}
|
45
|
+
draggable
|
46
|
+
id={id}
|
47
|
+
key={id}
|
48
|
+
onDragEnd={() => handleDragEnd()}
|
49
|
+
onDragEnter={() => handleDragEnter(id, container)}
|
50
|
+
onDragStart={() => handleDragStart(id, container)}
|
51
|
+
>
|
52
|
+
{children}
|
53
|
+
</div>
|
54
|
+
);
|
55
|
+
};
|
56
|
+
|
57
|
+
export default DraggableItem;
|
@@ -107,7 +107,7 @@
|
|
107
107
|
}
|
108
108
|
|
109
109
|
& > [class^=pb_date_picker_kit]:not(:last-child) {
|
110
|
-
.
|
110
|
+
.input_wrapper input, [class^=pb_text_input_kit] .date_picker_input_wrapper .flatpickr-wrapper {
|
111
111
|
border-bottom-right-radius: 0;
|
112
112
|
border-top-right-radius: 0;
|
113
113
|
border-right-width: 0;
|
@@ -115,7 +115,7 @@
|
|
115
115
|
}
|
116
116
|
|
117
117
|
& > [class^=pb_date_picker_kit]:not(:first-child) {
|
118
|
-
.
|
118
|
+
.input_wrapper input, [class^=pb_text_input_kit] .date_picker_input_wrapper .flatpickr-wrapper {
|
119
119
|
border-bottom-left-radius: 0;
|
120
120
|
border-top-left-radius: 0;
|
121
121
|
}
|
@@ -13,11 +13,13 @@ import typography from "../tokens/exports/_typography.scss";
|
|
13
13
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from "../utilities/props";
|
14
14
|
import { globalProps } from "../utilities/globalProps";
|
15
15
|
import { GenericObject } from "../types";
|
16
|
+
import { merge } from 'lodash'
|
16
17
|
|
17
18
|
type GaugeProps = {
|
18
19
|
aria: { [key: string]: string };
|
19
20
|
className?: string;
|
20
21
|
chartData?: { name: string; value: number[] | number }[];
|
22
|
+
customOptions?: Partial<Highcharts.Options>;
|
21
23
|
dark?: boolean;
|
22
24
|
data?: { [key: string]: string };
|
23
25
|
disableAnimation?: boolean;
|
@@ -41,6 +43,7 @@ type GaugeProps = {
|
|
41
43
|
const Gauge = ({
|
42
44
|
aria = {},
|
43
45
|
chartData,
|
46
|
+
customOptions = {},
|
44
47
|
dark = false,
|
45
48
|
data = {},
|
46
49
|
disableAnimation = false,
|
@@ -175,7 +178,7 @@ const Gauge = ({
|
|
175
178
|
},
|
176
179
|
};
|
177
180
|
|
178
|
-
setOptions(
|
181
|
+
setOptions(merge(staticOptions, customOptions));
|
179
182
|
|
180
183
|
if (document.querySelector(".prefix")) {
|
181
184
|
document.querySelectorAll(".prefix").forEach((prefix) => {
|