@streamscloud/kit 1.0.2 → 1.0.3
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/README.md +1 -1
- package/dist/ui/drag-and-drop/cmp.drop-zone.svelte +31 -32
- package/dist/ui/drag-and-drop/cmp.drop-zone.svelte.d.ts +16 -21
- package/dist/ui/drag-and-drop/cmp.file-drop-zone.svelte +149 -0
- package/dist/ui/drag-and-drop/cmp.file-drop-zone.svelte.d.ts +36 -0
- package/dist/ui/drag-and-drop/index.d.ts +1 -0
- package/dist/ui/drag-and-drop/index.js +1 -0
- package/dist/ui/file-uploader/cmp.file-uploader.svelte +4 -4
- package/dist/ui/file-uploader/cmp.file-uploader.svelte.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<script lang="ts" generics="T">import { DragAndDrop } from './drag-and-drop.svelte';
|
|
2
|
-
const { acceptedEvents,
|
|
3
|
-
const dragEvent = $derived.by(() =>
|
|
4
|
-
|
|
5
|
-
(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
const { acceptedEvents, accepts, disabled, silent = false, showRejection = false, children, on } = $props();
|
|
3
|
+
const dragEvent = $derived.by(() => {
|
|
4
|
+
const event = DragAndDrop.event;
|
|
5
|
+
if (!event || disabled) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
if (acceptedEvents.length && !acceptedEvents.includes(event.type)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return !accepts || accepts(event) ? event : null;
|
|
12
|
+
});
|
|
13
|
+
// A drag is in progress AND this zone refuses it (type or `accepts`). Drives the
|
|
9
14
|
// optional red-shield visual; `on.drop` / `on.enter` still don't fire for rejected drags.
|
|
10
15
|
const dragRejected = $derived(!!DragAndDrop.event && !disabled && !dragEvent && showRejection);
|
|
11
16
|
let dragOver = $state(false);
|
|
@@ -46,7 +51,6 @@ const onDragLeave = () => {
|
|
|
46
51
|
class:drop-zone--drag-over={dragOver && dragEvent && !silent}
|
|
47
52
|
class:drop-zone--drag-reject={dragOver && dragRejected && !silent}
|
|
48
53
|
class:drop-zone--disabled={disabled}
|
|
49
|
-
style:--_dz--offset="{highlightOffset}px"
|
|
50
54
|
ondrop={onDrop}
|
|
51
55
|
ondragover={onDragOver}
|
|
52
56
|
ondragleave={onDragLeave}
|
|
@@ -58,39 +62,33 @@ const onDragLeave = () => {
|
|
|
58
62
|
|
|
59
63
|
<!--
|
|
60
64
|
@component
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
hover (`dragover`) the outline becomes solid and the body fills with the accent tint. The
|
|
65
|
-
consumer handles the actual drop via `on.drop`.
|
|
66
|
-
|
|
67
|
-
Set `silent` when the host paints its own active / hover visuals; the zone keeps the event
|
|
68
|
-
plumbing but skips the built-in chrome. Use `highlightOffset` to outset the dashed border
|
|
69
|
-
(e.g. when the host has a rounded background that should remain visible inside the border).
|
|
70
|
-
Pass `showRejection` to paint a red shield when the zone is hovered with a drag whose type
|
|
71
|
-
isn't in `acceptedEvents` — useful for visible zones where silent inertia could be confusing.
|
|
65
|
+
Drop target for in-app drags, paired with `DragSource` through the `DragAndDrop` singleton store.
|
|
66
|
+
A drag it takes (by `acceptedEvents` and `accepts`) draws a dashed outline that turns solid over an
|
|
67
|
+
info tint on hover, and its payload reaches `on.drop`.
|
|
72
68
|
|
|
73
69
|
### CSS Custom Properties
|
|
74
70
|
| Property | Description | Default |
|
|
75
71
|
|---|---|---|
|
|
76
|
-
| `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--
|
|
77
|
-
| `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--
|
|
78
|
-
| `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--
|
|
79
|
-
| `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected
|
|
80
|
-
| `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected
|
|
72
|
+
| `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--info)` |
|
|
73
|
+
| `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--info)` |
|
|
74
|
+
| `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--info)` at 12% over transparent |
|
|
75
|
+
| `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected drag (requires `showRejection`) | `var(--sc-kit--color--danger)` |
|
|
76
|
+
| `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected drag | `var(--sc-kit--color--danger)` at 12% over transparent |
|
|
77
|
+
| `--sc-kit--drop-zone--border-width` | Outline width in every state | `2px` |
|
|
81
78
|
| `--sc-kit--drop-zone--border-radius` | Outline radius | `var(--sc-kit--radius--sm)` |
|
|
79
|
+
| `--sc-kit--drop-zone--inset` | Outline inset from the zone edges; negative values outset it | `0px` |
|
|
82
80
|
-->
|
|
83
81
|
|
|
84
82
|
<style>.drop-zone {
|
|
85
|
-
--_dz--
|
|
86
|
-
--_dz--border-color: var(--sc-kit--drop-zone--border-color, var(--sc-kit--color--
|
|
83
|
+
--_dz--inset: var(--sc-kit--drop-zone--inset, 0px);
|
|
84
|
+
--_dz--border-color: var(--sc-kit--drop-zone--border-color, var(--sc-kit--color--info));
|
|
87
85
|
--_dz--border-color-hover: var(
|
|
88
86
|
--sc-kit--drop-zone--border-color--hover,
|
|
89
|
-
var(--sc-kit--color--
|
|
87
|
+
var(--sc-kit--color--info)
|
|
90
88
|
);
|
|
91
89
|
--_dz--background-hover: var(
|
|
92
90
|
--sc-kit--drop-zone--background--hover,
|
|
93
|
-
color-mix(in srgb, var(--sc-kit--color--
|
|
91
|
+
color-mix(in srgb, var(--sc-kit--color--info) 12%, transparent)
|
|
94
92
|
);
|
|
95
93
|
--_dz--border-color-reject: var(
|
|
96
94
|
--sc-kit--drop-zone--border-color--reject,
|
|
@@ -100,6 +98,7 @@ isn't in `acceptedEvents` — useful for visible zones where silent inertia coul
|
|
|
100
98
|
--sc-kit--drop-zone--background--reject,
|
|
101
99
|
color-mix(in srgb, var(--sc-kit--color--danger) 12%, transparent)
|
|
102
100
|
);
|
|
101
|
+
--_dz--border-width: var(--sc-kit--drop-zone--border-width, 2px);
|
|
103
102
|
--_dz--border-radius: var(--sc-kit--drop-zone--border-radius, var(--sc-kit--radius--sm));
|
|
104
103
|
width: 100%;
|
|
105
104
|
height: 100%;
|
|
@@ -111,10 +110,10 @@ isn't in `acceptedEvents` — useful for visible zones where silent inertia coul
|
|
|
111
110
|
.drop-zone--active::before {
|
|
112
111
|
content: "";
|
|
113
112
|
position: absolute;
|
|
114
|
-
inset:
|
|
113
|
+
inset: var(--_dz--inset);
|
|
115
114
|
pointer-events: none;
|
|
116
115
|
box-sizing: border-box;
|
|
117
|
-
border:
|
|
116
|
+
border: var(--_dz--border-width) dashed var(--_dz--border-color);
|
|
118
117
|
border-radius: var(--_dz--border-radius);
|
|
119
118
|
z-index: 2;
|
|
120
119
|
}
|
|
@@ -126,10 +125,10 @@ isn't in `acceptedEvents` — useful for visible zones where silent inertia coul
|
|
|
126
125
|
.drop-zone--drag-reject::before {
|
|
127
126
|
content: "";
|
|
128
127
|
position: absolute;
|
|
129
|
-
inset:
|
|
128
|
+
inset: var(--_dz--inset);
|
|
130
129
|
pointer-events: none;
|
|
131
130
|
box-sizing: border-box;
|
|
132
|
-
border:
|
|
131
|
+
border: var(--_dz--border-width) solid var(--_dz--border-color-reject);
|
|
133
132
|
background: var(--_dz--background-reject);
|
|
134
133
|
border-radius: var(--_dz--border-radius);
|
|
135
134
|
z-index: 2;
|
|
@@ -7,15 +7,16 @@ declare function $$render<T>(): {
|
|
|
7
7
|
* `type` field of whatever `DragSource` set on the shared store.
|
|
8
8
|
*/
|
|
9
9
|
acceptedEvents: string[];
|
|
10
|
+
/** Payload check on top of `acceptedEvents`; `false` refuses the drag exactly like a type mismatch. */
|
|
11
|
+
accepts?: (event: DragEventModel<T>) => boolean;
|
|
10
12
|
disabled?: boolean;
|
|
11
|
-
/** Offset (px) for the dashed-border overlay. Positive values outset, negative inset. @default 0 */
|
|
12
|
-
highlightOffset?: number;
|
|
13
13
|
/** Suppress the built-in dashed-border + fill visual; the host paints its own. */
|
|
14
14
|
silent?: boolean;
|
|
15
15
|
/**
|
|
16
|
-
* When `true`, the zone paints a red shield on hover if there's a drag in progress
|
|
17
|
-
* type
|
|
18
|
-
* think it accepts the dragged item — explicit refusal
|
|
16
|
+
* When `true`, the zone paints a red shield on hover if there's a drag in progress it
|
|
17
|
+
* refuses (type not in `acceptedEvents`, or `accepts` returned `false`). Useful when the
|
|
18
|
+
* zone is visible and the user might think it accepts the dragged item — explicit refusal
|
|
19
|
+
* beats silent inertia. @default false
|
|
19
20
|
*/
|
|
20
21
|
showRejection?: boolean;
|
|
21
22
|
children?: Snippet;
|
|
@@ -45,27 +46,21 @@ interface $$IsomorphicComponent {
|
|
|
45
46
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* hover (`dragover`) the outline becomes solid and the body fills with the accent tint. The
|
|
52
|
-
* consumer handles the actual drop via `on.drop`.
|
|
53
|
-
*
|
|
54
|
-
* Set `silent` when the host paints its own active / hover visuals; the zone keeps the event
|
|
55
|
-
* plumbing but skips the built-in chrome. Use `highlightOffset` to outset the dashed border
|
|
56
|
-
* (e.g. when the host has a rounded background that should remain visible inside the border).
|
|
57
|
-
* Pass `showRejection` to paint a red shield when the zone is hovered with a drag whose type
|
|
58
|
-
* isn't in `acceptedEvents` — useful for visible zones where silent inertia could be confusing.
|
|
49
|
+
* Drop target for in-app drags, paired with `DragSource` through the `DragAndDrop` singleton store.
|
|
50
|
+
* A drag it takes (by `acceptedEvents` and `accepts`) draws a dashed outline that turns solid over an
|
|
51
|
+
* info tint on hover, and its payload reaches `on.drop`.
|
|
59
52
|
*
|
|
60
53
|
* ### CSS Custom Properties
|
|
61
54
|
* | Property | Description | Default |
|
|
62
55
|
* |---|---|---|
|
|
63
|
-
* | `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--
|
|
64
|
-
* | `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--
|
|
65
|
-
* | `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--
|
|
66
|
-
* | `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected
|
|
67
|
-
* | `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected
|
|
56
|
+
* | `--sc-kit--drop-zone--border-color` | Dashed outline color (active, idle) | `var(--sc-kit--color--info)` |
|
|
57
|
+
* | `--sc-kit--drop-zone--border-color--hover` | Solid outline color on dragover | `var(--sc-kit--color--info)` |
|
|
58
|
+
* | `--sc-kit--drop-zone--background--hover` | Translucent fill on dragover (overlays content) | `var(--sc-kit--color--info)` at 12% over transparent |
|
|
59
|
+
* | `--sc-kit--drop-zone--border-color--reject` | Solid outline color when hovered with a rejected drag (requires `showRejection`) | `var(--sc-kit--color--danger)` |
|
|
60
|
+
* | `--sc-kit--drop-zone--background--reject` | Translucent fill when hovered with a rejected drag | `var(--sc-kit--color--danger)` at 12% over transparent |
|
|
61
|
+
* | `--sc-kit--drop-zone--border-width` | Outline width in every state | `2px` |
|
|
68
62
|
* | `--sc-kit--drop-zone--border-radius` | Outline radius | `var(--sc-kit--radius--sm)` |
|
|
63
|
+
* | `--sc-kit--drop-zone--inset` | Outline inset from the zone edges; negative values outset it | `0px` |
|
|
69
64
|
*/
|
|
70
65
|
declare const Cmp: $$IsomorphicComponent;
|
|
71
66
|
type Cmp<T> = InstanceType<typeof Cmp<T>>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script lang="ts">import { matchesAcceptedFileTypes } from '../../core/files';
|
|
2
|
+
const { accept = '', refused = false, disabled = false, hint, children, on } = $props();
|
|
3
|
+
let rootRef = $state();
|
|
4
|
+
let verdict = $state(null);
|
|
5
|
+
const isFileDrag = (e) => !!e.dataTransfer?.types.includes('Files');
|
|
6
|
+
const isOverNestedZone = (e) => {
|
|
7
|
+
const element = e.target instanceof Text ? e.target.parentElement : e.target;
|
|
8
|
+
return !(element instanceof Element) || element.closest('[data-file-drop-zone]') !== rootRef;
|
|
9
|
+
};
|
|
10
|
+
// An extension token can't be checked before the drop: the browser hides file names until then.
|
|
11
|
+
const acceptsType = (type) => !type ||
|
|
12
|
+
accept.split(',').some((token) => token.trim().startsWith('.')) ||
|
|
13
|
+
matchesAcceptedFileTypes(new File([], '', { type }), accept);
|
|
14
|
+
const evaluate = (dataTransfer) => {
|
|
15
|
+
if (refused) {
|
|
16
|
+
return 'reject';
|
|
17
|
+
}
|
|
18
|
+
const types = [...dataTransfer.items]
|
|
19
|
+
.filter((item) => item.kind === 'file')
|
|
20
|
+
.map((item) => item.type);
|
|
21
|
+
if (!types.length) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return types.some(acceptsType) ? 'accept' : 'reject';
|
|
25
|
+
};
|
|
26
|
+
const onDragOver = (e) => {
|
|
27
|
+
if (!isFileDrag(e) || !e.dataTransfer) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (isOverNestedZone(e)) {
|
|
31
|
+
verdict = null;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
verdict = disabled ? null : (evaluate(e.dataTransfer) ?? verdict ?? 'accept');
|
|
37
|
+
e.dataTransfer.dropEffect = verdict === 'accept' ? 'copy' : 'none';
|
|
38
|
+
};
|
|
39
|
+
const onDragLeave = (e) => {
|
|
40
|
+
if (!(e.relatedTarget instanceof Node) || !rootRef?.contains(e.relatedTarget)) {
|
|
41
|
+
verdict = null;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const onDrop = (e) => {
|
|
45
|
+
if (!isFileDrag(e)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
verdict = null;
|
|
49
|
+
if (isOverNestedZone(e)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
if (disabled || refused) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const files = [...(e.dataTransfer?.files ?? [])];
|
|
58
|
+
const accepted = files.filter((file) => matchesAcceptedFileTypes(file, accept));
|
|
59
|
+
const rejected = files.filter((file) => !accepted.includes(file));
|
|
60
|
+
if (accepted.length) {
|
|
61
|
+
on.drop(accepted);
|
|
62
|
+
}
|
|
63
|
+
if (rejected.length) {
|
|
64
|
+
on.reject?.(rejected);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<div
|
|
70
|
+
class="file-drop-zone"
|
|
71
|
+
class:file-drop-zone--active={verdict !== null}
|
|
72
|
+
data-file-drop-zone
|
|
73
|
+
bind:this={rootRef}
|
|
74
|
+
ondragovercapture={onDragOver}
|
|
75
|
+
ondragleave={onDragLeave}
|
|
76
|
+
ondropcapture={onDrop}
|
|
77
|
+
role="none">
|
|
78
|
+
{@render children()}
|
|
79
|
+
{#if verdict}
|
|
80
|
+
<div
|
|
81
|
+
class="file-drop-zone__shield"
|
|
82
|
+
class:file-drop-zone__shield--rejected={verdict === 'reject'}>
|
|
83
|
+
{#if hint}
|
|
84
|
+
<div class="file-drop-zone__hint">{@render hint({ rejected: verdict === 'reject' })}</div>
|
|
85
|
+
{/if}
|
|
86
|
+
</div>
|
|
87
|
+
{/if}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<!--
|
|
91
|
+
@component
|
|
92
|
+
Drop target for files dragged in from the OS: hovering files paint an info shield when they match
|
|
93
|
+
`accept` and a danger one otherwise, and `on.drop` receives only the matching files (the rest go to `on.reject`). A file drop never
|
|
94
|
+
reaches the browser, in-app drags pass through untouched, and of nested zones the innermost takes the
|
|
95
|
+
files.
|
|
96
|
+
|
|
97
|
+
### CSS Custom Properties
|
|
98
|
+
| Property | Description | Default |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `--sc-kit--file-drop-zone--color` | Outline and shield color for accepted files | `var(--sc-kit--color--info)` |
|
|
101
|
+
| `--sc-kit--file-drop-zone--color--reject` | Outline and shield color for rejected files | `var(--sc-kit--color--danger)` |
|
|
102
|
+
| `--sc-kit--file-drop-zone--border-width` | Shield outline width | `2px` |
|
|
103
|
+
| `--sc-kit--file-drop-zone--border-radius` | Shield radius | `var(--sc-kit--radius--sm)` |
|
|
104
|
+
| `--sc-kit--file-drop-zone--inset` | Shield inset from the zone edges | `0px` |
|
|
105
|
+
-->
|
|
106
|
+
|
|
107
|
+
<style>.file-drop-zone {
|
|
108
|
+
--_fdz--color: var(--sc-kit--file-drop-zone--color, var(--sc-kit--color--info));
|
|
109
|
+
--_fdz--color-reject: var(
|
|
110
|
+
--sc-kit--file-drop-zone--color--reject,
|
|
111
|
+
var(--sc-kit--color--danger)
|
|
112
|
+
);
|
|
113
|
+
--_fdz--border-width: var(--sc-kit--file-drop-zone--border-width, 2px);
|
|
114
|
+
--_fdz--border-radius: var(--sc-kit--file-drop-zone--border-radius, var(--sc-kit--radius--sm));
|
|
115
|
+
--_fdz--inset: var(--sc-kit--file-drop-zone--inset, 0px);
|
|
116
|
+
position: relative;
|
|
117
|
+
width: 100%;
|
|
118
|
+
height: 100%;
|
|
119
|
+
}
|
|
120
|
+
.file-drop-zone--active {
|
|
121
|
+
isolation: isolate;
|
|
122
|
+
}
|
|
123
|
+
.file-drop-zone__shield {
|
|
124
|
+
--_fdz--shield-color: var(--_fdz--color);
|
|
125
|
+
position: absolute;
|
|
126
|
+
inset: var(--_fdz--inset);
|
|
127
|
+
z-index: 2;
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
justify-content: center;
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
border: var(--_fdz--border-width) solid var(--_fdz--shield-color);
|
|
133
|
+
border-radius: var(--_fdz--border-radius);
|
|
134
|
+
background: color-mix(in srgb, var(--_fdz--shield-color) 12%, transparent);
|
|
135
|
+
}
|
|
136
|
+
.file-drop-zone__shield--rejected {
|
|
137
|
+
--_fdz--shield-color: var(--_fdz--color-reject);
|
|
138
|
+
}
|
|
139
|
+
.file-drop-zone__hint {
|
|
140
|
+
position: sticky;
|
|
141
|
+
inset-block: var(--sc-kit--space--4);
|
|
142
|
+
inline-size: fit-content;
|
|
143
|
+
max-inline-size: calc(100% - 2 * var(--sc-kit--space--2));
|
|
144
|
+
margin-inline: auto;
|
|
145
|
+
padding: var(--sc-kit--space--2) var(--sc-kit--space--4);
|
|
146
|
+
background: var(--sc-kit--color--bg--element);
|
|
147
|
+
border-radius: var(--sc-kit--radius--md);
|
|
148
|
+
box-shadow: var(--sc-kit--shadow--md);
|
|
149
|
+
}</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
type Props = {
|
|
3
|
+
/** Like `<input accept>`; `''` takes any file. @default '' */
|
|
4
|
+
accept?: string;
|
|
5
|
+
/** Files hovering the zone are shown as rejected and can't be dropped (e.g. while busy). */
|
|
6
|
+
refused?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
/** Content centered in the shield while files hover the zone. */
|
|
9
|
+
hint?: Snippet<[{
|
|
10
|
+
rejected: boolean;
|
|
11
|
+
}]>;
|
|
12
|
+
children: Snippet;
|
|
13
|
+
on: {
|
|
14
|
+
drop: (files: File[]) => void;
|
|
15
|
+
/** Dropped files that don't match `accept`; they never reach `drop`. */
|
|
16
|
+
reject?: (files: File[]) => void;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Drop target for files dragged in from the OS: hovering files paint an info shield when they match
|
|
21
|
+
* `accept` and a danger one otherwise, and `on.drop` receives only the matching files (the rest go to `on.reject`). A file drop never
|
|
22
|
+
* reaches the browser, in-app drags pass through untouched, and of nested zones the innermost takes the
|
|
23
|
+
* files.
|
|
24
|
+
*
|
|
25
|
+
* ### CSS Custom Properties
|
|
26
|
+
* | Property | Description | Default |
|
|
27
|
+
* |---|---|---|
|
|
28
|
+
* | `--sc-kit--file-drop-zone--color` | Outline and shield color for accepted files | `var(--sc-kit--color--info)` |
|
|
29
|
+
* | `--sc-kit--file-drop-zone--color--reject` | Outline and shield color for rejected files | `var(--sc-kit--color--danger)` |
|
|
30
|
+
* | `--sc-kit--file-drop-zone--border-width` | Shield outline width | `2px` |
|
|
31
|
+
* | `--sc-kit--file-drop-zone--border-radius` | Shield radius | `var(--sc-kit--radius--sm)` |
|
|
32
|
+
* | `--sc-kit--file-drop-zone--inset` | Shield inset from the zone edges | `0px` |
|
|
33
|
+
*/
|
|
34
|
+
declare const Cmp: import("svelte").Component<Props, {}, "">;
|
|
35
|
+
type Cmp = ReturnType<typeof Cmp>;
|
|
36
|
+
export default Cmp;
|
|
@@ -2,3 +2,4 @@ export type { DragEventModel } from './types';
|
|
|
2
2
|
export { DragAndDrop } from './drag-and-drop.svelte';
|
|
3
3
|
export { default as DragSource } from './cmp.drag-source.svelte';
|
|
4
4
|
export { default as DropZone } from './cmp.drop-zone.svelte';
|
|
5
|
+
export { default as FileDropZone } from './cmp.file-drop-zone.svelte';
|
|
@@ -132,10 +132,10 @@ via `DataTransfer.items` — extension-only accept tokens defer to drop).
|
|
|
132
132
|
| Property | Description | Default |
|
|
133
133
|
|---|---|---|
|
|
134
134
|
| `--sc-kit--file-uploader--background` | Drop-zone background | `var(--sc-kit--color--bg--subtle)` |
|
|
135
|
-
| `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--
|
|
135
|
+
| `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--info--soft)` |
|
|
136
136
|
| `--sc-kit--file-uploader--background--drag-invalid` | Background when a dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger--soft)` |
|
|
137
137
|
| `--sc-kit--file-uploader--border-color` | Dashed border color (idle) | `var(--sc-kit--color--border--strong)` |
|
|
138
|
-
| `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--
|
|
138
|
+
| `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--info)` |
|
|
139
139
|
| `--sc-kit--file-uploader--border-color--drag-invalid` | Dashed border color when dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger)` |
|
|
140
140
|
| `--sc-kit--file-uploader--border-radius` | Drop-zone radius | `var(--sc-kit--radius--lg)` |
|
|
141
141
|
| `--sc-kit--file-uploader--padding` | Inner padding | `var(--sc-kit--space--6)` |
|
|
@@ -152,7 +152,7 @@ via `DataTransfer.items` — extension-only accept tokens defer to drop).
|
|
|
152
152
|
--_fu--background: var(--sc-kit--file-uploader--background, var(--sc-kit--color--bg--subtle));
|
|
153
153
|
--_fu--background-drag: var(
|
|
154
154
|
--sc-kit--file-uploader--background--drag,
|
|
155
|
-
var(--sc-kit--color--
|
|
155
|
+
var(--sc-kit--color--info--soft)
|
|
156
156
|
);
|
|
157
157
|
--_fu--background-drag-invalid: var(
|
|
158
158
|
--sc-kit--file-uploader--background--drag-invalid,
|
|
@@ -164,7 +164,7 @@ via `DataTransfer.items` — extension-only accept tokens defer to drop).
|
|
|
164
164
|
);
|
|
165
165
|
--_fu--border-color-drag: var(
|
|
166
166
|
--sc-kit--file-uploader--border-color--drag,
|
|
167
|
-
var(--sc-kit--color--
|
|
167
|
+
var(--sc-kit--color--info)
|
|
168
168
|
);
|
|
169
169
|
--_fu--border-color-drag-invalid: var(
|
|
170
170
|
--sc-kit--file-uploader--border-color--drag-invalid,
|
|
@@ -43,10 +43,10 @@ type Props = {
|
|
|
43
43
|
* | Property | Description | Default |
|
|
44
44
|
* |---|---|---|
|
|
45
45
|
* | `--sc-kit--file-uploader--background` | Drop-zone background | `var(--sc-kit--color--bg--subtle)` |
|
|
46
|
-
* | `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--
|
|
46
|
+
* | `--sc-kit--file-uploader--background--drag` | Background during valid drag-over / hover | `var(--sc-kit--color--info--soft)` |
|
|
47
47
|
* | `--sc-kit--file-uploader--background--drag-invalid` | Background when a dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger--soft)` |
|
|
48
48
|
* | `--sc-kit--file-uploader--border-color` | Dashed border color (idle) | `var(--sc-kit--color--border--strong)` |
|
|
49
|
-
* | `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--
|
|
49
|
+
* | `--sc-kit--file-uploader--border-color--drag` | Dashed border color during valid drag-over / hover | `var(--sc-kit--color--info)` |
|
|
50
50
|
* | `--sc-kit--file-uploader--border-color--drag-invalid` | Dashed border color when dragged file's MIME does not match the Mime rule | `var(--sc-kit--color--danger)` |
|
|
51
51
|
* | `--sc-kit--file-uploader--border-radius` | Drop-zone radius | `var(--sc-kit--radius--lg)` |
|
|
52
52
|
* | `--sc-kit--file-uploader--padding` | Inner padding | `var(--sc-kit--space--6)` |
|