import type { Meta, StoryObj } from 'storybook-solidjs-vite';
import { fn } from 'storybook/test';
import { createSignal, For } from 'solid-js';
import { FileUpload, FileUploadTrigger, FileUploadContent } from './file-upload';
import { Upload } from 'lucide-solid';
import { componentDescription } from '../stories/docs/element-controls';
const meta = {
title: 'Solid (Advanced)/Elements/FileUpload',
component: FileUpload,
tags: ['autodocs'],
parameters: {
layout: 'padded',
docs: {
controls: { exclude: ['use:eventListener'] },
description: componentDescription([
'A headless file-upload root that handles window-wide drag-and-drop plus a hidden file input, composed with `FileUploadTrigger` (opens the picker) and `FileUploadContent` (full-screen drop overlay).',
'**When to use:** to let users attach files to a chat — via a button click or by dragging files anywhere onto the page.',
'**How to use:** wrap a `FileUploadTrigger` and optional `FileUploadContent` in `FileUpload`, and read selected files from `onFilesAdded`. Set `multiple`, `accept`, or `disabled` as needed.',
'**Placement:** in the prompt input area or composer toolbar where attachments are added.',
]),
},
},
argTypes: {
multiple: {
control: 'boolean',
description: 'Allow selecting / dropping more than one file.',
table: { defaultValue: { summary: 'true' } },
},
accept: {
control: 'text',
description: 'Accepted file types, forwarded to the file input (e.g. `image/*`).',
},
disabled: {
control: 'boolean',
description: 'Disables the file input and suppresses the drop overlay.',
},
onFilesAdded: {
action: 'filesAdded',
description: 'Fired with the selected/dropped `File[]` (capped to one when `multiple` is false).',
table: { category: 'Events' },
},
children: {
control: false,
description: 'Trigger and overlay composition (`FileUploadTrigger`, `FileUploadContent`).',
},
},
args: {
multiple: true,
onFilesAdded: fn(),
},
render: (args) => (
Upload files