@tremolo-ui/svelte 0.7.0
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/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/actions/drag-value.d.ts +22 -0
- package/dist/actions/drag-value.d.ts.map +1 -0
- package/dist/actions/drag-value.js +30 -0
- package/dist/actions/drag.d.ts +14 -0
- package/dist/actions/drag.d.ts.map +1 -0
- package/dist/actions/drag.js +22 -0
- package/dist/actions/drop-zone.d.ts +12 -0
- package/dist/actions/drop-zone.d.ts.map +1 -0
- package/dist/actions/drop-zone.js +20 -0
- package/dist/actions/long-press.d.ts +11 -0
- package/dist/actions/long-press.d.ts.map +1 -0
- package/dist/actions/long-press.js +24 -0
- package/dist/actions/wheel.d.ts +15 -0
- package/dist/actions/wheel.d.ts.map +1 -0
- package/dist/actions/wheel.js +32 -0
- package/dist/components/AnimationCanvas/AnimationCanvas.svelte +69 -0
- package/dist/components/AnimationCanvas/AnimationCanvas.svelte.d.ts +7 -0
- package/dist/components/AnimationCanvas/AnimationCanvas.svelte.d.ts.map +1 -0
- package/dist/components/AnimationCanvas/types.d.ts +46 -0
- package/dist/components/AnimationCanvas/types.d.ts.map +1 -0
- package/dist/components/AnimationCanvas/types.js +1 -0
- package/dist/components/DropZone/Root.svelte +47 -0
- package/dist/components/DropZone/Root.svelte.d.ts +7 -0
- package/dist/components/DropZone/Root.svelte.d.ts.map +1 -0
- package/dist/components/DropZone/index.d.ts +2 -0
- package/dist/components/DropZone/index.d.ts.map +1 -0
- package/dist/components/DropZone/index.js +1 -0
- package/dist/components/DropZone/types.d.ts +26 -0
- package/dist/components/DropZone/types.d.ts.map +1 -0
- package/dist/components/DropZone/types.js +1 -0
- package/dist/components/FileInput/Root.svelte +68 -0
- package/dist/components/FileInput/Root.svelte.d.ts +7 -0
- package/dist/components/FileInput/Root.svelte.d.ts.map +1 -0
- package/dist/components/FileInput/Trigger.svelte +28 -0
- package/dist/components/FileInput/Trigger.svelte.d.ts +11 -0
- package/dist/components/FileInput/Trigger.svelte.d.ts.map +1 -0
- package/dist/components/FileInput/context.d.ts +10 -0
- package/dist/components/FileInput/context.d.ts.map +1 -0
- package/dist/components/FileInput/context.js +5 -0
- package/dist/components/FileInput/index.d.ts +3 -0
- package/dist/components/FileInput/index.d.ts.map +1 -0
- package/dist/components/FileInput/index.js +2 -0
- package/dist/components/FileInput/types.d.ts +28 -0
- package/dist/components/FileInput/types.d.ts.map +1 -0
- package/dist/components/FileInput/types.js +1 -0
- package/dist/components/Knob/ActiveLine.svelte +29 -0
- package/dist/components/Knob/ActiveLine.svelte.d.ts +6 -0
- package/dist/components/Knob/ActiveLine.svelte.d.ts.map +1 -0
- package/dist/components/Knob/InactiveLine.svelte +41 -0
- package/dist/components/Knob/InactiveLine.svelte.d.ts +6 -0
- package/dist/components/Knob/InactiveLine.svelte.d.ts.map +1 -0
- package/dist/components/Knob/Root.svelte +189 -0
- package/dist/components/Knob/Root.svelte.d.ts +10 -0
- package/dist/components/Knob/Root.svelte.d.ts.map +1 -0
- package/dist/components/Knob/SVGRoot.svelte +28 -0
- package/dist/components/Knob/SVGRoot.svelte.d.ts +13 -0
- package/dist/components/Knob/SVGRoot.svelte.d.ts.map +1 -0
- package/dist/components/Knob/Thumb.svelte +43 -0
- package/dist/components/Knob/Thumb.svelte.d.ts +7 -0
- package/dist/components/Knob/Thumb.svelte.d.ts.map +1 -0
- package/dist/components/Knob/context.d.ts +22 -0
- package/dist/components/Knob/context.d.ts.map +1 -0
- package/dist/components/Knob/context.js +5 -0
- package/dist/components/Knob/index.d.ts +6 -0
- package/dist/components/Knob/index.d.ts.map +1 -0
- package/dist/components/Knob/index.js +5 -0
- package/dist/components/Knob/types.d.ts +139 -0
- package/dist/components/Knob/types.d.ts.map +1 -0
- package/dist/components/Knob/types.js +1 -0
- package/dist/components/NumberInput/DecrementStepper.svelte +11 -0
- package/dist/components/NumberInput/DecrementStepper.svelte.d.ts +9 -0
- package/dist/components/NumberInput/DecrementStepper.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/IncrementStepper.svelte +11 -0
- package/dist/components/NumberInput/IncrementStepper.svelte.d.ts +9 -0
- package/dist/components/NumberInput/IncrementStepper.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/InputField.svelte +134 -0
- package/dist/components/NumberInput/InputField.svelte.d.ts +8 -0
- package/dist/components/NumberInput/InputField.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/Root.svelte +209 -0
- package/dist/components/NumberInput/Root.svelte.d.ts +10 -0
- package/dist/components/NumberInput/Root.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/Stepper.svelte +61 -0
- package/dist/components/NumberInput/Stepper.svelte.d.ts +10 -0
- package/dist/components/NumberInput/Stepper.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/StepperButton.svelte +63 -0
- package/dist/components/NumberInput/StepperButton.svelte.d.ts +10 -0
- package/dist/components/NumberInput/StepperButton.svelte.d.ts.map +1 -0
- package/dist/components/NumberInput/context.d.ts +48 -0
- package/dist/components/NumberInput/context.d.ts.map +1 -0
- package/dist/components/NumberInput/context.js +8 -0
- package/dist/components/NumberInput/index.d.ts +6 -0
- package/dist/components/NumberInput/index.d.ts.map +1 -0
- package/dist/components/NumberInput/index.js +5 -0
- package/dist/components/NumberInput/types.d.ts +104 -0
- package/dist/components/NumberInput/types.d.ts.map +1 -0
- package/dist/components/NumberInput/types.js +1 -0
- package/dist/components/Piano/Root.svelte +177 -0
- package/dist/components/Piano/Root.svelte.d.ts +10 -0
- package/dist/components/Piano/Root.svelte.d.ts.map +1 -0
- package/dist/components/Piano/index.d.ts +2 -0
- package/dist/components/Piano/index.d.ts.map +1 -0
- package/dist/components/Piano/index.js +1 -0
- package/dist/components/Piano/types.d.ts +90 -0
- package/dist/components/Piano/types.d.ts.map +1 -0
- package/dist/components/Piano/types.js +1 -0
- package/dist/components/PointsEditor/Background.svelte +14 -0
- package/dist/components/PointsEditor/Background.svelte.d.ts +9 -0
- package/dist/components/PointsEditor/Background.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/Container.svelte +82 -0
- package/dist/components/PointsEditor/Container.svelte.d.ts +10 -0
- package/dist/components/PointsEditor/Container.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/Point.svelte +213 -0
- package/dist/components/PointsEditor/Point.svelte.d.ts +7 -0
- package/dist/components/PointsEditor/Point.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/Root.svelte +107 -0
- package/dist/components/PointsEditor/Root.svelte.d.ts +7 -0
- package/dist/components/PointsEditor/Root.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/SelectionBox.svelte +32 -0
- package/dist/components/PointsEditor/SelectionBox.svelte.d.ts +9 -0
- package/dist/components/PointsEditor/SelectionBox.svelte.d.ts.map +1 -0
- package/dist/components/PointsEditor/context.d.ts +28 -0
- package/dist/components/PointsEditor/context.d.ts.map +1 -0
- package/dist/components/PointsEditor/context.js +5 -0
- package/dist/components/PointsEditor/index.d.ts +6 -0
- package/dist/components/PointsEditor/index.d.ts.map +1 -0
- package/dist/components/PointsEditor/index.js +5 -0
- package/dist/components/PointsEditor/types.d.ts +84 -0
- package/dist/components/PointsEditor/types.d.ts.map +1 -0
- package/dist/components/PointsEditor/types.js +1 -0
- package/dist/components/Slider/Marks.svelte +42 -0
- package/dist/components/Slider/Marks.svelte.d.ts +7 -0
- package/dist/components/Slider/Marks.svelte.d.ts.map +1 -0
- package/dist/components/Slider/MarksOption.svelte +63 -0
- package/dist/components/Slider/MarksOption.svelte.d.ts +7 -0
- package/dist/components/Slider/MarksOption.svelte.d.ts.map +1 -0
- package/dist/components/Slider/Root.svelte +217 -0
- package/dist/components/Slider/Root.svelte.d.ts +10 -0
- package/dist/components/Slider/Root.svelte.d.ts.map +1 -0
- package/dist/components/Slider/Thumb.svelte +84 -0
- package/dist/components/Slider/Thumb.svelte.d.ts +10 -0
- package/dist/components/Slider/Thumb.svelte.d.ts.map +1 -0
- package/dist/components/Slider/Track.svelte +51 -0
- package/dist/components/Slider/Track.svelte.d.ts +7 -0
- package/dist/components/Slider/Track.svelte.d.ts.map +1 -0
- package/dist/components/Slider/context.d.ts +28 -0
- package/dist/components/Slider/context.d.ts.map +1 -0
- package/dist/components/Slider/context.js +5 -0
- package/dist/components/Slider/index.d.ts +6 -0
- package/dist/components/Slider/index.d.ts.map +1 -0
- package/dist/components/Slider/index.js +5 -0
- package/dist/components/Slider/types.d.ts +138 -0
- package/dist/components/Slider/types.d.ts.map +1 -0
- package/dist/components/Slider/types.js +1 -0
- package/dist/components/XYPad/Area.svelte +29 -0
- package/dist/components/XYPad/Area.svelte.d.ts +10 -0
- package/dist/components/XYPad/Area.svelte.d.ts.map +1 -0
- package/dist/components/XYPad/Root.svelte +238 -0
- package/dist/components/XYPad/Root.svelte.d.ts +10 -0
- package/dist/components/XYPad/Root.svelte.d.ts.map +1 -0
- package/dist/components/XYPad/Thumb.svelte +109 -0
- package/dist/components/XYPad/Thumb.svelte.d.ts +10 -0
- package/dist/components/XYPad/Thumb.svelte.d.ts.map +1 -0
- package/dist/components/XYPad/context.d.ts +25 -0
- package/dist/components/XYPad/context.d.ts.map +1 -0
- package/dist/components/XYPad/context.js +5 -0
- package/dist/components/XYPad/index.d.ts +4 -0
- package/dist/components/XYPad/index.d.ts.map +1 -0
- package/dist/components/XYPad/index.js +3 -0
- package/dist/components/XYPad/types.d.ts +80 -0
- package/dist/components/XYPad/types.d.ts.map +1 -0
- package/dist/components/XYPad/types.js +1 -0
- package/dist/components/_util/VisuallyHiddenRangeInput.svelte +17 -0
- package/dist/components/_util/VisuallyHiddenRangeInput.svelte.d.ts +8 -0
- package/dist/components/_util/VisuallyHiddenRangeInput.svelte.d.ts.map +1 -0
- package/dist/components/_util/check-steps.svelte.d.ts +10 -0
- package/dist/components/_util/check-steps.svelte.d.ts.map +1 -0
- package/dist/components/_util/check-steps.svelte.js +17 -0
- package/dist/components/_util/placement.d.ts +15 -0
- package/dist/components/_util/placement.d.ts.map +1 -0
- package/dist/components/_util/placement.js +30 -0
- package/dist/components/_util/style.d.ts +5 -0
- package/dist/components/_util/style.d.ts.map +1 -0
- package/dist/components/_util/style.js +9 -0
- package/dist/hooks/useMIDIAccess.svelte.d.ts +29 -0
- package/dist/hooks/useMIDIAccess.svelte.d.ts.map +1 -0
- package/dist/hooks/useMIDIAccess.svelte.js +62 -0
- package/dist/hooks/useMIDIInput.svelte.d.ts +18 -0
- package/dist/hooks/useMIDIInput.svelte.d.ts.map +1 -0
- package/dist/hooks/useMIDIInput.svelte.js +31 -0
- package/dist/hooks/useMIDIMessage.svelte.d.ts +9 -0
- package/dist/hooks/useMIDIMessage.svelte.d.ts.map +1 -0
- package/dist/hooks/useMIDIMessage.svelte.js +23 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/FileInput/context.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAC3B;AAID,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,6BAAM,CAAA;AACtC,eAAO,MAAM,mBAAmB,2DAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FileInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface FileInputProps {
|
|
3
|
+
/**
|
|
4
|
+
* Which files to take, written the way the HTML attribute is: extensions
|
|
5
|
+
* (`.wav`), MIME types (`audio/wav`) and type groups (`audio/*`). It is
|
|
6
|
+
* checked again when the files arrive, since the picker only takes it as a
|
|
7
|
+
* hint.
|
|
8
|
+
*/
|
|
9
|
+
accept?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Let several files be picked at once.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
/** Make the input unusable. The parts carry `data-disabled`. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** Called with the picked files that satisfy `accept`. */
|
|
18
|
+
onChange?: (files: File[]) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Called with the picked files that do not satisfy `accept`, after
|
|
21
|
+
* `onChange` for the same selection.
|
|
22
|
+
*/
|
|
23
|
+
onReject?: (files: File[]) => void;
|
|
24
|
+
/** The root element, bound with `bind:ref`. */
|
|
25
|
+
ref?: HTMLDivElement | null;
|
|
26
|
+
children: Snippet;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/FileInput/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAA;IAClC,+CAA+C;IAC/C,GAAG,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC3B,QAAQ,EAAE,OAAO,CAAA;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { knobArcPath, knobArcRadius } from '@tremolo-ui/dom'
|
|
3
|
+
|
|
4
|
+
import { checkPlacement } from '../_util/placement.js'
|
|
5
|
+
|
|
6
|
+
import { useKnobContext } from './context.js'
|
|
7
|
+
|
|
8
|
+
import type { SVGAttributes } from 'svelte/elements'
|
|
9
|
+
|
|
10
|
+
type Props = Omit<SVGAttributes<SVGPathElement>, 'd'>
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
stroke = 'currentColor',
|
|
14
|
+
'stroke-width': strokeWidth = 6,
|
|
15
|
+
...rest
|
|
16
|
+
}: Props = $props()
|
|
17
|
+
|
|
18
|
+
checkPlacement('Knob.ActiveLine', 'Knob.SVGRoot')
|
|
19
|
+
const knob = useKnobContext()
|
|
20
|
+
const radius = $derived(knobArcRadius(strokeWidth ?? undefined))
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<path
|
|
24
|
+
d={knobArcPath(knob.angles.r2, knob.angles.r3, radius)}
|
|
25
|
+
fill="none"
|
|
26
|
+
{stroke}
|
|
27
|
+
stroke-width={strokeWidth}
|
|
28
|
+
{...rest}
|
|
29
|
+
/>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
2
|
+
type Props = Omit<SVGAttributes<SVGPathElement>, 'd'>;
|
|
3
|
+
declare const ActiveLine: import("svelte").Component<Props, {}, "">;
|
|
4
|
+
type ActiveLine = ReturnType<typeof ActiveLine>;
|
|
5
|
+
export default ActiveLine;
|
|
6
|
+
//# sourceMappingURL=ActiveLine.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActiveLine.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/ActiveLine.svelte.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGnD,KAAK,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,CAAC;AA0BxD,QAAA,MAAM,UAAU,2CAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { knobArcPath, knobArcRadius } from '@tremolo-ui/dom'
|
|
3
|
+
|
|
4
|
+
import { checkPlacement } from '../_util/placement.js'
|
|
5
|
+
|
|
6
|
+
import { useKnobContext } from './context.js'
|
|
7
|
+
|
|
8
|
+
import type { SVGAttributes } from 'svelte/elements'
|
|
9
|
+
|
|
10
|
+
type Props = Omit<SVGAttributes<SVGPathElement>, 'd'>
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
stroke = 'currentColor',
|
|
14
|
+
'stroke-width': strokeWidth = 6,
|
|
15
|
+
...rest
|
|
16
|
+
}: Props = $props()
|
|
17
|
+
|
|
18
|
+
checkPlacement('Knob.InactiveLine', 'Knob.SVGRoot')
|
|
19
|
+
const knob = useKnobContext()
|
|
20
|
+
const radius = $derived(knobArcRadius(strokeWidth ?? undefined))
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<!-- The travel on either side of the active arc. -->
|
|
24
|
+
{#if knob.startValue > knob.min}
|
|
25
|
+
<path
|
|
26
|
+
d={knobArcPath(knob.angles.r1, knob.angles.r2, radius)}
|
|
27
|
+
fill="none"
|
|
28
|
+
{stroke}
|
|
29
|
+
stroke-width={strokeWidth}
|
|
30
|
+
{...rest}
|
|
31
|
+
/>
|
|
32
|
+
{/if}
|
|
33
|
+
{#if knob.startValue < knob.max}
|
|
34
|
+
<path
|
|
35
|
+
d={knobArcPath(knob.angles.r3, knob.angles.r4, radius)}
|
|
36
|
+
fill="none"
|
|
37
|
+
{stroke}
|
|
38
|
+
stroke-width={strokeWidth}
|
|
39
|
+
{...rest}
|
|
40
|
+
/>
|
|
41
|
+
{/if}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
2
|
+
type Props = Omit<SVGAttributes<SVGPathElement>, 'd'>;
|
|
3
|
+
declare const InactiveLine: import("svelte").Component<Props, {}, "">;
|
|
4
|
+
type InactiveLine = ReturnType<typeof InactiveLine>;
|
|
5
|
+
export default InactiveLine;
|
|
6
|
+
//# sourceMappingURL=InactiveLine.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InactiveLine.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/InactiveLine.svelte.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGnD,KAAK,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,CAAC;AAgCxD,QAAA,MAAM,YAAY,2CAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
applyDelta,
|
|
4
|
+
arrowKeyDirection,
|
|
5
|
+
cssLength,
|
|
6
|
+
DEFAULT_DRAG_SENSITIVITY,
|
|
7
|
+
DEFAULT_KEYBOARD_OPTIONS,
|
|
8
|
+
DEFAULT_WHEEL_OPTIONS,
|
|
9
|
+
knobAngles,
|
|
10
|
+
relativeMapping,
|
|
11
|
+
selectModifier,
|
|
12
|
+
wheelDirection,
|
|
13
|
+
type AxisOptions,
|
|
14
|
+
type XY,
|
|
15
|
+
} from '@tremolo-ui/dom'
|
|
16
|
+
import { linearScale, type ValueRange } from '@tremolo-ui/functions'
|
|
17
|
+
|
|
18
|
+
import { dragValue } from '../../actions/drag-value.js'
|
|
19
|
+
import { wheel as wheelAction } from '../../actions/wheel.js'
|
|
20
|
+
import { useCheckSteps } from '../_util/check-steps.svelte.js'
|
|
21
|
+
|
|
22
|
+
import { setKnobContext } from './context.js'
|
|
23
|
+
import type { KnobProps } from './types.js'
|
|
24
|
+
|
|
25
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
26
|
+
|
|
27
|
+
type Props = KnobProps & Omit<HTMLAttributes<HTMLDivElement>, keyof KnobProps>
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
value = $bindable(),
|
|
31
|
+
min,
|
|
32
|
+
max,
|
|
33
|
+
step = 1,
|
|
34
|
+
scale = linearScale,
|
|
35
|
+
defaultValue,
|
|
36
|
+
startValue,
|
|
37
|
+
size,
|
|
38
|
+
externalStyles,
|
|
39
|
+
wheel = DEFAULT_WHEEL_OPTIONS,
|
|
40
|
+
keyboard = DEFAULT_KEYBOARD_OPTIONS,
|
|
41
|
+
dragSensitivity = DEFAULT_DRAG_SENSITIVITY,
|
|
42
|
+
pointerLock = false,
|
|
43
|
+
enableDoubleClickDefault = true,
|
|
44
|
+
disabled = false,
|
|
45
|
+
readonly = false,
|
|
46
|
+
angleRange = 270,
|
|
47
|
+
onChange,
|
|
48
|
+
ref = $bindable(null),
|
|
49
|
+
children,
|
|
50
|
+
style,
|
|
51
|
+
onkeydown,
|
|
52
|
+
ondblclick,
|
|
53
|
+
...rest
|
|
54
|
+
}: Props = $props()
|
|
55
|
+
|
|
56
|
+
const inactive = $derived(disabled || readonly)
|
|
57
|
+
const range: ValueRange = $derived({ min, max, step, scale })
|
|
58
|
+
const angles = $derived(
|
|
59
|
+
knobAngles({
|
|
60
|
+
value,
|
|
61
|
+
min,
|
|
62
|
+
max,
|
|
63
|
+
scale,
|
|
64
|
+
startValue: startValue ?? min,
|
|
65
|
+
angleRange,
|
|
66
|
+
}),
|
|
67
|
+
)
|
|
68
|
+
let dragging = $state(false)
|
|
69
|
+
|
|
70
|
+
useCheckSteps(() => ({ component: 'Knob', range, keyboard, wheel }))
|
|
71
|
+
|
|
72
|
+
setKnobContext({
|
|
73
|
+
get value() {
|
|
74
|
+
return value
|
|
75
|
+
},
|
|
76
|
+
get min() {
|
|
77
|
+
return min
|
|
78
|
+
},
|
|
79
|
+
get max() {
|
|
80
|
+
return max
|
|
81
|
+
},
|
|
82
|
+
get step() {
|
|
83
|
+
return step
|
|
84
|
+
},
|
|
85
|
+
get scale() {
|
|
86
|
+
return scale
|
|
87
|
+
},
|
|
88
|
+
get startValue() {
|
|
89
|
+
return startValue ?? min
|
|
90
|
+
},
|
|
91
|
+
get angleRange() {
|
|
92
|
+
return angleRange
|
|
93
|
+
},
|
|
94
|
+
get angles() {
|
|
95
|
+
return angles
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
function change(next: number) {
|
|
100
|
+
value = next
|
|
101
|
+
onChange?.(next)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// The knob has no travel of its own: the value moves away from where it
|
|
105
|
+
// stood when the drag started, 100px of movement spanning the whole range.
|
|
106
|
+
// Only the vertical axis carries a value, reversed so that dragging up
|
|
107
|
+
// raises it. `mapping` is read once, when the action starts; the rest is
|
|
108
|
+
// handed over as it changes.
|
|
109
|
+
const dragOptions = $derived({
|
|
110
|
+
axis: [range, { ...range, reverse: true }] as XY<AxisOptions>,
|
|
111
|
+
mapping: relativeMapping({
|
|
112
|
+
pixelRange: 100,
|
|
113
|
+
sensitivity: (state) =>
|
|
114
|
+
selectModifier(dragSensitivity, state.event).value,
|
|
115
|
+
}),
|
|
116
|
+
getValue: (): XY<number> => [value, value],
|
|
117
|
+
threshold: 1,
|
|
118
|
+
cursor: inactive ? undefined : (externalStyles?.cursor ?? 'grabbing'),
|
|
119
|
+
pointerLock: inactive ? false : pointerLock,
|
|
120
|
+
shouldStart: () => !inactive,
|
|
121
|
+
onChange: (v: XY<number>) => {
|
|
122
|
+
if (!inactive) change(v[1])
|
|
123
|
+
},
|
|
124
|
+
onDragStart: () => {
|
|
125
|
+
dragging = true
|
|
126
|
+
},
|
|
127
|
+
onDragEnd: () => {
|
|
128
|
+
dragging = false
|
|
129
|
+
},
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const wheelOptions = $derived({
|
|
133
|
+
requireFocus: true,
|
|
134
|
+
onWheel: (event: WheelEvent) => {
|
|
135
|
+
if (!wheel || inactive) return
|
|
136
|
+
// A notch the knob does not read — a sideways scroll — is left to the
|
|
137
|
+
// page rather than swallowed.
|
|
138
|
+
const direction = wheelDirection(event)
|
|
139
|
+
if (direction === null) return
|
|
140
|
+
event.preventDefault()
|
|
141
|
+
change(applyDelta(value, direction, wheel, range, event))
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
/** Move the focus to the knob. */
|
|
146
|
+
export function focus() {
|
|
147
|
+
if (!disabled) ref?.focus()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Take the focus away from the knob. */
|
|
151
|
+
export function blur() {
|
|
152
|
+
ref?.blur()
|
|
153
|
+
}
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<div
|
|
157
|
+
bind:this={ref}
|
|
158
|
+
role="slider"
|
|
159
|
+
tabindex={disabled ? -1 : 0}
|
|
160
|
+
aria-valuenow={value}
|
|
161
|
+
aria-valuemin={min}
|
|
162
|
+
aria-valuemax={max}
|
|
163
|
+
aria-disabled={disabled}
|
|
164
|
+
aria-readonly={readonly}
|
|
165
|
+
data-disabled={disabled ? '' : undefined}
|
|
166
|
+
data-readonly={readonly ? '' : undefined}
|
|
167
|
+
data-dragging={dragging ? '' : undefined}
|
|
168
|
+
{style}
|
|
169
|
+
style:--knob-size={cssLength(size)}
|
|
170
|
+
use:dragValue={dragOptions}
|
|
171
|
+
use:wheelAction={wheelOptions}
|
|
172
|
+
onkeydown={(event) => {
|
|
173
|
+
if (keyboard && !inactive) {
|
|
174
|
+
const direction = arrowKeyDirection(event.key)
|
|
175
|
+
if (direction !== null) {
|
|
176
|
+
event.preventDefault()
|
|
177
|
+
change(applyDelta(value, direction, keyboard, range, event))
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
onkeydown?.(event)
|
|
181
|
+
}}
|
|
182
|
+
ondblclick={(event) => {
|
|
183
|
+
if (!inactive && enableDoubleClickDefault) change(defaultValue ?? min)
|
|
184
|
+
ondblclick?.(event)
|
|
185
|
+
}}
|
|
186
|
+
{...rest}
|
|
187
|
+
>
|
|
188
|
+
{@render children()}
|
|
189
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { KnobProps } from './types.js';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = KnobProps & Omit<HTMLAttributes<HTMLDivElement>, keyof KnobProps>;
|
|
4
|
+
declare const Root: import("svelte").Component<Props, {
|
|
5
|
+
focus: () => void;
|
|
6
|
+
blur: () => void;
|
|
7
|
+
}, "ref" | "value">;
|
|
8
|
+
type Root = ReturnType<typeof Root>;
|
|
9
|
+
export default Root;
|
|
10
|
+
//# sourceMappingURL=Root.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Root.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/Root.svelte.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD,KAAK,KAAK,GAAG,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,MAAM,SAAS,CAAC,CAAC;AAgKjF,QAAA,MAAM,IAAI;;;mBAAwC,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { KNOB_VIEWBOX_SIZE } from '@tremolo-ui/dom'
|
|
3
|
+
|
|
4
|
+
import { setPlacement } from '../_util/placement.js'
|
|
5
|
+
|
|
6
|
+
import type { Snippet } from 'svelte'
|
|
7
|
+
import type { SVGAttributes } from 'svelte/elements'
|
|
8
|
+
|
|
9
|
+
type Props = SVGAttributes<SVGSVGElement> & {
|
|
10
|
+
/**
|
|
11
|
+
* `Knob.InactiveLine`, `Knob.ActiveLine` and `Knob.Thumb` go here, in the
|
|
12
|
+
* order you want them painted.
|
|
13
|
+
*/
|
|
14
|
+
children: Snippet
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let { children, style, ...rest }: Props = $props()
|
|
18
|
+
|
|
19
|
+
setPlacement('Knob.SVGRoot')
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<svg
|
|
23
|
+
viewBox="0 0 {KNOB_VIEWBOX_SIZE} {KNOB_VIEWBOX_SIZE}"
|
|
24
|
+
style="display: block; {style ?? ''}"
|
|
25
|
+
{...rest}
|
|
26
|
+
>
|
|
27
|
+
{@render children()}
|
|
28
|
+
</svg>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = SVGAttributes<SVGSVGElement> & {
|
|
4
|
+
/**
|
|
5
|
+
* `Knob.InactiveLine`, `Knob.ActiveLine` and `Knob.Thumb` go here, in the
|
|
6
|
+
* order you want them painted.
|
|
7
|
+
*/
|
|
8
|
+
children: Snippet;
|
|
9
|
+
};
|
|
10
|
+
declare const SVGRoot: import("svelte").Component<Props, {}, "">;
|
|
11
|
+
type SVGRoot = ReturnType<typeof SVGRoot>;
|
|
12
|
+
export default SVGRoot;
|
|
13
|
+
//# sourceMappingURL=SVGRoot.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SVGRoot.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/SVGRoot.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGnD,KAAK,KAAK,GAAG,aAAa,CAAC,aAAa,CAAC,GAAG;IAC1C;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAC;AAqBJ,QAAA,MAAM,OAAO,2CAAwC,CAAC;AACtD,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAC1C,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { KNOB_VIEWBOX_SIZE } from '@tremolo-ui/dom'
|
|
3
|
+
import { clamp } from '@tremolo-ui/functions'
|
|
4
|
+
|
|
5
|
+
import { checkPlacement } from '../_util/placement.js'
|
|
6
|
+
|
|
7
|
+
import { useKnobContext } from './context.js'
|
|
8
|
+
import type { KnobThumbProps } from './types.js'
|
|
9
|
+
|
|
10
|
+
import type { SVGAttributes } from 'svelte/elements'
|
|
11
|
+
|
|
12
|
+
type Props = KnobThumbProps &
|
|
13
|
+
Omit<SVGAttributes<SVGSVGElement>, keyof KnobThumbProps>
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
thumb = 'currentColor',
|
|
17
|
+
thumbLine = 'currentColor',
|
|
18
|
+
thumbSize = 84,
|
|
19
|
+
thumbLineWeight = 6,
|
|
20
|
+
thumbLineLength = 35,
|
|
21
|
+
classes,
|
|
22
|
+
...rest
|
|
23
|
+
}: Props = $props()
|
|
24
|
+
|
|
25
|
+
checkPlacement('Knob.Thumb', 'Knob.SVGRoot')
|
|
26
|
+
const knob = useKnobContext()
|
|
27
|
+
const angle = $derived(knob.angles.r1 + knob.angles.p * knob.angleRange)
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<svg {...rest}>
|
|
31
|
+
<circle cx="50%" cy="50%" r="{thumbSize / 2}%" fill={thumb} />
|
|
32
|
+
<line
|
|
33
|
+
class={classes?.thumbLine}
|
|
34
|
+
x1="50%"
|
|
35
|
+
y1="{(KNOB_VIEWBOX_SIZE - clamp(thumbSize, 0, 100)) / 2}%"
|
|
36
|
+
x2="50%"
|
|
37
|
+
y2="{thumbLineLength}%"
|
|
38
|
+
stroke={thumbLine}
|
|
39
|
+
stroke-width="{thumbLineWeight}%"
|
|
40
|
+
style:transform="rotate({angle}deg)"
|
|
41
|
+
style:transform-origin="50% 50%"
|
|
42
|
+
/>
|
|
43
|
+
</svg>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KnobThumbProps } from './types.js';
|
|
2
|
+
import type { SVGAttributes } from 'svelte/elements';
|
|
3
|
+
type Props = KnobThumbProps & Omit<SVGAttributes<SVGSVGElement>, keyof KnobThumbProps>;
|
|
4
|
+
declare const Thumb: import("svelte").Component<Props, {}, "">;
|
|
5
|
+
type Thumb = ReturnType<typeof Thumb>;
|
|
6
|
+
export default Thumb;
|
|
7
|
+
//# sourceMappingURL=Thumb.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Thumb.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/Thumb.svelte.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGnD,KAAK,KAAK,GAAG,cAAc,GACzB,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC;AAmC7D,QAAA,MAAM,KAAK,2CAAwC,CAAC;AACpD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { KnobAngles } from '@tremolo-ui/dom';
|
|
2
|
+
import type { Scale } from '@tremolo-ui/functions';
|
|
3
|
+
/**
|
|
4
|
+
* What `Knob.Root` shares with its parts. Every field is a getter, so reading
|
|
5
|
+
* one inside markup or `$derived` follows the value as it changes.
|
|
6
|
+
*/
|
|
7
|
+
export interface KnobContextValue {
|
|
8
|
+
readonly value: number;
|
|
9
|
+
readonly min: number;
|
|
10
|
+
readonly max: number;
|
|
11
|
+
readonly step: number;
|
|
12
|
+
readonly scale: Scale;
|
|
13
|
+
readonly startValue: number;
|
|
14
|
+
/** How far the knob turns from `min` to `max`, in degrees. */
|
|
15
|
+
readonly angleRange: number;
|
|
16
|
+
/** The angles the parts are drawn with. See `knobAngles` in `@tremolo-ui/dom`. */
|
|
17
|
+
readonly angles: KnobAngles;
|
|
18
|
+
}
|
|
19
|
+
/** The context of the enclosing `Knob.Root`, for a part of your own. */
|
|
20
|
+
export declare const useKnobContext: () => KnobContextValue;
|
|
21
|
+
export declare const setKnobContext: (context: KnobContextValue) => KnobContextValue;
|
|
22
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAC5B;AAID,wEAAwE;AACxE,eAAO,MAAM,cAAc,wBAAM,CAAA;AACjC,eAAO,MAAM,cAAc,iDAAM,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as ActiveLine } from './ActiveLine.svelte';
|
|
2
|
+
export { default as InactiveLine } from './InactiveLine.svelte';
|
|
3
|
+
export { default as Root } from './Root.svelte';
|
|
4
|
+
export { default as SVGRoot } from './SVGRoot.svelte';
|
|
5
|
+
export { default as Thumb } from './Thumb.svelte';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as ActiveLine } from './ActiveLine.svelte';
|
|
2
|
+
export { default as InactiveLine } from './InactiveLine.svelte';
|
|
3
|
+
export { default as Root } from './Root.svelte';
|
|
4
|
+
export { default as SVGRoot } from './SVGRoot.svelte';
|
|
5
|
+
export { default as Thumb } from './Thumb.svelte';
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { InputEventOption, ModifierValue } from '@tremolo-ui/dom';
|
|
2
|
+
import type { Scale } from '@tremolo-ui/functions';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
export interface KnobProps {
|
|
5
|
+
/**
|
|
6
|
+
* The current value. Bind it (`bind:value`) or update it from `onChange`.
|
|
7
|
+
*/
|
|
8
|
+
value: number;
|
|
9
|
+
/** The value with the knob turned all the way down. */
|
|
10
|
+
min: number;
|
|
11
|
+
/** The value with the knob turned all the way up. */
|
|
12
|
+
max: number;
|
|
13
|
+
/**
|
|
14
|
+
* Granularity of the value. A drag, the wheel and the arrow keys snap it to
|
|
15
|
+
* multiples of `step`.
|
|
16
|
+
*
|
|
17
|
+
* @default 1
|
|
18
|
+
*/
|
|
19
|
+
step?: number;
|
|
20
|
+
/**
|
|
21
|
+
* How the value is distributed across the travel. Pick one of the scales
|
|
22
|
+
* from `@tremolo-ui/functions`.
|
|
23
|
+
*
|
|
24
|
+
* @default linearScale
|
|
25
|
+
*/
|
|
26
|
+
scale?: Scale;
|
|
27
|
+
/**
|
|
28
|
+
* The value a double click restores, while `enableDoubleClickDefault` is on.
|
|
29
|
+
* @default min
|
|
30
|
+
*/
|
|
31
|
+
defaultValue?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Where the active arc starts. Put it at the centre of a bipolar control,
|
|
34
|
+
* such as a pan knob, so that the arc grows from there either way.
|
|
35
|
+
* @default min
|
|
36
|
+
*/
|
|
37
|
+
startValue?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Width and height of the knob. Sets `--knob-size`; the size the theme
|
|
40
|
+
* gives it stands when this is omitted.
|
|
41
|
+
*/
|
|
42
|
+
size?: number | string;
|
|
43
|
+
/**
|
|
44
|
+
* The cursor to show while dragging.
|
|
45
|
+
* @default { cursor: 'grabbing' }
|
|
46
|
+
*/
|
|
47
|
+
externalStyles?: {
|
|
48
|
+
cursor?: string;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* How much one notch of the wheel moves the value, while the focus is
|
|
52
|
+
* inside. `null` turns the wheel off.
|
|
53
|
+
* @default ['raw', 1]
|
|
54
|
+
*/
|
|
55
|
+
wheel?: ModifierValue<InputEventOption> | null;
|
|
56
|
+
/**
|
|
57
|
+
* How much a drag moves the value, per modifier key. `1` is 100px for the
|
|
58
|
+
* whole range.
|
|
59
|
+
* @default { default: 1, shift: 0.1 }
|
|
60
|
+
*/
|
|
61
|
+
dragSensitivity?: ModifierValue<number>;
|
|
62
|
+
/**
|
|
63
|
+
* Hide the cursor while dragging and read the pointer movement directly,
|
|
64
|
+
* so the drag does not stop at the edge of the screen.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
pointerLock?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* How much one arrow key press moves the value. `null` turns the arrow
|
|
70
|
+
* keys off.
|
|
71
|
+
* @default { default: ['raw', 1], shift: ['raw', 0.1] }
|
|
72
|
+
*/
|
|
73
|
+
keyboard?: ModifierValue<InputEventOption> | null;
|
|
74
|
+
/**
|
|
75
|
+
* Restore `defaultValue` on a double click.
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
enableDoubleClickDefault?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Make the knob unchangeable and remove it from the tab order.
|
|
81
|
+
* The parts carry `data-disabled` while it is set.
|
|
82
|
+
*/
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Make the knob unchangeable while leaving it focusable.
|
|
86
|
+
* The parts carry `data-readonly` while it is set.
|
|
87
|
+
*/
|
|
88
|
+
readonly?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* How far the knob turns from `min` to `max`, in degrees, centred on the
|
|
91
|
+
* top.
|
|
92
|
+
* @default 270
|
|
93
|
+
*/
|
|
94
|
+
angleRange?: number;
|
|
95
|
+
/**
|
|
96
|
+
* Called with the new value when a drag, the wheel, an arrow key or a
|
|
97
|
+
* double click moves it.
|
|
98
|
+
*/
|
|
99
|
+
onChange?: (value: number) => void;
|
|
100
|
+
/** The root element, bound with `bind:ref`. */
|
|
101
|
+
ref?: HTMLDivElement | null;
|
|
102
|
+
/**
|
|
103
|
+
* The knob renders exactly what you compose here; there is no default
|
|
104
|
+
* markup to fall back to.
|
|
105
|
+
*/
|
|
106
|
+
children: Snippet;
|
|
107
|
+
}
|
|
108
|
+
export interface KnobThumbProps {
|
|
109
|
+
/**
|
|
110
|
+
* Fill colour of the circle.
|
|
111
|
+
* @default 'currentColor'
|
|
112
|
+
*/
|
|
113
|
+
thumb?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Colour of the line that points at the value.
|
|
116
|
+
* @default 'currentColor'
|
|
117
|
+
*/
|
|
118
|
+
thumbLine?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Diameter of the circle, as a percentage of the knob.
|
|
121
|
+
* @default 84
|
|
122
|
+
*/
|
|
123
|
+
thumbSize?: number;
|
|
124
|
+
/**
|
|
125
|
+
* Thickness of the line, as a percentage of the knob.
|
|
126
|
+
* @default 6
|
|
127
|
+
*/
|
|
128
|
+
thumbLineWeight?: number;
|
|
129
|
+
/**
|
|
130
|
+
* How far down the line reaches, as a percentage of the knob from its top.
|
|
131
|
+
* @default 35
|
|
132
|
+
*/
|
|
133
|
+
thumbLineLength?: number;
|
|
134
|
+
/** Classes for the line that points at the value. */
|
|
135
|
+
classes?: {
|
|
136
|
+
thumbLine?: string;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Knob/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAErC,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAA;IACX,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAA;IACX;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,CAAA;IACb;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB;;;OAGG;IACH,cAAc,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACpC;;;;OAIG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IAC9C;;;;OAIG;IACH,eAAe,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACvC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAA;IACjD;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,+CAA+C;IAC/C,GAAG,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;IAC3B;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,qDAAqD;IACrD,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|