FileUpload
عرض شاملimport { FileFormatIcon, FileUploadArea, FileUploadCard, ImageUpload, ImageUploadShape } from '@nili/ui';هذه صفحة العرض الشامل الخاصة بالمكتبة، معروضة حيّة. غيّر اللغة أو السمة من الأعلى وسَتتبعك.
منطقة الرفع
هدف الإفلات. يتلقّى onFiles مصفوفة File سواء أُفلتت الملفات أو اختيرت من الحوار، فيبقى مسار كود واحد. وتحته حقل input حقيقي، فيحصل مستخدمو لوحة المفاتيح وقارئات الشاشة على المنتقي أيضًا.
import { FileUploadArea } from "@nili/ui"
export function Example() {
return (
<FileUploadArea
multiple
accept="image/*,application/pdf"
label="Upload files"
title="Choose a file or drag it here"
description="PNG, JPG or PDF, up to 10 MB."
onFiles={(files) => upload(files)}
/>
)
}حالات منطقة الرفع
invalid لملف مرفوض — نوع خاطئ أو حجم كبير — وdisabled حين تنفد الحصة أو يكون النموذج قيد الإرسال.
import { FileUploadArea } from "@nili/ui"
export function Example() {
return (
<>
<FileUploadArea label="Upload" onFiles={onFiles} />
<FileUploadArea label="Upload" invalid onFiles={onFiles} />
<FileUploadArea label="Upload" disabled onFiles={onFiles} />
</>
)
}بطاقة الملف
ملف مرفوع واحد: أيقونة صيغته واسمه وحجمه وحالته. ويحرّك progress الشريط، ويظهر onRetry مع الخطأ وonRemove مع أي حالة. وكلاهما يحتاج تسمية، فالأزرار أيقونات.
import { FileUploadCard } from "@nili/ui"
export function Example() {
return (
<>
<FileUploadCard
fileName="annual-report.pdf"
fileSize="2.4 MB"
status="progress"
progress={62}
onRemove={cancel}
removeLabel="Cancel upload"
/>
<FileUploadCard
fileName="photo.png"
fileSize="840 KB"
status="success"
onRemove={remove}
removeLabel="Remove file"
/>
<FileUploadCard
fileName="archive.zip"
fileSize="18 MB"
status="error"
errorMessage="File is larger than 10 MB."
onRetry={retry}
retryLabel="Try again"
onRemove={remove}
removeLabel="Remove file"
/>
</>
)
}أيقونة صيغة الملف
يُشتق الرمز من اسم الملف، فتلوّن قائمة الرفع المختلطة نفسها. وتجاوزه بـcolor حين لا يكون الامتداد هو ما تريد الإشارة إليه.
import { FileFormatIcon } from "@nili/ui"
export function Example() {
return (
<>
<FileFormatIcon fileName="report.pdf" />
<FileFormatIcon fileName="sheet.xlsx" />
<FileFormatIcon fileName="photo.png" size="xs" />
<FileFormatIcon fileName="anything.bin" color="purple" />
</>
)
}رفع الصور
النسخة التي تقدّم المعاينة، لصورة رمزية أو شعار شركة أو غلاف. يضبط shape الإطار والاقتصاص الذي توحي به المعاينة، ويضع alignment عناصر التحكّم تحت الصورة أو بجانبها.
import { ImageUpload, Button } from "@nili/ui"
export function Example() {
return (
<>
<ImageUpload
shape="avatar"
label="Profile photo"
hint="JPG or PNG, at least 256×256."
onFiles={(files) => upload(files[0])}
actions={<Button size="xs" appearance="stroke">Choose file</Button>}
/>
<ImageUpload shape="16:9" alignment="horizontal" label="Cover" onFiles={onFiles} />
</>
)
}FileCard
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| status | progress | success | error | progress |
FileFormatIcon
extends Omit< ComponentPropsWithoutRef<'span'>, 'color' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| color | red | orange | yellow | green | teal | sky | blue | purple | pink | gray | gray | |
| size | md | xs | md |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| fileName* | string | — |
FileProgress
داخليFileProgressBar
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| status | progress | success | error | progress |
FileUploadArea
extends Omit< ComponentPropsWithoutRef<'label'>, 'onDrop' | 'onChange' | 'title' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| disabled | boolean | false | |
| invalid | boolean | false | |
| dragging | 'true' | 'false' | false |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| onFiles* | (files: File[]) => void | — | |
| accept | string | — | |
| multiple | boolean | false | |
| title | ReactNode | Choose a file or drag it here | |
| description | ReactNode | — | |
| icon | ReactNode | — | |
| label | string | Upload file | Accessible name for the hidden file input. |
FileUploadCard
extends Omit< ComponentPropsWithoutRef<'div'>, 'children' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| fileName* | string | — | |
| fileSize | string | — | Pre-formatted — size formatting is a locale decision. |
| status | error | success | progress | progress | |
| progress | number | 0 | 0–100. Ignored unless `status` is `'progress'`. |
| errorMessage | ReactNode | — | |
| onRemove | () => void | — | |
| onRetry | () => void | — | |
| removeLabel | string | Remove | |
| retryLabel | string | Retry |
ImageUpload
extends Omit< ComponentPropsWithoutRef<'div'>, 'onChange' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| shape | avatar | company | square | 4:3 | 16:9 | square |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| alignment | vertical | horizontal | vertical | |
| src | string | — | Preview URL. Absent means the Figma "Empty" state. |
| onFiles* | (files: File[]) => void | — | |
| accept | string | image/* | |
| label | string | Upload image | |
| hint | ReactNode | — | |
| actions | ReactNode | — | |
| alt | string |
ImageUploadRoot
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| alignment | vertical | horizontal | vertical |