diff --git a/packages/bbui/src/Table/Table.svelte b/packages/bbui/src/Table/Table.svelte index 1b1d5df037..94e2f7cc39 100644 --- a/packages/bbui/src/Table/Table.svelte +++ b/packages/bbui/src/Table/Table.svelte @@ -4,6 +4,7 @@ import CellRenderer from "./CellRenderer.svelte" import SelectEditRenderer from "./SelectEditRenderer.svelte" import { cloneDeep, deepGet } from "../helpers" + import ProgressCircle from "../ProgressCircle/ProgressCircle.svelte" /** * The expected schema is our normal couch schemas for our tables. @@ -14,6 +15,7 @@ * sortable: Set to false to disable sorting data by a certain column * editable: Set to false to disable editing a certain column if the * allowEditColumns prop is true + * width: the width of the column */ export let data = [] export let schema = {} @@ -31,14 +33,11 @@ export let autoSortColumns = true export let compact = false - rowCount = 5 - const dispatch = createEventDispatcher() // Config $: rowHeight = compact ? 46 : 55 const headerHeight = 36 - const rowPreload = 5 // Sorting state let sortColumn @@ -57,26 +56,6 @@ $: gridStyle = getGridStyle(fields, schema, showEditColumn) $: showEditColumn = allowEditRows || allowSelectRows - // Scrolling state - let timeout - let nextScrollTop = 0 - let scrollTop = 0 - $: firstVisibleRow = calculateFirstVisibleRow(scrollTop) - $: lastVisibleRow = calculateLastVisibleRow( - firstVisibleRow, - visibleRowCount, - rows.length - ) - - // Reset state when data changes - $: rows.length, reset() - const reset = () => { - nextScrollTop = 0 - scrollTop = 0 - clearTimeout(timeout) - timeout = null - } - const fixSchema = schema => { let fixedSchema = {} Object.entries(schema || {}).forEach(([fieldName, fieldSchema]) => { @@ -193,28 +172,6 @@ .map(column => column.name) } - const onScroll = event => { - nextScrollTop = event.target.scrollTop - if (timeout) { - return - } - timeout = setTimeout(() => { - scrollTop = nextScrollTop - timeout = null - }, 50) - } - - const calculateFirstVisibleRow = scrollTop => { - return Math.max(Math.floor(scrollTop / (rowHeight + 1)) - rowPreload, 0) - } - - const calculateLastVisibleRow = (firstRow, visibleRowCount, allRowCount) => { - if (visibleRowCount === 0) { - return -1 - } - return Math.min(firstRow + visibleRowCount + 2 * rowPreload, allRowCount) - } - const editColumn = (e, field) => { e.stopPropagation() dispatch("editcolumn", field) @@ -245,16 +202,16 @@ style={`--row-height: ${rowHeight}px; --header-height: ${headerHeight}px;`} > {#if !loaded} -
+