Use slots to render lightning bolt icons in the correct position regardless of labels

This commit is contained in:
Andrew Kingston 2025-03-26 09:48:44 +00:00
parent 99abeb4104
commit dfdb23f2a7
No known key found for this signature in database
5 changed files with 30 additions and 17 deletions

View File

@ -75,6 +75,7 @@
class:is-disabled={disabled} class:is-disabled={disabled}
class:is-focused={isFocused} class:is-focused={isFocused}
> >
<!-- We need to ignore prettier here as we want no whitespace -->
<!-- prettier-ignore --> <!-- prettier-ignore -->
<textarea <textarea
bind:this={textarea} bind:this={textarea}
@ -90,6 +91,7 @@
on:blur on:blur
on:keypress on:keypress
>{value || ""}</textarea> >{value || ""}</textarea>
<slot />
</div> </div>
<style> <style>

View File

@ -114,6 +114,7 @@
inputmode={getInputMode(type)} inputmode={getInputMode(type)}
autocomplete={autocompleteValue} autocomplete={autocompleteValue}
/> />
<slot />
</div> </div>
<style> <style>

View File

@ -41,5 +41,7 @@
on:blur on:blur
on:focus on:focus
on:keyup on:keyup
/> >
<slot />
</TextField>
</Field> </Field>

View File

@ -7,11 +7,13 @@
export let label: string | undefined = undefined export let label: string | undefined = undefined
export let labelPosition = "above" export let labelPosition = "above"
export let placeholder: string | undefined = undefined export let placeholder: string | undefined = undefined
export let disabled = false export let readonly: boolean = false
export let disabled: boolean = false
export let error: string | undefined = undefined export let error: string | undefined = undefined
export let height: number | undefined = undefined export let height: number | undefined = undefined
export let minHeight: number | undefined = undefined export let minHeight: number | undefined = undefined
export let helpText: string | undefined = undefined export let helpText: string | undefined = undefined
export let updateOnChange: boolean = false
let textarea: TextArea let textarea: TextArea
export function focus() { export function focus() {
@ -33,11 +35,16 @@
<TextArea <TextArea
bind:this={textarea} bind:this={textarea}
{disabled} {disabled}
{readonly}
{value} {value}
{placeholder} {placeholder}
{height} {height}
{minHeight} {minHeight}
{updateOnChange}
on:change={onChange} on:change={onChange}
on:keypress on:keypress
/> on:scrollable
>
<slot />
</TextArea>
</Field> </Field>

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import { Icon, Input, Drawer, Button, CoreTextArea } from "@budibase/bbui" import { Icon, Input, Drawer, Button, TextArea } from "@budibase/bbui"
import { import {
readableToRuntimeBinding, readableToRuntimeBinding,
runtimeToReadableBinding, runtimeToReadableBinding,
@ -67,7 +67,7 @@
<!-- svelte-ignore a11y-no-static-element-interactions --> <!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="control" class:multiline class:disabled class:scrollable> <div class="control" class:multiline class:disabled class:scrollable>
<svelte:component <svelte:component
this={multiline ? CoreTextArea : Input} this={multiline ? TextArea : Input}
{label} {label}
{disabled} {disabled}
readonly={isJS} readonly={isJS}
@ -78,18 +78,19 @@
{placeholder} {placeholder}
{updateOnChange} {updateOnChange}
{autocomplete} {autocomplete}
/> >
{#if !disabled && !disableBindings} {#if !disabled && !disableBindings}
<div <div
class="icon" class="icon"
on:click={() => { on:click={() => {
builderStore.propertyFocus(key) builderStore.propertyFocus(key)
bindingDrawer.show() bindingDrawer.show()
}} }}
> >
<Icon size="S" name="FlashOn" /> <Icon size="S" name="FlashOn" />
</div> </div>
{/if} {/if}
</svelte:component>
</div> </div>
<Drawer <Drawer
on:drawerHide={onDrawerHide} on:drawerHide={onDrawerHide}