Fix grid block having incorrect toolbar position in builder preview

This commit is contained in:
Andrew Kingston 2024-05-17 11:24:51 +01:00
parent a705fbd497
commit 28e91959e5
1 changed files with 39 additions and 37 deletions

View File

@ -44,6 +44,7 @@
$: schemaOverrides = getSchemaOverrides(parsedColumns) $: schemaOverrides = getSchemaOverrides(parsedColumns)
$: enrichedButtons = enrichButtons(buttons) $: enrichedButtons = enrichButtons(buttons)
$: selectedRows = deriveSelectedRows(gridContext) $: selectedRows = deriveSelectedRows(gridContext)
$: styles = patchStyles($component.styles, minHeight)
$: data = { selectedRows: $selectedRows } $: data = { selectedRows: $selectedRows }
$: actions = [ $: actions = [
{ {
@ -128,52 +129,54 @@
) )
} }
const patchStyles = (styles, minHeight) => {
return {
...styles,
normal: {
...styles?.normal,
"min-height": `${minHeight}px`,
},
}
}
onMount(() => { onMount(() => {
gridContext = grid.getContext() gridContext = grid.getContext()
gridContext.minHeight.subscribe($height => (minHeight = $height)) gridContext.minHeight.subscribe($height => (minHeight = $height))
}) })
</script> </script>
<span style="--min-height:{minHeight}px"> <div use:styleable={styles} class:in-builder={$builderStore.inBuilder}>
<div <Grid
use:styleable={$component.styles} bind:this={grid}
class:in-builder={$builderStore.inBuilder} datasource={table}
> {API}
<Grid {stripeRows}
bind:this={grid} {quiet}
datasource={table} {initialFilter}
{API} {initialSortColumn}
{stripeRows} {initialSortOrder}
{quiet} {fixedRowHeight}
{initialFilter} {columnWhitelist}
{initialSortColumn} {schemaOverrides}
{initialSortOrder} canAddRows={allowAddRows}
{fixedRowHeight} canEditRows={allowEditRows}
{columnWhitelist} canDeleteRows={allowDeleteRows}
{schemaOverrides} canEditColumns={false}
canAddRows={allowAddRows} canExpandRows={false}
canEditRows={allowEditRows} canSaveSchema={false}
canDeleteRows={allowDeleteRows} canSelectRows={true}
canEditColumns={false} showControls={false}
canExpandRows={false} notifySuccess={notificationStore.actions.success}
canSaveSchema={false} notifyError={notificationStore.actions.error}
canSelectRows={true} buttons={enrichedButtons}
showControls={false} isCloud={$environmentStore.cloud}
notifySuccess={notificationStore.actions.success} on:rowclick={e => onRowClick?.({ row: e.detail })}
notifyError={notificationStore.actions.error} />
buttons={enrichedButtons} </div>
isCloud={$environmentStore.cloud}
on:rowclick={e => onRowClick?.({ row: e.detail })}
/>
</div>
</span>
<Provider {data} {actions} /> <Provider {data} {actions} />
<style> <style>
span {
display: contents;
}
div { div {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -182,7 +185,6 @@
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
height: 410px; height: 410px;
min-height: var(--min-height);
} }
div.in-builder :global(*) { div.in-builder :global(*) {
pointer-events: none; pointer-events: none;