Merge branch 'master' into BUDI-8281/update-view-column-ui

This commit is contained in:
Adria Navarro 2024-05-30 10:33:51 +02:00 committed by GitHub
commit 60aa9e48d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 14 deletions

View File

@ -16,9 +16,10 @@
scroll,
isDragging,
buttonColumnWidth,
showVScrollbar,
} = getContext("grid")
let measureContainer
let container
$: buttons = $props.buttons?.slice(0, 3) || []
$: columnsWidth = $visibleColumns.reduce(
@ -39,7 +40,7 @@
const width = entries?.[0]?.contentRect?.width ?? 0
buttonColumnWidth.set(width)
})
observer.observe(measureContainer)
observer.observe(container)
})
</script>
@ -50,7 +51,7 @@
class:hidden={$buttonColumnWidth === 0}
>
<div class="content" on:mouseleave={() => ($hoveredRowId = null)}>
<GridScrollWrapper scrollVertically attachHandlers>
<GridScrollWrapper scrollVertically attachHandlers bind:ref={container}>
{#each $renderedRows as row}
{@const rowSelected = !!$selectedRows[row._id]}
{@const rowHovered = $hoveredRowId === row._id}
@ -59,7 +60,6 @@
class="row"
on:mouseenter={$isDragging ? null : () => ($hoveredRowId = row._id)}
on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
bind:this={measureContainer}
>
<GridCell
width="auto"
@ -67,7 +67,7 @@
selected={rowSelected}
highlighted={rowHovered || rowFocused}
>
<div class="buttons">
<div class="buttons" class:offset={$showVScrollbar}>
{#each buttons as button}
<Button
newStyles
@ -121,6 +121,9 @@
gap: var(--cell-padding);
height: inherit;
}
.buttons.offset {
padding-right: calc(var(--cell-padding) + 2 * var(--scroll-bar-size) - 2px);
}
.buttons :global(.spectrum-Button-Label) {
display: flex;
align-items: center;

View File

@ -29,6 +29,7 @@
Padding,
SmallRowHeight,
ControlsHeight,
ScrollBarSize,
} from "../lib/constants"
export let API = null
@ -145,7 +146,7 @@
class:quiet
on:mouseenter={() => gridFocused.set(true)}
on:mouseleave={() => gridFocused.set(false)}
style="--row-height:{$rowHeight}px; --default-row-height:{DefaultRowHeight}px; --gutter-width:{GutterWidth}px; --max-cell-render-overflow:{MaxCellRenderOverflow}px; --content-lines:{$contentLines}; --min-height:{$minHeight}px; --controls-height:{ControlsHeight}px;"
style="--row-height:{$rowHeight}px; --default-row-height:{DefaultRowHeight}px; --gutter-width:{GutterWidth}px; --max-cell-render-overflow:{MaxCellRenderOverflow}px; --content-lines:{$contentLines}; --min-height:{$minHeight}px; --controls-height:{ControlsHeight}px; --scroll-bar-size:{ScrollBarSize}px;"
>
{#if showControls}
<div class="controls">

View File

@ -18,6 +18,7 @@
export let scrollVertically = false
export let scrollHorizontally = false
export let attachHandlers = false
export let ref
// Used for tracking touch events
let initialTouchX
@ -109,7 +110,7 @@
on:touchmove={attachHandlers ? handleTouchMove : null}
on:click|self={() => ($focusedCellId = null)}
>
<div {style} class="inner">
<div {style} class="inner" bind:this={ref}>
<slot />
</div>
</div>

View File

@ -119,7 +119,7 @@
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class="v-scrollbar"
style="--size:{ScrollBarSize}px; top:{barTop}px; height:{barHeight}px;"
style="top:{barTop}px; height:{barHeight}px;"
on:mousedown={startVDragging}
on:touchstart={startVDragging}
class:dragging={isDraggingV}
@ -129,7 +129,7 @@
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class="h-scrollbar"
style="--size:{ScrollBarSize}px; left:{barLeft}px; width:{barWidth}px;"
style="left:{barLeft}px; width:{barWidth}px;"
on:mousedown={startHDragging}
on:touchstart={startHDragging}
class:dragging={isDraggingH}
@ -149,11 +149,11 @@
opacity: 1;
}
.v-scrollbar {
width: var(--size);
right: var(--size);
width: var(--scroll-bar-size);
right: var(--scroll-bar-size);
}
.h-scrollbar {
height: var(--size);
bottom: var(--size);
height: var(--scroll-bar-size);
bottom: var(--scroll-bar-size);
}
</style>

View File

@ -109,6 +109,7 @@ export const initialise = context => {
maxScrollTop,
scrollLeft,
maxScrollLeft,
buttonColumnWidth,
} = context
// Ensure scroll state never goes invalid, which can happen when changing
@ -194,8 +195,10 @@ export const initialise = context => {
// Ensure column is not cutoff on right edge
else {
const $buttonColumnWidth = get(buttonColumnWidth)
const rightEdge = column.left + column.width
const rightBound = $bounds.width + $scroll.left - FocusedCellMinOffset
const rightBound =
$bounds.width + $scroll.left - FocusedCellMinOffset - $buttonColumnWidth
delta = rightEdge - rightBound
if (delta > 0) {
scroll.update(state => ({