@tialro2/rnbokit 1.0.15 → 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.
@@ -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>
@@ -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>
@@ -1,4 +1,4 @@
1
- <script>
1
+ <script>
2
2
  /**
3
3
  * @typedef {Object} Props
4
4
  * @property {any} [value]
@@ -14,37 +14,37 @@
14
14
  max = 100,
15
15
  labelledby = ''
16
16
  } = $props();
17
- let fillPercent = $derived(value ? (100 * (value - min)) / (max - min) : 0);
18
- </script>
19
-
20
- <!-- Track -->
21
- <div
22
- class="RNBOprogress-bar"
23
- data-testid="progress-bar"
24
- role="progressbar"
25
- aria-labelledby={labelledby}
26
- aria-valuenow={value}
27
- aria-valuemin={min}
28
- aria-valuemax={max - min}
29
- >
30
- <!-- Meter -->
31
- <div class="RNBOprogress-bar-meter" style:width="{fillPercent}%"></div>
32
- </div>
33
-
34
- <style>
35
- .RNBOprogress-bar {
36
- overflow: hidden;
37
- width: 100%;
38
- height: 6px;
39
- border-radius: var(--local-rounded-base);
40
- border-style: solid;
41
- border-color: rgba(var(--local-surface-color), 0.5);
42
- border-width: 0.5px;
43
- background-color: white;
44
- }
45
- .RNBOprogress-bar-meter {
46
- height: 100%;
47
- border-radius: var(--local-rounded-base);
48
- background-color: rgb(var(--local-accent-color));
49
- }
50
- </style>
17
+ let fillPercent = $derived(value ? (100 * (value - min)) / (max - min) : 0);
18
+ </script>
19
+
20
+ <!-- Track -->
21
+ <div
22
+ class="RNBOprogress-bar"
23
+ data-testid="progress-bar"
24
+ role="progressbar"
25
+ aria-labelledby={labelledby}
26
+ aria-valuenow={value}
27
+ aria-valuemin={min}
28
+ aria-valuemax={max - min}
29
+ >
30
+ <!-- Meter -->
31
+ <div class="RNBOprogress-bar-meter" style:width="{fillPercent}%"></div>
32
+ </div>
33
+
34
+ <style>
35
+ .RNBOprogress-bar {
36
+ overflow: hidden;
37
+ width: 100%;
38
+ height: 6px;
39
+ border-radius: var(--local-rounded-base);
40
+ border-style: solid;
41
+ border-color: rgba(var(--local-surface-color), 0.5);
42
+ border-width: 0.5px;
43
+ background-color: white;
44
+ }
45
+ .RNBOprogress-bar-meter {
46
+ height: 100%;
47
+ border-radius: var(--local-rounded-base);
48
+ background-color: rgb(var(--local-accent-color));
49
+ }
50
+ </style>
@@ -1,4 +1,4 @@
1
- <script>
1
+ <script>
2
2
  /**
3
3
  * @typedef {Object} Props
4
4
  * @property {string} [labelledby]
@@ -7,29 +7,29 @@
7
7
 
8
8
  /** @type {Props} */
9
9
  let { labelledby = '', children } = $props();
10
- </script>
11
-
12
- <div
13
- class="RNBOradio-group"
14
- data-testid="radio-group"
15
- role="radiogroup"
16
- aria-labelledby={labelledby}
17
- >
18
- {@render children?.()}
19
- </div>
20
-
21
- <style>
22
- .RNBOradio-group {
23
- display: inline-flex;
24
- flex-wrap: wrap;
25
- margin-left: 0.25rem;
26
- background-color: rgba(var(--local-surface-color), 0);
27
- border-width: var(--local-border-base);
28
- border-color: rgb(var(--local-surface-color));
29
- border-style: solid;
30
- border-radius: var(--local-rounded-base);
31
- }
32
- /* .RNBOradio-group:hover { */
33
- /* background-color: rgba(var(--local-surface-color), 0.2); */
34
- /* } */
35
- </style>
10
+ </script>
11
+
12
+ <div
13
+ class="RNBOradio-group"
14
+ data-testid="radio-group"
15
+ role="radiogroup"
16
+ aria-labelledby={labelledby}
17
+ >
18
+ {@render children?.()}
19
+ </div>
20
+
21
+ <style>
22
+ .RNBOradio-group {
23
+ display: inline-flex;
24
+ flex-wrap: wrap;
25
+ margin-left: 0.25rem;
26
+ background-color: rgba(var(--local-surface-color), 0);
27
+ border-width: var(--local-border-base);
28
+ border-color: rgb(var(--local-surface-color));
29
+ border-style: solid;
30
+ border-radius: var(--local-rounded-base);
31
+ }
32
+ /* .RNBOradio-group:hover { */
33
+ /* background-color: rgba(var(--local-surface-color), 0.2); */
34
+ /* } */
35
+ </style>