@patchbayhq/svelte 0.1.0 → 0.1.1
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/package.json +2 -2
- package/src/Menu.svelte +11 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patchbayhq/svelte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Svelte wrappers for patchbay UI audio controls.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"check-types": "svelte-check --tsconfig tsconfig.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@patchbayhq/ui": "^0.1.
|
|
48
|
+
"@patchbayhq/ui": "^0.1.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"svelte": "^5.0.0"
|
package/src/Menu.svelte
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
findEnabledMenuItemIndex,
|
|
4
|
+
parseComponentProps,
|
|
5
|
+
type MenuItem,
|
|
6
|
+
} from "@patchbayhq/ui";
|
|
3
7
|
|
|
4
8
|
export let value = "classic";
|
|
5
9
|
export let items: MenuItem[] = [
|
|
@@ -21,17 +25,6 @@
|
|
|
21
25
|
);
|
|
22
26
|
$: selected = props.items[selectedIndex] ?? props.items[0];
|
|
23
27
|
|
|
24
|
-
function firstEnabledIndex(startIndex: number, direction: 1 | -1) {
|
|
25
|
-
for (let offset = 0; offset < props.items.length; offset += 1) {
|
|
26
|
-
const index =
|
|
27
|
-
(startIndex + offset * direction + props.items.length) %
|
|
28
|
-
props.items.length;
|
|
29
|
-
if (!props.items[index]?.disabled) return index;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return selectedIndex;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
28
|
function commit(index: number) {
|
|
36
29
|
const item = props.items[index];
|
|
37
30
|
if (!item || item.disabled) return;
|
|
@@ -51,7 +44,12 @@
|
|
|
51
44
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
52
45
|
event.preventDefault();
|
|
53
46
|
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
54
|
-
activeIndex =
|
|
47
|
+
activeIndex = findEnabledMenuItemIndex(
|
|
48
|
+
props.items,
|
|
49
|
+
activeIndex + direction,
|
|
50
|
+
direction,
|
|
51
|
+
selectedIndex,
|
|
52
|
+
);
|
|
55
53
|
open = true;
|
|
56
54
|
return;
|
|
57
55
|
}
|