Remove leftover usages of inversion params which are no longer needed

This commit is contained in:
Andrew Kingston 2024-05-20 11:53:19 +01:00
parent 0fbbc3c88a
commit f906bd3dd5
11 changed files with 10 additions and 99 deletions

View File

@ -8,7 +8,6 @@
export let onChange export let onChange
export let readonly = false export let readonly = false
export let api export let api
export let invertX = false
export let schema export let schema
export let maximum export let maximum
@ -92,13 +91,7 @@
</div> </div>
{#if isOpen} {#if isOpen}
<GridPopover <GridPopover open={isOpen} {anchor} maxHeight={null} on:close={close}>
open={isOpen}
{anchor}
{invertX}
maxHeight={null}
on:close={close}
>
<div class="dropzone"> <div class="dropzone">
<Dropzone <Dropzone
{value} {value}

View File

@ -18,8 +18,6 @@
export let row export let row
export let cellId export let cellId
export let updateValue = rows.actions.updateValue export let updateValue = rows.actions.updateValue
export let invertX = false
export let invertY = false
export let contentLines = 1 export let contentLines = 1
export let hidden = false export let hidden = false
@ -93,8 +91,6 @@
onChange={cellAPI.setValue} onChange={cellAPI.setValue}
{focused} {focused}
{readonly} {readonly}
{invertY}
{invertX}
{contentLines} {contentLines}
/> />
<slot /> <slot />

View File

@ -10,7 +10,6 @@
export let focused = false export let focused = false
export let readonly = false export let readonly = false
export let api export let api
export let invertX = false
let isOpen let isOpen
let anchor let anchor
@ -111,7 +110,7 @@
</div> </div>
{#if isOpen} {#if isOpen}
<GridPopover {anchor} {invertX} maxHeight={null} on:close={close}> <GridPopover {anchor} maxHeight={null} on:close={close}>
<CoreDatePickerPopoverContents <CoreDatePickerPopoverContents
value={parsedValue} value={parsedValue}
useKeyboardShortcuts={false} useKeyboardShortcuts={false}

View File

@ -8,7 +8,6 @@
export let onChange export let onChange
export let readonly = false export let readonly = false
export let api export let api
export let invertX = false
let textarea let textarea
let isOpen = false let isOpen = false
@ -67,7 +66,7 @@
</div> </div>
{#if isOpen} {#if isOpen}
<GridPopover {anchor} {invertX} on:close={close}> <GridPopover {anchor} on:close={close}>
<textarea <textarea
bind:this={textarea} bind:this={textarea}
value={value || ""} value={value || ""}

View File

@ -11,7 +11,6 @@
export let multi = false export let multi = false
export let readonly = false export let readonly = false
export let api export let api
export let invertX
export let contentLines = 1 export let contentLines = 1
let isOpen = false let isOpen = false
@ -120,7 +119,7 @@
</div> </div>
{#if isOpen} {#if isOpen}
<GridPopover {anchor} {invertX} on:close={close}> <GridPopover {anchor} on:close={close}>
<div class="options"> <div class="options">
{#each options as option, idx} {#each options as option, idx}
{@const color = optionColors[option] || getOptionColor(option)} {@const color = optionColors[option] || getOptionColor(option)}

View File

@ -13,7 +13,6 @@
export let focused export let focused
export let schema export let schema
export let onChange export let onChange
export let invertX = false
export let contentLines = 1 export let contentLines = 1
export let searchFunction = API.searchTable export let searchFunction = API.searchTable
export let primaryDisplay export let primaryDisplay
@ -275,7 +274,7 @@
<!-- svelte-ignore a11y-no-static-element-interactions --> <!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
{#if isOpen} {#if isOpen}
<GridPopover open={isOpen} {anchor} {invertX} on:close={close}> <GridPopover open={isOpen} {anchor} on:close={close}>
<div class="dropdown" on:wheel|stopPropagation> <div class="dropdown" on:wheel|stopPropagation>
<div class="search"> <div class="search">
<Input <Input

View File

@ -10,7 +10,6 @@
export let onChange export let onChange
export let readonly = false export let readonly = false
export let api export let api
export let invertX = false
const { API, notifications, props } = getContext("grid") const { API, notifications, props } = getContext("grid")
@ -91,13 +90,7 @@
/> />
{#if isOpen} {#if isOpen}
<GridPopover <GridPopover open={isOpen} {anchor} maxHeight={null} on:close={close}>
open={isOpen}
{anchor}
{invertX}
maxHeight={null}
on:close={close}
>
<div class="signature" class:empty={!value}> <div class="signature" class:empty={!value}>
{#if value?.key} {#if value?.key}
<div class="signature-wrap"> <div class="signature-wrap">

View File

@ -9,7 +9,6 @@
bounds, bounds,
renderedRows, renderedRows,
visibleColumns, visibleColumns,
rowVerticalInversionIndex,
hoveredRowId, hoveredRowId,
dispatch, dispatch,
isDragging, isDragging,
@ -41,11 +40,7 @@
<div bind:this={body} class="grid-body"> <div bind:this={body} class="grid-body">
<GridScrollWrapper scrollHorizontally scrollVertically attachHandlers> <GridScrollWrapper scrollHorizontally scrollVertically attachHandlers>
{#each $renderedRows as row, idx} {#each $renderedRows as row, idx}
<GridRow <GridRow {row} top={idx === 0} />
{row}
top={idx === 0}
invertY={idx >= $rowVerticalInversionIndex}
/>
{/each} {/each}
{#if $config.canAddRows} {#if $config.canAddRows}
<div <div

View File

@ -5,7 +5,6 @@
export let row export let row
export let top = false export let top = false
export let invertY = false
const { const {
focusedCellId, focusedCellId,
@ -15,7 +14,6 @@
hoveredRowId, hoveredRowId,
selectedCellMap, selectedCellMap,
focusedRow, focusedRow,
columnHorizontalInversionIndex,
contentLines, contentLines,
isDragging, isDragging,
dispatch, dispatch,
@ -38,15 +36,13 @@
on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)} on:mouseleave={$isDragging ? null : () => ($hoveredRowId = null)}
on:click={() => dispatch("rowclick", rows.actions.cleanRow(row))} on:click={() => dispatch("rowclick", rows.actions.cleanRow(row))}
> >
{#each $visibleColumns as column, columnIdx} {#each $visibleColumns as column}
{@const cellId = getCellID(row._id, column.name)} {@const cellId = getCellID(row._id, column.name)}
<DataCell <DataCell
{cellId} {cellId}
{column} {column}
{row} {row}
{invertY}
{rowFocused} {rowFocused}
invertX={columnIdx >= $columnHorizontalInversionIndex}
highlighted={rowHovered || rowFocused || reorderSource === column.name} highlighted={rowHovered || rowFocused || reorderSource === column.name}
selected={rowSelected} selected={rowSelected}
rowIdx={row.__idx} rowIdx={row.__idx}

View File

@ -24,8 +24,6 @@
rowHeight, rowHeight,
hasNextPage, hasNextPage,
maxScrollTop, maxScrollTop,
rowVerticalInversionIndex,
columnHorizontalInversionIndex,
selectedRows, selectedRows,
loaded, loaded,
refreshing, refreshing,
@ -43,17 +41,9 @@
$: firstColumn = $stickyColumn || $visibleColumns[0] $: firstColumn = $stickyColumn || $visibleColumns[0]
$: width = GutterWidth + ($stickyColumn?.width || 0) $: width = GutterWidth + ($stickyColumn?.width || 0)
$: $datasource, (visible = false) $: $datasource, (visible = false)
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
$: selectedRowCount = Object.values($selectedRows).length $: selectedRowCount = Object.values($selectedRows).length
$: hasNoRows = !$rows.length $: hasNoRows = !$rows.length
const shouldInvertY = (offset, inversionIndex, rows) => {
if (offset === 0) {
return false
}
return rows.length >= inversionIndex
}
const addRow = async () => { const addRow = async () => {
// Blur the active cell and tick to let final value updates propagate // Blur the active cell and tick to let final value updates propagate
isAdding = true isAdding = true
@ -205,7 +195,6 @@
width={$stickyColumn.width} width={$stickyColumn.width}
{updateValue} {updateValue}
topRow={offset === 0} topRow={offset === 0}
{invertY}
> >
{#if $stickyColumn?.schema?.autocolumn} {#if $stickyColumn?.schema?.autocolumn}
<div class="readonly-overlay">Can't edit auto column</div> <div class="readonly-overlay">Can't edit auto column</div>
@ -219,7 +208,7 @@
<div class="normal-columns" transition:fade|local={{ duration: 130 }}> <div class="normal-columns" transition:fade|local={{ duration: 130 }}>
<GridScrollWrapper scrollHorizontally attachHandlers> <GridScrollWrapper scrollHorizontally attachHandlers>
<div class="row"> <div class="row">
{#each $visibleColumns as column, columnIdx} {#each $visibleColumns as column}
{@const cellId = `new-${column.name}`} {@const cellId = `new-${column.name}`}
<DataCell <DataCell
{cellId} {cellId}
@ -230,8 +219,6 @@
focused={$focusedCellId === cellId} focused={$focusedCellId === cellId}
width={column.width} width={column.width}
topRow={offset === 0} topRow={offset === 0}
invertX={columnIdx >= $columnHorizontalInversionIndex}
{invertY}
hidden={!$columnRenderMap[column.name]} hidden={!$columnRenderMap[column.name]}
> >
{#if column?.schema?.autocolumn} {#if column?.schema?.autocolumn}

View File

@ -1,9 +1,5 @@
import { derived } from "svelte/store" import { derived } from "svelte/store"
import { import { MinColumnWidth } from "../lib/constants"
MaxCellRenderOverflow,
MinColumnWidth,
ScrollBarSize,
} from "../lib/constants"
export const deriveStores = context => { export const deriveStores = context => {
const { const {
@ -85,51 +81,10 @@ export const deriveStores = context => {
} }
) )
// Determine the row index at which we should start vertically inverting cell
// dropdowns
const rowVerticalInversionIndex = derived(
[height, rowHeight, scrollTop],
([$height, $rowHeight, $scrollTop]) => {
const offset = $scrollTop % $rowHeight
// Compute the last row index with space to render popovers below it
const minBottom =
$height - ScrollBarSize * 3 - MaxCellRenderOverflow + offset
const lastIdx = Math.floor(minBottom / $rowHeight)
// Compute the first row index with space to render popovers above it
const minTop = MaxCellRenderOverflow + offset
const firstIdx = Math.ceil(minTop / $rowHeight)
// Use the greater of the two indices so that we prefer content below,
// unless there is room to render the entire popover above
return Math.max(lastIdx, firstIdx)
}
)
// Determine the column index at which we should start horizontally inverting
// cell dropdowns
const columnHorizontalInversionIndex = derived(
[visibleColumns, scrollLeft, width],
([$visibleColumns, $scrollLeft, $width]) => {
const cutoff = $width + $scrollLeft - ScrollBarSize * 3
let inversionIdx = $visibleColumns.length
for (let i = $visibleColumns.length - 1; i >= 0; i--, inversionIdx--) {
const rightEdge = $visibleColumns[i].left + $visibleColumns[i].width
if (rightEdge + MaxCellRenderOverflow <= cutoff) {
break
}
}
return inversionIdx
}
)
return { return {
scrolledRowCount, scrolledRowCount,
visualRowCapacity, visualRowCapacity,
renderedRows, renderedRows,
columnRenderMap, columnRenderMap,
rowVerticalInversionIndex,
columnHorizontalInversionIndex,
} }
} }