@hkdigital/lib-sveltekit 0.1.81 → 0.1.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/drag-drop/Draggable.svelte +71 -60
- package/dist/components/drag-drop/DropZone.svelte +171 -155
- package/dist/components/drag-drop/DropZone.svelte.d.ts +2 -14
- package/dist/constants/state-labels/drop-states.d.ts +0 -2
- package/dist/constants/state-labels/drop-states.js +2 -2
- package/dist/themes/hkdev/components/drag-drop/dropzone.css +3 -3
- package/dist/typedef/drag.d.ts +2 -0
- package/dist/typedef/drag.js +2 -0
- package/dist/typedef/drop.d.ts +4 -13
- package/dist/typedef/drop.js +8 -5
- package/package.json +1 -1
@@ -162,70 +162,81 @@
|
|
162
162
|
startDrag(event);
|
163
163
|
}
|
164
164
|
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
// Function to get the preview controller
|
187
|
-
const getController = () => previewController;
|
188
|
-
|
189
|
-
// Call onDragStart with the getController function
|
190
|
-
onDragStart?.({ event, item, source, group, getController });
|
191
|
-
|
192
|
-
// Check if we have a preview snippet and no custom preview was set by preview controller
|
193
|
-
if (draggingSnippet && !previewController.hasCustomPreview()) {
|
194
|
-
try {
|
195
|
-
// Get the element's bounding rectangle
|
196
|
-
const rect = draggableElement.getBoundingClientRect();
|
197
|
-
elementRect = rect;
|
198
|
-
|
199
|
-
// Calculate offsets - this is the natural position where the user grabbed
|
200
|
-
dragOffsetX = event.clientX - rect.left;
|
201
|
-
dragOffsetY = event.clientY - rect.top;
|
202
|
-
|
203
|
-
// Set initial position
|
204
|
-
previewX = event.clientX - dragOffsetX;
|
205
|
-
previewY = event.clientY - dragOffsetY;
|
206
|
-
|
207
|
-
// Set a transparent 1x1 pixel image as drag preview to hide browser preview
|
208
|
-
const emptyImg = new Image();
|
209
|
-
emptyImg.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
210
|
-
event.dataTransfer.setDragImage(emptyImg, 0, 0);
|
211
|
-
|
212
|
-
// Add document level event listener to catch all dragover events
|
213
|
-
document.addEventListener('dragover', handleDocumentDragOver);
|
214
|
-
|
215
|
-
// Show our custom preview
|
216
|
-
showPreview = true;
|
217
|
-
customPreviewSet = true;
|
218
|
-
} catch (err) {
|
219
|
-
console.error('Error setting up custom preview:', err);
|
220
|
-
// Fallback to default preview
|
221
|
-
previewController.applyDefaultPreview();
|
222
|
-
}
|
165
|
+
/**
|
166
|
+
* Start the drag operation
|
167
|
+
* @param {DragEvent} event - The drag event
|
168
|
+
*/
|
169
|
+
function startDrag(event) {
|
170
|
+
// Get the element's bounding rectangle
|
171
|
+
const rect = draggableElement.getBoundingClientRect();
|
172
|
+
|
173
|
+
// Calculate grab offsets - this is where the user grabbed the element
|
174
|
+
dragOffsetX = event.clientX - rect.left;
|
175
|
+
dragOffsetY = event.clientY - rect.top;
|
176
|
+
|
177
|
+
// Create drag data with your preferred structure
|
178
|
+
const dragData = {
|
179
|
+
offsetX: dragOffsetX,
|
180
|
+
offsetY: dragOffsetY,
|
181
|
+
item,
|
182
|
+
source,
|
183
|
+
group,
|
184
|
+
metadata: {
|
185
|
+
timestamp: Date.now()
|
223
186
|
}
|
224
|
-
|
225
|
-
|
187
|
+
};
|
188
|
+
|
189
|
+
// Set shared drag state
|
190
|
+
dragState.start(draggableId, dragData);
|
191
|
+
|
192
|
+
// Set data transfer for browser drag and drop API
|
193
|
+
event.dataTransfer.effectAllowed = 'move';
|
194
|
+
event.dataTransfer.setData('application/json', JSON.stringify(dragData));
|
195
|
+
|
196
|
+
// Create the preview controller
|
197
|
+
const previewController = new DragController(event);
|
198
|
+
|
199
|
+
// Function to get the preview controller
|
200
|
+
const getController = () => previewController;
|
201
|
+
|
202
|
+
// Call onDragStart with the getController function
|
203
|
+
onDragStart?.({ event, item, source, group, getController });
|
204
|
+
|
205
|
+
// Apply drag preview if available
|
206
|
+
if (draggingSnippet && !previewController.hasCustomPreview()) {
|
207
|
+
try {
|
208
|
+
// Store rectangle information for the snippet
|
209
|
+
elementRect = rect;
|
210
|
+
|
211
|
+
// These offsets represent where the user grabbed the element relative to its top-left corner
|
212
|
+
dragOffsetX = event.clientX - rect.left;
|
213
|
+
dragOffsetY = event.clientY - rect.top;
|
214
|
+
|
215
|
+
// Set initial position - this places the preview at the element's original position
|
216
|
+
previewX = rect.left;
|
217
|
+
previewY = rect.top;
|
218
|
+
|
219
|
+
// Set a transparent 1x1 pixel image to hide browser's default preview
|
220
|
+
const emptyImg = new Image();
|
221
|
+
emptyImg.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
|
222
|
+
event.dataTransfer.setDragImage(emptyImg, 0, 0);
|
223
|
+
|
224
|
+
// Add document level event listener to track mouse movement
|
225
|
+
document.addEventListener('dragover', handleDocumentDragOver);
|
226
|
+
|
227
|
+
// Show custom preview
|
228
|
+
showPreview = true;
|
229
|
+
customPreviewSet = true;
|
230
|
+
} catch (err) {
|
231
|
+
console.error('Error setting up custom preview:', err);
|
232
|
+
// Fallback to default preview
|
226
233
|
previewController.applyDefaultPreview();
|
227
234
|
}
|
235
|
+
} else if (!previewController.hasCustomPreview()) {
|
236
|
+
// Apply default preview if no custom preview was set
|
237
|
+
previewController.applyDefaultPreview();
|
228
238
|
}
|
239
|
+
}
|
229
240
|
|
230
241
|
/**
|
231
242
|
* Handle during drag
|
@@ -7,20 +7,21 @@
|
|
7
7
|
import { GridLayers } from '../layout';
|
8
8
|
|
9
9
|
import {
|
10
|
-
findDraggableSource,
|
11
|
-
getDraggableIdFromEvent
|
12
|
-
processDropWithData
|
10
|
+
// findDraggableSource,
|
11
|
+
getDraggableIdFromEvent
|
12
|
+
// processDropWithData
|
13
13
|
} from './util.js';
|
14
14
|
|
15
15
|
import {
|
16
16
|
READY,
|
17
17
|
DRAG_OVER,
|
18
18
|
CAN_DROP,
|
19
|
-
CANNOT_DROP
|
20
|
-
DROP_DISABLED
|
19
|
+
CANNOT_DROP
|
20
|
+
// DROP_DISABLED
|
21
21
|
} from '../../constants/state-labels/drop-states.js';
|
22
22
|
|
23
23
|
/** @typedef {import('../../typedef').DragData} DragData */
|
24
|
+
/** @typedef {import('../../typedef').DropData} DropData */
|
24
25
|
|
25
26
|
/**
|
26
27
|
* @type {{
|
@@ -50,13 +51,7 @@
|
|
50
51
|
* event: DragEvent,
|
51
52
|
* zone: string
|
52
53
|
* }) => void,
|
53
|
-
* onDrop?: (detail:
|
54
|
-
* event: DragEvent,
|
55
|
-
* zone: string,
|
56
|
-
* item: any,
|
57
|
-
* source: string,
|
58
|
-
* metadata?: any
|
59
|
-
* }) => any | Promise<any>,
|
54
|
+
* onDrop?: (detail: DropData) => any | Promise<any>,
|
60
55
|
* onDropStart?: (detail: {
|
61
56
|
* event: DragEvent,
|
62
57
|
* zone: string,
|
@@ -80,7 +75,7 @@
|
|
80
75
|
base = '',
|
81
76
|
classes = '',
|
82
77
|
height = 'h-min',
|
83
|
-
autoHeight= false,
|
78
|
+
autoHeight = false,
|
84
79
|
children,
|
85
80
|
contextKey,
|
86
81
|
dropPreviewSnippet,
|
@@ -95,7 +90,6 @@
|
|
95
90
|
...attrs
|
96
91
|
} = $props();
|
97
92
|
|
98
|
-
|
99
93
|
const dragState = createOrGetDragState(contextKey);
|
100
94
|
|
101
95
|
// console.debug('DropZone contextKey:', contextKey);
|
@@ -141,11 +135,7 @@
|
|
141
135
|
|
142
136
|
// Update bindable props
|
143
137
|
$effect(() => {
|
144
|
-
isDragOver = [
|
145
|
-
DRAG_OVER,
|
146
|
-
CAN_DROP,
|
147
|
-
CANNOT_DROP
|
148
|
-
].includes(currentState);
|
138
|
+
isDragOver = [DRAG_OVER, CAN_DROP, CANNOT_DROP].includes(currentState);
|
149
139
|
|
150
140
|
canDrop = currentState === CAN_DROP;
|
151
141
|
});
|
@@ -167,96 +157,90 @@
|
|
167
157
|
return true;
|
168
158
|
}
|
169
159
|
|
170
|
-
/**
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
function handleDragEnter(event) {
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
// If we're already in a drag-over state, don't reset anything
|
179
|
-
if (isCurrentlyOver) return;
|
160
|
+
/**
|
161
|
+
* Handle drag enter with improved DOM traversal check
|
162
|
+
* @param {DragEvent} event
|
163
|
+
*/
|
164
|
+
function handleDragEnter(event) {
|
165
|
+
// Prevent default to allow drop
|
166
|
+
event.preventDefault();
|
180
167
|
|
181
|
-
|
182
|
-
|
168
|
+
// If we're already in a drag-over state, don't reset anything
|
169
|
+
if (isCurrentlyOver) return;
|
183
170
|
|
184
|
-
|
185
|
-
|
171
|
+
// Now we're over this dropzone
|
172
|
+
isCurrentlyOver = true;
|
186
173
|
|
187
|
-
|
188
|
-
|
189
|
-
const dragData = dragState.getDraggable(draggableId);
|
174
|
+
// Get the draggable ID from the event
|
175
|
+
const draggableId = getDraggableIdFromEvent(event);
|
190
176
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
const dragData = dragState.current;
|
202
|
-
|
203
|
-
if (dragData) {
|
204
|
-
currentState = canAcceptDrop(dragData)
|
205
|
-
? CAN_DROP
|
206
|
-
: CANNOT_DROP;
|
177
|
+
if (draggableId) {
|
178
|
+
// Get the drag data for this specific draggable
|
179
|
+
const dragData = dragState.getDraggable(draggableId);
|
180
|
+
|
181
|
+
// Update state based on acceptance
|
182
|
+
if (dragData) {
|
183
|
+
currentState = canAcceptDrop(dragData) ? CAN_DROP : CANNOT_DROP;
|
184
|
+
} else {
|
185
|
+
currentState = DRAG_OVER;
|
186
|
+
}
|
207
187
|
} else {
|
208
|
-
|
188
|
+
// Fallback to the current drag data (for compatibility)
|
189
|
+
const dragData = dragState.current;
|
190
|
+
|
191
|
+
if (dragData) {
|
192
|
+
currentState = canAcceptDrop(dragData) ? CAN_DROP : CANNOT_DROP;
|
193
|
+
} else {
|
194
|
+
currentState = DRAG_OVER;
|
195
|
+
}
|
209
196
|
}
|
210
|
-
}
|
211
197
|
|
212
|
-
|
213
|
-
|
214
|
-
}
|
215
|
-
|
216
|
-
/**
|
217
|
-
* Handle drag over
|
218
|
-
* @param {DragEvent} event
|
219
|
-
*/
|
220
|
-
function handleDragOver(event) {
|
221
|
-
// Prevent default to allow drop
|
222
|
-
event.preventDefault();
|
223
|
-
|
224
|
-
// If we're not currently over this dropzone (despite dragover firing),
|
225
|
-
// treat it as an enter event
|
226
|
-
if (!isCurrentlyOver) {
|
227
|
-
handleDragEnter(event);
|
228
|
-
return;
|
198
|
+
// Notify listeners
|
199
|
+
onDragEnter?.({ event, zone, canDrop: currentState === CAN_DROP });
|
229
200
|
}
|
230
201
|
|
231
|
-
|
232
|
-
|
233
|
-
|
202
|
+
/**
|
203
|
+
* Handle drag over
|
204
|
+
* @param {DragEvent} event
|
205
|
+
*/
|
206
|
+
function handleDragOver(event) {
|
207
|
+
// Prevent default to allow drop
|
208
|
+
event.preventDefault();
|
209
|
+
|
210
|
+
// If we're not currently over this dropzone (despite dragover firing),
|
211
|
+
// treat it as an enter event
|
212
|
+
if (!isCurrentlyOver) {
|
213
|
+
handleDragEnter(event);
|
214
|
+
return;
|
215
|
+
}
|
234
216
|
|
235
|
-
|
236
|
-
|
237
|
-
dragData
|
238
|
-
} else {
|
239
|
-
// Fallback to the current drag data (for compatibility)
|
240
|
-
dragData = dragState.current;
|
241
|
-
}
|
217
|
+
// Get the draggable ID from the event
|
218
|
+
const draggableId = getDraggableIdFromEvent(event);
|
219
|
+
let dragData;
|
242
220
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
221
|
+
if (draggableId) {
|
222
|
+
// Get the drag data for this specific draggable
|
223
|
+
dragData = dragState.getDraggable(draggableId);
|
224
|
+
} else {
|
225
|
+
// Fallback to the current drag data (for compatibility)
|
226
|
+
dragData = dragState.current;
|
227
|
+
}
|
249
228
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
event.dataTransfer.dropEffect = 'none';
|
255
|
-
}
|
229
|
+
// Re-evaluate acceptance
|
230
|
+
if (dragData && [DRAG_OVER, CAN_DROP, CANNOT_DROP].includes(currentState)) {
|
231
|
+
currentState = canAcceptDrop(dragData) ? CAN_DROP : CANNOT_DROP;
|
232
|
+
}
|
256
233
|
|
257
|
-
|
258
|
-
|
259
|
-
|
234
|
+
// Set visual feedback based on drop acceptance
|
235
|
+
if (currentState === CAN_DROP) {
|
236
|
+
event.dataTransfer.dropEffect = 'move';
|
237
|
+
} else if (currentState === CANNOT_DROP) {
|
238
|
+
event.dataTransfer.dropEffect = 'none';
|
239
|
+
}
|
240
|
+
|
241
|
+
// Notify listeners
|
242
|
+
onDragOver?.({ event, zone });
|
243
|
+
}
|
260
244
|
|
261
245
|
/**
|
262
246
|
* Handle drag leave with improved DOM traversal check
|
@@ -270,8 +254,8 @@ function handleDragOver(event) {
|
|
270
254
|
const relatedTarget = event.relatedTarget;
|
271
255
|
|
272
256
|
// If relatedTarget is null or outside our dropzone, we're truly leaving
|
273
|
-
const isActuallyLeaving =
|
274
|
-
|
257
|
+
const isActuallyLeaving =
|
258
|
+
!relatedTarget || !dropzoneElement.contains(relatedTarget);
|
275
259
|
|
276
260
|
if (isActuallyLeaving) {
|
277
261
|
isCurrentlyOver = false;
|
@@ -280,68 +264,96 @@ function handleDragOver(event) {
|
|
280
264
|
}
|
281
265
|
}
|
282
266
|
|
283
|
-
/**
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
function handleDrop(event) {
|
288
|
-
|
289
|
-
|
267
|
+
/**
|
268
|
+
* Handle drop
|
269
|
+
* @param {DragEvent} event
|
270
|
+
*/
|
271
|
+
function handleDrop(event) {
|
272
|
+
// Prevent default browser actions
|
273
|
+
event.preventDefault();
|
290
274
|
|
291
|
-
|
292
|
-
|
275
|
+
// Reset our tracking state
|
276
|
+
isCurrentlyOver = false;
|
293
277
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
278
|
+
try {
|
279
|
+
// First try to get the draggable ID from the event
|
280
|
+
const draggableId = getDraggableIdFromEvent(event);
|
281
|
+
let dragData;
|
298
282
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
283
|
+
if (draggableId) {
|
284
|
+
// Get the drag data from state using the draggable ID
|
285
|
+
dragData = dragState.getDraggable(draggableId);
|
286
|
+
}
|
303
287
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
288
|
+
// If we couldn't get it from the element attribute, try dataTransfer
|
289
|
+
if (!dragData) {
|
290
|
+
// Parse the JSON data from the dataTransfer object (only works during drop)
|
291
|
+
const jsonData = event.dataTransfer.getData('application/json');
|
292
|
+
if (jsonData) {
|
293
|
+
dragData = JSON.parse(jsonData);
|
294
|
+
}
|
310
295
|
}
|
311
|
-
}
|
312
296
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
297
|
+
// Check if we can accept this drop
|
298
|
+
if (dragData && canAcceptDrop(dragData)) {
|
299
|
+
// Notify listener
|
300
|
+
onDropStart?.({ event, zone, data: dragData });
|
301
|
+
|
302
|
+
const style = window.getComputedStyle(dropzoneElement);
|
303
|
+
|
304
|
+
// Parse border widths from computed style
|
305
|
+
const borderLeftWidth = parseInt(style.borderLeftWidth, 10) || 0;
|
306
|
+
const borderTopWidth = parseInt(style.borderTopWidth, 10) || 0;
|
307
|
+
|
308
|
+
// Get dropzone rectangle
|
309
|
+
const dropzoneRect = dropzoneElement.getBoundingClientRect();
|
310
|
+
|
311
|
+
// Calculate position with both dragData.offsetX/Y adjustment and border adjustment
|
312
|
+
// This combines your current approach with the border adjustment
|
313
|
+
const offsetX =
|
314
|
+
event.clientX -
|
315
|
+
dropzoneRect.left -
|
316
|
+
borderLeftWidth -
|
317
|
+
(dragData.offsetX ?? 0);
|
318
|
+
|
319
|
+
const offsetY =
|
320
|
+
event.clientY -
|
321
|
+
dropzoneRect.top -
|
322
|
+
borderTopWidth -
|
323
|
+
(dragData.offsetY ?? 0);
|
324
|
+
|
325
|
+
// console.debug("dragData", dragData);
|
326
|
+
|
327
|
+
const dropResult = onDrop?.({
|
328
|
+
event,
|
329
|
+
offsetX,
|
330
|
+
offsetY,
|
331
|
+
zone,
|
332
|
+
item: dragData.item,
|
333
|
+
source: dragData.source,
|
334
|
+
metadata: dragData.metadata
|
335
|
+
});
|
336
|
+
|
337
|
+
// Handle async or sync results
|
338
|
+
Promise.resolve(dropResult)
|
339
|
+
.then(() => {
|
340
|
+
currentState = READY;
|
341
|
+
onDropEnd?.({ event, zone, data: dragData, success: true });
|
342
|
+
})
|
343
|
+
.catch((error) => {
|
344
|
+
currentState = READY;
|
345
|
+
onDropEnd?.({ event, zone, data: dragData, success: false, error });
|
346
|
+
});
|
347
|
+
} else {
|
348
|
+
// Not a valid drop, reset state
|
332
349
|
currentState = READY;
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
350
|
+
}
|
351
|
+
} catch (error) {
|
352
|
+
// Handle parsing errors
|
353
|
+
console.error('Drop error:', error);
|
337
354
|
currentState = READY;
|
338
355
|
}
|
339
|
-
} catch (error) {
|
340
|
-
// Handle parsing errors
|
341
|
-
console.error('Drop error:', error);
|
342
|
-
currentState = READY;
|
343
356
|
}
|
344
|
-
}
|
345
357
|
</script>
|
346
358
|
|
347
359
|
<div
|
@@ -367,14 +379,16 @@ function handleDrop(event) {
|
|
367
379
|
{@render dropPreviewSnippet(dragState.current)}
|
368
380
|
</div>
|
369
381
|
{/if}
|
370
|
-
|
371
382
|
</GridLayers>
|
372
383
|
</div>
|
373
384
|
|
374
385
|
<style>
|
375
386
|
[data-layer='content']:not(.auto-height) {
|
376
387
|
position: absolute;
|
377
|
-
left: 0;
|
388
|
+
left: 0;
|
389
|
+
right: 0;
|
390
|
+
top: 0;
|
391
|
+
bottom: 0;
|
378
392
|
}
|
379
393
|
|
380
394
|
[data-layer='content'].auto-height {
|
@@ -382,10 +396,12 @@ function handleDrop(event) {
|
|
382
396
|
width: 100%;
|
383
397
|
}
|
384
398
|
|
385
|
-
[data-layer='preview']
|
386
|
-
{
|
399
|
+
[data-layer='preview'] {
|
387
400
|
position: absolute;
|
388
|
-
left: 0;
|
401
|
+
left: 0;
|
402
|
+
right: 0;
|
403
|
+
top: 0;
|
404
|
+
bottom: 0;
|
389
405
|
pointer-events: none;
|
390
406
|
}
|
391
407
|
</style>
|
@@ -29,13 +29,7 @@ type DropZone = {
|
|
29
29
|
event: DragEvent;
|
30
30
|
zone: string;
|
31
31
|
}) => void;
|
32
|
-
onDrop?: (detail:
|
33
|
-
event: DragEvent;
|
34
|
-
zone: string;
|
35
|
-
item: any;
|
36
|
-
source: string;
|
37
|
-
metadata?: any;
|
38
|
-
}) => any;
|
32
|
+
onDrop?: (detail: DropData) => any;
|
39
33
|
onDropStart?: (detail: {
|
40
34
|
event: DragEvent;
|
41
35
|
zone: string;
|
@@ -78,13 +72,7 @@ declare const DropZone: import("svelte").Component<{
|
|
78
72
|
event: DragEvent;
|
79
73
|
zone: string;
|
80
74
|
}) => void;
|
81
|
-
onDrop?: (detail:
|
82
|
-
event: DragEvent;
|
83
|
-
zone: string;
|
84
|
-
item: any;
|
85
|
-
source: string;
|
86
|
-
metadata?: any;
|
87
|
-
}) => any | Promise<any>;
|
75
|
+
onDrop?: (detail: import("../../typedef").DropData) => any | Promise<any>;
|
88
76
|
onDropStart?: (detail: {
|
89
77
|
event: DragEvent;
|
90
78
|
zone: string;
|
@@ -2,5 +2,5 @@ export const READY = 'ready'; // Waiting for drag
|
|
2
2
|
export const DRAG_OVER = 'drag-over'; // Item dragged over zone
|
3
3
|
export const CAN_DROP = 'can-drop'; // Valid drop target
|
4
4
|
export const CANNOT_DROP = 'cannot-drop'; // Invalid drop target
|
5
|
-
export const DROP_DISABLED = 'drop-disabled'; // Dropping not allowed
|
6
|
-
export const ACTIVE_DROP = 'active-drop'; // Currently processing drop
|
5
|
+
// export const DROP_DISABLED = 'drop-disabled'; // Dropping not allowed
|
6
|
+
// export const ACTIVE_DROP = 'active-drop'; // Currently processing drop
|
@@ -2,9 +2,9 @@
|
|
2
2
|
/* Visual styling and customizable aspects */
|
3
3
|
[data-component='dropzone'] {
|
4
4
|
/*min-height: 100px;*/
|
5
|
-
border:
|
5
|
+
border: 1px dashed rgb(var(--color-surface-400));
|
6
6
|
border-radius: var(--theme-rounded-container);
|
7
|
-
padding: 1rem
|
7
|
+
/*padding: 1rem;*/
|
8
8
|
transition: all 0.2s ease;
|
9
9
|
position: relative;
|
10
10
|
background-color: rgb(var(--color-surface-50) / 0.5);
|
@@ -23,7 +23,7 @@
|
|
23
23
|
&.state-can-drop {
|
24
24
|
border-color: rgb(var(--color-success-500));
|
25
25
|
background-color: rgb(var(--color-success-500) / 0.08);
|
26
|
-
transform: scale(1.01)
|
26
|
+
/*transform: scale(1.01);*/
|
27
27
|
box-shadow: 0 0 0 3px rgb(var(--color-success-500) / 0.2);
|
28
28
|
}
|
29
29
|
|
package/dist/typedef/drag.d.ts
CHANGED
package/dist/typedef/drag.js
CHANGED
package/dist/typedef/drop.d.ts
CHANGED
@@ -1,20 +1,11 @@
|
|
1
1
|
declare const _default: {};
|
2
2
|
export default _default;
|
3
3
|
export type DropData = {
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
event: DragEvent;
|
5
|
+
offsetX: number;
|
6
|
+
offsetY: number;
|
7
|
+
zone: string;
|
7
8
|
item: any;
|
8
|
-
/**
|
9
|
-
* - Source identifier
|
10
|
-
*/
|
11
9
|
source: string;
|
12
|
-
/**
|
13
|
-
* - Drag group
|
14
|
-
*/
|
15
|
-
group: string;
|
16
|
-
/**
|
17
|
-
* - Additional metadata
|
18
|
-
*/
|
19
10
|
metadata?: any;
|
20
11
|
};
|
package/dist/typedef/drop.js
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
/**
|
2
2
|
* @typedef {Object} DropData
|
3
|
-
* @property {
|
4
|
-
* @property {
|
5
|
-
* @property {
|
6
|
-
* @property {
|
3
|
+
* @property {DragEvent} event
|
4
|
+
* @property {number} offsetX
|
5
|
+
* @property {number} offsetY
|
6
|
+
* @property {string} zone
|
7
|
+
* @property {any} item
|
8
|
+
* @property {string} source
|
9
|
+
* @property {any} [metadata]
|
7
10
|
*/
|
8
11
|
|
9
|
-
export default {}
|
12
|
+
export default {};
|