mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 19:01:05 +00:00
- Inline class assignments to avoid script-level clutter - Ignore a11y-missing-attribute instead of redundant href
49 lines
1.3 KiB
Svelte
49 lines
1.3 KiB
Svelte
<script>
|
|
let className = undefined;
|
|
export { className as class };
|
|
export let id = Math.random();
|
|
export let status = 'uploading';
|
|
export let iconDescription = '';
|
|
export let name = '';
|
|
export let invalid = false;
|
|
export let errorSubject = '';
|
|
export let errorBody = '';
|
|
export let style = undefined;
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
import { cx } from '../../lib';
|
|
import Filename from './Filename.svelte';
|
|
|
|
const dispatch = createEventDispatcher();
|
|
</script>
|
|
|
|
<span
|
|
on:mouseover
|
|
on:mouseenter
|
|
on:mouseleave
|
|
class={cx('--file__selected-file', invalid && '--file__selected-file--invalid', className)}
|
|
{style}>
|
|
<p class={cx('--file-filename')}>{name}</p>
|
|
<span class={cx('--file__state-container')}>
|
|
<Filename
|
|
{iconDescription}
|
|
{status}
|
|
{invalid}
|
|
on:keydown={({ key }) => {
|
|
if (key === ' ' || key === 'Enter') {
|
|
dispatch('delete', id);
|
|
}
|
|
}}
|
|
on:click={() => {
|
|
dispatch('delete', id);
|
|
}} />
|
|
</span>
|
|
{#if invalid && errorSubject}
|
|
<div class={cx('--form-requirement')}>
|
|
<div class={cx('--form-requirement__title')}>{errorSubject}</div>
|
|
{#if errorBody}
|
|
<p class={cx('--form-requirement__supplement')}>{errorBody}</p>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
</span>
|