@casinogate/ui 1.11.7 → 1.11.9
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/dist/assets/css/root.css +57 -0
- package/dist/components/file-upload/components/file-upload.clear-trigger.svelte +30 -0
- package/dist/components/file-upload/components/file-upload.clear-trigger.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.context.svelte +10 -0
- package/dist/components/file-upload/components/file-upload.context.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.dropzone.svelte +72 -0
- package/dist/components/file-upload/components/file-upload.dropzone.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.hidden-input.svelte +35 -0
- package/dist/components/file-upload/components/file-upload.hidden-input.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.item-delete-trigger.svelte +31 -0
- package/dist/components/file-upload/components/file-upload.item-delete-trigger.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.item-group.svelte +21 -0
- package/dist/components/file-upload/components/file-upload.item-group.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.item-name.svelte +28 -0
- package/dist/components/file-upload/components/file-upload.item-name.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.item-preview-image.svelte +33 -0
- package/dist/components/file-upload/components/file-upload.item-preview-image.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.item-preview.svelte +29 -0
- package/dist/components/file-upload/components/file-upload.item-preview.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.item-size-text.svelte +28 -0
- package/dist/components/file-upload/components/file-upload.item-size-text.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.item.svelte +29 -0
- package/dist/components/file-upload/components/file-upload.item.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.root.svelte +47 -0
- package/dist/components/file-upload/components/file-upload.root.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/file-upload.svelte.d.ts +41 -0
- package/dist/components/file-upload/components/file-upload.svelte.js +120 -0
- package/dist/components/file-upload/components/file-upload.trigger.svelte +31 -0
- package/dist/components/file-upload/components/file-upload.trigger.svelte.d.ts +4 -0
- package/dist/components/file-upload/components/index.d.ts +13 -0
- package/dist/components/file-upload/components/index.js +13 -0
- package/dist/components/file-upload/composed/index.d.ts +1 -0
- package/dist/components/file-upload/composed/index.js +1 -0
- package/dist/components/file-upload/composed/root/file-upload.root.svelte +36 -0
- package/dist/components/file-upload/composed/root/file-upload.root.svelte.d.ts +4 -0
- package/dist/components/file-upload/composed/root/index.d.ts +1 -0
- package/dist/components/file-upload/composed/root/index.js +1 -0
- package/dist/components/file-upload/index.d.ts +3 -0
- package/dist/components/file-upload/index.js +3 -0
- package/dist/components/file-upload/styles.d.ts +80 -0
- package/dist/components/file-upload/styles.js +68 -0
- package/dist/components/file-upload/types.d.ts +83 -0
- package/dist/components/file-upload/types.js +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/pagination/components/index.d.ts +6 -0
- package/dist/components/pagination/components/index.js +6 -0
- package/dist/components/pagination/components/pagination.ellipsis.svelte +2 -5
- package/dist/components/pagination/components/pagination.item.svelte +4 -5
- package/dist/components/pagination/components/pagination.next-button.svelte +3 -6
- package/dist/components/pagination/components/pagination.page-size.svelte +40 -0
- package/dist/components/pagination/components/pagination.page-size.svelte.d.ts +4 -0
- package/dist/components/pagination/components/pagination.prev-button.svelte +2 -4
- package/dist/components/pagination/components/pagination.root.svelte +3 -5
- package/dist/components/pagination/composed/index.d.ts +1 -0
- package/dist/components/pagination/composed/index.js +1 -0
- package/dist/components/pagination/composed/root/index.d.ts +1 -0
- package/dist/components/pagination/composed/root/index.js +1 -0
- package/dist/components/pagination/composed/root/pagination.root.svelte +36 -0
- package/dist/components/pagination/composed/root/pagination.root.svelte.d.ts +4 -0
- package/dist/components/pagination/index.d.ts +3 -3
- package/dist/components/pagination/index.js +3 -2
- package/dist/components/pagination/styles.d.ts +41 -80
- package/dist/components/pagination/styles.js +33 -39
- package/dist/components/pagination/types.d.ts +14 -1
- package/dist/components/select/components/select.trigger.svelte +3 -0
- package/dist/components/select/select.svelte +5 -2
- package/dist/components/select/styles.d.ts +10 -1
- package/dist/components/select/styles.js +16 -2
- package/dist/components/select/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/components/pagination/exports-primitive.d.ts +0 -5
- package/dist/components/pagination/exports-primitive.js +0 -5
- package/dist/components/pagination/exports.d.ts +0 -1
- package/dist/components/pagination/exports.js +0 -1
- package/dist/components/pagination/pagination.svelte +0 -28
- package/dist/components/pagination/pagination.svelte.d.ts +0 -3
package/dist/assets/css/root.css
CHANGED
|
@@ -248,6 +248,9 @@
|
|
|
248
248
|
.cgui\:\!m-0 {
|
|
249
249
|
margin: calc(var(--cgui-spacing) * 0) !important;
|
|
250
250
|
}
|
|
251
|
+
.cgui\:m-0 {
|
|
252
|
+
margin: calc(var(--cgui-spacing) * 0);
|
|
253
|
+
}
|
|
251
254
|
.cgui\:mx-1 {
|
|
252
255
|
margin-inline: calc(var(--cgui-spacing) * 1);
|
|
253
256
|
}
|
|
@@ -454,6 +457,9 @@
|
|
|
454
457
|
.cgui\:h-34 {
|
|
455
458
|
height: calc(var(--cgui-spacing) * 34);
|
|
456
459
|
}
|
|
460
|
+
.cgui\:h-40 {
|
|
461
|
+
height: calc(var(--cgui-spacing) * 40);
|
|
462
|
+
}
|
|
457
463
|
.cgui\:h-100 {
|
|
458
464
|
height: calc(var(--cgui-spacing) * 100);
|
|
459
465
|
}
|
|
@@ -493,12 +499,21 @@
|
|
|
493
499
|
.cgui\:max-h-80 {
|
|
494
500
|
max-height: calc(var(--cgui-spacing) * 80);
|
|
495
501
|
}
|
|
502
|
+
.cgui\:min-h-6 {
|
|
503
|
+
min-height: calc(var(--cgui-spacing) * 6);
|
|
504
|
+
}
|
|
496
505
|
.cgui\:min-h-7\.5 {
|
|
497
506
|
min-height: calc(var(--cgui-spacing) * 7.5);
|
|
498
507
|
}
|
|
508
|
+
.cgui\:min-h-8 {
|
|
509
|
+
min-height: calc(var(--cgui-spacing) * 8);
|
|
510
|
+
}
|
|
499
511
|
.cgui\:min-h-9 {
|
|
500
512
|
min-height: calc(var(--cgui-spacing) * 9);
|
|
501
513
|
}
|
|
514
|
+
.cgui\:min-h-10 {
|
|
515
|
+
min-height: calc(var(--cgui-spacing) * 10);
|
|
516
|
+
}
|
|
502
517
|
.cgui\:min-h-11 {
|
|
503
518
|
min-height: calc(var(--cgui-spacing) * 11);
|
|
504
519
|
}
|
|
@@ -625,6 +640,18 @@
|
|
|
625
640
|
.cgui\:min-w-5 {
|
|
626
641
|
min-width: calc(var(--cgui-spacing) * 5);
|
|
627
642
|
}
|
|
643
|
+
.cgui\:min-w-6 {
|
|
644
|
+
min-width: calc(var(--cgui-spacing) * 6);
|
|
645
|
+
}
|
|
646
|
+
.cgui\:min-w-8 {
|
|
647
|
+
min-width: calc(var(--cgui-spacing) * 8);
|
|
648
|
+
}
|
|
649
|
+
.cgui\:min-w-10 {
|
|
650
|
+
min-width: calc(var(--cgui-spacing) * 10);
|
|
651
|
+
}
|
|
652
|
+
.cgui\:min-w-15 {
|
|
653
|
+
min-width: calc(var(--cgui-spacing) * 15);
|
|
654
|
+
}
|
|
628
655
|
.cgui\:min-w-35 {
|
|
629
656
|
min-width: calc(var(--cgui-spacing) * 35);
|
|
630
657
|
}
|
|
@@ -712,6 +739,9 @@
|
|
|
712
739
|
.cgui\:scroll-py-1 {
|
|
713
740
|
scroll-padding-block: calc(var(--cgui-spacing) * 1);
|
|
714
741
|
}
|
|
742
|
+
.cgui\:list-none {
|
|
743
|
+
list-style-type: none;
|
|
744
|
+
}
|
|
715
745
|
.cgui\:flex-col {
|
|
716
746
|
flex-direction: column;
|
|
717
747
|
}
|
|
@@ -1020,6 +1050,12 @@
|
|
|
1020
1050
|
.cgui\:bg-surface-primary-light-active {
|
|
1021
1051
|
background-color: var(--cg-ui-color-surface-primary-light-active);
|
|
1022
1052
|
}
|
|
1053
|
+
.cgui\:bg-surface-primary\/5 {
|
|
1054
|
+
background-color: var(--cg-ui-color-surface-primary);
|
|
1055
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
1056
|
+
background-color: color-mix(in oklab, var(--cg-ui-color-surface-primary) 5%, transparent);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1023
1059
|
.cgui\:bg-surface-regular {
|
|
1024
1060
|
background-color: var(--cg-ui-color-surface-regular);
|
|
1025
1061
|
}
|
|
@@ -1053,6 +1089,12 @@
|
|
|
1053
1089
|
.cgui\:bg-clip-padding {
|
|
1054
1090
|
background-clip: padding-box;
|
|
1055
1091
|
}
|
|
1092
|
+
.cgui\:object-contain {
|
|
1093
|
+
object-fit: contain;
|
|
1094
|
+
}
|
|
1095
|
+
.cgui\:object-cover {
|
|
1096
|
+
object-fit: cover;
|
|
1097
|
+
}
|
|
1056
1098
|
.cgui\:p-0 {
|
|
1057
1099
|
padding: calc(var(--cgui-spacing) * 0);
|
|
1058
1100
|
}
|
|
@@ -1837,6 +1879,21 @@
|
|
|
1837
1879
|
padding-right: calc(var(--cgui-spacing) * 14);
|
|
1838
1880
|
}
|
|
1839
1881
|
}
|
|
1882
|
+
.cgui\:data-\[has-chevron\]\:pr-8 {
|
|
1883
|
+
&[data-has-chevron] {
|
|
1884
|
+
padding-right: calc(var(--cgui-spacing) * 8);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
.cgui\:data-\[has-chevron\]\:pr-10 {
|
|
1888
|
+
&[data-has-chevron] {
|
|
1889
|
+
padding-right: calc(var(--cgui-spacing) * 10);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
.cgui\:data-\[has-chevron\]\:pr-14 {
|
|
1893
|
+
&[data-has-chevron] {
|
|
1894
|
+
padding-right: calc(var(--cgui-spacing) * 14);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1840
1897
|
.cgui\:data-\[highlighted\]\:bg-surface-lightest {
|
|
1841
1898
|
&[data-highlighted] {
|
|
1842
1899
|
background-color: var(--cg-ui-color-surface-lightest);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveClearTriggerStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveClearTriggerProps } from '../types.js';
|
|
5
|
+
import { FileUploadRootContext } from './file-upload.svelte.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
children,
|
|
10
|
+
class: className,
|
|
11
|
+
...restProps
|
|
12
|
+
}: FileUploadPrimitiveClearTriggerProps = $props();
|
|
13
|
+
|
|
14
|
+
const rootState = FileUploadRootContext.get();
|
|
15
|
+
|
|
16
|
+
function handleClick() {
|
|
17
|
+
rootState.clearFiles();
|
|
18
|
+
}
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<button
|
|
22
|
+
bind:this={ref}
|
|
23
|
+
type="button"
|
|
24
|
+
class={cn(fileUploadPrimitiveClearTriggerStyles(), className)}
|
|
25
|
+
data-slot="file-upload-clear-trigger"
|
|
26
|
+
onclick={handleClick}
|
|
27
|
+
{...restProps}
|
|
28
|
+
>
|
|
29
|
+
{@render children?.()}
|
|
30
|
+
</button>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FileUploadPrimitiveContextProps } from '../types.js';
|
|
3
|
+
import { FileUploadRootContext } from './file-upload.svelte.js';
|
|
4
|
+
|
|
5
|
+
const { children }: FileUploadPrimitiveContextProps = $props();
|
|
6
|
+
|
|
7
|
+
const context = FileUploadRootContext.get();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{@render children?.(context)}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveDropzoneStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveDropzoneProps } from '../types.js';
|
|
5
|
+
import { FileUploadRootContext } from './file-upload.svelte.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
disableClick = false,
|
|
10
|
+
children,
|
|
11
|
+
class: className,
|
|
12
|
+
...restProps
|
|
13
|
+
}: FileUploadPrimitiveDropzoneProps = $props();
|
|
14
|
+
|
|
15
|
+
const rootState = FileUploadRootContext.get();
|
|
16
|
+
|
|
17
|
+
function handleDragEnter(e: DragEvent) {
|
|
18
|
+
e.preventDefault();
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
rootState.dragging = true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function handleDragLeave(e: DragEvent) {
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
rootState.dragging = false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function handleDragOver(e: DragEvent) {
|
|
30
|
+
e.preventDefault();
|
|
31
|
+
e.stopPropagation();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function handleDrop(e: DragEvent) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
rootState.dragging = false;
|
|
38
|
+
|
|
39
|
+
if (e.dataTransfer?.files) {
|
|
40
|
+
rootState.addFiles(e.dataTransfer.files);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function handleClick() {
|
|
45
|
+
if (!disableClick) {
|
|
46
|
+
rootState.openFilePicker();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<div
|
|
52
|
+
bind:this={ref}
|
|
53
|
+
role="presentation"
|
|
54
|
+
class={cn(
|
|
55
|
+
fileUploadPrimitiveDropzoneStyles({
|
|
56
|
+
dragging: rootState.dragging,
|
|
57
|
+
invalid: rootState.opts.invalid.current,
|
|
58
|
+
disabled: rootState.opts.disabled.current,
|
|
59
|
+
}),
|
|
60
|
+
className,
|
|
61
|
+
)}
|
|
62
|
+
data-slot="file-upload-dropzone"
|
|
63
|
+
data-dragging={rootState.dragging || undefined}
|
|
64
|
+
ondragenter={handleDragEnter}
|
|
65
|
+
ondragleave={handleDragLeave}
|
|
66
|
+
ondragover={handleDragOver}
|
|
67
|
+
ondrop={handleDrop}
|
|
68
|
+
onclick={handleClick}
|
|
69
|
+
{...restProps}
|
|
70
|
+
>
|
|
71
|
+
{@render children?.()}
|
|
72
|
+
</div>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FileUploadPrimitiveHiddenInputProps } from '../types.js';
|
|
3
|
+
import { FileUploadRootContext } from './file-upload.svelte.js';
|
|
4
|
+
|
|
5
|
+
let { ref = $bindable(null), ...restProps }: FileUploadPrimitiveHiddenInputProps = $props();
|
|
6
|
+
|
|
7
|
+
const rootState = FileUploadRootContext.get();
|
|
8
|
+
|
|
9
|
+
let inputEl = $state<HTMLInputElement | null>(null);
|
|
10
|
+
|
|
11
|
+
$effect(() => {
|
|
12
|
+
rootState.setHiddenInput(inputEl);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function handleChange(e: Event) {
|
|
16
|
+
const input = e.target as HTMLInputElement;
|
|
17
|
+
if (input.files) {
|
|
18
|
+
rootState.addFiles(input.files);
|
|
19
|
+
input.value = '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<input
|
|
25
|
+
bind:this={inputEl}
|
|
26
|
+
type="file"
|
|
27
|
+
tabindex={-1}
|
|
28
|
+
style="position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;"
|
|
29
|
+
data-slot="file-upload-hidden-input"
|
|
30
|
+
accept={rootState.opts.accept.current}
|
|
31
|
+
multiple={rootState.opts.maxFiles.current > 1}
|
|
32
|
+
disabled={rootState.opts.disabled.current}
|
|
33
|
+
onchange={handleChange}
|
|
34
|
+
{...restProps}
|
|
35
|
+
/>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveItemDeleteTriggerStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveItemDeleteTriggerProps } from '../types.js';
|
|
5
|
+
import { FileUploadItemContext, FileUploadRootContext } from './file-upload.svelte.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
children,
|
|
10
|
+
class: className,
|
|
11
|
+
...restProps
|
|
12
|
+
}: FileUploadPrimitiveItemDeleteTriggerProps = $props();
|
|
13
|
+
|
|
14
|
+
const rootState = FileUploadRootContext.get();
|
|
15
|
+
const itemState = FileUploadItemContext.get();
|
|
16
|
+
|
|
17
|
+
function handleClick() {
|
|
18
|
+
rootState.removeFile(itemState.opts.file.current);
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<button
|
|
23
|
+
bind:this={ref}
|
|
24
|
+
type="button"
|
|
25
|
+
class={cn(fileUploadPrimitiveItemDeleteTriggerStyles(), className)}
|
|
26
|
+
data-slot="file-upload-item-delete-trigger"
|
|
27
|
+
onclick={handleClick}
|
|
28
|
+
{...restProps}
|
|
29
|
+
>
|
|
30
|
+
{@render children?.()}
|
|
31
|
+
</button>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveItemGroupStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveItemGroupProps } from '../types.js';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
children,
|
|
9
|
+
class: className,
|
|
10
|
+
...restProps
|
|
11
|
+
}: FileUploadPrimitiveItemGroupProps = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<ul
|
|
15
|
+
bind:this={ref}
|
|
16
|
+
class={cn(fileUploadPrimitiveItemGroupStyles(), className)}
|
|
17
|
+
data-slot="file-upload-item-group"
|
|
18
|
+
{...restProps}
|
|
19
|
+
>
|
|
20
|
+
{@render children?.()}
|
|
21
|
+
</ul>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveItemNameStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveItemNameProps } from '../types.js';
|
|
5
|
+
import { FileUploadItemContext } from './file-upload.svelte.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
children,
|
|
10
|
+
class: className,
|
|
11
|
+
...restProps
|
|
12
|
+
}: FileUploadPrimitiveItemNameProps = $props();
|
|
13
|
+
|
|
14
|
+
const itemState = FileUploadItemContext.get();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div
|
|
18
|
+
bind:this={ref}
|
|
19
|
+
class={cn(fileUploadPrimitiveItemNameStyles(), className)}
|
|
20
|
+
data-slot="file-upload-item-name"
|
|
21
|
+
{...restProps}
|
|
22
|
+
>
|
|
23
|
+
{#if children}
|
|
24
|
+
{@render children()}
|
|
25
|
+
{:else}
|
|
26
|
+
{itemState.opts.file.current.name}
|
|
27
|
+
{/if}
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveItemPreviewImageStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveItemPreviewImageProps } from '../types.js';
|
|
5
|
+
import { FileUploadItemContext } from './file-upload.svelte.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: FileUploadPrimitiveItemPreviewImageProps = $props();
|
|
8
|
+
|
|
9
|
+
const itemState = FileUploadItemContext.get();
|
|
10
|
+
|
|
11
|
+
let url = $state<string | undefined>(undefined);
|
|
12
|
+
|
|
13
|
+
$effect(() => {
|
|
14
|
+
const file = itemState.opts.file.current;
|
|
15
|
+
const objectUrl = URL.createObjectURL(file);
|
|
16
|
+
url = objectUrl;
|
|
17
|
+
|
|
18
|
+
return () => {
|
|
19
|
+
URL.revokeObjectURL(objectUrl);
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if url}
|
|
25
|
+
<img
|
|
26
|
+
bind:this={ref}
|
|
27
|
+
src={url}
|
|
28
|
+
alt={itemState.opts.file.current.name}
|
|
29
|
+
class={cn(fileUploadPrimitiveItemPreviewImageStyles(), className)}
|
|
30
|
+
data-slot="file-upload-item-preview-image"
|
|
31
|
+
{...restProps}
|
|
32
|
+
/>
|
|
33
|
+
{/if}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveItemPreviewStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveItemPreviewProps } from '../types.js';
|
|
5
|
+
import { FileUploadItemContext } from './file-upload.svelte.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
type = '.*',
|
|
10
|
+
children,
|
|
11
|
+
class: className,
|
|
12
|
+
...restProps
|
|
13
|
+
}: FileUploadPrimitiveItemPreviewProps = $props();
|
|
14
|
+
|
|
15
|
+
const itemState = FileUploadItemContext.get();
|
|
16
|
+
|
|
17
|
+
const isMatch = $derived(Boolean(itemState.opts.file.current.type.match(type)));
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
{#if isMatch}
|
|
21
|
+
<div
|
|
22
|
+
bind:this={ref}
|
|
23
|
+
class={cn(fileUploadPrimitiveItemPreviewStyles(), className)}
|
|
24
|
+
data-slot="file-upload-item-preview"
|
|
25
|
+
{...restProps}
|
|
26
|
+
>
|
|
27
|
+
{@render children?.()}
|
|
28
|
+
</div>
|
|
29
|
+
{/if}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { fileUploadPrimitiveItemSizeTextStyles } from '../styles.js';
|
|
4
|
+
import type { FileUploadPrimitiveItemSizeTextProps } from '../types.js';
|
|
5
|
+
import { FileUploadItemContext, formatFileSize } from './file-upload.svelte.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
children,
|
|
10
|
+
class: className,
|
|
11
|
+
...restProps
|
|
12
|
+
}: FileUploadPrimitiveItemSizeTextProps = $props();
|
|
13
|
+
|
|
14
|
+
const itemState = FileUploadItemContext.get();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div
|
|
18
|
+
bind:this={ref}
|
|
19
|
+
class={cn(fileUploadPrimitiveItemSizeTextStyles(), className)}
|
|
20
|
+
data-slot="file-upload-item-size-text"
|
|
21
|
+
{...restProps}
|
|
22
|
+
>
|
|
23
|
+
{#if children}
|
|
24
|
+
{@render children()}
|
|
25
|
+
{:else}
|
|
26
|
+
{formatFileSize(itemState.opts.file.current.size)}
|
|
27
|
+
{/if}
|
|
28
|
+
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { box } from 'svelte-toolbelt';
|
|
4
|
+
import { fileUploadPrimitiveItemStyles } from '../styles.js';
|
|
5
|
+
import type { FileUploadPrimitiveItemProps } from '../types.js';
|
|
6
|
+
import { FileUploadItemState } from './file-upload.svelte.js';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
ref = $bindable(null),
|
|
10
|
+
file,
|
|
11
|
+
children,
|
|
12
|
+
class: className,
|
|
13
|
+
variant = 'default',
|
|
14
|
+
...restProps
|
|
15
|
+
}: FileUploadPrimitiveItemProps = $props();
|
|
16
|
+
|
|
17
|
+
FileUploadItemState.create({
|
|
18
|
+
file: box.with(() => file),
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<li
|
|
23
|
+
bind:this={ref}
|
|
24
|
+
class={cn(fileUploadPrimitiveItemStyles({ variant }), className)}
|
|
25
|
+
data-slot="file-upload-item"
|
|
26
|
+
{...restProps}
|
|
27
|
+
>
|
|
28
|
+
{@render children?.()}
|
|
29
|
+
</li>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { box } from 'svelte-toolbelt';
|
|
4
|
+
import { fileUploadPrimitiveRootStyles } from '../styles.js';
|
|
5
|
+
import type { FileUploadPrimitiveRootProps } from '../types.js';
|
|
6
|
+
import { FileUploadRootState } from './file-upload.svelte.js';
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
ref = $bindable(null),
|
|
10
|
+
accept,
|
|
11
|
+
maxFiles = 1,
|
|
12
|
+
maxFileSize = Infinity,
|
|
13
|
+
disabled = false,
|
|
14
|
+
invalid = false,
|
|
15
|
+
onFileAccept,
|
|
16
|
+
onFileReject,
|
|
17
|
+
onFileChange,
|
|
18
|
+
children,
|
|
19
|
+
class: className,
|
|
20
|
+
...restProps
|
|
21
|
+
}: FileUploadPrimitiveRootProps = $props();
|
|
22
|
+
|
|
23
|
+
const rootState = FileUploadRootState.create({
|
|
24
|
+
accept: box.with(() => accept),
|
|
25
|
+
maxFiles: box.with(() => maxFiles),
|
|
26
|
+
maxFileSize: box.with(() => maxFileSize),
|
|
27
|
+
disabled: box.with(() => disabled),
|
|
28
|
+
invalid: box.with(() => invalid),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
$effect(() => {
|
|
32
|
+
rootState.onFileAccept = onFileAccept;
|
|
33
|
+
rootState.onFileReject = onFileReject;
|
|
34
|
+
rootState.onFileChange = onFileChange;
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div
|
|
39
|
+
bind:this={ref}
|
|
40
|
+
class={cn(fileUploadPrimitiveRootStyles({ disabled }), className)}
|
|
41
|
+
data-slot="file-upload-root"
|
|
42
|
+
data-disabled={disabled || undefined}
|
|
43
|
+
data-dragging={rootState.dragging || undefined}
|
|
44
|
+
{...restProps}
|
|
45
|
+
>
|
|
46
|
+
{@render children?.()}
|
|
47
|
+
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Context } from 'runed';
|
|
2
|
+
import type { ReadableBoxedValues } from 'svelte-toolbelt';
|
|
3
|
+
import type { FileAcceptDetails, FileChangeDetails, FileRejectDetails, RejectedFile } from '../types.js';
|
|
4
|
+
export declare const FileUploadRootContext: Context<FileUploadRootState>;
|
|
5
|
+
type FileUploadRootStateOpts = ReadableBoxedValues<{
|
|
6
|
+
accept: string | undefined;
|
|
7
|
+
maxFiles: number;
|
|
8
|
+
maxFileSize: number;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
invalid: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export declare class FileUploadRootState {
|
|
13
|
+
static create(opts: FileUploadRootStateOpts): FileUploadRootState;
|
|
14
|
+
readonly opts: FileUploadRootStateOpts;
|
|
15
|
+
acceptedFiles: File[];
|
|
16
|
+
rejectedFiles: RejectedFile[];
|
|
17
|
+
dragging: boolean;
|
|
18
|
+
onFileAccept?: (details: FileAcceptDetails) => void;
|
|
19
|
+
onFileReject?: (details: FileRejectDetails) => void;
|
|
20
|
+
onFileChange?: (details: FileChangeDetails) => void;
|
|
21
|
+
private hiddenInputRef;
|
|
22
|
+
constructor(opts: FileUploadRootStateOpts);
|
|
23
|
+
setHiddenInput(input: HTMLInputElement | null): void;
|
|
24
|
+
openFilePicker(): void;
|
|
25
|
+
addFiles(files: FileList | File[]): void;
|
|
26
|
+
removeFile(file: File): void;
|
|
27
|
+
clearFiles(): void;
|
|
28
|
+
private validateFile;
|
|
29
|
+
private matchesAccept;
|
|
30
|
+
}
|
|
31
|
+
export declare const FileUploadItemContext: Context<FileUploadItemState>;
|
|
32
|
+
type FileUploadItemStateOpts = ReadableBoxedValues<{
|
|
33
|
+
file: File;
|
|
34
|
+
}>;
|
|
35
|
+
export declare class FileUploadItemState {
|
|
36
|
+
static create(opts: FileUploadItemStateOpts): FileUploadItemState;
|
|
37
|
+
readonly opts: FileUploadItemStateOpts;
|
|
38
|
+
constructor(opts: FileUploadItemStateOpts);
|
|
39
|
+
}
|
|
40
|
+
export declare function formatFileSize(bytes: number): string;
|
|
41
|
+
export {};
|