@tialro2/rnbokit 1.0.14 → 1.0.17
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 +242 -242
- package/dist/RNBO.css +113 -113
- package/dist/RNBO.svelte +230 -230
- package/dist/RNBO.svelte.d.ts +19 -18
- package/dist/RNBOcomponents/AudioDropIn.svelte +125 -125
- package/dist/RNBOcomponents/ExtMidiIn.svelte +85 -85
- package/dist/RNBOcomponents/ExtMidiIn.svelte.d.ts +2 -2
- package/dist/RNBOcomponents/ExtMidiOut.svelte +85 -85
- package/dist/RNBOcomponents/ExtMidiOut.svelte.d.ts +2 -2
- package/dist/RNBOcomponents/MicIn.svelte +80 -80
- package/dist/RNBOcomponents/RNBOInlet.svelte +66 -66
- package/dist/RNBOcomponents/RNBOInlet.svelte.d.ts +6 -6
- package/dist/RNBOcomponents/RNBOInport.svelte +21 -21
- package/dist/RNBOcomponents/RNBOMidiIn.svelte +63 -63
- package/dist/RNBOcomponents/RNBOMidiIn.svelte.d.ts +6 -6
- package/dist/RNBOcomponents/RNBOMidiOut.svelte +22 -22
- package/dist/RNBOcomponents/RNBOMidiOut.svelte.d.ts +4 -4
- package/dist/RNBOcomponents/RNBOOutport.svelte +36 -36
- package/dist/RNBOcomponents/RNBOOutport.svelte.d.ts +4 -4
- package/dist/RNBOcomponents/RNBOParam.svelte +37 -37
- package/dist/RNBOcomponents/XYMidiIn.svelte +93 -93
- package/dist/RNBOcomponents/XYMidiIn.svelte.d.ts +2 -2
- package/dist/UIcomponents/Controls.svelte +12 -12
- package/dist/UIcomponents/FileDropZone.svelte +118 -118
- package/dist/UIcomponents/ProgressBar.svelte +35 -35
- package/dist/UIcomponents/ProgressBar.svelte.d.ts +6 -6
- package/dist/UIcomponents/RadioGroup.svelte +27 -27
- package/dist/UIcomponents/RadioGroup.svelte.d.ts +4 -4
- package/dist/UIcomponents/RadioItem.svelte +96 -96
- package/dist/UIcomponents/RadioItem.svelte.d.ts +6 -6
- package/dist/UIcomponents/RangeSlider.svelte.d.ts +10 -10
- package/dist/index.js +20 -20
- package/package.json +7 -7
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import ProgressBar from '../UIcomponents/ProgressBar.svelte';
|
|
3
|
-
|
|
4
|
-
/** @type {import ('@rnbo/js').MessagePayload } */
|
|
5
|
-
let value = $state(0);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {Object} Props
|
|
9
|
-
* @property {import ('@rnbo/js').MessageInfo} outport
|
|
10
|
-
* @property {import ('@rnbo/js').Device} device
|
|
11
|
-
* @property {number} [min]
|
|
12
|
-
* @property {number} [max]
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/** @type {Props & { [key: string]: any }} */
|
|
16
|
-
let { outport, device, min = 0, max = 1, ...rest } = $props();
|
|
17
|
-
|
|
18
|
-
$effect(() => {
|
|
19
|
-
device.messageEvent.subscribe((ev) => {
|
|
20
|
-
if (ev.tag == outport.tag) {
|
|
21
|
-
value = ev.payload;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
</script>
|
|
26
|
-
|
|
27
|
-
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
28
|
-
<div class="RNBOalign">
|
|
29
|
-
<div class="RNBOtag">{outport.tag}</div>
|
|
30
|
-
<!-- some hack to make the value max 2 decimal floats: -->
|
|
31
|
-
<div class="RNBOval">{+parseFloat(value).toFixed(2)}</div>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
<p class="RNBOtext">{outport.meta.slice(1, -1)}</p>
|
|
35
|
-
<ProgressBar value={Array.isArray(value) ? value[0] : value} {max} {min} />
|
|
36
|
-
</div>
|
|
1
|
+
<script>
|
|
2
|
+
import ProgressBar from '../UIcomponents/ProgressBar.svelte';
|
|
3
|
+
|
|
4
|
+
/** @type {import ('@rnbo/js').MessagePayload } */
|
|
5
|
+
let value = $state(0);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} Props
|
|
9
|
+
* @property {import ('@rnbo/js').MessageInfo} outport
|
|
10
|
+
* @property {import ('@rnbo/js').Device} device
|
|
11
|
+
* @property {number} [min]
|
|
12
|
+
* @property {number} [max]
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** @type {Props & { [key: string]: any }} */
|
|
16
|
+
let { outport, device, min = 0, max = 1, ...rest } = $props();
|
|
17
|
+
|
|
18
|
+
$effect(() => {
|
|
19
|
+
device.messageEvent.subscribe((ev) => {
|
|
20
|
+
if (ev.tag == outport.tag) {
|
|
21
|
+
value = ev.payload;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
28
|
+
<div class="RNBOalign">
|
|
29
|
+
<div class="RNBOtag">{outport.tag}</div>
|
|
30
|
+
<!-- some hack to make the value max 2 decimal floats: -->
|
|
31
|
+
<div class="RNBOval">{+parseFloat(value).toFixed(2)}</div>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<p class="RNBOtext">{outport.meta.slice(1, -1)}</p>
|
|
35
|
+
<ProgressBar value={Array.isArray(value) ? value[0] : value} {max} {min} />
|
|
36
|
+
</div>
|
|
@@ -8,14 +8,14 @@ type RNBOOutport = {
|
|
|
8
8
|
declare const RNBOOutport: import("svelte").Component<{
|
|
9
9
|
outport: import("@rnbo/js").MessageInfo;
|
|
10
10
|
device: import("@rnbo/js").Device;
|
|
11
|
-
min?: number;
|
|
12
|
-
max?: number;
|
|
11
|
+
min?: number | undefined;
|
|
12
|
+
max?: number | undefined;
|
|
13
13
|
} & {
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
}, {}, "">;
|
|
16
16
|
type Props = {
|
|
17
17
|
outport: import("@rnbo/js").MessageInfo;
|
|
18
18
|
device: import("@rnbo/js").Device;
|
|
19
|
-
min?: number;
|
|
20
|
-
max?: number;
|
|
19
|
+
min?: number | undefined;
|
|
20
|
+
max?: number | undefined;
|
|
21
21
|
};
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import RangeSlider from '../UIcomponents/RangeSlider.svelte';
|
|
3
|
-
import RadioGroup from '../UIcomponents/RadioGroup.svelte';
|
|
4
|
-
import RadioItem from '../UIcomponents/RadioItem.svelte';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @typedef {Object} Props
|
|
8
|
-
* @property {import ('@rnbo/js').Parameter} parameter
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** @type {Props & { [key: string]: any }} */
|
|
12
|
-
let { parameter = $bindable(), ...rest } = $props();
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
16
|
-
{#if parameter.enumValues}
|
|
17
|
-
<div class="RNBOtag">{parameter.name}</div>
|
|
18
|
-
<RadioGroup>
|
|
19
|
-
{#each parameter.enumValues as enumValue, i}
|
|
20
|
-
<RadioItem bind:group={parameter.value} name="justify" value={i}>{enumValue}</RadioItem>
|
|
21
|
-
{/each}
|
|
22
|
-
</RadioGroup>
|
|
23
|
-
{:else}
|
|
24
|
-
<div class="RNBOalign">
|
|
25
|
-
<div class="RNBOtag">{parameter.name}</div>
|
|
26
|
-
<!-- some hack to make the value max 2 decimal floats: -->
|
|
27
|
-
<div class="RNBOval">{+parseFloat(value).toFixed(2)} / {parameter.max}</div>
|
|
28
|
-
</div>
|
|
29
|
-
<RangeSlider
|
|
30
|
-
name="range-slider"
|
|
31
|
-
bind:value={parameter.value}
|
|
32
|
-
min={parameter.min}
|
|
33
|
-
max={parameter.max}
|
|
34
|
-
step={0.01}
|
|
35
|
-
/>
|
|
36
|
-
{/if}
|
|
37
|
-
</div>
|
|
1
|
+
<script>
|
|
2
|
+
import RangeSlider from '../UIcomponents/RangeSlider.svelte';
|
|
3
|
+
import RadioGroup from '../UIcomponents/RadioGroup.svelte';
|
|
4
|
+
import RadioItem from '../UIcomponents/RadioItem.svelte';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} Props
|
|
8
|
+
* @property {import ('@rnbo/js').Parameter} parameter
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** @type {Props & { [key: string]: any }} */
|
|
12
|
+
let { parameter = $bindable(), ...rest } = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div class="RNBOcomponent RNBOsection" {...rest}>
|
|
16
|
+
{#if parameter.enumValues}
|
|
17
|
+
<div class="RNBOtag">{parameter.name}</div>
|
|
18
|
+
<RadioGroup>
|
|
19
|
+
{#each parameter.enumValues as enumValue, i}
|
|
20
|
+
<RadioItem bind:group={parameter.value} name="justify" value={i}>{enumValue}</RadioItem>
|
|
21
|
+
{/each}
|
|
22
|
+
</RadioGroup>
|
|
23
|
+
{:else}
|
|
24
|
+
<div class="RNBOalign">
|
|
25
|
+
<div class="RNBOtag">{parameter.name}</div>
|
|
26
|
+
<!-- some hack to make the value max 2 decimal floats: -->
|
|
27
|
+
<div class="RNBOval">{+parseFloat(value).toFixed(2)} / {parameter.max}</div>
|
|
28
|
+
</div>
|
|
29
|
+
<RangeSlider
|
|
30
|
+
name="range-slider"
|
|
31
|
+
bind:value={parameter.value}
|
|
32
|
+
min={parameter.min}
|
|
33
|
+
max={parameter.max}
|
|
34
|
+
step={0.01}
|
|
35
|
+
/>
|
|
36
|
+
{/if}
|
|
37
|
+
</div>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
|
|
3
|
-
/** @type {Uint8Array} */
|
|
4
|
-
let currentNote = $state(new Uint8Array([0, 0]));
|
|
5
|
-
|
|
1
|
+
<script>
|
|
2
|
+
|
|
3
|
+
/** @type {Uint8Array} */
|
|
4
|
+
let currentNote = $state(new Uint8Array([0, 0]));
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {Object} Props
|
|
8
8
|
* @property {number} [midiChannel]
|
|
@@ -11,91 +11,91 @@
|
|
|
11
11
|
|
|
12
12
|
/** @type {Props & { [key: string]: any }} */
|
|
13
13
|
let { midiChannel = 0, midiMessage = $bindable(), ...rest } = $props();
|
|
14
|
-
let isOn = $state(false);
|
|
15
|
-
|
|
16
|
-
/** @param {MouseEvent} e */
|
|
17
|
-
function NoteOn(e) {
|
|
18
|
-
// @ts-ignore - ts not knowing getBoundingClientRect()
|
|
19
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
20
|
-
currentNote[0] = Math.round(((e.clientX - rect.left) / rect.width) * 127);
|
|
21
|
-
currentNote[1] = Math.round((1 - (e.clientY - rect.top) / rect.height) * 127);
|
|
22
|
-
midiMessage = new Uint8Array([midiChannel + 144, ...currentNote]);
|
|
23
|
-
isOn = true;
|
|
24
|
-
// console.log('from XYMidiIn', midiMessage);
|
|
25
|
-
}
|
|
26
|
-
function NoteOff() {
|
|
27
|
-
if (!isOn) return;
|
|
28
|
-
// currentNote[1] = 0;
|
|
29
|
-
midiMessage = new Uint8Array([midiChannel + 128, ...currentNote]);
|
|
30
|
-
isOn = false;
|
|
31
|
-
}
|
|
32
|
-
//preview the note and velocity value on hover
|
|
33
|
-
/** @param {MouseEvent} e */
|
|
34
|
-
function NoteUpdate(e) {
|
|
35
|
-
if (isOn) return;
|
|
36
|
-
// @ts-ignore - ts not knowing getBoundingClientRect()
|
|
37
|
-
const rect = e.currentTarget.getBoundingClientRect();
|
|
38
|
-
currentNote[0] = Math.round(((e.clientX - rect.left) / rect.width) * 127);
|
|
39
|
-
currentNote[1] = Math.round((1 - (e.clientY - rect.top) / rect.height) * 127);
|
|
40
|
-
}
|
|
41
|
-
</script>
|
|
42
|
-
|
|
43
|
-
<svelte:window onmouseup={NoteOff} />
|
|
44
|
-
<div class="RNBOsubcomponent" {...rest}>
|
|
45
|
-
<p class="RNBOtext">click the pad to generate MIDI notes</p>
|
|
46
|
-
<!-- TODO: fix accessibility roles, quick hack for now -->
|
|
47
|
-
<div
|
|
48
|
-
class="xy"
|
|
49
|
-
id="group"
|
|
50
|
-
onmousedown={NoteOn}
|
|
51
|
-
onmousemove={NoteUpdate}
|
|
52
|
-
onkeydown={NoteOn}
|
|
53
|
-
role="none"
|
|
54
|
-
>
|
|
55
|
-
<p class="xyval" class:text-gray-500={!isOn}>
|
|
56
|
-
note: {currentNote[0]} | velocity: {currentNote[1]}
|
|
57
|
-
</p>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<style>
|
|
62
|
-
.xy {
|
|
63
|
-
/* @apply group card flex align-center justify-center p-4 m-4 max-w-md min-h-max select-none hover:bg-primary-hover-token active:bg-primary-active-token */
|
|
64
|
-
display: flex;
|
|
65
|
-
justify-content: center;
|
|
66
|
-
align-items: center;
|
|
67
|
-
padding: 5rem;
|
|
68
|
-
margin-top: 1rem;
|
|
69
|
-
max-width: 28rem /* 448px */;
|
|
70
|
-
min-height: max-content;
|
|
71
|
-
user-select: none;
|
|
72
|
-
background-color: rgba(var(--local-accent-color), 0.1);
|
|
73
|
-
border-radius: var(--local-rounded-container);
|
|
74
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
75
|
-
transition-timing-function: var(--local-animation-function);
|
|
76
|
-
}
|
|
77
|
-
.xy:hover {
|
|
78
|
-
background-color: rgba(var(--local-accent-color), 0.3);
|
|
79
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
80
|
-
transition-timing-function: var(--local-animation-function);
|
|
81
|
-
}
|
|
82
|
-
.xy:active {
|
|
83
|
-
background-color: rgb(var(--local-accent-color)) !important;
|
|
84
|
-
/* color: black; */
|
|
85
|
-
fill: rgb(var(--local-accent-color));
|
|
86
|
-
transition: var(--local-animation) calc(var(--local-animation-duration) / 3);
|
|
87
|
-
transition-timing-function: var(--local-animation-function);
|
|
88
|
-
}
|
|
89
|
-
.xy .xyval {
|
|
90
|
-
/* visibility: hidden; */
|
|
91
|
-
color: rgba(var(--local-font-color), 0);
|
|
92
|
-
}
|
|
93
|
-
.xy:hover .xyval {
|
|
94
|
-
/* color: blue; */
|
|
95
|
-
color: rgba(var(--local-font-color), 0.5);
|
|
96
|
-
}
|
|
97
|
-
.xy:active .xyval {
|
|
98
|
-
/* color: black; */
|
|
99
|
-
color: rgb(var(--local-font-color));
|
|
100
|
-
}
|
|
101
|
-
</style>
|
|
14
|
+
let isOn = $state(false);
|
|
15
|
+
|
|
16
|
+
/** @param {MouseEvent} e */
|
|
17
|
+
function NoteOn(e) {
|
|
18
|
+
// @ts-ignore - ts not knowing getBoundingClientRect()
|
|
19
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
20
|
+
currentNote[0] = Math.round(((e.clientX - rect.left) / rect.width) * 127);
|
|
21
|
+
currentNote[1] = Math.round((1 - (e.clientY - rect.top) / rect.height) * 127);
|
|
22
|
+
midiMessage = new Uint8Array([midiChannel + 144, ...currentNote]);
|
|
23
|
+
isOn = true;
|
|
24
|
+
// console.log('from XYMidiIn', midiMessage);
|
|
25
|
+
}
|
|
26
|
+
function NoteOff() {
|
|
27
|
+
if (!isOn) return;
|
|
28
|
+
// currentNote[1] = 0;
|
|
29
|
+
midiMessage = new Uint8Array([midiChannel + 128, ...currentNote]);
|
|
30
|
+
isOn = false;
|
|
31
|
+
}
|
|
32
|
+
//preview the note and velocity value on hover
|
|
33
|
+
/** @param {MouseEvent} e */
|
|
34
|
+
function NoteUpdate(e) {
|
|
35
|
+
if (isOn) return;
|
|
36
|
+
// @ts-ignore - ts not knowing getBoundingClientRect()
|
|
37
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
38
|
+
currentNote[0] = Math.round(((e.clientX - rect.left) / rect.width) * 127);
|
|
39
|
+
currentNote[1] = Math.round((1 - (e.clientY - rect.top) / rect.height) * 127);
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<svelte:window onmouseup={NoteOff} />
|
|
44
|
+
<div class="RNBOsubcomponent" {...rest}>
|
|
45
|
+
<p class="RNBOtext">click the pad to generate MIDI notes</p>
|
|
46
|
+
<!-- TODO: fix accessibility roles, quick hack for now -->
|
|
47
|
+
<div
|
|
48
|
+
class="xy"
|
|
49
|
+
id="group"
|
|
50
|
+
onmousedown={NoteOn}
|
|
51
|
+
onmousemove={NoteUpdate}
|
|
52
|
+
onkeydown={NoteOn}
|
|
53
|
+
role="none"
|
|
54
|
+
>
|
|
55
|
+
<p class="xyval" class:text-gray-500={!isOn}>
|
|
56
|
+
note: {currentNote[0]} | velocity: {currentNote[1]}
|
|
57
|
+
</p>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
.xy {
|
|
63
|
+
/* @apply group card flex align-center justify-center p-4 m-4 max-w-md min-h-max select-none hover:bg-primary-hover-token active:bg-primary-active-token */
|
|
64
|
+
display: flex;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
align-items: center;
|
|
67
|
+
padding: 5rem;
|
|
68
|
+
margin-top: 1rem;
|
|
69
|
+
max-width: 28rem /* 448px */;
|
|
70
|
+
min-height: max-content;
|
|
71
|
+
user-select: none;
|
|
72
|
+
background-color: rgba(var(--local-accent-color), 0.1);
|
|
73
|
+
border-radius: var(--local-rounded-container);
|
|
74
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
75
|
+
transition-timing-function: var(--local-animation-function);
|
|
76
|
+
}
|
|
77
|
+
.xy:hover {
|
|
78
|
+
background-color: rgba(var(--local-accent-color), 0.3);
|
|
79
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
80
|
+
transition-timing-function: var(--local-animation-function);
|
|
81
|
+
}
|
|
82
|
+
.xy:active {
|
|
83
|
+
background-color: rgb(var(--local-accent-color)) !important;
|
|
84
|
+
/* color: black; */
|
|
85
|
+
fill: rgb(var(--local-accent-color));
|
|
86
|
+
transition: var(--local-animation) calc(var(--local-animation-duration) / 3);
|
|
87
|
+
transition-timing-function: var(--local-animation-function);
|
|
88
|
+
}
|
|
89
|
+
.xy .xyval {
|
|
90
|
+
/* visibility: hidden; */
|
|
91
|
+
color: rgba(var(--local-font-color), 0);
|
|
92
|
+
}
|
|
93
|
+
.xy:hover .xyval {
|
|
94
|
+
/* color: blue; */
|
|
95
|
+
color: rgba(var(--local-font-color), 0.5);
|
|
96
|
+
}
|
|
97
|
+
.xy:active .xyval {
|
|
98
|
+
/* color: black; */
|
|
99
|
+
color: rgb(var(--local-font-color));
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -6,12 +6,12 @@ type XYMidiIn = {
|
|
|
6
6
|
}>): void;
|
|
7
7
|
};
|
|
8
8
|
declare const XYMidiIn: import("svelte").Component<{
|
|
9
|
-
midiChannel?: number;
|
|
9
|
+
midiChannel?: number | undefined;
|
|
10
10
|
midiMessage: Uint8Array;
|
|
11
11
|
} & {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
}, {}, "midiMessage">;
|
|
14
14
|
type Props = {
|
|
15
|
-
midiChannel?: number;
|
|
15
|
+
midiChannel?: number | undefined;
|
|
16
16
|
midiMessage: Uint8Array;
|
|
17
17
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
interface Props {
|
|
3
|
-
tag: string;
|
|
4
|
-
sendMessage: () => void;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
let { tag, sendMessage }: Props = $props();
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<button onclick={sendMessage}>
|
|
11
|
-
<img src="/{tag}.png" alt={tag} />
|
|
12
|
-
</button>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
tag: string;
|
|
4
|
+
sendMessage: () => void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
let { tag, sendMessage }: Props = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<button onclick={sendMessage}>
|
|
11
|
+
<img src="/{tag}.png" alt={tag} />
|
|
12
|
+
</button>
|
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
let {
|
|
3
|
-
files = $bindable(void 0),
|
|
4
|
-
name,
|
|
5
|
-
lead,
|
|
6
|
-
message,
|
|
7
|
-
meta,
|
|
8
|
-
ondragenter,
|
|
9
|
-
ondragleave,
|
|
10
|
-
onchange,
|
|
11
|
-
ondragover,
|
|
12
|
-
ondrop,
|
|
13
|
-
onclick,
|
|
14
|
-
onkeydown,
|
|
15
|
-
onkeyup,
|
|
16
|
-
onkeypress,
|
|
17
|
-
...rest
|
|
18
|
-
} = $props();
|
|
19
|
-
let dragOver = $state(false);
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<div class="RNBOdropzone" data-testid="file-dropzone">
|
|
23
|
-
<!-- Input: File (hidden) -->
|
|
24
|
-
<!-- NOTE: keep `bind:files` here, unlike FileButton -->
|
|
25
|
-
<input
|
|
26
|
-
bind:files
|
|
27
|
-
type="file"
|
|
28
|
-
{name}
|
|
29
|
-
{...rest}
|
|
30
|
-
class="RNBOdropzone-input"
|
|
31
|
-
class:RNBOdrag={dragOver}
|
|
32
|
-
ondragenter={() => {
|
|
33
|
-
dragOver = true;
|
|
34
|
-
ondragenter();
|
|
35
|
-
}}
|
|
36
|
-
ondragleave={() => {
|
|
37
|
-
dragOver = false;
|
|
38
|
-
ondragleave();
|
|
39
|
-
}}
|
|
40
|
-
{onchange}
|
|
41
|
-
{ondragover}
|
|
42
|
-
{ondrop}
|
|
43
|
-
{onclick}
|
|
44
|
-
{onkeydown}
|
|
45
|
-
{onkeyup}
|
|
46
|
-
{onkeypress}
|
|
47
|
-
/>
|
|
48
|
-
<!-- Interface -->
|
|
49
|
-
<div class="RNBOdropzone-interface">
|
|
50
|
-
<div class="dropzone-interface-text">
|
|
51
|
-
<!-- Lead -->
|
|
52
|
-
{#if lead}<div class="RNBOdropzone-lead">{@render lead?.()}</div>{/if}
|
|
53
|
-
<!-- Message -->
|
|
54
|
-
<div class="RNBOdropzone-message">
|
|
55
|
-
{#if message}{@render message()}{:else}<strong>Upload files</strong> or drag and drop{/if}
|
|
56
|
-
</div>
|
|
57
|
-
<!-- Meta Text -->
|
|
58
|
-
{#if meta}<small class="RNBOdropzone-meta">{@render meta?.()}</small>{/if}
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<style>
|
|
64
|
-
.RNBOdropzone {
|
|
65
|
-
display: flex;
|
|
66
|
-
position: relative;
|
|
67
|
-
padding: 1rem;
|
|
68
|
-
padding-top: 2rem;
|
|
69
|
-
padding-bottom: 2rem;
|
|
70
|
-
justify-content: center;
|
|
71
|
-
align-items: center;
|
|
72
|
-
border-width: 2px;
|
|
73
|
-
border-style: dashed;
|
|
74
|
-
border-radius: var(--local-rounded-container);
|
|
75
|
-
border-color: rgb(var(--local-surface-color));
|
|
76
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
77
|
-
transition-timing-function: var(--local-animation-function);
|
|
78
|
-
}
|
|
79
|
-
.RNBOdrag {
|
|
80
|
-
background-color: rgba(var(--local-accent-color), 0.2);
|
|
81
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
82
|
-
transition-timing-function: var(--local-animation-function);
|
|
83
|
-
}
|
|
84
|
-
.RNBOdropzone:hover {
|
|
85
|
-
background-color: rgba(var(--local-accent-color), 0.2);
|
|
86
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
87
|
-
transition-timing-function: var(--local-animation-function);
|
|
88
|
-
}
|
|
89
|
-
.RNBOdropzone:active {
|
|
90
|
-
background-color: rgba(var(--local-accent-color), 0.5);
|
|
91
|
-
transition: var(--local-animation) var(--local-animation-duration);
|
|
92
|
-
transition-timing-function: var(--local-animation-function);
|
|
93
|
-
}
|
|
94
|
-
.RNBOdropzone-input {
|
|
95
|
-
position: absolute;
|
|
96
|
-
top: 0;
|
|
97
|
-
right: 0;
|
|
98
|
-
bottom: 0;
|
|
99
|
-
left: 0;
|
|
100
|
-
width: 100%;
|
|
101
|
-
cursor: pointer;
|
|
102
|
-
opacity: 0;
|
|
103
|
-
}
|
|
104
|
-
.RNBOdropzone-interface {
|
|
105
|
-
display: flex;
|
|
106
|
-
text-align: center;
|
|
107
|
-
justify-content: center;
|
|
108
|
-
align-items: center;
|
|
109
|
-
}
|
|
110
|
-
/* .RNBOdropzone-interface-text { */
|
|
111
|
-
/* } */
|
|
112
|
-
.RNBOdropzone-meta {
|
|
113
|
-
opacity: 0.75;
|
|
114
|
-
}
|
|
115
|
-
.RNBOdropzone-lead {
|
|
116
|
-
margin-bottom: 1rem;
|
|
117
|
-
}
|
|
118
|
-
</style>
|
|
1
|
+
<script>
|
|
2
|
+
let {
|
|
3
|
+
files = $bindable(void 0),
|
|
4
|
+
name,
|
|
5
|
+
lead,
|
|
6
|
+
message,
|
|
7
|
+
meta,
|
|
8
|
+
ondragenter,
|
|
9
|
+
ondragleave,
|
|
10
|
+
onchange,
|
|
11
|
+
ondragover,
|
|
12
|
+
ondrop,
|
|
13
|
+
onclick,
|
|
14
|
+
onkeydown,
|
|
15
|
+
onkeyup,
|
|
16
|
+
onkeypress,
|
|
17
|
+
...rest
|
|
18
|
+
} = $props();
|
|
19
|
+
let dragOver = $state(false);
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<div class="RNBOdropzone" data-testid="file-dropzone">
|
|
23
|
+
<!-- Input: File (hidden) -->
|
|
24
|
+
<!-- NOTE: keep `bind:files` here, unlike FileButton -->
|
|
25
|
+
<input
|
|
26
|
+
bind:files
|
|
27
|
+
type="file"
|
|
28
|
+
{name}
|
|
29
|
+
{...rest}
|
|
30
|
+
class="RNBOdropzone-input"
|
|
31
|
+
class:RNBOdrag={dragOver}
|
|
32
|
+
ondragenter={() => {
|
|
33
|
+
dragOver = true;
|
|
34
|
+
ondragenter();
|
|
35
|
+
}}
|
|
36
|
+
ondragleave={() => {
|
|
37
|
+
dragOver = false;
|
|
38
|
+
ondragleave();
|
|
39
|
+
}}
|
|
40
|
+
{onchange}
|
|
41
|
+
{ondragover}
|
|
42
|
+
{ondrop}
|
|
43
|
+
{onclick}
|
|
44
|
+
{onkeydown}
|
|
45
|
+
{onkeyup}
|
|
46
|
+
{onkeypress}
|
|
47
|
+
/>
|
|
48
|
+
<!-- Interface -->
|
|
49
|
+
<div class="RNBOdropzone-interface">
|
|
50
|
+
<div class="dropzone-interface-text">
|
|
51
|
+
<!-- Lead -->
|
|
52
|
+
{#if lead}<div class="RNBOdropzone-lead">{@render lead?.()}</div>{/if}
|
|
53
|
+
<!-- Message -->
|
|
54
|
+
<div class="RNBOdropzone-message">
|
|
55
|
+
{#if message}{@render message()}{:else}<strong>Upload files</strong> or drag and drop{/if}
|
|
56
|
+
</div>
|
|
57
|
+
<!-- Meta Text -->
|
|
58
|
+
{#if meta}<small class="RNBOdropzone-meta">{@render meta?.()}</small>{/if}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<style>
|
|
64
|
+
.RNBOdropzone {
|
|
65
|
+
display: flex;
|
|
66
|
+
position: relative;
|
|
67
|
+
padding: 1rem;
|
|
68
|
+
padding-top: 2rem;
|
|
69
|
+
padding-bottom: 2rem;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
align-items: center;
|
|
72
|
+
border-width: 2px;
|
|
73
|
+
border-style: dashed;
|
|
74
|
+
border-radius: var(--local-rounded-container);
|
|
75
|
+
border-color: rgb(var(--local-surface-color));
|
|
76
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
77
|
+
transition-timing-function: var(--local-animation-function);
|
|
78
|
+
}
|
|
79
|
+
.RNBOdrag {
|
|
80
|
+
background-color: rgba(var(--local-accent-color), 0.2);
|
|
81
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
82
|
+
transition-timing-function: var(--local-animation-function);
|
|
83
|
+
}
|
|
84
|
+
.RNBOdropzone:hover {
|
|
85
|
+
background-color: rgba(var(--local-accent-color), 0.2);
|
|
86
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
87
|
+
transition-timing-function: var(--local-animation-function);
|
|
88
|
+
}
|
|
89
|
+
.RNBOdropzone:active {
|
|
90
|
+
background-color: rgba(var(--local-accent-color), 0.5);
|
|
91
|
+
transition: var(--local-animation) var(--local-animation-duration);
|
|
92
|
+
transition-timing-function: var(--local-animation-function);
|
|
93
|
+
}
|
|
94
|
+
.RNBOdropzone-input {
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 0;
|
|
97
|
+
right: 0;
|
|
98
|
+
bottom: 0;
|
|
99
|
+
left: 0;
|
|
100
|
+
width: 100%;
|
|
101
|
+
cursor: pointer;
|
|
102
|
+
opacity: 0;
|
|
103
|
+
}
|
|
104
|
+
.RNBOdropzone-interface {
|
|
105
|
+
display: flex;
|
|
106
|
+
text-align: center;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
align-items: center;
|
|
109
|
+
}
|
|
110
|
+
/* .RNBOdropzone-interface-text { */
|
|
111
|
+
/* } */
|
|
112
|
+
.RNBOdropzone-meta {
|
|
113
|
+
opacity: 0.75;
|
|
114
|
+
}
|
|
115
|
+
.RNBOdropzone-lead {
|
|
116
|
+
margin-bottom: 1rem;
|
|
117
|
+
}
|
|
118
|
+
</style>
|