Skip to content

Commit c5c83dd

Browse files
committed
fix: Dropzone, update progress files
1 parent 2474108 commit c5c83dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+7302
-128
lines changed

src/lib/forms/dropzone/Dropzone.svelte

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
3535
const onDrop: DragEventHandler<HTMLButtonElement> = function (this: Window, event) {
3636
event.preventDefault();
37+
38+
// When files are dropped, update the files binding
39+
if (event.dataTransfer?.files && event.dataTransfer.files.length > 0) {
40+
files = event.dataTransfer.files;
41+
}
42+
43+
// Then call any custom ondrop handler
3744
if (ondrop) {
3845
ondrop.call(this, event);
3946
}
@@ -58,11 +65,4 @@
5865
</button>
5966
<label class="hidden">
6067
<input {...restProps} bind:files bind:this={input} onchange={onChange} type="file" />
61-
</label>
62-
63-
<!--
64-
@component
65-
[Go to docs](https://flowbite-svelte-next.com/)
66-
## Props
67-
@props:
68-
-->
68+
</label>

src/lib/pagination/PaginationItem.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
const group = getContext<boolean>("group");
1010
const table = getContext<boolean>("table");
11-
const paginationClass = $derived(paginationItem({ size, active, group, table, class: clsx(className) }));
11+
const paginationClass = $derived(paginationItem({ size: getContext("size") ?? size, active, group, table, class: clsx(className) }));
1212
</script>
1313

1414
{#if href}

src/lib/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ export interface DropzoneProps extends HTMLInputAttributes {
672672

673673
// fileupload
674674
export interface FileuploadProps extends Omit<HTMLInputAttributes, "size"> {
675-
files?: FileList;
675+
files?: FileList | null;
676676
size?: FileuploadViariants["size"];
677677
color?: InputProps<never>["color"];
678678
clearable?: boolean;
@@ -760,6 +760,7 @@ export type SelectOptionType<T> = {
760760
name: string | number;
761761
value: T;
762762
disabled?: boolean;
763+
[key: string]: any;
763764
};
764765

765766
export interface SelectProps<T> extends SelectVariants, Omit<HTMLSelectAttributes, "size"> {

src/routes/docs/components/pagination.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ Use the following list of pagination items to indicate a series of content for y
3535
3636
let activeUrl = $derived(page.url.searchParams.get("page"));
3737
let pages = $state([
38-
{ name: 1, href: "/docs/components/pagination?page=1" },
39-
{ name: 2, href: "/docs/components/pagination?page=2" },
40-
{ name: 3, href: "/docs/components/pagination?page=3" },
41-
{ name: 4, href: "/docs/components/pagination?page=4" },
42-
{ name: 5, href: "/docs/components/pagination?page=5" }
38+
{ name: "1", href: "/docs/components/pagination?page=1" },
39+
{ name: "2", href: "/docs/components/pagination?page=2" },
40+
{ name: "3", href: "/docs/components/pagination?page=3" },
41+
{ name: "4", href: "/docs/components/pagination?page=4" },
42+
{ name: "5", href: "/docs/components/pagination?page=5" }
4343
]);
4444
4545
$effect(() => {
4646
pages.forEach((page) => {
47-
let splitUrl = page.href.split("?");
48-
let queryString = splitUrl.slice(1).join("?");
47+
let splitUrl = page.href?.split("?");
48+
let queryString = splitUrl?.slice(1).join("?");
4949
const hrefParams = new URLSearchParams(queryString);
5050
let hrefValue = hrefParams.get("page");
5151
if (hrefValue === activeUrl) {
@@ -66,7 +66,7 @@ Use the following list of pagination items to indicate a series of content for y
6666
</script>
6767
6868
<Pagination {pages} {previous} {next} />
69-
<Pagination {pages} large {previous} {next} />
69+
<Pagination {pages} size="large" {previous} {next} />
7070
```
7171

7272
## Pagination with icons
@@ -126,8 +126,8 @@ Use the following markup to show simple previous and next elements.
126126
<PaginationItem onclick={next}>Next</PaginationItem>
127127
</div>
128128
<div class="flex space-x-3 rtl:space-x-reverse">
129-
<PaginationItem large onclick={previous}>Previous</PaginationItem>
130-
<PaginationItem large onclick={next}>Next</PaginationItem>
129+
<PaginationItem size="large" onclick={previous}>Previous</PaginationItem>
130+
<PaginationItem size="large" onclick={next}>Next</PaginationItem>
131131
</div>
132132
```
133133

@@ -148,21 +148,21 @@ Use the following code to show simple previous and next elements with icons.
148148
</script>
149149
150150
<div class="flex space-x-3 rtl:space-x-reverse">
151-
<PaginationItem class="flex items-center" {previous}>
151+
<PaginationItem class="flex items-center" onclick={previous}>
152152
<ArrowLeftOutline class="me-2 h-3.5 w-3.5" />
153153
Previous
154154
</PaginationItem>
155-
<PaginationItem class="flex items-center" {next}>
155+
<PaginationItem class="flex items-center" onclick={next}>
156156
Next
157157
<ArrowRightOutline class="ms-2 h-3.5 w-3.5" />
158158
</PaginationItem>
159159
</div>
160160
<div class="flex space-x-3 rtl:space-x-reverse">
161-
<PaginationItem large class="flex items-center" {previous}>
161+
<PaginationItem size="large" class="flex items-center" onclick={previous}>
162162
<ArrowLeftOutline class="me-2 h-5 w-5" />
163163
Previous
164164
</PaginationItem>
165-
<PaginationItem large class="flex items-center" {next}>
165+
<PaginationItem size="large" class="flex items-center" onclick={next}>
166166
Next
167167
<ArrowRightOutline class="ms-2 h-5 w-5" />
168168
</PaginationItem>

src/routes/docs/components/skeleton.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Use the skeleton component to indicate a loading status with placeholder element
3535
<Skeleton size="md" class="my-8" />
3636
<Skeleton size="lg" class="my-8" />
3737
<Skeleton size="xl" class="my-8" />
38-
<Skeleton size="xxl" class="mt-8 mb-2.5" />
38+
<Skeleton size="2xl" class="mt-8 mb-2.5" />
3939
```
4040

4141
## Image placeholder
@@ -63,7 +63,7 @@ To display image placeholder without text, use `imgOnly` prop as seen in the fol
6363
<VideoPlaceholder size="md" class="mt-8" />
6464
<VideoPlaceholder size="lg" class="mt-8" />
6565
<VideoPlaceholder size="xl" class="mt-8" />
66-
<VideoPlaceholder size="xxl" class="mt-8" />
66+
<VideoPlaceholder size="2xl" class="mt-8" />
6767
```
6868

6969
## Text placeholder
@@ -77,7 +77,7 @@ To display image placeholder without text, use `imgOnly` prop as seen in the fol
7777
<TextPlaceholder size="md" class="mt-8" />
7878
<TextPlaceholder size="lg" class="mt-8" />
7979
<TextPlaceholder size="xl" class="mt-8" />
80-
<TextPlaceholder size="xxl" class="mt-8" />
80+
<TextPlaceholder size="2xl" class="mt-8" />
8181
```
8282

8383
## Card placeholder
@@ -91,7 +91,7 @@ To display image placeholder without text, use `imgOnly` prop as seen in the fol
9191
<CardPlaceholder size="md" class="mt-8" />
9292
<CardPlaceholder size="lg" class="mt-8" />
9393
<CardPlaceholder size="xl" class="mt-8" />
94-
<CardPlaceholder size="xxl" class="mt-8" />
94+
<CardPlaceholder size="2xl" class="mt-8" />
9595
```
9696

9797
## Widget placeholder

src/routes/docs/components/spinner.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ Change the size of the spinner component using the `size` prop.
6363
import { Spinner } from "flowbite-svelte";
6464
</script>
6565
66-
<Spinner size={4} />
66+
<Spinner size="4" />
6767
<Spinner size="6" />
68-
<Spinner size={8} />
68+
<Spinner size="8" />
6969
```
7070

7171
## Alignment
@@ -91,10 +91,10 @@ The spinner component can also be used inside elements such as buttons when subm
9191
9292
<div class="flex flex-wrap items-center gap-2">
9393
<Button>
94-
<Spinner class="me-3" size="4" color="white" />
94+
<Spinner class="me-3" size="4" color="blue" />
9595
Loading ...
9696
</Button>
97-
<Button outline color="dark">
97+
<Button outline color="gray">
9898
<Spinner class="me-3" size="4" />
9999
Loading ...
100100
</Button>

src/routes/docs/components/typography.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ Use the following code to create list items with ordered and unordered lists.
102102
</script>
103103
104104
<Heading tag="h5">List disc</Heading>
105-
<List list="disc">
105+
<List class="list-disc">
106106
<Li>Design</Li>
107107
<Li>Develop</Li>
108108
<Li>Test</Li>
109109
</List>
110110
<Heading tag="h5">List decimal</Heading>
111-
<List list="decimal">
111+
<List class="list-decimal">
112112
<Li>Design</Li>
113113
<Li>Develop</Li>
114114
<Li>Test</Li>
115115
</List>
116116
<Heading tag="h5">List none</Heading>
117-
<List list="none">
117+
<List class="list-none">
118118
<Li>Design</Li>
119119
<Li>Develop</Li>
120120
<Li>Test</Li>
@@ -123,7 +123,7 @@ Use the following code to create list items with ordered and unordered lists.
123123

124124
## List position
125125

126-
Use the list-inside and list-outside classes to set the list item position inside a list component.
126+
Use the `position="inside"` and `position="outside"` props to set the list item position inside or outside of a list component.
127127

128128
```svelte example hideResponsiveButtons
129129
<script>

src/routes/docs/forms/file-input.md

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ thumnailSize: w-48
1010

1111
<script>
1212
import { CompoAttributesViewer, GitHubCompoLinks, toKebabCase } from '../../utils'
13-
import { Badge, A } from '$lib'
1413
const components = 'Fileupload'
1514
</script>
1615

@@ -39,9 +38,9 @@ The file input component can be used to upload one or more files from the device
3938
## Clearable and multiple files
4039

4140
```svelte example
42-
<script>
41+
<script lang="ts">
4342
import { Fileupload, Helper } from "flowbite-svelte";
44-
let selectedFiles = $state();
43+
let selectedFiles = $state<FileList | null>(null);
4544
let fileNames = $derived(
4645
selectedFiles
4746
? Array.from(selectedFiles)
@@ -73,68 +72,59 @@ The file input component can be used to upload one or more files from the device
7372
## Dropzone
7473

7574
```svelte example
76-
<script>
75+
<script lang="ts">
7776
import { Dropzone } from "flowbite-svelte";
7877
79-
let value = [];
80-
const dropHandle = (event) => {
81-
value = [];
82-
event.preventDefault();
83-
if (event.dataTransfer.items) {
84-
[...event.dataTransfer.items].forEach((item, i) => {
85-
if (item.kind === "file") {
86-
const file = item.getAsFile();
87-
value.push(file.name);
88-
value = value;
89-
}
90-
});
91-
} else {
92-
[...event.dataTransfer.files].forEach((file, i) => {
93-
value = file.name;
94-
});
95-
}
96-
};
97-
98-
const handleChange = (event) => {
99-
const files = event.target.files;
100-
if (files.length > 0) {
101-
value.push(files[0].name);
102-
value = value;
103-
}
104-
};
105-
106-
const showFiles = (files) => {
107-
if (files.length === 1) return files[0];
108-
let concat = "";
109-
files.map((file) => {
110-
concat += file;
111-
concat += ",";
112-
concat += " ";
113-
});
114-
115-
if (concat.length > 40) concat = concat.slice(0, 40);
116-
concat += "...";
117-
return concat;
118-
};
78+
let value: FileList | null = $state(null);
79+
80+
function handleChange(event: Event) {
81+
const target = event.target as HTMLInputElement;
82+
value = target.files;
83+
}
84+
85+
function dropHandle(event: DragEvent) {
86+
event.preventDefault();
87+
value = event.dataTransfer?.files ?? null;
88+
}
89+
90+
function showFiles(files: FileList | null): string {
91+
if (!files || files.length === 0) return 'No files selected.';
92+
return Array.from(files).map(file => file.name).join(', ');
93+
}
11994
</script>
12095
12196
<Dropzone
12297
id="dropzone"
98+
bind:files={value}
12399
ondrop={dropHandle}
124-
ondragover={(event) => {
125-
event.preventDefault();
126-
}}
100+
ondragover={(event) => event.preventDefault()}
127101
onchange={handleChange}
128102
>
129-
<svg aria-hidden="true" class="mb-3 h-10 w-10 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>
130-
{#if value.length === 0}
103+
<svg
104+
aria-hidden="true"
105+
class="mb-3 h-10 w-10 text-gray-400"
106+
fill="none"
107+
stroke="currentColor"
108+
viewBox="0 0 24 24"
109+
xmlns="http://www.w3.org/2000/svg"
110+
>
111+
<path
112+
stroke-linecap="round"
113+
stroke-linejoin="round"
114+
stroke-width="2"
115+
d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"
116+
/>
117+
</svg>
118+
119+
{#if !value || value.length === 0}
131120
<p class="mb-2 text-sm text-gray-500 dark:text-gray-400">
132-
<span class="font-semibold">Click to upload</span>
133-
or drag and drop
121+
<span class="font-semibold">Click to upload</span> or drag and drop
122+
</p>
123+
<p class="text-xs text-gray-500 dark:text-gray-400">
124+
SVG, PNG, JPG or GIF (MAX. 800x400px)
134125
</p>
135-
<p class="text-xs text-gray-500 dark:text-gray-400">SVG, PNG, JPG or GIF (MAX. 800x400px)</p>
136126
{:else}
137-
<p>{showFiles(value)}</p>
127+
<p class="text-sm text-green-600">{showFiles(value)}</p>
138128
{/if}
139129
</Dropzone>
140130
```

src/routes/docs/forms/floating-label.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ thumnailSize: w-40
1010

1111
<script>
1212
import { CompoAttributesViewer, GitHubCompoLinks, toKebabCase } from '../../utils'
13-
import { Badge, A } from '$lib'
1413

1514
const components = 'FloatingLabelInput, Helper'
1615
</script>
@@ -39,7 +38,7 @@ Get started with the following three styles for the floating label component and
3938
<div id="exampleWrapper" class="grid w-full items-end gap-6 md:grid-cols-3">
4039
<FloatingLabelInput variant="filled" id="floating_filled" name="floating_filled" type="text">Floating filled</FloatingLabelInput>
4140
<FloatingLabelInput variant="outlined" id="floating_outlined" name="floating_outlined" type="text">Floating outlined</FloatingLabelInput>
42-
<FloatingLabelInput id="floating_standard" name="floating_standard" type="text" label="Floating standard">Floating standard</FloatingLabelInput>
41+
<FloatingLabelInput id="floating_standard" name="floating_standard" type="text">Floating standard</FloatingLabelInput>
4342
</div>
4443
```
4544

0 commit comments

Comments
 (0)