@lavalogic/scoria 0.40.22 → 0.40.24
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.
|
@@ -294,6 +294,34 @@ function onSlotMouseEnter(resourceId, slotIndex, e) {
|
|
|
294
294
|
}
|
|
295
295
|
dragEndSlotIndex = slotIndex;
|
|
296
296
|
}
|
|
297
|
+
/** Builds a range selection spanning slots [startIdx, endIdx] inclusive. */
|
|
298
|
+
function buildSlotRange(resourceId, startIdx, endIdx) {
|
|
299
|
+
const startSlot = timeSlots[startIdx];
|
|
300
|
+
const endSlot = timeSlots[endIdx];
|
|
301
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
302
|
+
const start = new Date(selected);
|
|
303
|
+
start.setHours(startSlot.hour, startSlot.minute, 0, 0);
|
|
304
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
305
|
+
const end = new Date(selected);
|
|
306
|
+
// End slot is the start of the last selected slot; add one interval.
|
|
307
|
+
end.setHours(endSlot.hour, endSlot.minute + slotIntervalMinutes, 0, 0);
|
|
308
|
+
return {
|
|
309
|
+
resourceId,
|
|
310
|
+
start,
|
|
311
|
+
end
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Double-clicking a single slot creates a one-interval range there. A single
|
|
316
|
+
* click is intentionally inert (see `onSlotMouseUp`): only a double-click or a
|
|
317
|
+
* multi-cell drag opens the consumer's range-select flow.
|
|
318
|
+
*/
|
|
319
|
+
function onSlotDoubleClick(resourceId, slotIndex) {
|
|
320
|
+
if (!onrangeselect || isSlotUnavailable(resourceId, slotIndex)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
onrangeselect(buildSlotRange(resourceId, slotIndex, slotIndex));
|
|
324
|
+
}
|
|
297
325
|
function onSlotMouseUp() {
|
|
298
326
|
// ---- Handle event drag-move ----
|
|
299
327
|
if (isDraggingEvent && draggedEvent && moveTargetResourceId != null && moveTargetSlotIndex != null) {
|
|
@@ -331,25 +359,20 @@ function onSlotMouseUp() {
|
|
|
331
359
|
}
|
|
332
360
|
const startIdx = Math.min(dragStartSlotIndex, dragEndSlotIndex);
|
|
333
361
|
const endIdx = Math.max(dragStartSlotIndex, dragEndSlotIndex);
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
//
|
|
337
|
-
const start = new Date(selected);
|
|
338
|
-
start.setHours(startSlot.hour, startSlot.minute, 0, 0);
|
|
339
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
340
|
-
const end = new Date(selected);
|
|
341
|
-
// End slot is the start of the last selected slot; add one interval.
|
|
342
|
-
end.setHours(endSlot.hour, endSlot.minute + slotIntervalMinutes, 0, 0);
|
|
343
|
-
const selection = {
|
|
344
|
-
resourceId: dragResourceId,
|
|
345
|
-
start,
|
|
346
|
-
end
|
|
347
|
-
};
|
|
362
|
+
const resourceId = dragResourceId;
|
|
363
|
+
// Capture done; clear the drag state before any early return so it is
|
|
364
|
+
// never left stuck for the next interaction.
|
|
348
365
|
isDragging = false;
|
|
349
366
|
dragResourceId = null;
|
|
350
367
|
dragStartSlotIndex = null;
|
|
351
368
|
dragEndSlotIndex = null;
|
|
352
|
-
|
|
369
|
+
// A single-cell selection is a plain click - intentionally inert. Creating
|
|
370
|
+
// from one cell requires a double-click (onSlotDoubleClick); only a drag
|
|
371
|
+
// across multiple cells opens the range-select flow here.
|
|
372
|
+
if (startIdx === endIdx) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
onrangeselect?.(buildSlotRange(resourceId, startIdx, endIdx));
|
|
353
376
|
}
|
|
354
377
|
function isSlotInDragRange(resourceId, slotIndex) {
|
|
355
378
|
if (!isDragging || resourceId !== dragResourceId) {
|
|
@@ -697,6 +720,9 @@ $effect(() => {
|
|
|
697
720
|
hoveredSlotIndex = slotIdx;
|
|
698
721
|
onSlotMouseEnter(resource.id, slotIdx, e);
|
|
699
722
|
}}
|
|
723
|
+
ondblclick={() => {
|
|
724
|
+
onSlotDoubleClick(resource.id, slotIdx);
|
|
725
|
+
}}
|
|
700
726
|
></div>
|
|
701
727
|
{/each}
|
|
702
728
|
<!-- Unavailable shading: one continuous block per contiguous run -->
|
|
@@ -961,8 +987,6 @@ $effect(() => {
|
|
|
961
987
|
left: 2px;
|
|
962
988
|
right: 2px;
|
|
963
989
|
z-index: 5;
|
|
964
|
-
border-radius: 4px;
|
|
965
|
-
overflow: hidden;
|
|
966
990
|
cursor: pointer;
|
|
967
991
|
user-select: none;
|
|
968
992
|
}
|