svelora 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +145 -0
- package/dist/Accordion/Accordion.svelte +207 -0
- package/dist/Accordion/Accordion.svelte.d.ts +6 -0
- package/dist/Accordion/accordion.types.d.ts +225 -0
- package/dist/Accordion/accordion.types.js +1 -0
- package/dist/Accordion/accordion.variants.d.ts +88 -0
- package/dist/Accordion/accordion.variants.js +28 -0
- package/dist/Accordion/index.d.ts +2 -0
- package/dist/Accordion/index.js +1 -0
- package/dist/Alert/Alert.svelte +131 -0
- package/dist/Alert/Alert.svelte.d.ts +5 -0
- package/dist/Alert/alert.types.d.ts +103 -0
- package/dist/Alert/alert.types.js +1 -0
- package/dist/Alert/alert.variants.d.ts +213 -0
- package/dist/Alert/alert.variants.js +293 -0
- package/dist/Alert/index.d.ts +2 -0
- package/dist/Alert/index.js +1 -0
- package/dist/Avatar/Avatar.svelte +114 -0
- package/dist/Avatar/Avatar.svelte.d.ts +6 -0
- package/dist/Avatar/avatar.types.d.ts +73 -0
- package/dist/Avatar/avatar.types.js +1 -0
- package/dist/Avatar/avatar.variants.d.ts +316 -0
- package/dist/Avatar/avatar.variants.js +39 -0
- package/dist/Avatar/index.d.ts +2 -0
- package/dist/Avatar/index.js +1 -0
- package/dist/AvatarGroup/AvatarGroup.svelte +71 -0
- package/dist/AvatarGroup/AvatarGroup.svelte.d.ts +5 -0
- package/dist/AvatarGroup/avatar-group.types.d.ts +49 -0
- package/dist/AvatarGroup/avatar-group.types.js +1 -0
- package/dist/AvatarGroup/avatar-group.variants.d.ts +258 -0
- package/dist/AvatarGroup/avatar-group.variants.js +35 -0
- package/dist/AvatarGroup/index.d.ts +2 -0
- package/dist/AvatarGroup/index.js +1 -0
- package/dist/Badge/Badge.svelte +79 -0
- package/dist/Badge/Badge.svelte.d.ts +5 -0
- package/dist/Badge/badge.types.d.ts +83 -0
- package/dist/Badge/badge.types.js +1 -0
- package/dist/Badge/badge.variants.d.ts +303 -0
- package/dist/Badge/badge.variants.js +259 -0
- package/dist/Badge/index.d.ts +2 -0
- package/dist/Badge/index.js +1 -0
- package/dist/Banner/Banner.svelte +130 -0
- package/dist/Banner/Banner.svelte.d.ts +5 -0
- package/dist/Banner/banner.types.d.ts +148 -0
- package/dist/Banner/banner.types.js +1 -0
- package/dist/Banner/banner.variants.d.ts +293 -0
- package/dist/Banner/banner.variants.js +86 -0
- package/dist/Banner/index.d.ts +2 -0
- package/dist/Banner/index.js +1 -0
- package/dist/Breadcrumb/Breadcrumb.svelte +79 -0
- package/dist/Breadcrumb/Breadcrumb.svelte.d.ts +5 -0
- package/dist/Breadcrumb/breadcrumb.types.d.ts +66 -0
- package/dist/Breadcrumb/breadcrumb.types.js +1 -0
- package/dist/Breadcrumb/breadcrumb.variants.d.ts +138 -0
- package/dist/Breadcrumb/breadcrumb.variants.js +53 -0
- package/dist/Breadcrumb/index.d.ts +2 -0
- package/dist/Breadcrumb/index.js +1 -0
- package/dist/Button/Button.svelte +177 -0
- package/dist/Button/Button.svelte.d.ts +5 -0
- package/dist/Button/button.types.d.ts +151 -0
- package/dist/Button/button.types.js +1 -0
- package/dist/Button/button.variants.d.ts +388 -0
- package/dist/Button/button.variants.js +461 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/Button/index.js +1 -0
- package/dist/Calendar/Calendar.svelte +344 -0
- package/dist/Calendar/Calendar.svelte.d.ts +6 -0
- package/dist/Calendar/calendar.types.d.ts +122 -0
- package/dist/Calendar/calendar.types.js +1 -0
- package/dist/Calendar/calendar.variants.d.ts +553 -0
- package/dist/Calendar/calendar.variants.js +368 -0
- package/dist/Calendar/index.d.ts +2 -0
- package/dist/Calendar/index.js +1 -0
- package/dist/Card/Card.svelte +54 -0
- package/dist/Card/Card.svelte.d.ts +5 -0
- package/dist/Card/card.types.d.ts +36 -0
- package/dist/Card/card.types.js +1 -0
- package/dist/Card/card.variants.d.ts +108 -0
- package/dist/Card/card.variants.js +32 -0
- package/dist/Card/index.d.ts +2 -0
- package/dist/Card/index.js +1 -0
- package/dist/Carousel/Carousel.svelte +277 -0
- package/dist/Carousel/Carousel.svelte.d.ts +26 -0
- package/dist/Carousel/carousel.types.d.ts +251 -0
- package/dist/Carousel/carousel.types.js +1 -0
- package/dist/Carousel/carousel.variants.d.ts +408 -0
- package/dist/Carousel/carousel.variants.js +88 -0
- package/dist/Carousel/index.d.ts +2 -0
- package/dist/Carousel/index.js +1 -0
- package/dist/Checkbox/Checkbox.svelte +161 -0
- package/dist/Checkbox/Checkbox.svelte.d.ts +6 -0
- package/dist/Checkbox/checkbox.types.d.ts +101 -0
- package/dist/Checkbox/checkbox.types.js +1 -0
- package/dist/Checkbox/checkbox.variants.d.ts +448 -0
- package/dist/Checkbox/checkbox.variants.js +209 -0
- package/dist/Checkbox/index.d.ts +2 -0
- package/dist/Checkbox/index.js +1 -0
- package/dist/CheckboxGroup/CheckboxGroup.svelte +219 -0
- package/dist/CheckboxGroup/CheckboxGroup.svelte.d.ts +5 -0
- package/dist/CheckboxGroup/checkbox-group.types.d.ts +130 -0
- package/dist/CheckboxGroup/checkbox-group.types.js +1 -0
- package/dist/CheckboxGroup/checkbox-group.variants.d.ts +553 -0
- package/dist/CheckboxGroup/checkbox-group.variants.js +231 -0
- package/dist/CheckboxGroup/index.d.ts +2 -0
- package/dist/CheckboxGroup/index.js +1 -0
- package/dist/Chip/Chip.svelte +51 -0
- package/dist/Chip/Chip.svelte.d.ts +5 -0
- package/dist/Chip/chip.types.d.ts +66 -0
- package/dist/Chip/chip.types.js +1 -0
- package/dist/Chip/chip.variants.d.ts +418 -0
- package/dist/Chip/chip.variants.js +74 -0
- package/dist/Chip/index.d.ts +2 -0
- package/dist/Chip/index.js +1 -0
- package/dist/Collapsible/Collapsible.svelte +69 -0
- package/dist/Collapsible/Collapsible.svelte.d.ts +6 -0
- package/dist/Collapsible/CollapsibleTestWrapper.svelte +17 -0
- package/dist/Collapsible/CollapsibleTestWrapper.svelte.d.ts +4 -0
- package/dist/Collapsible/collapsible.types.d.ts +77 -0
- package/dist/Collapsible/collapsible.types.js +1 -0
- package/dist/Collapsible/collapsible.variants.d.ts +53 -0
- package/dist/Collapsible/collapsible.variants.js +21 -0
- package/dist/Collapsible/index.d.ts +2 -0
- package/dist/Collapsible/index.js +1 -0
- package/dist/Command/Command.svelte +183 -0
- package/dist/Command/Command.svelte.d.ts +6 -0
- package/dist/Command/CommandTestWrapper.svelte +13 -0
- package/dist/Command/CommandTestWrapper.svelte.d.ts +4 -0
- package/dist/Command/command.types.d.ts +100 -0
- package/dist/Command/command.types.js +1 -0
- package/dist/Command/command.variants.d.ts +226 -0
- package/dist/Command/command.variants.js +86 -0
- package/dist/Command/index.d.ts +2 -0
- package/dist/Command/index.js +1 -0
- package/dist/Container/Container.svelte +21 -0
- package/dist/Container/Container.svelte.d.ts +5 -0
- package/dist/Container/container.types.d.ts +19 -0
- package/dist/Container/container.types.js +1 -0
- package/dist/Container/container.variants.d.ts +29 -0
- package/dist/Container/container.variants.js +9 -0
- package/dist/Container/index.d.ts +2 -0
- package/dist/Container/index.js +1 -0
- package/dist/ContextMenu/ContextMenu.svelte +344 -0
- package/dist/ContextMenu/ContextMenu.svelte.d.ts +6 -0
- package/dist/ContextMenu/context-menu.types.d.ts +265 -0
- package/dist/ContextMenu/context-menu.types.js +1 -0
- package/dist/ContextMenu/context-menu.variants.d.ts +307 -0
- package/dist/ContextMenu/context-menu.variants.js +144 -0
- package/dist/ContextMenu/index.d.ts +2 -0
- package/dist/ContextMenu/index.js +1 -0
- package/dist/Drawer/Drawer.svelte +207 -0
- package/dist/Drawer/Drawer.svelte.d.ts +6 -0
- package/dist/Drawer/DrawerTriggerTestWrapper.svelte +10 -0
- package/dist/Drawer/DrawerTriggerTestWrapper.svelte.d.ts +18 -0
- package/dist/Drawer/drawer.types.d.ts +116 -0
- package/dist/Drawer/drawer.types.js +1 -0
- package/dist/Drawer/drawer.variants.d.ts +193 -0
- package/dist/Drawer/drawer.variants.js +139 -0
- package/dist/Drawer/index.d.ts +2 -0
- package/dist/Drawer/index.js +1 -0
- package/dist/DropdownMenu/DropdownMenu.svelte +363 -0
- package/dist/DropdownMenu/DropdownMenu.svelte.d.ts +6 -0
- package/dist/DropdownMenu/DropdownMenuTriggerTestWrapper.svelte +12 -0
- package/dist/DropdownMenu/DropdownMenuTriggerTestWrapper.svelte.d.ts +7 -0
- package/dist/DropdownMenu/dropdown-menu.types.d.ts +279 -0
- package/dist/DropdownMenu/dropdown-menu.types.js +1 -0
- package/dist/DropdownMenu/dropdown-menu.variants.d.ts +312 -0
- package/dist/DropdownMenu/dropdown-menu.variants.js +149 -0
- package/dist/DropdownMenu/index.d.ts +2 -0
- package/dist/DropdownMenu/index.js +1 -0
- package/dist/Editor/Editor.svelte +756 -0
- package/dist/Editor/Editor.svelte.d.ts +6 -0
- package/dist/Editor/EditorUrlPrompt.svelte +94 -0
- package/dist/Editor/EditorUrlPrompt.svelte.d.ts +15 -0
- package/dist/Editor/SlashPopup.svelte +74 -0
- package/dist/Editor/SlashPopup.svelte.d.ts +11 -0
- package/dist/Editor/editor.extensions.d.ts +23 -0
- package/dist/Editor/editor.extensions.js +132 -0
- package/dist/Editor/editor.schemas.d.ts +5 -0
- package/dist/Editor/editor.schemas.js +27 -0
- package/dist/Editor/editor.slash.svelte.d.ts +25 -0
- package/dist/Editor/editor.slash.svelte.js +299 -0
- package/dist/Editor/editor.suggestion.d.ts +7 -0
- package/dist/Editor/editor.suggestion.js +165 -0
- package/dist/Editor/editor.toolbar.d.ts +11 -0
- package/dist/Editor/editor.toolbar.js +204 -0
- package/dist/Editor/editor.types.d.ts +367 -0
- package/dist/Editor/editor.types.js +1 -0
- package/dist/Editor/editor.variants.d.ts +303 -0
- package/dist/Editor/editor.variants.js +135 -0
- package/dist/Editor/index.d.ts +55 -0
- package/dist/Editor/index.js +54 -0
- package/dist/Empty/Empty.svelte +118 -0
- package/dist/Empty/Empty.svelte.d.ts +5 -0
- package/dist/Empty/empty.types.d.ts +91 -0
- package/dist/Empty/empty.types.js +1 -0
- package/dist/Empty/empty.variants.d.ts +308 -0
- package/dist/Empty/empty.variants.js +73 -0
- package/dist/Empty/index.d.ts +2 -0
- package/dist/Empty/index.js +1 -0
- package/dist/FieldGroup/FieldGroup.svelte +53 -0
- package/dist/FieldGroup/FieldGroup.svelte.d.ts +5 -0
- package/dist/FieldGroup/field-group.types.d.ts +37 -0
- package/dist/FieldGroup/field-group.types.js +1 -0
- package/dist/FieldGroup/field-group.variants.d.ts +116 -0
- package/dist/FieldGroup/field-group.variants.js +49 -0
- package/dist/FieldGroup/index.d.ts +2 -0
- package/dist/FieldGroup/index.js +1 -0
- package/dist/FileUpload/FileUpload.svelte +639 -0
- package/dist/FileUpload/FileUpload.svelte.d.ts +8 -0
- package/dist/FileUpload/file-upload.types.d.ts +203 -0
- package/dist/FileUpload/file-upload.types.js +1 -0
- package/dist/FileUpload/file-upload.variants.d.ts +397 -0
- package/dist/FileUpload/file-upload.variants.js +224 -0
- package/dist/FileUpload/index.d.ts +2 -0
- package/dist/FileUpload/index.js +1 -0
- package/dist/Form/Form.svelte +197 -0
- package/dist/Form/Form.svelte.d.ts +26 -0
- package/dist/Form/form.context.svelte.d.ts +64 -0
- package/dist/Form/form.context.svelte.js +478 -0
- package/dist/Form/form.types.d.ts +164 -0
- package/dist/Form/form.types.js +12 -0
- package/dist/Form/form.variants.d.ts +39 -0
- package/dist/Form/form.variants.js +17 -0
- package/dist/Form/index.d.ts +4 -0
- package/dist/Form/index.js +6 -0
- package/dist/Form/validate-schema.d.ts +13 -0
- package/dist/Form/validate-schema.js +113 -0
- package/dist/FormField/FormField.svelte +186 -0
- package/dist/FormField/FormField.svelte.d.ts +5 -0
- package/dist/FormField/form-field.types.d.ts +109 -0
- package/dist/FormField/form-field.types.js +1 -0
- package/dist/FormField/form-field.variants.d.ts +313 -0
- package/dist/FormField/form-field.variants.js +74 -0
- package/dist/FormField/index.d.ts +2 -0
- package/dist/FormField/index.js +1 -0
- package/dist/Icon/Icon.svelte +46 -0
- package/dist/Icon/Icon.svelte.d.ts +6 -0
- package/dist/Icon/icon.types.d.ts +49 -0
- package/dist/Icon/icon.types.js +1 -0
- package/dist/Icon/index.d.ts +2 -0
- package/dist/Icon/index.js +1 -0
- package/dist/Input/Input.svelte +199 -0
- package/dist/Input/Input.svelte.d.ts +26 -0
- package/dist/Input/index.d.ts +2 -0
- package/dist/Input/index.js +1 -0
- package/dist/Input/input.types.d.ts +113 -0
- package/dist/Input/input.types.js +1 -0
- package/dist/Input/input.variants.d.ts +398 -0
- package/dist/Input/input.variants.js +387 -0
- package/dist/Kbd/Kbd.svelte +45 -0
- package/dist/Kbd/Kbd.svelte.d.ts +5 -0
- package/dist/Kbd/index.d.ts +3 -0
- package/dist/Kbd/index.js +2 -0
- package/dist/Kbd/kbd.types.d.ts +91 -0
- package/dist/Kbd/kbd.types.js +1 -0
- package/dist/Kbd/kbd.variants.d.ts +180 -0
- package/dist/Kbd/kbd.variants.js +168 -0
- package/dist/Kbd/useKbd.svelte.d.ts +29 -0
- package/dist/Kbd/useKbd.svelte.js +248 -0
- package/dist/Link/Link.svelte +168 -0
- package/dist/Link/Link.svelte.d.ts +5 -0
- package/dist/Link/index.d.ts +2 -0
- package/dist/Link/index.js +1 -0
- package/dist/Link/link.types.d.ts +86 -0
- package/dist/Link/link.types.js +1 -0
- package/dist/Link/link.variants.d.ts +113 -0
- package/dist/Link/link.variants.js +43 -0
- package/dist/Modal/Modal.svelte +218 -0
- package/dist/Modal/Modal.svelte.d.ts +5 -0
- package/dist/Modal/ModalTriggerTestWrapper.svelte +10 -0
- package/dist/Modal/ModalTriggerTestWrapper.svelte.d.ts +18 -0
- package/dist/Modal/index.d.ts +2 -0
- package/dist/Modal/index.js +1 -0
- package/dist/Modal/modal.types.d.ts +155 -0
- package/dist/Modal/modal.types.js +1 -0
- package/dist/Modal/modal.variants.d.ts +303 -0
- package/dist/Modal/modal.variants.js +90 -0
- package/dist/Pagination/Pagination.svelte +253 -0
- package/dist/Pagination/Pagination.svelte.d.ts +6 -0
- package/dist/Pagination/index.d.ts +2 -0
- package/dist/Pagination/index.js +1 -0
- package/dist/Pagination/pagination.types.d.ts +191 -0
- package/dist/Pagination/pagination.types.js +1 -0
- package/dist/Pagination/pagination.variants.d.ts +160 -0
- package/dist/Pagination/pagination.variants.js +125 -0
- package/dist/PinInput/PinInput.svelte +162 -0
- package/dist/PinInput/PinInput.svelte.d.ts +6 -0
- package/dist/PinInput/index.d.ts +2 -0
- package/dist/PinInput/index.js +1 -0
- package/dist/PinInput/pin-input.types.d.ts +110 -0
- package/dist/PinInput/pin-input.types.js +1 -0
- package/dist/PinInput/pin-input.variants.d.ts +303 -0
- package/dist/PinInput/pin-input.variants.js +196 -0
- package/dist/Popover/Popover.svelte +122 -0
- package/dist/Popover/Popover.svelte.d.ts +6 -0
- package/dist/Popover/index.d.ts +2 -0
- package/dist/Popover/index.js +1 -0
- package/dist/Popover/popover.types.d.ts +58 -0
- package/dist/Popover/popover.types.js +1 -0
- package/dist/Popover/popover.variants.d.ts +53 -0
- package/dist/Popover/popover.variants.js +31 -0
- package/dist/Progress/Progress.svelte +135 -0
- package/dist/Progress/Progress.svelte.d.ts +6 -0
- package/dist/Progress/index.d.ts +2 -0
- package/dist/Progress/index.js +1 -0
- package/dist/Progress/progress.types.d.ts +71 -0
- package/dist/Progress/progress.types.js +1 -0
- package/dist/Progress/progress.variants.d.ts +513 -0
- package/dist/Progress/progress.variants.js +204 -0
- package/dist/RadioGroup/RadioGroup.svelte +226 -0
- package/dist/RadioGroup/RadioGroup.svelte.d.ts +6 -0
- package/dist/RadioGroup/index.d.ts +2 -0
- package/dist/RadioGroup/index.js +1 -0
- package/dist/RadioGroup/radio-group.types.d.ts +111 -0
- package/dist/RadioGroup/radio-group.types.js +1 -0
- package/dist/RadioGroup/radio-group.variants.d.ts +543 -0
- package/dist/RadioGroup/radio-group.variants.js +232 -0
- package/dist/Select/Select.svelte +461 -0
- package/dist/Select/Select.svelte.d.ts +6 -0
- package/dist/Select/index.d.ts +2 -0
- package/dist/Select/index.js +1 -0
- package/dist/Select/select.types.d.ts +263 -0
- package/dist/Select/select.types.js +1 -0
- package/dist/Select/select.variants.d.ts +713 -0
- package/dist/Select/select.variants.js +482 -0
- package/dist/SelectMenu/SelectMenu.svelte +637 -0
- package/dist/SelectMenu/SelectMenu.svelte.d.ts +5 -0
- package/dist/SelectMenu/SelectMenuFormFieldTestWrapper.svelte +11 -0
- package/dist/SelectMenu/SelectMenuFormFieldTestWrapper.svelte.d.ts +7 -0
- package/dist/SelectMenu/index.d.ts +2 -0
- package/dist/SelectMenu/index.js +1 -0
- package/dist/SelectMenu/select-menu.types.d.ts +326 -0
- package/dist/SelectMenu/select-menu.types.js +1 -0
- package/dist/SelectMenu/select-menu.variants.d.ts +795 -0
- package/dist/SelectMenu/select-menu.variants.js +70 -0
- package/dist/Separator/Separator.svelte +77 -0
- package/dist/Separator/Separator.svelte.d.ts +6 -0
- package/dist/Separator/index.d.ts +2 -0
- package/dist/Separator/index.js +1 -0
- package/dist/Separator/separator.types.d.ts +53 -0
- package/dist/Separator/separator.types.js +1 -0
- package/dist/Separator/separator.variants.d.ts +509 -0
- package/dist/Separator/separator.variants.js +110 -0
- package/dist/Skeleton/Skeleton.svelte +39 -0
- package/dist/Skeleton/Skeleton.svelte.d.ts +5 -0
- package/dist/Skeleton/index.d.ts +2 -0
- package/dist/Skeleton/index.js +1 -0
- package/dist/Skeleton/skeleton.types.d.ts +27 -0
- package/dist/Skeleton/skeleton.types.js +1 -0
- package/dist/Skeleton/skeleton.variants.d.ts +18 -0
- package/dist/Skeleton/skeleton.variants.js +12 -0
- package/dist/Slideover/Slideover.svelte +212 -0
- package/dist/Slideover/Slideover.svelte.d.ts +5 -0
- package/dist/Slideover/SlideoverTriggerTestWrapper.svelte +10 -0
- package/dist/Slideover/SlideoverTriggerTestWrapper.svelte.d.ts +18 -0
- package/dist/Slideover/index.d.ts +2 -0
- package/dist/Slideover/index.js +1 -0
- package/dist/Slideover/slideover.types.d.ts +154 -0
- package/dist/Slideover/slideover.types.js +1 -0
- package/dist/Slideover/slideover.variants.d.ts +298 -0
- package/dist/Slideover/slideover.variants.js +145 -0
- package/dist/Slider/Slider.svelte +129 -0
- package/dist/Slider/Slider.svelte.d.ts +6 -0
- package/dist/Slider/index.d.ts +2 -0
- package/dist/Slider/index.js +1 -0
- package/dist/Slider/slider.types.d.ts +55 -0
- package/dist/Slider/slider.types.js +1 -0
- package/dist/Slider/slider.variants.d.ts +383 -0
- package/dist/Slider/slider.variants.js +102 -0
- package/dist/Stepper/Stepper.svelte +254 -0
- package/dist/Stepper/Stepper.svelte.d.ts +5 -0
- package/dist/Stepper/index.d.ts +2 -0
- package/dist/Stepper/index.js +1 -0
- package/dist/Stepper/stepper.types.d.ts +223 -0
- package/dist/Stepper/stepper.types.js +1 -0
- package/dist/Stepper/stepper.variants.d.ts +428 -0
- package/dist/Stepper/stepper.variants.js +204 -0
- package/dist/Switch/Switch.svelte +150 -0
- package/dist/Switch/Switch.svelte.d.ts +6 -0
- package/dist/Switch/index.d.ts +2 -0
- package/dist/Switch/index.js +1 -0
- package/dist/Switch/switch.types.d.ts +80 -0
- package/dist/Switch/switch.types.js +1 -0
- package/dist/Switch/switch.variants.d.ts +433 -0
- package/dist/Switch/switch.variants.js +171 -0
- package/dist/Table/Table.svelte +667 -0
- package/dist/Table/Table.svelte.d.ts +26 -0
- package/dist/Table/index.d.ts +2 -0
- package/dist/Table/index.js +1 -0
- package/dist/Table/table.types.d.ts +202 -0
- package/dist/Table/table.types.js +1 -0
- package/dist/Table/table.utils.d.ts +54 -0
- package/dist/Table/table.utils.js +167 -0
- package/dist/Table/table.variants.d.ts +205 -0
- package/dist/Table/table.variants.js +126 -0
- package/dist/Tabs/Tabs.svelte +188 -0
- package/dist/Tabs/Tabs.svelte.d.ts +6 -0
- package/dist/Tabs/index.d.ts +2 -0
- package/dist/Tabs/index.js +1 -0
- package/dist/Tabs/tabs.types.d.ts +207 -0
- package/dist/Tabs/tabs.types.js +1 -0
- package/dist/Tabs/tabs.variants.d.ts +298 -0
- package/dist/Tabs/tabs.variants.js +251 -0
- package/dist/Textarea/Textarea.svelte +215 -0
- package/dist/Textarea/Textarea.svelte.d.ts +5 -0
- package/dist/Textarea/index.d.ts +2 -0
- package/dist/Textarea/index.js +1 -0
- package/dist/Textarea/textarea.types.d.ts +103 -0
- package/dist/Textarea/textarea.types.js +1 -0
- package/dist/Textarea/textarea.variants.d.ts +403 -0
- package/dist/Textarea/textarea.variants.js +404 -0
- package/dist/ThemeModeButton/ThemeModeButton.svelte +74 -0
- package/dist/ThemeModeButton/ThemeModeButton.svelte.d.ts +5 -0
- package/dist/ThemeModeButton/index.d.ts +2 -0
- package/dist/ThemeModeButton/index.js +1 -0
- package/dist/ThemeModeButton/theme-mode-button.types.d.ts +69 -0
- package/dist/ThemeModeButton/theme-mode-button.types.js +1 -0
- package/dist/ThemeModeButton/theme-mode-button.variants.d.ts +21 -0
- package/dist/ThemeModeButton/theme-mode-button.variants.js +17 -0
- package/dist/Timeline/Timeline.svelte +116 -0
- package/dist/Timeline/Timeline.svelte.d.ts +5 -0
- package/dist/Timeline/index.d.ts +2 -0
- package/dist/Timeline/index.js +1 -0
- package/dist/Timeline/timeline.types.d.ts +138 -0
- package/dist/Timeline/timeline.types.js +1 -0
- package/dist/Timeline/timeline.variants.d.ts +413 -0
- package/dist/Timeline/timeline.variants.js +201 -0
- package/dist/Toast/Toaster.svelte +619 -0
- package/dist/Toast/Toaster.svelte.d.ts +5 -0
- package/dist/Toast/index.d.ts +4 -0
- package/dist/Toast/index.js +2 -0
- package/dist/Toast/toast.d.ts +38 -0
- package/dist/Toast/toast.js +73 -0
- package/dist/Toast/toast.types.d.ts +19 -0
- package/dist/Toast/toast.types.js +1 -0
- package/dist/Toast/toast.variants.d.ts +7 -0
- package/dist/Toast/toast.variants.js +5 -0
- package/dist/Tooltip/Tooltip.svelte +151 -0
- package/dist/Tooltip/Tooltip.svelte.d.ts +6 -0
- package/dist/Tooltip/TooltipTestWrapper.svelte +8 -0
- package/dist/Tooltip/TooltipTestWrapper.svelte.d.ts +4 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/Tooltip/index.js +1 -0
- package/dist/Tooltip/tooltip.types.d.ts +62 -0
- package/dist/Tooltip/tooltip.types.js +1 -0
- package/dist/Tooltip/tooltip.variants.d.ts +68 -0
- package/dist/Tooltip/tooltip.variants.js +35 -0
- package/dist/User/User.svelte +98 -0
- package/dist/User/User.svelte.d.ts +5 -0
- package/dist/User/index.d.ts +2 -0
- package/dist/User/index.js +1 -0
- package/dist/User/user.types.d.ts +78 -0
- package/dist/User/user.types.js +1 -0
- package/dist/User/user.variants.d.ts +368 -0
- package/dist/User/user.variants.js +85 -0
- package/dist/config.d.ts +73 -0
- package/dist/config.js +108 -0
- package/dist/hooks/HookContextProbe.svelte +7 -0
- package/dist/hooks/HookContextProbe.svelte.d.ts +18 -0
- package/dist/hooks/HookContextProvider.svelte +9 -0
- package/dist/hooks/HookContextProvider.svelte.d.ts +18 -0
- package/dist/hooks/HookEmitProbe.svelte +14 -0
- package/dist/hooks/HookEmitProbe.svelte.d.ts +18 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useClickOutside.svelte.d.ts +31 -0
- package/dist/hooks/useClickOutside.svelte.js +37 -0
- package/dist/hooks/useClipboard.svelte.d.ts +30 -0
- package/dist/hooks/useClipboard.svelte.js +45 -0
- package/dist/hooks/useDebounce.svelte.d.ts +36 -0
- package/dist/hooks/useDebounce.svelte.js +56 -0
- package/dist/hooks/useEscapeKeydown.svelte.d.ts +31 -0
- package/dist/hooks/useEscapeKeydown.svelte.js +37 -0
- package/dist/hooks/useFormField.svelte.d.ts +54 -0
- package/dist/hooks/useFormField.svelte.js +65 -0
- package/dist/hooks/useInfiniteScroll.svelte.d.ts +57 -0
- package/dist/hooks/useInfiniteScroll.svelte.js +69 -0
- package/dist/hooks/useMediaQuery.svelte.d.ts +31 -0
- package/dist/hooks/useMediaQuery.svelte.js +38 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.js +57 -0
- package/dist/theme.css +680 -0
- package/package.json +237 -0
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { FileUploadProps, FileUploadRejection } from './file-upload.types.js'
|
|
3
|
+
|
|
4
|
+
export type Props = FileUploadProps
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { useId } from 'bits-ui'
|
|
9
|
+
import { untrack } from 'svelte'
|
|
10
|
+
import Button from '../Button/Button.svelte'
|
|
11
|
+
import { getComponentConfig, iconsDefaults } from '../config.js'
|
|
12
|
+
import { useFormField, useFormFieldEmit } from '../hooks/useFormField.svelte.js'
|
|
13
|
+
import Icon from '../Icon/Icon.svelte'
|
|
14
|
+
import Modal from '../Modal/Modal.svelte'
|
|
15
|
+
import { fileUploadDefaults, fileUploadVariants } from './file-upload.variants.js'
|
|
16
|
+
|
|
17
|
+
const config = getComponentConfig('fileUpload', fileUploadDefaults)
|
|
18
|
+
const icons = getComponentConfig('icons', iconsDefaults)
|
|
19
|
+
|
|
20
|
+
let {
|
|
21
|
+
ref = $bindable(null),
|
|
22
|
+
value = $bindable([]),
|
|
23
|
+
onValueChange,
|
|
24
|
+
multiple = false,
|
|
25
|
+
accept,
|
|
26
|
+
maxSize,
|
|
27
|
+
maxFiles,
|
|
28
|
+
onReject,
|
|
29
|
+
dropzone = true,
|
|
30
|
+
interactive = true,
|
|
31
|
+
label = 'Drop files here or click to upload',
|
|
32
|
+
description,
|
|
33
|
+
icon = icons.upload,
|
|
34
|
+
color = config.defaultVariants.color,
|
|
35
|
+
size = config.defaultVariants.size,
|
|
36
|
+
variant = config.defaultVariants.variant,
|
|
37
|
+
layout = config.defaultVariants.layout,
|
|
38
|
+
disabled = false,
|
|
39
|
+
loading = false,
|
|
40
|
+
loadingIcon = icons.loading,
|
|
41
|
+
preview = true,
|
|
42
|
+
highlight = false,
|
|
43
|
+
required = false,
|
|
44
|
+
fileIcon = icons.file,
|
|
45
|
+
imagePreview = true,
|
|
46
|
+
id,
|
|
47
|
+
name,
|
|
48
|
+
leadingSlot,
|
|
49
|
+
labelSlot,
|
|
50
|
+
descriptionSlot,
|
|
51
|
+
actionsSlot,
|
|
52
|
+
filesSlot,
|
|
53
|
+
fileSlot,
|
|
54
|
+
children,
|
|
55
|
+
class: className,
|
|
56
|
+
ui,
|
|
57
|
+
...restProps
|
|
58
|
+
}: Props = $props()
|
|
59
|
+
|
|
60
|
+
const autoId = useId()
|
|
61
|
+
|
|
62
|
+
let inputRef = $state<HTMLInputElement | null>(null)
|
|
63
|
+
let dragCounter = $state(0)
|
|
64
|
+
let previewOpen = $state(false)
|
|
65
|
+
let previewFile = $state<File | null>(null)
|
|
66
|
+
|
|
67
|
+
const formFieldContext = useFormField()
|
|
68
|
+
const emit = useFormFieldEmit()
|
|
69
|
+
|
|
70
|
+
// Stable file identity key with separator to avoid collisions
|
|
71
|
+
const fileKey = (f: File) => `${f.name}:${f.size}:${f.lastModified}`
|
|
72
|
+
|
|
73
|
+
// Plain Map intentionally — urlCache is an internal optimization cache, not reactive UI
|
|
74
|
+
// state. SvelteMap mutations would cascade re-renders every time a URL is cached/evicted.
|
|
75
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
76
|
+
const urlCache = new Map<string, string>()
|
|
77
|
+
|
|
78
|
+
const hasError = $derived(
|
|
79
|
+
formFieldContext?.error !== undefined && formFieldContext?.error !== false
|
|
80
|
+
)
|
|
81
|
+
const resolvedHighlight = $derived(highlight || hasError)
|
|
82
|
+
const resolvedId = $derived(id ?? formFieldContext?.ariaId)
|
|
83
|
+
const resolvedName = $derived(name ?? formFieldContext?.name)
|
|
84
|
+
const ariaDescribedBy = $derived(
|
|
85
|
+
!formFieldContext
|
|
86
|
+
? undefined
|
|
87
|
+
: hasError
|
|
88
|
+
? `${formFieldContext.ariaId}-error`
|
|
89
|
+
: `${formFieldContext.ariaId}-description ${formFieldContext.ariaId}-help`
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
const isDisabled = $derived(disabled || loading)
|
|
93
|
+
const isDragging = $derived(dragCounter > 0)
|
|
94
|
+
const isFull = $derived(maxFiles !== undefined && value.length >= maxFiles)
|
|
95
|
+
const showFilesInside = $derived(
|
|
96
|
+
layout === 'grid' && !multiple && value.length > 0 && preview && variant === 'area'
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
// Pass booleans directly so compound variants with `false` values match correctly
|
|
100
|
+
const slots = $derived(
|
|
101
|
+
fileUploadVariants({
|
|
102
|
+
color: hasError ? 'error' : color,
|
|
103
|
+
size,
|
|
104
|
+
variant,
|
|
105
|
+
layout,
|
|
106
|
+
dropzone,
|
|
107
|
+
interactive: interactive && !isDisabled,
|
|
108
|
+
highlight: resolvedHighlight,
|
|
109
|
+
multiple,
|
|
110
|
+
disabled: isDisabled
|
|
111
|
+
})
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
const classes = $derived.by(() => {
|
|
115
|
+
const u = ui ?? {}
|
|
116
|
+
return {
|
|
117
|
+
root: slots.root({ class: [config.slots.root, className, u.root] }),
|
|
118
|
+
base: slots.base({ class: [config.slots.base, u.base] }),
|
|
119
|
+
wrapper: slots.wrapper({ class: [config.slots.wrapper, u.wrapper] }),
|
|
120
|
+
icon: slots.icon({ class: [config.slots.icon, u.icon] }),
|
|
121
|
+
label: slots.label({ class: [config.slots.label, u.label] }),
|
|
122
|
+
description: slots.description({ class: [config.slots.description, u.description] }),
|
|
123
|
+
actions: slots.actions({ class: [config.slots.actions, u.actions] }),
|
|
124
|
+
files: slots.files({ class: [config.slots.files, u.files] }),
|
|
125
|
+
file: slots.file({ class: [config.slots.file, u.file] }),
|
|
126
|
+
fileLeading: slots.fileLeading({ class: [config.slots.fileLeading, u.fileLeading] }),
|
|
127
|
+
fileWrapper: slots.fileWrapper({ class: [config.slots.fileWrapper, u.fileWrapper] }),
|
|
128
|
+
fileName: slots.fileName({ class: [config.slots.fileName, u.fileName] }),
|
|
129
|
+
fileSize: slots.fileSize({ class: [config.slots.fileSize, u.fileSize] }),
|
|
130
|
+
fileTrailing: slots.fileTrailing({
|
|
131
|
+
class: [config.slots.fileTrailing, u.fileTrailing]
|
|
132
|
+
}),
|
|
133
|
+
previewContent: slots.previewContent({
|
|
134
|
+
class: [config.slots.previewContent, u.previewContent]
|
|
135
|
+
}),
|
|
136
|
+
previewBody: slots.previewBody({ class: [config.slots.previewBody, u.previewBody] })
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
// Revoke blob URLs for files no longer in value (handles external bind:value resets)
|
|
141
|
+
$effect(() => {
|
|
142
|
+
const current = new Set(value.map(fileKey))
|
|
143
|
+
// Close preview if its file was removed externally — untrack to avoid subscribing to previewFile
|
|
144
|
+
const pf = untrack(() => previewFile)
|
|
145
|
+
if (pf && !current.has(fileKey(pf))) {
|
|
146
|
+
previewOpen = false
|
|
147
|
+
previewFile = null
|
|
148
|
+
}
|
|
149
|
+
for (const [key, url] of urlCache) {
|
|
150
|
+
if (!current.has(key)) {
|
|
151
|
+
URL.revokeObjectURL(url)
|
|
152
|
+
urlCache.delete(key)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
$effect(() => {
|
|
158
|
+
return () => {
|
|
159
|
+
for (const [, url] of urlCache) URL.revokeObjectURL(url)
|
|
160
|
+
urlCache.clear()
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
export function open() {
|
|
165
|
+
if (isDisabled) return
|
|
166
|
+
inputRef?.click()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function isFileAccepted(file: File): boolean {
|
|
170
|
+
if (!accept) return true
|
|
171
|
+
return accept
|
|
172
|
+
.split(',')
|
|
173
|
+
.map((s) => s.trim())
|
|
174
|
+
.some((token) => {
|
|
175
|
+
if (!token || token === '*') return true
|
|
176
|
+
if (token.startsWith('.'))
|
|
177
|
+
return file.name.toLowerCase().endsWith(token.toLowerCase())
|
|
178
|
+
if (token.endsWith('/*')) return file.type.startsWith(token.slice(0, -1))
|
|
179
|
+
return file.type === token
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function validateIngress(file: File): FileUploadRejection['reason'] | null {
|
|
184
|
+
if (accept && !isFileAccepted(file)) return 'accept'
|
|
185
|
+
if (maxSize !== undefined && file.size > maxSize) return 'maxSize'
|
|
186
|
+
return null
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function applyMaxFiles(candidates: File[]): {
|
|
190
|
+
accepted: File[]
|
|
191
|
+
rejected: FileUploadRejection[]
|
|
192
|
+
} {
|
|
193
|
+
if (maxFiles === undefined) return { accepted: candidates, rejected: [] }
|
|
194
|
+
const remaining = Math.max(0, maxFiles - value.length)
|
|
195
|
+
if (candidates.length <= remaining) return { accepted: candidates, rejected: [] }
|
|
196
|
+
return {
|
|
197
|
+
accepted: candidates.slice(0, remaining),
|
|
198
|
+
rejected: candidates.slice(remaining).map((file) => ({ file, reason: 'maxFiles' }))
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function addFiles(newFiles: File[]) {
|
|
203
|
+
if (isDisabled) return
|
|
204
|
+
|
|
205
|
+
const rejected: FileUploadRejection[] = []
|
|
206
|
+
const passed: File[] = []
|
|
207
|
+
for (const file of newFiles) {
|
|
208
|
+
const reason = validateIngress(file)
|
|
209
|
+
if (reason) rejected.push({ file, reason })
|
|
210
|
+
else passed.push(file)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
let accepted: File[]
|
|
214
|
+
if (!multiple) {
|
|
215
|
+
accepted = passed.slice(0, 1)
|
|
216
|
+
} else {
|
|
217
|
+
const existing = new Set(value.map(fileKey))
|
|
218
|
+
const deduped = passed.filter((f) => !existing.has(fileKey(f)))
|
|
219
|
+
const result = applyMaxFiles(deduped)
|
|
220
|
+
accepted = result.accepted
|
|
221
|
+
rejected.push(...result.rejected)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (accepted.length) {
|
|
225
|
+
value = multiple ? [...value, ...accepted] : accepted
|
|
226
|
+
onValueChange?.(value)
|
|
227
|
+
emit.onChange()
|
|
228
|
+
}
|
|
229
|
+
if (rejected.length) onReject?.(rejected)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function removeFile(index: number) {
|
|
233
|
+
const removed = value[index]
|
|
234
|
+
const key = fileKey(removed)
|
|
235
|
+
if (previewFile && fileKey(previewFile) === key) {
|
|
236
|
+
previewOpen = false
|
|
237
|
+
previewFile = null
|
|
238
|
+
}
|
|
239
|
+
if (urlCache.has(key)) {
|
|
240
|
+
URL.revokeObjectURL(urlCache.get(key)!)
|
|
241
|
+
urlCache.delete(key)
|
|
242
|
+
}
|
|
243
|
+
value = value.filter((_, i) => i !== index)
|
|
244
|
+
onValueChange?.(value)
|
|
245
|
+
emit.onChange()
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function clearAll() {
|
|
249
|
+
previewOpen = false
|
|
250
|
+
previewFile = null
|
|
251
|
+
for (const [, url] of urlCache) URL.revokeObjectURL(url)
|
|
252
|
+
urlCache.clear()
|
|
253
|
+
value = []
|
|
254
|
+
onValueChange?.(value)
|
|
255
|
+
emit.onChange()
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function handleInputChange(e: Event) {
|
|
259
|
+
const input = e.target as HTMLInputElement
|
|
260
|
+
if (input.files?.length) {
|
|
261
|
+
addFiles(Array.from(input.files))
|
|
262
|
+
input.value = ''
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function handleDrop(e: DragEvent) {
|
|
267
|
+
e.preventDefault()
|
|
268
|
+
dragCounter = 0
|
|
269
|
+
if (!dropzone || isDisabled) return
|
|
270
|
+
const files = e.dataTransfer?.files
|
|
271
|
+
if (files?.length) addFiles(Array.from(files))
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function handleDragEnter(e: DragEvent) {
|
|
275
|
+
e.preventDefault()
|
|
276
|
+
if (dropzone && !isDisabled) dragCounter++
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function handleDragOver(e: DragEvent) {
|
|
280
|
+
e.preventDefault()
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function handleDragLeave() {
|
|
284
|
+
dragCounter = Math.max(0, dragCounter - 1)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function handleAreaClick() {
|
|
288
|
+
if (interactive && !isDisabled) open()
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function handleKeydown(e: KeyboardEvent) {
|
|
292
|
+
if (!interactive) return
|
|
293
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
294
|
+
e.preventDefault()
|
|
295
|
+
open()
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function formatFileSize(bytes: number): string {
|
|
300
|
+
if (bytes === 0) return '0 B'
|
|
301
|
+
const k = 1024
|
|
302
|
+
const sizes = ['B', 'KB', 'MB', 'GB']
|
|
303
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
304
|
+
return `${(bytes / k ** i).toFixed(1)} ${sizes[i]}`
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function isImageFile(file: File): boolean {
|
|
308
|
+
return file.type.startsWith('image/')
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function openPreview(file: File) {
|
|
312
|
+
previewFile = file
|
|
313
|
+
previewOpen = true
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function getObjectUrl(file: File): string {
|
|
317
|
+
const key = fileKey(file)
|
|
318
|
+
if (!urlCache.has(key)) {
|
|
319
|
+
urlCache.set(key, URL.createObjectURL(file))
|
|
320
|
+
}
|
|
321
|
+
return urlCache.get(key)!
|
|
322
|
+
}
|
|
323
|
+
</script>
|
|
324
|
+
|
|
325
|
+
<div {...restProps} bind:this={ref} class={classes.root} data-full={isFull ? '' : undefined}>
|
|
326
|
+
<!-- Hidden file input — uses auto-generated id internally -->
|
|
327
|
+
<input
|
|
328
|
+
bind:this={inputRef}
|
|
329
|
+
type="file"
|
|
330
|
+
id={autoId}
|
|
331
|
+
name={resolvedName}
|
|
332
|
+
{accept}
|
|
333
|
+
{multiple}
|
|
334
|
+
{required}
|
|
335
|
+
disabled={isDisabled}
|
|
336
|
+
onchange={handleInputChange}
|
|
337
|
+
class="sr-only"
|
|
338
|
+
tabindex="-1"
|
|
339
|
+
aria-hidden="true"
|
|
340
|
+
/>
|
|
341
|
+
|
|
342
|
+
{#if variant === 'area'}
|
|
343
|
+
<!-- Area / Dropzone -->
|
|
344
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
345
|
+
<div
|
|
346
|
+
id={resolvedId}
|
|
347
|
+
class={classes.base}
|
|
348
|
+
data-dragging={isDragging ? '' : undefined}
|
|
349
|
+
role={interactive ? 'button' : undefined}
|
|
350
|
+
tabindex={interactive && !isDisabled ? 0 : undefined}
|
|
351
|
+
aria-disabled={isDisabled || undefined}
|
|
352
|
+
aria-label={interactive ? label : undefined}
|
|
353
|
+
aria-invalid={resolvedHighlight ? true : undefined}
|
|
354
|
+
aria-describedby={ariaDescribedBy}
|
|
355
|
+
onclick={handleAreaClick}
|
|
356
|
+
ondragenter={handleDragEnter}
|
|
357
|
+
ondragover={handleDragOver}
|
|
358
|
+
ondragleave={handleDragLeave}
|
|
359
|
+
ondrop={handleDrop}
|
|
360
|
+
onkeydown={handleKeydown}
|
|
361
|
+
onfocus={() => emit.onFocus()}
|
|
362
|
+
onblur={() => emit.onBlur()}
|
|
363
|
+
>
|
|
364
|
+
{#if showFilesInside}
|
|
365
|
+
<!-- Grid single: file fills the area as overlay -->
|
|
366
|
+
{#each value as file, i (fileKey(file))}
|
|
367
|
+
<div class={classes.file} role="none" onclick={(e) => e.stopPropagation()}>
|
|
368
|
+
{#if isImageFile(file)}
|
|
369
|
+
{#if imagePreview}
|
|
370
|
+
<button
|
|
371
|
+
class="group relative size-full cursor-zoom-in overflow-hidden rounded-[7px]"
|
|
372
|
+
onclick={() => openPreview(file)}
|
|
373
|
+
aria-label="Preview {file.name}"
|
|
374
|
+
>
|
|
375
|
+
<img
|
|
376
|
+
src={getObjectUrl(file)}
|
|
377
|
+
alt={file.name}
|
|
378
|
+
class="size-full object-cover transition-[filter] duration-200 group-hover:brightness-75"
|
|
379
|
+
/>
|
|
380
|
+
<div
|
|
381
|
+
class="absolute inset-0 flex items-center justify-center opacity-0 transition-opacity duration-200 group-hover:opacity-100"
|
|
382
|
+
>
|
|
383
|
+
<Icon
|
|
384
|
+
name={icons.zoomIn}
|
|
385
|
+
class="size-6 text-white drop-shadow-md"
|
|
386
|
+
/>
|
|
387
|
+
</div>
|
|
388
|
+
</button>
|
|
389
|
+
{:else}
|
|
390
|
+
<div class="size-full overflow-hidden rounded-[7px]">
|
|
391
|
+
<img
|
|
392
|
+
src={getObjectUrl(file)}
|
|
393
|
+
alt={file.name}
|
|
394
|
+
class="size-full object-cover"
|
|
395
|
+
/>
|
|
396
|
+
</div>
|
|
397
|
+
{/if}
|
|
398
|
+
{:else}
|
|
399
|
+
<div
|
|
400
|
+
class="flex size-full flex-col items-center justify-center gap-1 p-4 text-on-surface-variant"
|
|
401
|
+
>
|
|
402
|
+
<Icon name={fileIcon} class="size-10 shrink-0" />
|
|
403
|
+
<span class="w-full truncate text-center text-xs">{file.name}</span>
|
|
404
|
+
</div>
|
|
405
|
+
{/if}
|
|
406
|
+
<div
|
|
407
|
+
class={classes.fileTrailing}
|
|
408
|
+
role="none"
|
|
409
|
+
onclick={(e) => e.stopPropagation()}
|
|
410
|
+
>
|
|
411
|
+
<Button
|
|
412
|
+
variant="solid"
|
|
413
|
+
color="error"
|
|
414
|
+
size="xs"
|
|
415
|
+
icon={icons.close}
|
|
416
|
+
square
|
|
417
|
+
ui={{
|
|
418
|
+
base: 'size-5 rounded-full border-2 border-surface p-0 shadow-sm'
|
|
419
|
+
}}
|
|
420
|
+
onclick={() => removeFile(i)}
|
|
421
|
+
aria-label="Remove {file.name}"
|
|
422
|
+
/>
|
|
423
|
+
</div>
|
|
424
|
+
</div>
|
|
425
|
+
{/each}
|
|
426
|
+
{:else}
|
|
427
|
+
<!-- Normal area content -->
|
|
428
|
+
<div class={classes.wrapper}>
|
|
429
|
+
{#if leadingSlot}
|
|
430
|
+
{@render leadingSlot()}
|
|
431
|
+
{:else}
|
|
432
|
+
<Icon name={loading ? loadingIcon : icon} class={classes.icon} />
|
|
433
|
+
{/if}
|
|
434
|
+
|
|
435
|
+
{#if labelSlot}
|
|
436
|
+
{@render labelSlot()}
|
|
437
|
+
{:else if label}
|
|
438
|
+
<p class={classes.label}>{label}</p>
|
|
439
|
+
{/if}
|
|
440
|
+
|
|
441
|
+
{#if descriptionSlot}
|
|
442
|
+
{@render descriptionSlot()}
|
|
443
|
+
{:else if description}
|
|
444
|
+
<p class={classes.description}>{description}</p>
|
|
445
|
+
{/if}
|
|
446
|
+
|
|
447
|
+
{#if actionsSlot}
|
|
448
|
+
<div
|
|
449
|
+
class={classes.actions}
|
|
450
|
+
role="none"
|
|
451
|
+
onclick={(e) => e.stopPropagation()}
|
|
452
|
+
>
|
|
453
|
+
{@render actionsSlot({ open })}
|
|
454
|
+
</div>
|
|
455
|
+
{/if}
|
|
456
|
+
|
|
457
|
+
{#if children}
|
|
458
|
+
{@render children()}
|
|
459
|
+
{/if}
|
|
460
|
+
</div>
|
|
461
|
+
{/if}
|
|
462
|
+
</div>
|
|
463
|
+
{:else}
|
|
464
|
+
<!-- Button variant -->
|
|
465
|
+
<Button
|
|
466
|
+
id={resolvedId}
|
|
467
|
+
{color}
|
|
468
|
+
{size}
|
|
469
|
+
disabled={isDisabled}
|
|
470
|
+
{loading}
|
|
471
|
+
{loadingIcon}
|
|
472
|
+
leadingIcon={loading ? undefined : icon}
|
|
473
|
+
{label}
|
|
474
|
+
aria-invalid={resolvedHighlight ? true : undefined}
|
|
475
|
+
aria-describedby={ariaDescribedBy}
|
|
476
|
+
onclick={handleAreaClick}
|
|
477
|
+
onfocus={() => emit.onFocus()}
|
|
478
|
+
onblur={() => emit.onBlur()}
|
|
479
|
+
/>
|
|
480
|
+
{/if}
|
|
481
|
+
|
|
482
|
+
<!-- File list (outside the zone) -->
|
|
483
|
+
{#if preview && value.length > 0 && !showFilesInside}
|
|
484
|
+
{#if filesSlot}
|
|
485
|
+
{@render filesSlot({ files: value })}
|
|
486
|
+
{:else}
|
|
487
|
+
<div class="flex items-center justify-between gap-2">
|
|
488
|
+
<span class="text-sm text-on-surface-variant">
|
|
489
|
+
{value.length}
|
|
490
|
+
{value.length === 1 ? 'file' : 'files'}
|
|
491
|
+
</span>
|
|
492
|
+
<Button
|
|
493
|
+
variant="ghost"
|
|
494
|
+
color="error"
|
|
495
|
+
size="xs"
|
|
496
|
+
label="Clear all"
|
|
497
|
+
leadingIcon={icons.trash}
|
|
498
|
+
onclick={clearAll}
|
|
499
|
+
/>
|
|
500
|
+
</div>
|
|
501
|
+
<div class={classes.files}>
|
|
502
|
+
{#each value as file, i (fileKey(file))}
|
|
503
|
+
{#if fileSlot}
|
|
504
|
+
{@render fileSlot({ file, index: i, remove: () => removeFile(i) })}
|
|
505
|
+
{:else if layout === 'grid'}
|
|
506
|
+
<!-- Grid item: no overflow-hidden on outer so close button can escape -->
|
|
507
|
+
<div class={classes.file}>
|
|
508
|
+
{#if isImageFile(file)}
|
|
509
|
+
{#if imagePreview}
|
|
510
|
+
<button
|
|
511
|
+
class="group relative size-full cursor-zoom-in overflow-hidden rounded-[7px]"
|
|
512
|
+
onclick={() => openPreview(file)}
|
|
513
|
+
aria-label="Preview {file.name}"
|
|
514
|
+
>
|
|
515
|
+
<img
|
|
516
|
+
src={getObjectUrl(file)}
|
|
517
|
+
alt={file.name}
|
|
518
|
+
class="size-full object-cover transition-[filter] duration-200 group-hover:brightness-75"
|
|
519
|
+
/>
|
|
520
|
+
<div
|
|
521
|
+
class="absolute inset-0 flex items-center justify-center opacity-0 transition-opacity duration-200 group-hover:opacity-100"
|
|
522
|
+
>
|
|
523
|
+
<Icon
|
|
524
|
+
name={icons.zoomIn}
|
|
525
|
+
class="size-6 text-white drop-shadow-md"
|
|
526
|
+
/>
|
|
527
|
+
</div>
|
|
528
|
+
</button>
|
|
529
|
+
{:else}
|
|
530
|
+
<div class="size-full overflow-hidden rounded-[7px]">
|
|
531
|
+
<img
|
|
532
|
+
src={getObjectUrl(file)}
|
|
533
|
+
alt={file.name}
|
|
534
|
+
class="size-full object-cover"
|
|
535
|
+
/>
|
|
536
|
+
</div>
|
|
537
|
+
{/if}
|
|
538
|
+
{:else}
|
|
539
|
+
<div
|
|
540
|
+
class="flex size-full flex-col items-center justify-center gap-1.5 overflow-hidden rounded-[7px] bg-surface-container-low p-3 text-on-surface-variant"
|
|
541
|
+
>
|
|
542
|
+
<Icon name={fileIcon} class="size-8 shrink-0" />
|
|
543
|
+
<span class="w-full truncate text-center text-xs"
|
|
544
|
+
>{file.name}</span
|
|
545
|
+
>
|
|
546
|
+
</div>
|
|
547
|
+
{/if}
|
|
548
|
+
<div class={classes.fileTrailing}>
|
|
549
|
+
<Button
|
|
550
|
+
variant="solid"
|
|
551
|
+
color="error"
|
|
552
|
+
size="xs"
|
|
553
|
+
icon={icons.close}
|
|
554
|
+
square
|
|
555
|
+
ui={{
|
|
556
|
+
base: 'size-5 rounded-full border-2 border-surface p-0 shadow-sm'
|
|
557
|
+
}}
|
|
558
|
+
onclick={() => removeFile(i)}
|
|
559
|
+
aria-label="Remove {file.name}"
|
|
560
|
+
/>
|
|
561
|
+
</div>
|
|
562
|
+
</div>
|
|
563
|
+
{:else}
|
|
564
|
+
<!-- List item -->
|
|
565
|
+
<div class={classes.file}>
|
|
566
|
+
<div class={classes.fileLeading}>
|
|
567
|
+
{#if isImageFile(file)}
|
|
568
|
+
<img
|
|
569
|
+
src={getObjectUrl(file)}
|
|
570
|
+
alt={file.name}
|
|
571
|
+
class="size-8 shrink-0 rounded object-cover"
|
|
572
|
+
/>
|
|
573
|
+
{:else}
|
|
574
|
+
<Icon
|
|
575
|
+
name={fileIcon}
|
|
576
|
+
class="size-4 shrink-0 text-on-surface-variant"
|
|
577
|
+
/>
|
|
578
|
+
{/if}
|
|
579
|
+
</div>
|
|
580
|
+
<div class={classes.fileWrapper}>
|
|
581
|
+
<span class={classes.fileName}>{file.name}</span>
|
|
582
|
+
<span class={classes.fileSize}>{formatFileSize(file.size)}</span>
|
|
583
|
+
</div>
|
|
584
|
+
<div class={classes.fileTrailing}>
|
|
585
|
+
<div class="flex items-center gap-0.5">
|
|
586
|
+
{#if isImageFile(file) && imagePreview}
|
|
587
|
+
<Button
|
|
588
|
+
variant="ghost"
|
|
589
|
+
{size}
|
|
590
|
+
icon={icons.zoomIn}
|
|
591
|
+
square
|
|
592
|
+
onclick={() => openPreview(file)}
|
|
593
|
+
aria-label="Preview {file.name}"
|
|
594
|
+
/>
|
|
595
|
+
{/if}
|
|
596
|
+
<Button
|
|
597
|
+
variant="ghost"
|
|
598
|
+
{size}
|
|
599
|
+
icon={icons.close}
|
|
600
|
+
square
|
|
601
|
+
onclick={() => removeFile(i)}
|
|
602
|
+
aria-label="Remove {file.name}"
|
|
603
|
+
/>
|
|
604
|
+
</div>
|
|
605
|
+
</div>
|
|
606
|
+
</div>
|
|
607
|
+
{/if}
|
|
608
|
+
{/each}
|
|
609
|
+
</div>
|
|
610
|
+
{/if}
|
|
611
|
+
{/if}
|
|
612
|
+
</div>
|
|
613
|
+
|
|
614
|
+
{#if imagePreview}
|
|
615
|
+
<Modal
|
|
616
|
+
bind:open={previewOpen}
|
|
617
|
+
onOpenChange={(v) => {
|
|
618
|
+
if (!v) previewFile = null
|
|
619
|
+
}}
|
|
620
|
+
title={previewFile?.name ?? ''}
|
|
621
|
+
description={previewFile ? formatFileSize(previewFile.size) : ''}
|
|
622
|
+
ui={{
|
|
623
|
+
content: ['max-w-3xl overflow-hidden', classes.previewContent],
|
|
624
|
+
body: ['p-0', classes.previewBody]
|
|
625
|
+
}}
|
|
626
|
+
>
|
|
627
|
+
{#snippet body()}
|
|
628
|
+
{#if previewFile}
|
|
629
|
+
<div class="flex items-center justify-center bg-surface-container-low">
|
|
630
|
+
<img
|
|
631
|
+
src={getObjectUrl(previewFile)}
|
|
632
|
+
alt={previewFile.name}
|
|
633
|
+
class="max-h-[75vh] max-w-full"
|
|
634
|
+
/>
|
|
635
|
+
</div>
|
|
636
|
+
{/if}
|
|
637
|
+
{/snippet}
|
|
638
|
+
</Modal>
|
|
639
|
+
{/if}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FileUploadProps } from './file-upload.types.js';
|
|
2
|
+
export type Props = FileUploadProps;
|
|
3
|
+
declare const FileUpload: import("svelte").Component<FileUploadProps, {
|
|
4
|
+
open: () => void;
|
|
5
|
+
clearAll: () => void;
|
|
6
|
+
}, "value" | "ref">;
|
|
7
|
+
type FileUpload = ReturnType<typeof FileUpload>;
|
|
8
|
+
export default FileUpload;
|