playbook_ui 15.5.0 → 15.6.0.pre.rc.1
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/pb_advanced_table/_advanced_table.scss +96 -6
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.html.erb +1 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +156 -6
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +8 -3
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.jsx +180 -0
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_multiple_containers_dropzone.md +22 -0
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +3 -2
- data/app/pb_kits/playbook/pb_draggable/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_draggable/draggable.test.jsx +77 -1
- data/app/pb_kits/playbook/pb_table/styles/_vertical_border.scss +49 -0
- data/dist/chunks/_typeahead-DUmTKJUc.js +6 -0
- data/dist/chunks/{lib-Dk4GKPut.js → lib-CgpqUb6l.js} +2 -2
- data/dist/chunks/vendor.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +2 -2
- metadata +6 -5
- data/app/pb_kits/playbook/pb_bar_graph/BarGraphStyles.scss +0 -58
- data/dist/chunks/_typeahead-Bx4QsIEU.js +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c8379c2539757c4db1dcf2ed5c4a7562899728174921420d2e937f35a03f87d
|
|
4
|
+
data.tar.gz: 8bb8fd5264d9773fb4acecf09edca3c439945444c4e77c17e5a1745723c56fab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b72606b5b4b030ff3da899075efbb2215b864a6f9c8286de288ee86bc0084185aac17a7e12446c92f93899498c685df5876549e40f7be3b8210726479a656d6
|
|
7
|
+
data.tar.gz: ea1c0cee0bed7a7144fed0c139a754b2b8487b61e771d8b841f6d92723b7c1f2dff97a7e49177506c3cd55d9ef64aa2d8884f22481d002e518d954f0136c501b
|
|
@@ -791,6 +791,28 @@
|
|
|
791
791
|
box-shadow: 1px 0px 0px 0px var(--column-border-color) !important;
|
|
792
792
|
}
|
|
793
793
|
|
|
794
|
+
// Override last-header-cell border color in dark mode
|
|
795
|
+
.pb_advanced_table_header {
|
|
796
|
+
> tr:not(:first-child) {
|
|
797
|
+
.last-header-cell {
|
|
798
|
+
border-right: 1px solid $border_dark !important;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
th[colspan]:not([colspan="1"]) {
|
|
803
|
+
border-right: 1px solid $border_dark !important;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
// Override last-cell border color in dark mode for body cells
|
|
808
|
+
.pb_advanced_table_body {
|
|
809
|
+
tr {
|
|
810
|
+
.last-cell:not(:last-of-type) {
|
|
811
|
+
border-right: 1px solid $border_dark !important;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
794
816
|
// Apply border colors in dark mode
|
|
795
817
|
&[class*="column-group-border-"] {
|
|
796
818
|
// For top-level column groups (ENROLLMENT DATA, PERFORMANCE DATA)
|
|
@@ -850,7 +872,7 @@
|
|
|
850
872
|
// Restore vertical border styling in dark mode when verticalBorder is true
|
|
851
873
|
.pb_table[data-vertical-border="true"] {
|
|
852
874
|
.pb_advanced_table_header {
|
|
853
|
-
> tr
|
|
875
|
+
> tr {
|
|
854
876
|
th:not(:last-child) {
|
|
855
877
|
border-right: 1px solid $border_dark !important;
|
|
856
878
|
}
|
|
@@ -864,11 +886,17 @@
|
|
|
864
886
|
}
|
|
865
887
|
}
|
|
866
888
|
|
|
889
|
+
tr.virtualized-table-row {
|
|
890
|
+
td:not(:last-child) {
|
|
891
|
+
border-right: 1px solid $border_dark !important;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
|
|
867
895
|
// When both verticalBorder AND columnGroupBorderColor are set in dark mode,
|
|
868
896
|
// override the default border-dark with the custom color
|
|
869
897
|
&.pb_advanced_table[class*="column-group-border-"] {
|
|
870
898
|
.pb_advanced_table_header {
|
|
871
|
-
> tr
|
|
899
|
+
> tr {
|
|
872
900
|
th:not(:last-child) {
|
|
873
901
|
border-right: 1px solid var(--column-border-color) !important;
|
|
874
902
|
}
|
|
@@ -881,6 +909,12 @@
|
|
|
881
909
|
border-right: 1px solid var(--column-border-color) !important;
|
|
882
910
|
}
|
|
883
911
|
}
|
|
912
|
+
|
|
913
|
+
tr.virtualized-table-row {
|
|
914
|
+
td:not(:last-child) {
|
|
915
|
+
border-right: 1px solid var(--column-border-color) !important;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
884
918
|
}
|
|
885
919
|
}
|
|
886
920
|
|
|
@@ -985,34 +1019,90 @@
|
|
|
985
1019
|
// Firefox-specific fix for last-header-cell and last-cell vertical borders
|
|
986
1020
|
@-moz-document url-prefix() {
|
|
987
1021
|
.pb_advanced_table_header {
|
|
988
|
-
|
|
1022
|
+
th[colspan]:not([colspan="1"]):not(:last-child) {
|
|
1023
|
+
border-right: none !important;
|
|
1024
|
+
box-shadow: 1px 0 0 0 $border_light !important;
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
.last-header-cell:not(:last-child),
|
|
1028
|
+
> tr:last-child .last-header-cell:not(:last-child) {
|
|
989
1029
|
border-right: none !important;
|
|
990
1030
|
box-shadow: 1px 0 0 0 $border_light !important;
|
|
991
1031
|
}
|
|
992
1032
|
}
|
|
993
1033
|
|
|
994
1034
|
.pb_advanced_table_body {
|
|
995
|
-
.last-cell:not(:last-
|
|
1035
|
+
tr .last-cell:not(:last-of-type),
|
|
1036
|
+
td.last-cell:not(:last-child),
|
|
1037
|
+
.pb_table_td.last-cell:not(:last-child) {
|
|
996
1038
|
border-right: none !important;
|
|
997
1039
|
box-shadow: 1px 0 0 0 $border_light !important;
|
|
998
1040
|
}
|
|
999
1041
|
}
|
|
1000
1042
|
|
|
1043
|
+
&[class*="column-group-border-"] {
|
|
1044
|
+
.pb_advanced_table_header {
|
|
1045
|
+
th[colspan]:not([colspan="1"]):not(:last-child),
|
|
1046
|
+
.last-header-cell:not(:last-child),
|
|
1047
|
+
> tr:last-child .last-header-cell:not(:last-child) {
|
|
1048
|
+
box-shadow: 1px 0 0 0 var(--column-border-color) !important;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
.pb_advanced_table_body {
|
|
1053
|
+
tr .last-cell:not(:last-of-type),
|
|
1054
|
+
td.last-cell:not(:last-child),
|
|
1055
|
+
.pb_table_td.last-cell:not(:last-child) {
|
|
1056
|
+
box-shadow: 1px 0 0 0 var(--column-border-color) !important;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1001
1061
|
// Dark mode Firefox fixes
|
|
1002
1062
|
&.dark {
|
|
1003
1063
|
.pb_advanced_table_header {
|
|
1004
|
-
|
|
1064
|
+
// Convert all colspan headers to box-shadow with dark color
|
|
1065
|
+
th[colspan]:not([colspan="1"]) {
|
|
1066
|
+
border-right: none !important;
|
|
1067
|
+
box-shadow: 1px 0 0 0 $border_dark !important;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// Convert all last-header-cell borders to box-shadow with dark color
|
|
1071
|
+
.last-header-cell:not(:last-child),
|
|
1072
|
+
> tr:last-child .last-header-cell:not(:last-child),
|
|
1073
|
+
> tr:not(:first-child) .last-header-cell:not(:last-child),
|
|
1074
|
+
> tr:not(:first-child) .last-header-cell:last-child {
|
|
1005
1075
|
border-right: none !important;
|
|
1006
1076
|
box-shadow: 1px 0 0 0 $border_dark !important;
|
|
1007
1077
|
}
|
|
1008
1078
|
}
|
|
1009
1079
|
|
|
1010
1080
|
.pb_advanced_table_body {
|
|
1011
|
-
.last-cell:not(:last-
|
|
1081
|
+
tr .last-cell:not(:last-of-type),
|
|
1082
|
+
td.last-cell:not(:last-child),
|
|
1083
|
+
.pb_table_td.last-cell:not(:last-child) {
|
|
1012
1084
|
border-right: none !important;
|
|
1013
1085
|
box-shadow: 1px 0 0 0 $border_dark !important;
|
|
1014
1086
|
}
|
|
1015
1087
|
}
|
|
1088
|
+
|
|
1089
|
+
&[class*="column-group-border-"] {
|
|
1090
|
+
.pb_advanced_table_header {
|
|
1091
|
+
th[colspan]:not([colspan="1"]):not(:last-child),
|
|
1092
|
+
.last-header-cell:not(:last-child),
|
|
1093
|
+
> tr:last-child .last-header-cell:not(:last-child) {
|
|
1094
|
+
box-shadow: 1px 0 0 0 var(--column-border-color) !important;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
.pb_advanced_table_body {
|
|
1099
|
+
tr .last-cell:not(:last-of-type),
|
|
1100
|
+
td.last-cell:not(:last-child),
|
|
1101
|
+
.pb_table_td.last-cell:not(:last-child) {
|
|
1102
|
+
box-shadow: 1px 0 0 0 var(--column-border-color) !important;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1016
1106
|
}
|
|
1017
1107
|
}
|
|
1018
1108
|
}
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
}
|
|
31
31
|
] %>
|
|
32
32
|
|
|
33
|
-
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: { vertical_border: true, container: false }}) %>
|
|
33
|
+
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: { vertical_border: true, container: false }}) %>
|
|
@@ -39,6 +39,59 @@ const reducer = (state: InitialStateType, action: ActionType) => {
|
|
|
39
39
|
|
|
40
40
|
return { ...state, items: newItems };
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
// Used only when enableCrossContainerPreview is true
|
|
44
|
+
case "REORDER_ITEMS_CROSS_CONTAINER": {
|
|
45
|
+
const { dragId, targetId, newContainer } = action.payload;
|
|
46
|
+
const newItems = [...state.items];
|
|
47
|
+
const draggedItem = newItems.find((item) => item && item.id === dragId);
|
|
48
|
+
|
|
49
|
+
if (!draggedItem) return state;
|
|
50
|
+
|
|
51
|
+
const draggedIndex = newItems.indexOf(draggedItem);
|
|
52
|
+
const targetIndex = newItems.findIndex(
|
|
53
|
+
(item) => item && item.id === targetId
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
if (draggedIndex === -1 || targetIndex === -1) return state;
|
|
57
|
+
|
|
58
|
+
const updatedItem = { ...draggedItem, container: newContainer };
|
|
59
|
+
newItems.splice(draggedIndex, 1);
|
|
60
|
+
newItems.splice(targetIndex, 0, updatedItem);
|
|
61
|
+
|
|
62
|
+
return { ...state, items: newItems };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Used only when enableCrossContainerPreview is true
|
|
66
|
+
case "MOVE_TO_CONTAINER_END": {
|
|
67
|
+
const { dragId, newContainer } = action.payload;
|
|
68
|
+
const newItems = [...state.items];
|
|
69
|
+
const draggedItem = newItems.find((item) => item && item.id === dragId);
|
|
70
|
+
|
|
71
|
+
if (!draggedItem) return state;
|
|
72
|
+
|
|
73
|
+
const draggedIndex = newItems.indexOf(draggedItem);
|
|
74
|
+
if (draggedIndex === -1) return state;
|
|
75
|
+
|
|
76
|
+
const updatedItem = { ...draggedItem, container: newContainer };
|
|
77
|
+
|
|
78
|
+
// Remove from current position
|
|
79
|
+
newItems.splice(draggedIndex, 1);
|
|
80
|
+
|
|
81
|
+
// Insert at end of target container
|
|
82
|
+
const lastIndexInContainer = newItems
|
|
83
|
+
.map((item) => item && item.container)
|
|
84
|
+
.lastIndexOf(newContainer);
|
|
85
|
+
|
|
86
|
+
if (lastIndexInContainer === -1) {
|
|
87
|
+
newItems.push(updatedItem);
|
|
88
|
+
} else {
|
|
89
|
+
newItems.splice(lastIndexInContainer + 1, 0, updatedItem);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return { ...state, items: newItems };
|
|
93
|
+
}
|
|
94
|
+
|
|
42
95
|
default:
|
|
43
96
|
return state;
|
|
44
97
|
}
|
|
@@ -61,7 +114,9 @@ export const DraggableProvider = ({
|
|
|
61
114
|
onDrop,
|
|
62
115
|
onDragOver,
|
|
63
116
|
dropZone = { type: 'ghost', color: 'neutral', direction: 'vertical' },
|
|
64
|
-
providerId = 'default', // fallback provided for backward compatibility
|
|
117
|
+
providerId = 'default', // fallback provided for backward compatibility
|
|
118
|
+
// Opt-in flag for cross-container preview
|
|
119
|
+
enableCrossContainerPreview = false,
|
|
65
120
|
}: DraggableProviderType) => {
|
|
66
121
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
67
122
|
|
|
@@ -103,17 +158,74 @@ export const DraggableProvider = ({
|
|
|
103
158
|
if (state.dragData.originId !== providerId) return; // Ignore drag events from other providers
|
|
104
159
|
|
|
105
160
|
if (state.dragData.id !== id) {
|
|
106
|
-
|
|
107
|
-
|
|
161
|
+
if (enableCrossContainerPreview) {
|
|
162
|
+
// Used only when enableCrossContainerPreview is true
|
|
163
|
+
const draggedItem = state.items.find(
|
|
164
|
+
(item) => item && item.id === state.dragData.id
|
|
165
|
+
);
|
|
166
|
+
const currentContainer =
|
|
167
|
+
draggedItem && draggedItem.container
|
|
168
|
+
? draggedItem.container
|
|
169
|
+
: state.dragData.initialGroup;
|
|
170
|
+
|
|
171
|
+
const isCrossContainer =
|
|
172
|
+
currentContainer !== container &&
|
|
173
|
+
(currentContainer !== undefined || container !== undefined);
|
|
174
|
+
|
|
175
|
+
if (isCrossContainer) {
|
|
176
|
+
dispatch({
|
|
177
|
+
type: "REORDER_ITEMS_CROSS_CONTAINER",
|
|
178
|
+
payload: {
|
|
179
|
+
dragId: state.dragData.id,
|
|
180
|
+
targetId: id,
|
|
181
|
+
newContainer: container,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
// Same container: keep original behavior
|
|
186
|
+
dispatch({
|
|
187
|
+
type: "REORDER_ITEMS",
|
|
188
|
+
payload: { dragId: state.dragData.id, targetId: id },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
// Original behavior (no preview across containers)
|
|
193
|
+
dispatch({type: "REORDER_ITEMS", payload: { dragId: state.dragData.id, targetId: id }});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
dispatch({type: "SET_DRAG_DATA",payload: {id: state.dragData.id, initialGroup: container, originId: providerId}});
|
|
108
197
|
}
|
|
109
198
|
if (onDragEnter) onDragEnter(id, container);
|
|
110
199
|
};
|
|
111
200
|
|
|
112
201
|
const handleDragEnd = () => {
|
|
202
|
+
const draggedItemId = state.dragData.id;
|
|
203
|
+
const originalContainer = state.dragData.initialGroup;
|
|
204
|
+
|
|
113
205
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
114
206
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
115
207
|
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
116
|
-
if (onDragEnd)
|
|
208
|
+
if (onDragEnd) {
|
|
209
|
+
if (!enableCrossContainerPreview) {
|
|
210
|
+
onDragEnd();
|
|
211
|
+
} else {
|
|
212
|
+
const draggedItem = state.items.find(item => item && item.id === draggedItemId);
|
|
213
|
+
const finalContainer = draggedItem ? draggedItem.container : originalContainer;
|
|
214
|
+
|
|
215
|
+
const itemsInContainer = state.items.filter(item => item && item.container === finalContainer);
|
|
216
|
+
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === draggedItemId);
|
|
217
|
+
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
218
|
+
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
219
|
+
|
|
220
|
+
onDragEnd(
|
|
221
|
+
draggedItemId,
|
|
222
|
+
finalContainer,
|
|
223
|
+
originalContainer,
|
|
224
|
+
itemAbove,
|
|
225
|
+
itemBelow
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
117
229
|
};
|
|
118
230
|
|
|
119
231
|
const changeCategory = (itemId: string, container: string) => {
|
|
@@ -123,10 +235,34 @@ export const DraggableProvider = ({
|
|
|
123
235
|
const handleDrop = (container: string) => {
|
|
124
236
|
if (state.dragData.originId !== providerId) return; // Ignore drop events from other providers
|
|
125
237
|
|
|
238
|
+
const draggedItemId = state.dragData.id;
|
|
239
|
+
const originalContainer = state.dragData.initialGroup;
|
|
240
|
+
|
|
126
241
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
127
242
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
128
243
|
changeCategory(state.dragData.id, container);
|
|
129
|
-
if (onDrop)
|
|
244
|
+
if (onDrop) {
|
|
245
|
+
if (!enableCrossContainerPreview) {
|
|
246
|
+
onDrop(container);
|
|
247
|
+
} else {
|
|
248
|
+
const draggedItem = state.items.find(item => item && item.id === draggedItemId);
|
|
249
|
+
const updatedItem = draggedItem ? { ...draggedItem, container } : null;
|
|
250
|
+
|
|
251
|
+
const itemsInContainer = state.items.filter(item => item && item.container === container);
|
|
252
|
+
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === draggedItemId);
|
|
253
|
+
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
254
|
+
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
255
|
+
|
|
256
|
+
onDrop(
|
|
257
|
+
draggedItemId,
|
|
258
|
+
container,
|
|
259
|
+
originalContainer,
|
|
260
|
+
updatedItem,
|
|
261
|
+
itemAbove,
|
|
262
|
+
itemBelow
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
130
266
|
};
|
|
131
267
|
|
|
132
268
|
const handleDragOver = (e: Event, container: string) => {
|
|
@@ -134,6 +270,20 @@ export const DraggableProvider = ({
|
|
|
134
270
|
|
|
135
271
|
e.preventDefault();
|
|
136
272
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: container });
|
|
273
|
+
|
|
274
|
+
if (enableCrossContainerPreview && state.dragData.id) {
|
|
275
|
+
// Only when enableCrossContainerPreview is true: when hovering over a different container, move item to end
|
|
276
|
+
const draggedItem = state.items.find(
|
|
277
|
+
(item) => item && item.id === state.dragData.id
|
|
278
|
+
);
|
|
279
|
+
if (draggedItem && draggedItem.container !== container) {
|
|
280
|
+
dispatch({
|
|
281
|
+
type: "MOVE_TO_CONTAINER_END",
|
|
282
|
+
payload: { dragId: state.dragData.id, newContainer: container },
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
137
287
|
if (onDragOver) onDragOver(e, container);
|
|
138
288
|
};
|
|
139
289
|
|
|
@@ -157,4 +307,4 @@ export const DraggableProvider = ({
|
|
|
157
307
|
return (
|
|
158
308
|
<DragContext.Provider value={contextValue}>{children}</DragContext.Provider>
|
|
159
309
|
);
|
|
160
|
-
};
|
|
310
|
+
};
|
|
@@ -18,8 +18,12 @@ export type ActionType =
|
|
|
18
18
|
} }
|
|
19
19
|
| { type: 'SET_IS_DRAGGING'; payload: string }
|
|
20
20
|
| { type: 'SET_ACTIVE_CONTAINER'; payload: string }
|
|
21
|
+
| { type: 'SET_CROSS_CONTAINER_PREVIEW'; payload: boolean }
|
|
21
22
|
| { type: 'CHANGE_CATEGORY'; payload: { itemId: string; container: string } }
|
|
22
|
-
| { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } }
|
|
23
|
+
| { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } }
|
|
24
|
+
| { type: 'REORDER_ITEMS_CROSS_CONTAINER'; payload: { dragId: string; targetId: string; newContainer: string } }
|
|
25
|
+
| { type: 'MOVE_TO_CONTAINER_END'; payload: { dragId: string; newContainer: string } }
|
|
26
|
+
| { type: 'RESET_DRAG_CONTAINER'; payload: { itemId: string; originalContainer: string } };
|
|
23
27
|
|
|
24
28
|
export interface DropZoneConfig {
|
|
25
29
|
type?: 'ghost' | 'outline' | 'shadow' | 'line';
|
|
@@ -33,9 +37,10 @@ export type ActionType =
|
|
|
33
37
|
onReorder: (items: ItemType[]) => void;
|
|
34
38
|
onDragStart?: (id: string, container: string) => void;
|
|
35
39
|
onDragEnter?: (id: string, container: string) => void;
|
|
36
|
-
onDragEnd?: () => void;
|
|
37
|
-
onDrop?: (
|
|
40
|
+
onDragEnd?: (...args: any[]) => void;
|
|
41
|
+
onDrop?: (...args: any[]) => void;
|
|
38
42
|
onDragOver?: (e: Event, container: string) => void;
|
|
39
43
|
dropZone?: DropZoneConfig | string; // Can accept string for backward compatibility
|
|
40
44
|
providerId?: string;
|
|
45
|
+
enableCrossContainerPreview?: boolean;
|
|
41
46
|
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import Flex from '../../pb_flex/_flex'
|
|
4
|
+
import Draggable from '../../pb_draggable/_draggable'
|
|
5
|
+
import { DraggableProvider } from '../../pb_draggable/context'
|
|
6
|
+
import Badge from '../../pb_badge/_badge'
|
|
7
|
+
import Title from '../../pb_title/_title'
|
|
8
|
+
import Caption from '../../pb_caption/_caption'
|
|
9
|
+
import Card from '../../pb_card/_card'
|
|
10
|
+
import FlexItem from '../../pb_flex/_flex_item'
|
|
11
|
+
import Avatar from '../../pb_avatar/_avatar'
|
|
12
|
+
import Body from '../../pb_body/_body'
|
|
13
|
+
|
|
14
|
+
// Initial groups to drag between
|
|
15
|
+
const containers = ["To Do", "In Progress", "Done"];
|
|
16
|
+
|
|
17
|
+
// Initial items to be dragged
|
|
18
|
+
const data = [
|
|
19
|
+
{
|
|
20
|
+
id: "11",
|
|
21
|
+
container: "To Do",
|
|
22
|
+
title: "Task 1",
|
|
23
|
+
description: "Bug fixes",
|
|
24
|
+
assignee_name: "Terry Miles",
|
|
25
|
+
assignee_img: "https://randomuser.me/api/portraits/men/44.jpg",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "12",
|
|
29
|
+
container: "To Do",
|
|
30
|
+
title: "Task 2",
|
|
31
|
+
description: "Documentation",
|
|
32
|
+
assignee_name: "Sophia Miles",
|
|
33
|
+
assignee_img: "https://randomuser.me/api/portraits/women/8.jpg",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "13",
|
|
37
|
+
container: "In Progress",
|
|
38
|
+
title: "Task 3",
|
|
39
|
+
description: "Add a variant",
|
|
40
|
+
assignee_name: "Alice Jones",
|
|
41
|
+
assignee_img: "https://randomuser.me/api/portraits/women/10.jpg",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "14",
|
|
45
|
+
container: "To Do",
|
|
46
|
+
title: "Task 4",
|
|
47
|
+
description: "Add jest tests",
|
|
48
|
+
assignee_name: "Mike James",
|
|
49
|
+
assignee_img: "https://randomuser.me/api/portraits/men/8.jpg",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "15",
|
|
53
|
+
container: "Done",
|
|
54
|
+
title: "Task 5",
|
|
55
|
+
description: "Alpha testing",
|
|
56
|
+
assignee_name: "James Guy",
|
|
57
|
+
assignee_img: "https://randomuser.me/api/portraits/men/18.jpg",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "16",
|
|
61
|
+
container: "In Progress",
|
|
62
|
+
title: "Task 6",
|
|
63
|
+
description: "Release",
|
|
64
|
+
assignee_name: "Sally Jones",
|
|
65
|
+
assignee_img: "https://randomuser.me/api/portraits/women/28.jpg",
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const DraggableMultipleContainersDropzone = (props) => {
|
|
70
|
+
const [initialState, setInitialState] = useState(data);
|
|
71
|
+
|
|
72
|
+
const badgeProperties = (container) => {
|
|
73
|
+
switch (container) {
|
|
74
|
+
case "To Do":
|
|
75
|
+
return { text: "queue", color: "warning" };
|
|
76
|
+
case "In Progress":
|
|
77
|
+
return { text: "progress", color: "primary" };
|
|
78
|
+
default:
|
|
79
|
+
return { text: "done", color: "success" };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<DraggableProvider
|
|
85
|
+
dropZone={{type: "outline"}}
|
|
86
|
+
enableCrossContainerPreview
|
|
87
|
+
initialItems={data}
|
|
88
|
+
onDragEnd={(draggedItemId, finalContainer, originalContainer, itemAbove, itemBelow) => {
|
|
89
|
+
console.log(`Dragged Item ID: ${draggedItemId}`);
|
|
90
|
+
console.log(`Final Container: ${finalContainer}`);
|
|
91
|
+
console.log(`Original Container: ${originalContainer}`);
|
|
92
|
+
console.log('Item Above:', itemAbove);
|
|
93
|
+
console.log('Item Below:', itemBelow);
|
|
94
|
+
}}
|
|
95
|
+
onDrop={(draggedItemId, droppedContainer, originalContainer, item, itemAbove, itemBelow) => {
|
|
96
|
+
console.log(`Dragged Item ID: ${draggedItemId}`);
|
|
97
|
+
console.log(`Dropped Container: ${droppedContainer}`);
|
|
98
|
+
console.log(`Original Container: ${originalContainer}`);
|
|
99
|
+
console.log('Dropped Item:', item);
|
|
100
|
+
console.log('Item Above:', itemAbove);
|
|
101
|
+
console.log('Item Below:', itemBelow);
|
|
102
|
+
}}
|
|
103
|
+
onReorder={(items) => setInitialState(items)}
|
|
104
|
+
>
|
|
105
|
+
<Flex
|
|
106
|
+
justifyContent="center"
|
|
107
|
+
{...props}
|
|
108
|
+
>
|
|
109
|
+
{containers?.map((container) => (
|
|
110
|
+
<Draggable.Container
|
|
111
|
+
container={container}
|
|
112
|
+
htmlOptions={{style:{ width: "200px", height: "70vh"}}}
|
|
113
|
+
key={container}
|
|
114
|
+
padding="sm"
|
|
115
|
+
>
|
|
116
|
+
<Caption textAlign="center">{container}</Caption>
|
|
117
|
+
<Flex
|
|
118
|
+
alignItems="stretch"
|
|
119
|
+
gap="sm"
|
|
120
|
+
orientation="column"
|
|
121
|
+
>
|
|
122
|
+
{initialState
|
|
123
|
+
.filter((item) => item.container === container)
|
|
124
|
+
.map(
|
|
125
|
+
({
|
|
126
|
+
assignee_img,
|
|
127
|
+
assignee_name,
|
|
128
|
+
description,
|
|
129
|
+
id,
|
|
130
|
+
title,
|
|
131
|
+
}) => (
|
|
132
|
+
<Draggable.Item
|
|
133
|
+
container={container}
|
|
134
|
+
dragId={id}
|
|
135
|
+
key={id}
|
|
136
|
+
>
|
|
137
|
+
<Card
|
|
138
|
+
padding="sm"
|
|
139
|
+
{...props}
|
|
140
|
+
>
|
|
141
|
+
<Flex justify="between">
|
|
142
|
+
<FlexItem>
|
|
143
|
+
<Flex>
|
|
144
|
+
<Avatar
|
|
145
|
+
imageUrl={assignee_img}
|
|
146
|
+
name={assignee_name}
|
|
147
|
+
size="xxs"
|
|
148
|
+
/>
|
|
149
|
+
<Title paddingLeft="xs"
|
|
150
|
+
size={4}
|
|
151
|
+
text={title}
|
|
152
|
+
{...props}
|
|
153
|
+
/>
|
|
154
|
+
</Flex>
|
|
155
|
+
</FlexItem>
|
|
156
|
+
<Badge
|
|
157
|
+
marginLeft="sm"
|
|
158
|
+
rounded
|
|
159
|
+
text={badgeProperties(container).text}
|
|
160
|
+
variant={badgeProperties(container).color}
|
|
161
|
+
{...props}
|
|
162
|
+
/>
|
|
163
|
+
</Flex>
|
|
164
|
+
<Body paddingTop="xs"
|
|
165
|
+
text={description}
|
|
166
|
+
{...props}
|
|
167
|
+
/>
|
|
168
|
+
</Card>
|
|
169
|
+
</Draggable.Item>
|
|
170
|
+
)
|
|
171
|
+
)}
|
|
172
|
+
</Flex>
|
|
173
|
+
</Draggable.Container>
|
|
174
|
+
))}
|
|
175
|
+
</Flex>
|
|
176
|
+
</DraggableProvider>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export default DraggableMultipleContainersDropzone;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The multiple container functionality also supports customized dropzone styling as shown here.
|
|
2
|
+
|
|
3
|
+
In addition to this, the `enableCrossContainerPreview` prop can be used on the `DraggableProvider` as shown here to enable dropzone preview for cross-container dragging.
|
|
4
|
+
|
|
5
|
+
With `enableCrossContainerPreview`, the `onDrop` and `onDragEnd` event listeners will also provide several arguments to allow developers more context from the drag event.
|
|
6
|
+
|
|
7
|
+
The `onDrop` callback is triggered when an item is successfully dropped into a container. It provides the following arguments:
|
|
8
|
+
|
|
9
|
+
- `draggedItemId` - The ID of the item that was dragged
|
|
10
|
+
- `droppedContainer` - The container where the item was dropped
|
|
11
|
+
- `originalContainer` - The container where the drag started
|
|
12
|
+
- `item` - The complete item object with all properties (including the updated container)
|
|
13
|
+
- `itemAbove` - The item directly above the dropped item in the final position (null if at the top)
|
|
14
|
+
- `itemBelow` - The item directly below the dropped item in the final position (null if at the bottom)
|
|
15
|
+
|
|
16
|
+
The `onDragEnd` callback is triggered when a drag operation ends, whether it was dropped or cancelled. It provides the following arguments:
|
|
17
|
+
|
|
18
|
+
- `draggedItemId` - The ID of the item that was dragged
|
|
19
|
+
- `finalContainer` - The container where the item ended up (could be same as original if drag was cancelled)
|
|
20
|
+
- `originalContainer` - The container where the drag started
|
|
21
|
+
- `itemAbove` - The item directly above the dragged item in the final position (null if at the top)
|
|
22
|
+
- `itemBelow` - The item directly below the dragged item in the final position (null if at the bottom)
|
|
@@ -5,11 +5,12 @@ examples:
|
|
|
5
5
|
- draggable_with_selectable_list: Draggable with SelectableList Kit
|
|
6
6
|
- draggable_with_cards: Draggable with Cards
|
|
7
7
|
- draggable_with_table: Draggable with Table
|
|
8
|
-
- draggable_multiple_containers: Dragging Across Multiple Containers
|
|
9
8
|
- draggable_drop_zones: Draggable Drop Zones
|
|
10
9
|
- draggable_drop_zones_colors: Draggable Drop Zones Colors
|
|
11
10
|
- draggable_drop_zones_line: Draggable Drop Zones Line
|
|
12
11
|
- draggable_event_listeners: Draggable Event Listeners
|
|
12
|
+
- draggable_multiple_containers: Dragging Across Multiple Containers
|
|
13
|
+
- draggable_multiple_containers_dropzone: Dragging Across Multiple Containers with Dropzones
|
|
13
14
|
|
|
14
15
|
rails:
|
|
15
16
|
- draggable_default: Default
|
|
@@ -17,8 +18,8 @@ examples:
|
|
|
17
18
|
- draggable_with_selectable_list: Draggable with SelectableList Kit
|
|
18
19
|
- draggable_with_cards: Draggable with Cards
|
|
19
20
|
- draggable_with_table: Draggable with Table
|
|
20
|
-
- draggable_multiple_containers: Dragging Across Multiple Containers
|
|
21
21
|
- draggable_drop_zones: Draggable Drop Zones
|
|
22
22
|
- draggable_drop_zones_colors: Draggable Drop Zones Colors
|
|
23
23
|
- draggable_drop_zones_line: Draggable Drop Zones Line
|
|
24
24
|
- draggable_event_listeners: Draggable Event Listeners
|
|
25
|
+
- draggable_multiple_containers: Dragging Across Multiple Containers
|
|
@@ -7,4 +7,5 @@ export { default as DraggableWithTable } from './_draggable_with_table.jsx'
|
|
|
7
7
|
export { default as DraggableDropZones } from './_draggable_drop_zones.jsx'
|
|
8
8
|
export { default as DraggableDropZonesColors } from './_draggable_drop_zones_colors.jsx'
|
|
9
9
|
export { default as DraggableDropZonesLine } from './_draggable_drop_zones_line.jsx'
|
|
10
|
-
export { default as DraggableEventListeners } from './_draggable_event_listeners.jsx'
|
|
10
|
+
export { default as DraggableEventListeners } from './_draggable_event_listeners.jsx'
|
|
11
|
+
export { default as DraggableMultipleContainersDropzone } from './_draggable_multiple_containers_dropzone.jsx'
|