mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
feat(file-uploader): export clearFiles method
This commit is contained in:
parent
8ea50a807a
commit
0fe8975850
2 changed files with 7 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
|||
let className = undefined;
|
||||
export { className as class };
|
||||
export let files = [];
|
||||
export const clearFiles = () => (files = []);
|
||||
export let name = '';
|
||||
export let labelDescription = '';
|
||||
export let labelTitle = '';
|
||||
|
@ -13,7 +14,7 @@
|
|||
export let accept = [];
|
||||
export let style = undefined;
|
||||
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { createEventDispatcher, afterUpdate } from 'svelte';
|
||||
import { cx } from '../../lib';
|
||||
import Filename from './Filename.svelte';
|
||||
import FileUploaderButton from './FileUploaderButton.svelte';
|
||||
|
@ -22,7 +23,7 @@
|
|||
|
||||
let prevFiles = [];
|
||||
|
||||
$: {
|
||||
afterUpdate(() => {
|
||||
if (files.length > prevFiles.length) {
|
||||
dispatch('add', files);
|
||||
} else {
|
||||
|
@ -33,7 +34,7 @@
|
|||
}
|
||||
|
||||
prevFiles = [...files];
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div on:click on:mouseover on:mouseenter on:mouseleave class={cx('--form-item', className)} {style}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue