playbook_ui 15.6.0.pre.alpha.play263913015 → 15.6.0.pre.alpha.play265012865
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_bar_graph/_bar_graph.tsx +6 -0
- data/app/pb_kits/playbook/pb_card/docs/_card_header.md +1 -1
- data/app/pb_kits/playbook/pb_card/docs/_card_highlight.md +1 -1
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +2 -2
- data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleIcon.tsx +8 -10
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_icons.jsx +1 -0
- data/app/pb_kits/playbook/pb_collapsible/docs/_collapsible_state.jsx +3 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker.test.js +0 -24
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +3 -181
- data/app/pb_kits/playbook/pb_distribution_bar/docs/_distribution_bar_custom_colors.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/context/index.tsx +15 -316
- data/app/pb_kits/playbook/pb_draggable/context/types.ts +1 -1
- data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.tsx +3 -3
- data/app/pb_kits/playbook/pb_legend/_legend.tsx +7 -1
- data/app/pb_kits/playbook/pb_radio/docs/_radio_error.md +1 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +3 -8
- data/app/pb_kits/playbook/pb_select/docs/_select_error.md +1 -1
- data/app/pb_kits/playbook/pb_select/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_select/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_select/select.html.erb +2 -2
- data/app/pb_kits/playbook/pb_select/select.rb +1 -3
- data/app/pb_kits/playbook/pb_select/select.test.js +0 -23
- data/app/pb_kits/playbook/pb_table/_table.tsx +33 -187
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_table/docs/index.js +0 -2
- data/app/pb_kits/playbook/pb_table/table.html.erb +12 -68
- data/app/pb_kits/playbook/pb_table/table.rb +3 -22
- data/app/pb_kits/playbook/pb_table/table.test.js +0 -143
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_error.md +1 -1
- data/app/pb_kits/playbook/pb_textarea/docs/_textarea_error.md +1 -1
- data/app/pb_kits/playbook/tokens/_colors.scss +1 -2
- data/app/pb_kits/playbook/utilities/DEPRECATION_WARNINGS.md +82 -0
- data/app/pb_kits/playbook/utilities/deprecated.ts +65 -0
- data/dist/chunks/_typeahead-Mjy3POtc.js +6 -0
- data/dist/chunks/lib-CgpqUb6l.js +29 -0
- data/dist/chunks/vendor.js +2 -2
- data/dist/menu.yml +3 -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/forms/builder/collection_select_field.rb +1 -9
- data/lib/playbook/forms/builder/select_field.rb +1 -9
- data/lib/playbook/forms/builder/time_zone_select_field.rb +1 -9
- data/lib/playbook/version.rb +1 -1
- metadata +6 -15
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.html.erb +0 -16
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.jsx +0 -30
- data/app/pb_kits/playbook/pb_select/docs/_select_input_options.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.jsx +0 -134
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.md +0 -34
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.html.erb +0 -101
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +0 -33
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.jsx +0 -180
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.md +0 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.html.erb +0 -122
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.md +0 -3
- data/dist/chunks/_typeahead-CHwm9MTE.js +0 -6
- data/dist/chunks/lib-Cugvy62C.js +0 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, useReducer, useContext, useEffect, useMemo
|
|
1
|
+
import React, { createContext, useReducer, useContext, useEffect, useMemo } from "react";
|
|
2
2
|
import { InitialStateType, ActionType, DraggableProviderType } from "./types";
|
|
3
3
|
|
|
4
4
|
const initialState: InitialStateType = {
|
|
@@ -92,35 +92,6 @@ const reducer = (state: InitialStateType, action: ActionType) => {
|
|
|
92
92
|
return { ...state, items: newItems };
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
// Reset item back to its original container and position (e.g., when drag ends without valid drop)
|
|
96
|
-
case "RESET_DRAG_CONTAINER": {
|
|
97
|
-
const { itemId, originalContainer, originalIndex } = action.payload;
|
|
98
|
-
const newItems = [...state.items];
|
|
99
|
-
const draggedItem = newItems.find(item => item && item.id === itemId);
|
|
100
|
-
|
|
101
|
-
if (!draggedItem) return state;
|
|
102
|
-
|
|
103
|
-
const currentIndex = newItems.indexOf(draggedItem);
|
|
104
|
-
|
|
105
|
-
// Remove from current position
|
|
106
|
-
newItems.splice(currentIndex, 1);
|
|
107
|
-
|
|
108
|
-
// Restore container property and insert at original index
|
|
109
|
-
const restoredItem = { ...draggedItem, container: originalContainer };
|
|
110
|
-
|
|
111
|
-
// Insert at original index, or at end if index is invalid
|
|
112
|
-
if (originalIndex !== undefined && originalIndex >= 0) {
|
|
113
|
-
newItems.splice(originalIndex, 0, restoredItem);
|
|
114
|
-
} else {
|
|
115
|
-
newItems.push(restoredItem);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
...state,
|
|
120
|
-
items: newItems
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
95
|
default:
|
|
125
96
|
return state;
|
|
126
97
|
}
|
|
@@ -148,29 +119,6 @@ export const DraggableProvider = ({
|
|
|
148
119
|
enableCrossContainerPreview = false,
|
|
149
120
|
}: DraggableProviderType) => {
|
|
150
121
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
151
|
-
|
|
152
|
-
// Track drag state for global listener
|
|
153
|
-
const dragStateRef = useRef<{
|
|
154
|
-
isDragging: boolean;
|
|
155
|
-
draggedItemId: string;
|
|
156
|
-
originalContainer: string;
|
|
157
|
-
originalIndex: number;
|
|
158
|
-
currentContainer: string;
|
|
159
|
-
dropOccurred: boolean;
|
|
160
|
-
}>({
|
|
161
|
-
isDragging: false,
|
|
162
|
-
draggedItemId: '',
|
|
163
|
-
originalContainer: '',
|
|
164
|
-
originalIndex: -1,
|
|
165
|
-
currentContainer: '',
|
|
166
|
-
dropOccurred: false,
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// Track current state for use in gated event listeners (avoid stale closures)
|
|
170
|
-
const stateRef = useRef(state);
|
|
171
|
-
useEffect(() => {
|
|
172
|
-
stateRef.current = state;
|
|
173
|
-
}, [state]);
|
|
174
122
|
|
|
175
123
|
// Parse dropZone prop - handle both string format (backward compatibility) and object format
|
|
176
124
|
let dropZoneType = 'ghost';
|
|
@@ -200,209 +148,7 @@ export const DraggableProvider = ({
|
|
|
200
148
|
onReorder(state.items);
|
|
201
149
|
}, [state.items]);
|
|
202
150
|
|
|
203
|
-
// Monitor for failed drops by detecting mouse/pointer release during drag (this is needed for cross container preview)
|
|
204
|
-
useEffect(() => {
|
|
205
|
-
if (!enableCrossContainerPreview) return;
|
|
206
|
-
|
|
207
|
-
// Allow drops anywhere on the document by preventing default dragover
|
|
208
|
-
const handleGlobalDragOver = (e: DragEvent) => {
|
|
209
|
-
if (dragStateRef.current.isDragging) {
|
|
210
|
-
e.preventDefault();
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// Handle drops anywhere on the document (including non-container areas)
|
|
215
|
-
const handleGlobalDrop = (e: DragEvent) => {
|
|
216
|
-
if (!dragStateRef.current.isDragging) return;
|
|
217
|
-
|
|
218
|
-
// If a container already handled the drop, don't process again
|
|
219
|
-
if (dragStateRef.current.dropOccurred) return;
|
|
220
|
-
|
|
221
|
-
e.preventDefault();
|
|
222
|
-
|
|
223
|
-
// If we reach here, it means the drop was NOT on a valid container
|
|
224
|
-
// (otherwise the container's handleDrop would have set dropOccurred = true)
|
|
225
|
-
// So we should ALWAYS reset to original container for invalid drops
|
|
226
|
-
const originalContainer = dragStateRef.current.originalContainer;
|
|
227
|
-
|
|
228
|
-
dispatch({
|
|
229
|
-
type: 'RESET_DRAG_CONTAINER',
|
|
230
|
-
payload: {
|
|
231
|
-
itemId: dragStateRef.current.draggedItemId,
|
|
232
|
-
originalContainer: originalContainer,
|
|
233
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
238
|
-
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
239
|
-
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
240
|
-
|
|
241
|
-
// Clear drag state
|
|
242
|
-
dragStateRef.current = {
|
|
243
|
-
isDragging: false,
|
|
244
|
-
draggedItemId: '',
|
|
245
|
-
originalContainer: '',
|
|
246
|
-
originalIndex: -1,
|
|
247
|
-
currentContainer: '',
|
|
248
|
-
dropOccurred: false,
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const handleGlobalMouseUp = () => {
|
|
253
|
-
// If we're dragging and mouse is released, wait a bit to see if drop occurs
|
|
254
|
-
if (dragStateRef.current.isDragging) {
|
|
255
|
-
setTimeout(() => {
|
|
256
|
-
const currentContainer = dragStateRef.current.currentContainer;
|
|
257
|
-
|
|
258
|
-
// If drop still hasn't occurred, check if item is in a different container
|
|
259
|
-
if (dragStateRef.current.isDragging && !dragStateRef.current.dropOccurred) {
|
|
260
|
-
// If item is in a different container than original, treat it as a successful drop
|
|
261
|
-
if (currentContainer && currentContainer !== dragStateRef.current.originalContainer) {
|
|
262
|
-
// Trigger onDrop callback with the current container
|
|
263
|
-
if (onDrop) {
|
|
264
|
-
const draggedItem = stateRef.current.items.find(item => item && item.id === dragStateRef.current.draggedItemId);
|
|
265
|
-
const updatedItem = draggedItem ? { ...draggedItem, container: currentContainer } : null;
|
|
266
|
-
const itemsInContainer = stateRef.current.items.filter(item => item && item.container === currentContainer);
|
|
267
|
-
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === dragStateRef.current.draggedItemId);
|
|
268
|
-
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
269
|
-
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
270
|
-
|
|
271
|
-
onDrop(
|
|
272
|
-
dragStateRef.current.draggedItemId,
|
|
273
|
-
currentContainer,
|
|
274
|
-
dragStateRef.current.originalContainer,
|
|
275
|
-
updatedItem,
|
|
276
|
-
itemAbove,
|
|
277
|
-
itemBelow
|
|
278
|
-
);
|
|
279
|
-
}
|
|
280
|
-
} else {
|
|
281
|
-
dispatch({
|
|
282
|
-
type: 'RESET_DRAG_CONTAINER',
|
|
283
|
-
payload: {
|
|
284
|
-
itemId: dragStateRef.current.draggedItemId,
|
|
285
|
-
originalContainer: dragStateRef.current.originalContainer,
|
|
286
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
287
|
-
},
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
291
|
-
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
292
|
-
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
293
|
-
|
|
294
|
-
// Clear drag state
|
|
295
|
-
dragStateRef.current = {
|
|
296
|
-
isDragging: false,
|
|
297
|
-
draggedItemId: '',
|
|
298
|
-
originalContainer: '',
|
|
299
|
-
originalIndex: -1,
|
|
300
|
-
currentContainer: '',
|
|
301
|
-
dropOccurred: false,
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
}, 50); // Small delay to let drop event fire if it's going to
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
// Detect when drag leaves document boundaries
|
|
309
|
-
const handleDragLeave = (e: DragEvent) => {
|
|
310
|
-
// Check if we're leaving the document (relatedTarget will be null)
|
|
311
|
-
if (!e.relatedTarget && dragStateRef.current.isDragging && !dragStateRef.current.dropOccurred) {
|
|
312
|
-
// Drag left the document: reset to original container immediately
|
|
313
|
-
dispatch({
|
|
314
|
-
type: 'RESET_DRAG_CONTAINER',
|
|
315
|
-
payload: {
|
|
316
|
-
itemId: dragStateRef.current.draggedItemId,
|
|
317
|
-
originalContainer: dragStateRef.current.originalContainer,
|
|
318
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
319
|
-
},
|
|
320
|
-
});
|
|
321
|
-
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
322
|
-
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
323
|
-
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
324
|
-
|
|
325
|
-
// Clear drag state
|
|
326
|
-
dragStateRef.current = {
|
|
327
|
-
isDragging: false,
|
|
328
|
-
draggedItemId: '',
|
|
329
|
-
originalContainer: '',
|
|
330
|
-
originalIndex: -1,
|
|
331
|
-
currentContainer: '',
|
|
332
|
-
dropOccurred: false,
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
document.addEventListener('dragover', handleGlobalDragOver);
|
|
338
|
-
document.addEventListener('drop', handleGlobalDrop);
|
|
339
|
-
document.addEventListener('dragleave', handleDragLeave);
|
|
340
|
-
document.addEventListener('mouseup', handleGlobalMouseUp);
|
|
341
|
-
document.addEventListener('pointerup', handleGlobalMouseUp);
|
|
342
|
-
|
|
343
|
-
return () => {
|
|
344
|
-
document.removeEventListener('dragover', handleGlobalDragOver);
|
|
345
|
-
document.removeEventListener('drop', handleGlobalDrop);
|
|
346
|
-
document.removeEventListener('dragleave', handleDragLeave);
|
|
347
|
-
document.removeEventListener('mouseup', handleGlobalMouseUp);
|
|
348
|
-
document.removeEventListener('pointerup', handleGlobalMouseUp);
|
|
349
|
-
};
|
|
350
|
-
}, [enableCrossContainerPreview]);
|
|
351
|
-
|
|
352
|
-
// Detect when dragging stops (isDragging goes from truthy to empty)
|
|
353
|
-
const prevIsDraggingRef = useRef(state.isDragging);
|
|
354
|
-
|
|
355
|
-
useEffect(() => {
|
|
356
|
-
if (!enableCrossContainerPreview) return;
|
|
357
|
-
|
|
358
|
-
const wasDragging = prevIsDraggingRef.current;
|
|
359
|
-
const isNowDragging = state.isDragging;
|
|
360
|
-
|
|
361
|
-
// Drag just ended (was dragging, now not)
|
|
362
|
-
if (wasDragging && !isNowDragging) {
|
|
363
|
-
|
|
364
|
-
// If drop didn't occur, reset to original container
|
|
365
|
-
if (!dragStateRef.current.dropOccurred && dragStateRef.current.draggedItemId) {
|
|
366
|
-
dispatch({
|
|
367
|
-
type: 'RESET_DRAG_CONTAINER',
|
|
368
|
-
payload: {
|
|
369
|
-
itemId: dragStateRef.current.draggedItemId,
|
|
370
|
-
originalContainer: dragStateRef.current.originalContainer,
|
|
371
|
-
originalIndex: dragStateRef.current.originalIndex,
|
|
372
|
-
},
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// Clear drag state
|
|
377
|
-
dragStateRef.current = {
|
|
378
|
-
isDragging: false,
|
|
379
|
-
draggedItemId: '',
|
|
380
|
-
originalContainer: '',
|
|
381
|
-
originalIndex: -1,
|
|
382
|
-
currentContainer: '',
|
|
383
|
-
dropOccurred: false,
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
prevIsDraggingRef.current = isNowDragging;
|
|
388
|
-
}, [state.isDragging, enableCrossContainerPreview]);
|
|
389
|
-
|
|
390
151
|
const handleDragStart = (id: string, container: string) => {
|
|
391
|
-
// Track drag in ref for global listener
|
|
392
|
-
if (enableCrossContainerPreview) {
|
|
393
|
-
// Find the original index of the item
|
|
394
|
-
const originalIndex = state.items.findIndex(item => item && item.id === id);
|
|
395
|
-
|
|
396
|
-
dragStateRef.current = {
|
|
397
|
-
isDragging: true,
|
|
398
|
-
draggedItemId: id,
|
|
399
|
-
originalContainer: container,
|
|
400
|
-
originalIndex: originalIndex,
|
|
401
|
-
currentContainer: container,
|
|
402
|
-
dropOccurred: false,
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
|
|
406
152
|
dispatch({ type: 'SET_DRAG_DATA', payload: { id: id, initialGroup: container, originId: providerId } });
|
|
407
153
|
dispatch({ type: 'SET_IS_DRAGGING', payload: id });
|
|
408
154
|
if (onDragStart) onDragStart(id, container);
|
|
@@ -435,10 +181,6 @@ export const DraggableProvider = ({
|
|
|
435
181
|
newContainer: container,
|
|
436
182
|
},
|
|
437
183
|
});
|
|
438
|
-
// Update current container in ref
|
|
439
|
-
if (enableCrossContainerPreview) {
|
|
440
|
-
dragStateRef.current.currentContainer = container;
|
|
441
|
-
}
|
|
442
184
|
} else {
|
|
443
185
|
// Same container: keep original behavior
|
|
444
186
|
dispatch({
|
|
@@ -451,10 +193,7 @@ export const DraggableProvider = ({
|
|
|
451
193
|
dispatch({type: "REORDER_ITEMS", payload: { dragId: state.dragData.id, targetId: id }});
|
|
452
194
|
}
|
|
453
195
|
|
|
454
|
-
|
|
455
|
-
// Otherwise, update it to track the current container
|
|
456
|
-
const newInitialGroup = enableCrossContainerPreview ? state.dragData.initialGroup : container;
|
|
457
|
-
dispatch({type: "SET_DRAG_DATA",payload: {id: state.dragData.id, initialGroup: newInitialGroup, originId: providerId}});
|
|
196
|
+
dispatch({type: "SET_DRAG_DATA",payload: {id: state.dragData.id, initialGroup: container, originId: providerId}});
|
|
458
197
|
}
|
|
459
198
|
if (onDragEnter) onDragEnter(id, container);
|
|
460
199
|
};
|
|
@@ -463,29 +202,17 @@ export const DraggableProvider = ({
|
|
|
463
202
|
const draggedItemId = state.dragData.id;
|
|
464
203
|
const originalContainer = state.dragData.initialGroup;
|
|
465
204
|
|
|
466
|
-
// If enableCrossContainerPreview is true and no drop occurred, reset item to original container
|
|
467
|
-
if (enableCrossContainerPreview && !dragStateRef.current.dropOccurred && draggedItemId && originalContainer) {
|
|
468
|
-
dispatch({ type: 'RESET_DRAG_CONTAINER', payload: { itemId: draggedItemId, originalContainer, originalIndex: dragStateRef.current.originalIndex } });
|
|
469
|
-
}
|
|
470
|
-
|
|
471
205
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
472
206
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
473
207
|
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
474
|
-
|
|
475
|
-
// Only call onDragEnd if drop didn't already occur (for enableCrossContainerPreview)
|
|
476
|
-
// If drop occurred, handleDrop or global drop handler already called onDragEnd
|
|
477
|
-
if (enableCrossContainerPreview && dragStateRef.current.dropOccurred) {
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
|
|
481
208
|
if (onDragEnd) {
|
|
482
209
|
if (!enableCrossContainerPreview) {
|
|
483
210
|
onDragEnd();
|
|
484
211
|
} else {
|
|
485
|
-
const draggedItem =
|
|
212
|
+
const draggedItem = state.items.find(item => item && item.id === draggedItemId);
|
|
486
213
|
const finalContainer = draggedItem ? draggedItem.container : originalContainer;
|
|
487
214
|
|
|
488
|
-
const itemsInContainer =
|
|
215
|
+
const itemsInContainer = state.items.filter(item => item && item.container === finalContainer);
|
|
489
216
|
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === draggedItemId);
|
|
490
217
|
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
491
218
|
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
@@ -510,58 +237,32 @@ export const DraggableProvider = ({
|
|
|
510
237
|
|
|
511
238
|
const draggedItemId = state.dragData.id;
|
|
512
239
|
const originalContainer = state.dragData.initialGroup;
|
|
513
|
-
|
|
514
|
-
// Mark drop as successful in ref for global listener
|
|
515
|
-
if (enableCrossContainerPreview) {
|
|
516
|
-
dragStateRef.current.dropOccurred = true;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
// Gather data for callbacks BEFORE clearing state
|
|
520
|
-
const isCrossContainer = container !== originalContainer;
|
|
521
|
-
let callbackData = null;
|
|
522
|
-
|
|
523
|
-
if (enableCrossContainerPreview) {
|
|
524
|
-
const draggedItem = stateRef.current.items.find(item => item && item.id === draggedItemId);
|
|
525
|
-
const updatedItem = draggedItem ? { ...draggedItem, container } : null;
|
|
526
|
-
const itemsInContainer = stateRef.current.items.filter(item => item && item.container === container);
|
|
527
|
-
const indexInContainer = itemsInContainer.findIndex(item => item && item.id === draggedItemId);
|
|
528
|
-
const itemAbove = indexInContainer > 0 ? itemsInContainer[indexInContainer - 1] : null;
|
|
529
|
-
const itemBelow = indexInContainer < itemsInContainer.length - 1 ? itemsInContainer[indexInContainer + 1] : null;
|
|
530
|
-
|
|
531
|
-
callbackData = { updatedItem, itemAbove, itemBelow };
|
|
532
|
-
}
|
|
533
240
|
|
|
534
241
|
dispatch({ type: 'SET_IS_DRAGGING', payload: "" });
|
|
535
242
|
dispatch({ type: 'SET_ACTIVE_CONTAINER', payload: "" });
|
|
536
|
-
dispatch({ type: 'SET_DRAG_DATA', payload: { id: "", initialGroup: "", originId: "" } });
|
|
537
243
|
changeCategory(state.dragData.id, container);
|
|
538
|
-
|
|
539
244
|
if (onDrop) {
|
|
540
245
|
if (!enableCrossContainerPreview) {
|
|
541
246
|
onDrop(container);
|
|
542
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
|
+
|
|
543
256
|
onDrop(
|
|
544
257
|
draggedItemId,
|
|
545
258
|
container,
|
|
546
259
|
originalContainer,
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
260
|
+
updatedItem,
|
|
261
|
+
itemAbove,
|
|
262
|
+
itemBelow
|
|
550
263
|
);
|
|
551
264
|
}
|
|
552
265
|
}
|
|
553
|
-
|
|
554
|
-
// Trigger onDragEnd ONLY for cross-container drops (dragend doesn't fire reliably in that case)
|
|
555
|
-
// For same-container drops, handleDragEnd will be called normally
|
|
556
|
-
if (enableCrossContainerPreview && isCrossContainer && onDragEnd && callbackData) {
|
|
557
|
-
onDragEnd(
|
|
558
|
-
draggedItemId,
|
|
559
|
-
container,
|
|
560
|
-
originalContainer,
|
|
561
|
-
callbackData.itemAbove,
|
|
562
|
-
callbackData.itemBelow
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
266
|
};
|
|
566
267
|
|
|
567
268
|
const handleDragOver = (e: Event, container: string) => {
|
|
@@ -580,8 +281,6 @@ export const DraggableProvider = ({
|
|
|
580
281
|
type: "MOVE_TO_CONTAINER_END",
|
|
581
282
|
payload: { dragId: state.dragData.id, newContainer: container },
|
|
582
283
|
});
|
|
583
|
-
// Update current container in ref
|
|
584
|
-
dragStateRef.current.currentContainer = container;
|
|
585
284
|
}
|
|
586
285
|
}
|
|
587
286
|
|
|
@@ -23,7 +23,7 @@ export type ActionType =
|
|
|
23
23
|
| { type: 'REORDER_ITEMS'; payload: { dragId: string; targetId: string } }
|
|
24
24
|
| { type: 'REORDER_ITEMS_CROSS_CONTAINER'; payload: { dragId: string; targetId: string; newContainer: string } }
|
|
25
25
|
| { type: 'MOVE_TO_CONTAINER_END'; payload: { dragId: string; newContainer: string } }
|
|
26
|
-
| { type: 'RESET_DRAG_CONTAINER'; payload: { itemId: string; originalContainer: string
|
|
26
|
+
| { type: 'RESET_DRAG_CONTAINER'; payload: { itemId: string; originalContainer: string } };
|
|
27
27
|
|
|
28
28
|
export interface DropZoneConfig {
|
|
29
29
|
type?: 'ghost' | 'outline' | 'shadow' | 'line';
|
|
@@ -6,10 +6,10 @@ import { GlobalProps, globalProps } from '../../utilities/globalProps'
|
|
|
6
6
|
import Card from '../../pb_card/_card'
|
|
7
7
|
|
|
8
8
|
export type FilterBackgroundProps = {
|
|
9
|
-
background
|
|
10
|
-
className
|
|
9
|
+
background: boolean,
|
|
10
|
+
className: string,
|
|
11
11
|
children?: React.ReactChild[] | React.ReactChild,
|
|
12
|
-
dark
|
|
12
|
+
dark: boolean,
|
|
13
13
|
} & GlobalProps
|
|
14
14
|
|
|
15
15
|
const FilterBackground = (props: FilterBackgroundProps): React.ReactElement => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useEffect } from 'react'
|
|
2
2
|
import classnames from 'classnames'
|
|
3
3
|
|
|
4
4
|
import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
|
|
5
5
|
import { globalProps } from '../utilities/globalProps'
|
|
6
|
+
import { deprecatedKitWarning } from '../utilities/deprecated'
|
|
6
7
|
|
|
7
8
|
import Body from '../pb_body/_body'
|
|
8
9
|
import Title from '../pb_title/_title'
|
|
@@ -32,6 +33,11 @@ const Legend = (props: LegendProps) => {
|
|
|
32
33
|
text,
|
|
33
34
|
} = props
|
|
34
35
|
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
console.log('TESTING ------------------------')
|
|
38
|
+
deprecatedKitWarning('Legend')
|
|
39
|
+
}, [])
|
|
40
|
+
|
|
35
41
|
const ariaProps = buildAriaProps(aria)
|
|
36
42
|
const dataProps = buildDataProps(data)
|
|
37
43
|
const htmlProps = buildHtmlProps(htmlOptions)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Error shows that the radio option must be selected or is invalid (
|
|
1
|
+
Error shows that the radio option must be selected or is invalid (ie when used in a form it signals a user to fix an error).
|
|
@@ -29,7 +29,6 @@ type SelectProps = {
|
|
|
29
29
|
id?: string,
|
|
30
30
|
includeBlank?: string,
|
|
31
31
|
inline?: boolean,
|
|
32
|
-
inputOptions?: {[key: string]: string | number | boolean | (() => void)},
|
|
33
32
|
label?: string,
|
|
34
33
|
margin: string,
|
|
35
34
|
marginBottom: string,
|
|
@@ -64,7 +63,6 @@ const Select = ({
|
|
|
64
63
|
label,
|
|
65
64
|
htmlOptions = {},
|
|
66
65
|
inline = false,
|
|
67
|
-
inputOptions = {},
|
|
68
66
|
multiple = false,
|
|
69
67
|
name,
|
|
70
68
|
onChange = () => undefined,
|
|
@@ -96,17 +94,14 @@ const Select = ({
|
|
|
96
94
|
const angleDown = getAllIcons()["angleDown"].icon as unknown as { [key: string]: SVGElement }
|
|
97
95
|
|
|
98
96
|
const selectWrapperClass = classnames(buildCss('pb_select_kit_wrapper'), { error }, className)
|
|
99
|
-
const selectId = (inputOptions?.id as string) || name
|
|
100
|
-
|
|
101
97
|
const selectBody =(() =>{
|
|
102
98
|
if (children) return children
|
|
103
99
|
return (
|
|
104
100
|
<select
|
|
105
101
|
{...htmlOptions}
|
|
106
102
|
{...domSafeProps(props)}
|
|
107
|
-
{...inputOptions}
|
|
108
103
|
disabled={disabled}
|
|
109
|
-
id={
|
|
104
|
+
id={name}
|
|
110
105
|
multiple={multiple}
|
|
111
106
|
name={name}
|
|
112
107
|
onChange={onChange}
|
|
@@ -130,7 +125,7 @@ const Select = ({
|
|
|
130
125
|
{label &&
|
|
131
126
|
<label
|
|
132
127
|
className="pb_select_kit_label"
|
|
133
|
-
htmlFor={
|
|
128
|
+
htmlFor={name}
|
|
134
129
|
>
|
|
135
130
|
<Caption
|
|
136
131
|
dark={props.dark}
|
|
@@ -140,7 +135,7 @@ const Select = ({
|
|
|
140
135
|
}
|
|
141
136
|
<label
|
|
142
137
|
className={selectWrapperClass}
|
|
143
|
-
htmlFor={
|
|
138
|
+
htmlFor={name}
|
|
144
139
|
>
|
|
145
140
|
{selectBody}
|
|
146
141
|
{ multiple !== true ?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Select w/ Error shows that
|
|
1
|
+
Select w/ Error shows that the radio option must be selected or is invalid (ie when used in a form it signals a user to fix an error).
|
|
@@ -15,7 +15,6 @@ examples:
|
|
|
15
15
|
- select_inline_compact: Select Inline Compact
|
|
16
16
|
- select_attributes: Select W/ Attributes
|
|
17
17
|
- select_multiple: Select Multiple
|
|
18
|
-
- select_input_options: Input Options
|
|
19
18
|
|
|
20
19
|
|
|
21
20
|
|
|
@@ -34,7 +33,6 @@ examples:
|
|
|
34
33
|
- select_inline_compact: Select Inline Compact
|
|
35
34
|
- select_multiple: Select Multiple
|
|
36
35
|
- select_react_hook: React Hook
|
|
37
|
-
- select_input_options: Input Options
|
|
38
36
|
|
|
39
37
|
swift:
|
|
40
38
|
- select_default_swift: Default
|
|
@@ -12,4 +12,3 @@ export { default as SelectInlineCompact } from './_select_inline_compact.jsx'
|
|
|
12
12
|
export { default as SelectMultiple } from './_select_multiple.jsx'
|
|
13
13
|
export { default as SelectReactHook } from './_select_react_hook.jsx'
|
|
14
14
|
export { default as SelectCustomSelectSubheaders } from './_select_custom_select_subheaders.jsx'
|
|
15
|
-
export { default as SelectInputOptions } from './_select_input_options.jsx'
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
id: nil,
|
|
3
3
|
class: object.classnames ) do %>
|
|
4
4
|
<% if object.label %>
|
|
5
|
-
<label class="pb_select_kit_label" for="<%= object.
|
|
5
|
+
<label class="pb_select_kit_label" for="<%= object.name %>">
|
|
6
6
|
<%= pb_rails("caption", props: { text: object.label, dark: object.dark }) %>
|
|
7
7
|
</label>
|
|
8
8
|
<% end %>
|
|
9
|
-
<label class="<%= object.select_wrapper_class %>" for="<%= object.
|
|
9
|
+
<label class="<%= object.select_wrapper_class %>" for="<%= object.name %>">
|
|
10
10
|
<% if content.present? %>
|
|
11
11
|
<%= content %>
|
|
12
12
|
<%= pb_rails("body", props: { status: "negative", text: object.error }) %>
|
|
@@ -14,8 +14,6 @@ module Playbook
|
|
|
14
14
|
prop :error
|
|
15
15
|
prop :include_blank
|
|
16
16
|
prop :inline, type: Playbook::Props::Boolean, default: false
|
|
17
|
-
prop :input_options, type: Playbook::Props::HashProp,
|
|
18
|
-
default: {}
|
|
19
17
|
prop :label
|
|
20
18
|
prop :multiple, type: Playbook::Props::Boolean, default: false
|
|
21
19
|
prop :name
|
|
@@ -40,7 +38,7 @@ module Playbook
|
|
|
40
38
|
multiple: multiple,
|
|
41
39
|
onchange: onchange,
|
|
42
40
|
include_blank: include_blank,
|
|
43
|
-
}.merge(attributes)
|
|
41
|
+
}.merge(attributes)
|
|
44
42
|
end
|
|
45
43
|
|
|
46
44
|
def classname
|
|
@@ -65,27 +65,4 @@ test('returns multiple variant', () => {
|
|
|
65
65
|
const selectElement = kit.querySelector('select');
|
|
66
66
|
|
|
67
67
|
expect(selectElement).toHaveAttribute('multiple', '');
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test('inputOptions are passed to select element', () => {
|
|
71
|
-
render(
|
|
72
|
-
<Select
|
|
73
|
-
data={{ testid: testId }}
|
|
74
|
-
inputOptions={{
|
|
75
|
-
id: 'custom-select-id',
|
|
76
|
-
className: 'custom-select-class',
|
|
77
|
-
'aria-label': 'Custom aria label',
|
|
78
|
-
}}
|
|
79
|
-
label="Favorite Food"
|
|
80
|
-
name="food"
|
|
81
|
-
options={options}
|
|
82
|
-
/>
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const kit = screen.getByTestId(testId)
|
|
86
|
-
const selectElement = kit.querySelector('select')
|
|
87
|
-
|
|
88
|
-
expect(selectElement).toHaveAttribute('id', 'custom-select-id')
|
|
89
|
-
expect(selectElement).toHaveClass('custom-select-class')
|
|
90
|
-
expect(selectElement).toHaveAttribute('aria-label', 'Custom aria label')
|
|
91
68
|
});
|