diff --git a/packages/frontend-core/src/components/sheet/Sheet.svelte b/packages/frontend-core/src/components/sheet/Sheet.svelte index dcf0cf6f38..365afab8fd 100644 --- a/packages/frontend-core/src/components/sheet/Sheet.svelte +++ b/packages/frontend-core/src/components/sheet/Sheet.svelte @@ -18,8 +18,9 @@ export let API export let tableId - export let allowAddColumns - export let allowAddRows + export let allowAddColumns = true + export let allowAddRows = true + export let allowSelectRows = true // export let filter // export let sortColumn // export let sortOrder @@ -29,7 +30,12 @@ const rand = Math.random() // State stores - const config = writable({ tableId, allowAddRows, allowAddColumns }) + const config = writable({ + tableId, + allowAddRows, + allowAddColumns, + allowSelectRows, + }) const selectedCellId = writable() const selectedRows = writable({}) const hoveredRowId = writable() @@ -71,6 +77,7 @@ tableId, allowAddColumns, allowAddRows, + allowSelectRows, }) // Set context for children to consume @@ -87,7 +94,9 @@ {#each $visibleRows as row} {/each} - + {#if allowAddRows} + + {/if} diff --git a/packages/frontend-core/src/components/sheet/StickyColumn.svelte b/packages/frontend-core/src/components/sheet/StickyColumn.svelte index b7cb321b96..6bbbc113b6 100644 --- a/packages/frontend-core/src/components/sheet/StickyColumn.svelte +++ b/packages/frontend-core/src/components/sheet/StickyColumn.svelte @@ -15,6 +15,7 @@ hoveredRowId, scroll, reorder, + config, } = getContext("spreadsheet") $: scrollLeft = $scroll.left @@ -57,8 +58,15 @@ >
- - + + {#if $config.allowSelectRows} + + {/if} {#if $stickyColumn} @@ -86,17 +94,20 @@ {@const rowSelected = !!$selectedRows[row._id]} {@const rowHovered = $hoveredRowId === row._id}
($hoveredRowId = row._id)}> - selectRow(row._id)} - width="40" - > -
+ +
selectRow(row._id)} + class="checkbox" + class:visible={$config.allowSelectRows && + (rowSelected || rowHovered)} + >
-
+
{row.__idx + 1}
@@ -126,24 +137,26 @@
{/each} -
($hoveredRowId = "new")}> - - - - {#if $stickyColumn} + {#if $config.allowAddRows} +
($hoveredRowId = "new")}> - {/if} -
+ label + on:click={addRow} + width="40" + > + + + {#if $stickyColumn} + + {/if} +
+ {/if}
@@ -195,7 +208,4 @@ .number.visible { display: flex; } - .row:hover .number { - display: none; - }