Update long form cells to use popovers

This commit is contained in:
Andrew Kingston 2024-04-24 20:39:16 +01:00
parent 23bd635a8b
commit 957facb99c
2 changed files with 32 additions and 34 deletions

View File

@ -1,6 +1,7 @@
<script>
import { onMount, tick } from "svelte"
import { clickOutside } from "@budibase/bbui"
import GridPopover from "../overlays/GridPopover.svelte"
export let value
export let focused = false
@ -8,10 +9,10 @@
export let readonly = false
export let api
export let invertX = false
export let invertY = false
let textarea
let isOpen = false
let anchor
$: editable = focused && !readonly
$: {
@ -52,10 +53,22 @@
})
</script>
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="long-form-cell"
on:click={editable ? open : null}
class:editable
bind:this={anchor}
>
<div class="value">
{value || ""}
</div>
</div>
{#if isOpen}
<GridPopover {anchor} {invertX} on:close={close}>
<textarea
class:invertX
class:invertY
bind:this={textarea}
value={value || ""}
on:change={handleChange}
@ -63,14 +76,7 @@
spellcheck="false"
use:clickOutside={close}
/>
{:else}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="long-form-cell" on:click={editable ? open : null} class:editable>
<div class="value">
{value || ""}
</div>
</div>
</GridPopover>
{/if}
<style>
@ -93,30 +99,20 @@
line-height: 20px;
}
textarea {
border: none;
width: 320px;
flex: 1 1 auto;
height: var(--max-cell-render-overflow);
padding: var(--cell-padding);
margin: 0;
border: 2px solid var(--cell-color);
background: var(--cell-background);
font-size: var(--cell-font-size);
font-family: var(--font-sans);
color: inherit;
position: absolute;
top: 0;
left: 0;
width: calc(100% + var(--max-cell-render-verflow));
height: calc(var(--row-height) + var(--max-cell-render-overflow));
z-index: 1;
border-radius: 2px;
resize: none;
line-height: 20px;
}
textarea.invertX {
left: auto;
right: 0;
}
textarea.invertY {
transform: translateY(-100%);
top: calc(100% + 1px);
overflow: auto;
}
textarea:focus {
outline: none;

View File

@ -61,5 +61,7 @@
.grid-popover-contents {
overflow-y: auto;
overflow-x: hidden;
display: flex;
flex-direction: column;
}
</style>