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

View File

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