feat(frontend): Add submitted text prop (#2864)

* feat(frontend): add a prop to control the text after a file is uploaded

* feat(frontend): add a prop to control the text after a file is uploaded
This commit is contained in:
Faton Ramadani
2023-12-15 17:36:42 +01:00
committed by GitHub
parent fa04c98874
commit 608af741ea
4 changed files with 15 additions and 2 deletions
@@ -20,6 +20,7 @@
let allowMultiple: boolean | undefined = undefined
let text: string | undefined = undefined
let includeMimeType: boolean | undefined = undefined
let submittedFileText: string | undefined = undefined
let outputs = initOutput($worldStore, id, {
result: [] as { name: string; data: string }[] | undefined
@@ -58,6 +59,12 @@
<InputValue key="multiple" {id} input={configuration.allowMultiple} bind:value={allowMultiple} />
<InputValue key="text" {id} input={configuration.text} bind:value={text} />
<InputValue key="mime" {id} input={configuration.includeMimeType} bind:value={includeMimeType} />
<InputValue
key="submittedFileText"
{id}
input={configuration.submittedFileText}
bind:value={submittedFileText}
/>
<InitializeComponent {id} />
@@ -73,6 +80,7 @@
}}
class={twMerge('w-full h-full', css?.container?.class, 'wm-file-input')}
style={css?.container?.style}
submittedText={submittedFileText}
>
{text}
</FileInput>
@@ -170,7 +170,6 @@
{#if nodes[0].id !== currentNodeId}
<Button on:click={prev} size="xs2" color="light" startIcon={{ icon: ArrowLeft }}>Prev</Button>
{/if}
<span class="text-xs text-primary">Tab: {currentNodeId}</span>
<Button
on:click={next}
size="xs2"
@@ -2357,6 +2357,11 @@ This is a paragraph.
value: false,
fieldType: 'boolean',
tooltip: 'If enabled, the mime type of the file will be included.'
},
submittedFileText: {
type: 'static',
value: 'Selected file',
fieldType: 'text'
}
}
}
@@ -16,6 +16,7 @@
export let hideIcon = false
export let iconSize = 36
export let returnFileNames = false
export let submittedText: string | undefined = undefined
const dispatch = createEventDispatcher()
let input: HTMLInputElement
let files: File[] | undefined = undefined
@@ -124,7 +125,7 @@
<div class="w-full max-h-full overflow-auto px-6">
<slot name="selected-title">
<div class="text-center mb-2 px-2">
Selected file{files.length > 1 ? 's' : ''}:
{submittedText ? submittedText : `Selected file${files.length > 1 ? 's' : ''}`}:
</div>
</slot>
<ul class="relative z-20 max-w-[500px] bg-surface rounded-lg overflow-hidden mx-auto">