1
0
Fork 0
mirror of synced 2024-09-09 22:16:26 +12:00

Merge branch 'master' into wrap-field-labels

This commit is contained in:
Andrew Kingston 2024-05-30 09:28:00 +01:00 committed by GitHub
commit 56c2bac382
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 => ({