zds-pickers 4.0.13 → 4.0.15
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/dist/index.cjs.js +160 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +12482 -36
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/midi/ccValues.js +2 -2
- package/dist/other/DefaultTooltip.js +1 -1
- package/dist/other/OctavePlayer.js +4 -4
- package/dist/other/SoundFontProvider.js +5 -3
- package/dist/other/{SVGText.js → SvgText.js} +2 -3
- package/dist/pickers/CCPicker.js +4 -4
- package/dist/pickers/ChannelMappingPicker.js +2 -2
- package/dist/pickers/ChannelPicker.js +2 -2
- package/dist/pickers/Knob.js +3 -3
- package/dist/pickers/KnobPicker.js +3 -3
- package/dist/pickers/LatchPicker.js +2 -2
- package/dist/pickers/MappingPicker.js +2 -2
- package/dist/pickers/NotePicker.js +2 -2
- package/dist/pickers/PianoPicker.js +4 -4
- package/dist/pickers/PolarityPicker.js +2 -2
- package/dist/pickers/ResponseCurve.js +4 -4
- package/dist/pickers/ResponseCurvePicker.js +4 -4
- package/dist/pickers/Select.js +1 -1
- package/dist/pickers/StatusPicker.js +2 -2
- package/dist/pickers/ValuePicker.js +2 -2
- package/dist/pickers/knobSkin10.js +1 -1
- package/dist/rotaryKnob/InternalInput.js +1 -1
- package/dist/rotaryKnob/helpers/DrawCircle.js +1 -1
- package/dist/rotaryKnob/helpers/DrawLine.js +1 -1
- package/dist/rotaryKnob/helpers/HelpersOverlay.js +1 -1
- package/dist/rotaryKnob/helpers/KnobVisualHelpers.js +6 -6
- package/dist/rotaryKnob/index.js +6 -6
- package/dist/rotaryKnob/utils.js +4 -8
- package/dist/types/index.d.ts +2 -2
- package/dist/types/midi/ccValues.d.ts +2 -2
- package/dist/types/other/DefaultTooltip.d.ts +1 -1
- package/dist/types/other/OctavePlayer.d.ts +10 -4
- package/dist/types/other/SoundFontProvider.d.ts +2 -2
- package/dist/types/other/{SVGText.d.ts → SvgText.d.ts} +2 -3
- package/dist/types/pickers/CCPicker.d.ts +1 -1
- package/dist/types/pickers/ChannelMappingPicker.d.ts +1 -1
- package/dist/types/pickers/ChannelPicker.d.ts +1 -1
- package/dist/types/pickers/Knob.d.ts +1 -1
- package/dist/types/pickers/KnobPicker.d.ts +1 -1
- package/dist/types/pickers/LatchPicker.d.ts +1 -1
- package/dist/types/pickers/MappingPicker.d.ts +1 -1
- package/dist/types/pickers/NotePicker.d.ts +1 -1
- package/dist/types/pickers/PianoPicker.d.ts +1 -1
- package/dist/types/pickers/PolarityPicker.d.ts +1 -1
- package/dist/types/pickers/ResponseCurve.d.ts +3 -3
- package/dist/types/pickers/ResponseCurvePicker.d.ts +1 -1
- package/dist/types/pickers/Select.d.ts +1 -1
- package/dist/types/pickers/StatusPicker.d.ts +1 -1
- package/dist/types/pickers/ValuePicker.d.ts +1 -1
- package/dist/types/pickers/knobSkin10.d.ts +1 -1
- package/dist/types/rotaryKnob/InternalInput.d.ts +1 -1
- package/dist/types/rotaryKnob/helpers/DrawCircle.d.ts +1 -1
- package/dist/types/rotaryKnob/helpers/DrawLine.d.ts +1 -1
- package/dist/types/rotaryKnob/helpers/HelpersOverlay.d.ts +1 -1
- package/dist/types/rotaryKnob/index.d.ts +1 -1
- package/dist/types/rotaryKnob/utils.d.ts +1 -7
- package/lib/index.ts +2 -2
- package/lib/midi/ccValues.ts +2 -2
- package/lib/other/DefaultTooltip.ts +1 -1
- package/lib/other/OctavePlayer.tsx +14 -7
- package/lib/other/SoundFontProvider.tsx +6 -4
- package/lib/other/{SVGText.tsx → SvgText.tsx} +2 -4
- package/lib/pickers/CCPicker.tsx +4 -4
- package/lib/pickers/ChannelMappingPicker.tsx +2 -2
- package/lib/pickers/ChannelPicker.tsx +2 -2
- package/lib/pickers/Knob.tsx +3 -3
- package/lib/pickers/KnobPicker.tsx +3 -3
- package/lib/pickers/LatchPicker.tsx +2 -2
- package/lib/pickers/MappingPicker.tsx +2 -2
- package/lib/pickers/NotePicker.tsx +2 -2
- package/lib/pickers/PianoPicker.tsx +4 -4
- package/lib/pickers/PolarityPicker.tsx +2 -2
- package/lib/pickers/ResponseCurve.tsx +8 -8
- package/lib/pickers/ResponseCurvePicker.tsx +4 -4
- package/lib/pickers/Select.tsx +1 -1
- package/lib/pickers/StatusPicker.tsx +2 -2
- package/lib/pickers/ValuePicker.tsx +2 -2
- package/lib/pickers/knobSkin10.tsx +1 -1
- package/lib/rotaryKnob/InternalInput.tsx +1 -1
- package/lib/rotaryKnob/helpers/DrawCircle.tsx +1 -1
- package/lib/rotaryKnob/helpers/DrawLine.tsx +1 -1
- package/lib/rotaryKnob/helpers/HelpersOverlay.tsx +1 -1
- package/lib/rotaryKnob/helpers/KnobVisualHelpers.tsx +6 -6
- package/lib/rotaryKnob/index.tsx +6 -6
- package/lib/rotaryKnob/utils.ts +1 -1
- package/package.json +1 -1
- package/stories/assets/utils.js +1 -1
- package/stories/picker.stories.tsx +15 -15
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from './midi/ccValues';
|
|
|
2
2
|
export * from './midi/export';
|
|
3
3
|
export * from './other/DefaultTooltip';
|
|
4
4
|
export * from './other/OctavePlayer';
|
|
5
|
-
export * from './other/
|
|
5
|
+
export * from './other/SvgText';
|
|
6
6
|
export * from './pickers/ChannelMappingPicker';
|
|
7
7
|
export * from './pickers/ChannelPicker';
|
|
8
8
|
export * from './pickers/Knob';
|
package/dist/midi/ccValues.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const changeControllerOptions = [
|
|
2
2
|
'Bank Select',
|
|
3
3
|
'Modulation Wheel',
|
|
4
4
|
'Breath Controller',
|
|
@@ -131,4 +131,4 @@ const CC_NAMES = [
|
|
|
131
131
|
label: String(label).length ? `${value} - ${label}` : String(value),
|
|
132
132
|
value,
|
|
133
133
|
}));
|
|
134
|
-
export
|
|
134
|
+
export { changeControllerOptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { /* Midi, */ Note } from 'tonal';
|
|
3
3
|
import { Piano as ReactPiano } from 'zds-react-piano';
|
|
4
|
-
import SoundfontProvider from './SoundFontProvider';
|
|
4
|
+
import { SoundfontProvider } from './SoundFontProvider';
|
|
5
5
|
const baseNotes = [
|
|
6
6
|
'C',
|
|
7
7
|
'C#',
|
|
@@ -23,7 +23,7 @@ const baseNotes = [
|
|
|
23
23
|
const numNotes = 12;
|
|
24
24
|
const whiteNotes = numNotes * 0.7; // approx
|
|
25
25
|
const audioContext = new window.AudioContext();
|
|
26
|
-
const
|
|
26
|
+
const BaseOctavePlayer = ({ octave, height, width, ...rest }) => {
|
|
27
27
|
const keyWidth = width / whiteNotes + 2;
|
|
28
28
|
const keyWidthToHeight = keyWidth / height;
|
|
29
29
|
const firstNote = Note.midi(baseNotes[0] + String(octave)) || 0;
|
|
@@ -35,7 +35,7 @@ const WithProvider = ({ format, height, hostname, instrumentName, octave = 4, on
|
|
|
35
35
|
hostname,
|
|
36
36
|
instrumentName,
|
|
37
37
|
onChange,
|
|
38
|
-
soundfont, render: ({ isLoading, playNote, stopNote, }) => (_jsxs(_Fragment, { children: [_jsx("div", { children: _jsxs("h2", { children: ["Octave: ", octave] }) }), _jsx(
|
|
38
|
+
soundfont, render: ({ isLoading, playNote, stopNote, }) => (_jsxs(_Fragment, { children: [_jsx("div", { children: _jsxs("h2", { children: ["Octave: ", octave] }) }), _jsx(BaseOctavePlayer, { disabled: isLoading, height,
|
|
39
39
|
octave,
|
|
40
40
|
onClick,
|
|
41
41
|
onDoubleClick,
|
|
@@ -45,4 +45,4 @@ const WithProvider = ({ format, height, hostname, instrumentName, octave = 4, on
|
|
|
45
45
|
stopNote,
|
|
46
46
|
Tooltip,
|
|
47
47
|
width })] })) }));
|
|
48
|
-
export
|
|
48
|
+
export { WithProvider as OctavePlayer };
|
|
@@ -22,7 +22,7 @@ const SoundfontProvider = (props) => {
|
|
|
22
22
|
setInstrument(newInstrument);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
else if (
|
|
25
|
+
else if (instrumentName) {
|
|
26
26
|
// the host app has already injected the soundfont into global space
|
|
27
27
|
Soundfont.instrument(audioContext, instrumentName).then(newInstrument => {
|
|
28
28
|
setInstrument(newInstrument);
|
|
@@ -34,7 +34,9 @@ const SoundfontProvider = (props) => {
|
|
|
34
34
|
}
|
|
35
35
|
}, [audioContext, format, hostname, instrumentName, soundfont]);
|
|
36
36
|
useEffect(() => {
|
|
37
|
-
|
|
37
|
+
if (instrumentName) {
|
|
38
|
+
loadInstrument(instrumentName);
|
|
39
|
+
}
|
|
38
40
|
}, [instrumentName, loadInstrument]);
|
|
39
41
|
useEffect(() => {
|
|
40
42
|
if (isDefined(instrumentName)) {
|
|
@@ -84,4 +86,4 @@ const SoundfontProvider = (props) => {
|
|
|
84
86
|
};
|
|
85
87
|
// https://gleitz.github.io/midi-js-soundfonts/MusyngKite/acoustic_grand_piano-mp3.js
|
|
86
88
|
// https://gleitz.github.io/midi-js-soundfonts/FluidR3_GM/.js
|
|
87
|
-
export
|
|
89
|
+
export { SoundfontProvider };
|
|
@@ -43,7 +43,7 @@ const calculateWordWidths = (style, textNode, text) => {
|
|
|
43
43
|
}
|
|
44
44
|
return undefined;
|
|
45
45
|
};
|
|
46
|
-
const
|
|
46
|
+
const SvgText = (props) => {
|
|
47
47
|
const { className = '', dx = 0, dy = 0, maxHeight = 1000, maxWidth = 1000,
|
|
48
48
|
// textAnchor = 'start',
|
|
49
49
|
text = '', verticalAnchor = 'start', x = 0, y = 0, transform = '', ...rest } = props;
|
|
@@ -105,5 +105,4 @@ const Text = (props) => {
|
|
|
105
105
|
// textAnchor={textAnchor}
|
|
106
106
|
transform: transform, ...rest, children: _jsxs(_Fragment, { children: [displayedLines.map((line, idx) => (_jsx("tspan", { dx: x + dx, dy: idx === 0 ? startDy + dy : wordWidths?.lineHeight || 0, x: 0, children: line.words.join(' ') }, idx))), textLines.length && displayedLines.length !== textLines.length && (_jsxs(_Fragment, { children: [_jsx("tspan", { children: "..." }), _jsx("title", { children: text })] }))] }) }));
|
|
107
107
|
};
|
|
108
|
-
export
|
|
109
|
-
export { MEASUREMENT_ELEMENT_ID };
|
|
108
|
+
export { SvgText, MEASUREMENT_ELEMENT_ID };
|
package/dist/pickers/CCPicker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import Select from './Select';
|
|
5
|
-
const CCPicker = forwardRef((props, ref) => (_jsx(Select, { ...props, options:
|
|
6
|
-
export
|
|
3
|
+
import { changeControllerOptions } from '../midi/ccValues';
|
|
4
|
+
import { Select } from './Select';
|
|
5
|
+
const CCPicker = forwardRef((props, ref) => (_jsx(Select, { ...props, options: changeControllerOptions, ref: ref })));
|
|
6
|
+
export { CCPicker };
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import cl from 'classnames';
|
|
3
3
|
import { forwardRef, useCallback, useEffect, useState } from 'react';
|
|
4
4
|
import { arraySequence } from '../utils';
|
|
5
|
-
import Select from './Select';
|
|
5
|
+
import { Select } from './Select';
|
|
6
6
|
const defaultOptions = arraySequence(16).map(value => ({
|
|
7
7
|
value,
|
|
8
8
|
label: value,
|
|
@@ -47,4 +47,4 @@ const ChannelMappingPicker = forwardRef(({ channels, className, ...rest }, ref)
|
|
|
47
47
|
}, [channels]);
|
|
48
48
|
return (_jsx(Select, { ...rest, className: cl(className, 'channel-mapping-picker'), formatOptionLabel: formatOptionLabel, options: options, ref: ref }));
|
|
49
49
|
});
|
|
50
|
-
export
|
|
50
|
+
export { ChannelMappingPicker };
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import cl from 'classnames';
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { arraySequence } from '../utils';
|
|
5
|
-
import Select from './Select';
|
|
5
|
+
import { Select } from './Select';
|
|
6
6
|
const options = arraySequence(16).map(value => ({
|
|
7
7
|
value: value,
|
|
8
8
|
label: `Channel ${value + 1}`,
|
|
@@ -18,4 +18,4 @@ const filterOptions = (option, input) => {
|
|
|
18
18
|
const ChannelPicker = forwardRef(({ className, ...rest }, ref) => {
|
|
19
19
|
return (_jsx(Select, { ...rest, className: cl(className, 'channel-picker'), filterOptions: filterOptions, formatOptionLabel: formatOptionLabel, options: options, ref: ref }));
|
|
20
20
|
});
|
|
21
|
-
export
|
|
21
|
+
export { ChannelPicker };
|
package/dist/pickers/Knob.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
3
|
import useStateWithDynamicDefault from '../hooks/useStateWithDynamicDefault';
|
|
4
|
-
import RotaryKnob from '../rotaryKnob';
|
|
4
|
+
import { RotaryKnob } from '../rotaryKnob';
|
|
5
5
|
import { assertRange } from '../utils';
|
|
6
|
-
import knobSkin10 from './knobSkin10';
|
|
6
|
+
import { knobSkin10 } from './knobSkin10';
|
|
7
7
|
const Knob = (props) => {
|
|
8
8
|
const { disabled = false, max = 127, min = 0, onChange, value: initialValue = 0, wheelEnabled = false, wheelSensitivity = 0.1, ...rest } = props;
|
|
9
9
|
const [value, setValue] = useStateWithDynamicDefault(initialValue);
|
|
@@ -46,4 +46,4 @@ const Knob = (props) => {
|
|
|
46
46
|
*/
|
|
47
47
|
skin: knobSkin10, style: { opacity: disabled ? 0.4 : 1 }, unlockDistance: 0, defaultValue: value, max, min, value, ...rest }));
|
|
48
48
|
};
|
|
49
|
-
export
|
|
49
|
+
export { Knob };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useMemo } from 'react';
|
|
3
3
|
import { arraySequence } from '../utils';
|
|
4
|
-
import Knob from './Knob';
|
|
5
|
-
import Select from './Select';
|
|
4
|
+
import { Knob } from './Knob';
|
|
5
|
+
import { Select } from './Select';
|
|
6
6
|
const KnobPicker = forwardRef((props, ref) => {
|
|
7
7
|
const { disabled, highToLow, includeLabel, includePicker, knobProps, label, max = 127, min = 0, onChange, shrinkLabel, value = 0, wheelEnabled, wheelSensitivity = 0.1, ...rest } = props;
|
|
8
8
|
const options = useMemo(() => {
|
|
@@ -26,4 +26,4 @@ const KnobPicker = forwardRef((props, ref) => {
|
|
|
26
26
|
wheelSensitivity,
|
|
27
27
|
...knobProps })] })] }));
|
|
28
28
|
});
|
|
29
|
-
export
|
|
29
|
+
export { KnobPicker };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import Select from './Select';
|
|
3
|
+
import { Select } from './Select';
|
|
4
4
|
const options = [
|
|
5
5
|
{ value: 0, label: 'Momentary' },
|
|
6
6
|
{ value: 1, label: 'Latching' },
|
|
7
7
|
];
|
|
8
8
|
const LatchPicker = forwardRef((props, ref) => (_jsx(Select, { ...props, options: options, ref: ref })));
|
|
9
|
-
export
|
|
9
|
+
export { LatchPicker };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useMemo } from 'react';
|
|
3
3
|
import { getStockNames, getUserMappingNames } from 'zds-mappings';
|
|
4
|
-
import Select from './Select';
|
|
4
|
+
import { Select } from './Select';
|
|
5
5
|
const MappingPicker = forwardRef(({ allowClearing, ...rest }, ref) => {
|
|
6
6
|
const stockMappings = getStockNames();
|
|
7
7
|
const userMappings = getUserMappingNames();
|
|
@@ -34,4 +34,4 @@ const MappingPicker = forwardRef(({ allowClearing, ...rest }, ref) => {
|
|
|
34
34
|
}, [allowClearing, stockMappings, userMappings]);
|
|
35
35
|
return (_jsx(Select, { ...rest, options: options, ref: ref }));
|
|
36
36
|
});
|
|
37
|
-
export
|
|
37
|
+
export { MappingPicker };
|
|
@@ -4,7 +4,7 @@ import { Midi } from 'tonal';
|
|
|
4
4
|
import { emptyMapping } from 'zds-mappings';
|
|
5
5
|
import useStateWithDynamicDefault from '../hooks/useStateWithDynamicDefault';
|
|
6
6
|
import { assertRange } from '../utils';
|
|
7
|
-
import Select from './Select';
|
|
7
|
+
import { Select } from './Select';
|
|
8
8
|
const { midiToNoteName } = Midi;
|
|
9
9
|
const formattedMapEntry = ({ note, name }) => `${note} ${name.length ? '-' : ''} ${name}`;
|
|
10
10
|
const formattedListEntry = (label, idx) => ({
|
|
@@ -42,4 +42,4 @@ const NotePicker = forwardRef((props, ref) => {
|
|
|
42
42
|
// isDisabled={disabled}
|
|
43
43
|
onChange: handleChange, options: options, ref: ref, value: value }));
|
|
44
44
|
});
|
|
45
|
-
export
|
|
45
|
+
export { NotePicker };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Piano as ReactPiano } from 'zds-react-piano';
|
|
3
|
-
import SoundfontProvider from '../other/SoundFontProvider';
|
|
3
|
+
import { SoundfontProvider } from '../other/SoundFontProvider';
|
|
4
4
|
const firstNote = 21;
|
|
5
5
|
const lastNote = 108;
|
|
6
6
|
const numNotes = lastNote - firstNote - 1;
|
|
7
7
|
const whiteNotes = numNotes * 0.7; // approx
|
|
8
8
|
const audioContext = new window.AudioContext();
|
|
9
|
-
const
|
|
9
|
+
const BasePianoPicker = ({ height, width, ...rest }) => {
|
|
10
10
|
const keyWidth = width / whiteNotes + 2;
|
|
11
11
|
const keyWidthToHeight = keyWidth / height;
|
|
12
12
|
return (_jsx("div", { children: _jsx(ReactPiano, { keyWidthToHeight: keyWidthToHeight, noteRange: { first: firstNote, last: lastNote }, width: width, ...rest }) }));
|
|
@@ -16,7 +16,7 @@ const WithProvider = ({ format, height, hostname, instrumentName, onChange, onCl
|
|
|
16
16
|
hostname,
|
|
17
17
|
instrumentName,
|
|
18
18
|
onChange,
|
|
19
|
-
soundfont, render: ({ isLoading, playNote, stopNote }) => (_jsx(
|
|
19
|
+
soundfont, render: ({ isLoading, playNote, stopNote }) => (_jsx(BasePianoPicker, { disabled: isLoading, height,
|
|
20
20
|
onClick,
|
|
21
21
|
onDoubleClick,
|
|
22
22
|
onKeyMouseEnter,
|
|
@@ -24,4 +24,4 @@ const WithProvider = ({ format, height, hostname, instrumentName, onChange, onCl
|
|
|
24
24
|
playNote,
|
|
25
25
|
stopNote,
|
|
26
26
|
width })) }));
|
|
27
|
-
export
|
|
27
|
+
export { WithProvider as PianoPicker };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import Select from './Select';
|
|
3
|
+
import { Select } from './Select';
|
|
4
4
|
const PolarityPicker = forwardRef(({ labelOff = 'Normally Off', labelOn = 'Normally On', ...rest }, ref) => {
|
|
5
5
|
const options = [
|
|
6
6
|
{ value: 0, label: labelOff },
|
|
@@ -8,4 +8,4 @@ const PolarityPicker = forwardRef(({ labelOff = 'Normally Off', labelOn = 'Norma
|
|
|
8
8
|
];
|
|
9
9
|
return (_jsx(Select, { ...rest, options: options, ref: ref }));
|
|
10
10
|
});
|
|
11
|
-
export
|
|
11
|
+
export { PolarityPicker };
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRef } from 'react';
|
|
3
3
|
import useComponentSize from '../hooks/useComponentSize';
|
|
4
4
|
import { responseCurves as origResponseCurves, } from '../midi/export';
|
|
5
|
-
import DefaultTooltip from '../other/DefaultTooltip';
|
|
6
|
-
import
|
|
5
|
+
import { DefaultTooltip } from '../other/DefaultTooltip';
|
|
6
|
+
import { SvgText } from '../other/SvgText';
|
|
7
7
|
// const width = 218
|
|
8
8
|
// const height = 150
|
|
9
9
|
const axisOffset = 20;
|
|
@@ -101,7 +101,7 @@ const ResponseCurve = (props) => {
|
|
|
101
101
|
labelY,
|
|
102
102
|
};
|
|
103
103
|
});
|
|
104
|
-
return (_jsx("div", { className: "response-curve-picker", ref: ref, children: _jsxs("svg", { ...svgProps, children: [_jsx("rect", { className: "container", height: height, rx: 3, ry: 3, width: width, x: 0, y: 0 }), _jsx(
|
|
104
|
+
return (_jsx("div", { className: "response-curve-picker", ref: ref, children: _jsxs("svg", { ...svgProps, children: [_jsx("rect", { className: "container", height: height, rx: 3, ry: 3, width: width, x: 0, y: 0 }), _jsx(SvgText, { className: "axis", textAnchor: "middle", transform: `translate(${axisX1 - 14} ${height / 2}) rotate(90)`, x: 0, y: 0, text: "Applied force" }), _jsx(SvgText, { className: "axis", textAnchor: "middle", transform: `translate(${width / 2} ${axisY2 + 13})`, x: 0, y: 0, text: "Output (velocity)" }), _jsx("line", { className: "axis", x1: axisX1, x2: axisX1, y1: axisY1, y2: axisY2 }), _jsx("line", { className: "axis", x1: axisX1, x2: axisX2, y1: axisY2, y2: axisY2 }), responseCurves.map(({ value, label, x1, y1, x2, y2, c1, c2, labelX, labelY }) => (_jsxs("g", { children: [_jsx("path", { className: value === responseCurve ? 'curve-selected' : 'curve', d: `M${x1} ${y1} C ${c1} ${c2}, ${c1} ${c2}, ${x2} ${y2}` }), _jsx(Tooltip, { placement: "left", title: label, children: _jsx("rect", { className: value === responseCurve ? 'button-selected' : 'button', height: buttonSize, onClick: disabled
|
|
105
105
|
? f => f
|
|
106
106
|
: () => onChange({
|
|
107
107
|
target: {
|
|
@@ -109,4 +109,4 @@ const ResponseCurve = (props) => {
|
|
|
109
109
|
},
|
|
110
110
|
}), transform: `translate(${labelX + 3} ${labelY - buttonSize / 1.05}) rotate(45)`, width: buttonSize }) }), _jsxs("text", { className: value === responseCurve ? 'button-selected' : 'button', transform: `translate(${labelX} ${labelY})`, children: [value, _jsx("title", { children: label })] })] }, value)))] }) }));
|
|
111
111
|
};
|
|
112
|
-
export
|
|
112
|
+
export { ResponseCurve };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback } from 'react';
|
|
3
3
|
import { responseCurves } from '../midi/export';
|
|
4
|
-
import DefaultTooltip from '../other/DefaultTooltip';
|
|
4
|
+
import { DefaultTooltip } from '../other/DefaultTooltip';
|
|
5
5
|
import { findObj } from '../utils';
|
|
6
|
-
import ResponseCurve from './ResponseCurve';
|
|
7
|
-
import Select from './Select';
|
|
6
|
+
import { ResponseCurve } from './ResponseCurve';
|
|
7
|
+
import { Select } from './Select';
|
|
8
8
|
const ResponseCurvePicker = forwardRef((props, ref) => {
|
|
9
9
|
const { Tooltip = DefaultTooltip, inverted = false, onChange, value, ...rest } = props;
|
|
10
10
|
const Placeholder = useCallback(() => (_jsx("div", { className: "singleValue", children: findObj('value', value)(responseCurves)?.label })), [value]);
|
|
@@ -17,4 +17,4 @@ const ResponseCurvePicker = forwardRef((props, ref) => {
|
|
|
17
17
|
MenuList,
|
|
18
18
|
}, isSearchable: false, onChange: f => f, ref: ref, value: value }));
|
|
19
19
|
});
|
|
20
|
-
export
|
|
20
|
+
export { ResponseCurvePicker };
|
package/dist/pickers/Select.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import Select from './Select';
|
|
3
|
+
import { Select } from './Select';
|
|
4
4
|
const StatusPicker = forwardRef(({ statuses, ...rest }, ref) => (_jsx(Select, { ...rest, options: statuses, ref: ref })));
|
|
5
|
-
export
|
|
5
|
+
export { StatusPicker };
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef, useCallback, useMemo } from 'react';
|
|
3
3
|
import useStateWithDynamicDefault from '../hooks/useStateWithDynamicDefault';
|
|
4
4
|
import { arraySequence, assertRange } from '../utils';
|
|
5
|
-
import Select from './Select';
|
|
5
|
+
import { Select } from './Select';
|
|
6
6
|
const ValuePicker = forwardRef((props, ref) => {
|
|
7
7
|
const { disabled, highToLow, max = 127, min = 0, onChange, value: initialValue = 0, ...rest } = props;
|
|
8
8
|
const options = useMemo(() => {
|
|
@@ -20,4 +20,4 @@ const ValuePicker = forwardRef((props, ref) => {
|
|
|
20
20
|
}, [max, min, onChange, setValue]);
|
|
21
21
|
return (_jsx(Select, { ...rest, disabled: disabled, onChange: handleChange, options: options, ref: ref, value: value }));
|
|
22
22
|
});
|
|
23
|
-
export
|
|
23
|
+
export { ValuePicker };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import
|
|
4
|
-
import DrawCircle from './DrawCircle';
|
|
5
|
-
import DrawLine from './DrawLine';
|
|
6
|
-
import HelpersOverlay from './HelpersOverlay';
|
|
3
|
+
import { toRadians } from '../utils';
|
|
4
|
+
import { DrawCircle } from './DrawCircle';
|
|
5
|
+
import { DrawLine } from './DrawLine';
|
|
6
|
+
import { HelpersOverlay } from './HelpersOverlay';
|
|
7
7
|
class KnobVisualHelpers extends React.Component {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
@@ -27,8 +27,8 @@ class KnobVisualHelpers extends React.Component {
|
|
|
27
27
|
const halfWidth = vbox.width / 2;
|
|
28
28
|
//Calculate current angle segment end point
|
|
29
29
|
//Note: Not sure why we need to subtract 90 here
|
|
30
|
-
const valueMarkerX = props.radius * Math.cos(
|
|
31
|
-
const valueMarkerY = props.radius * Math.sin(
|
|
30
|
+
const valueMarkerX = props.radius * Math.cos(toRadians(props.valueAngle - 90));
|
|
31
|
+
const valueMarkerY = props.radius * Math.sin(toRadians(props.valueAngle - 90));
|
|
32
32
|
return {
|
|
33
33
|
...state,
|
|
34
34
|
centerX: vbox.left + halfWidth,
|
package/dist/rotaryKnob/index.js
CHANGED
|
@@ -8,10 +8,10 @@ import { scaleLinear } from 'd3-scale';
|
|
|
8
8
|
import { select } from 'd3-selection';
|
|
9
9
|
import { useEffect, useRef, useState } from 'react';
|
|
10
10
|
import { SvgLoader, SvgProxy } from 'react-svgmt';
|
|
11
|
-
import InternalInput from './InternalInput';
|
|
11
|
+
import { InternalInput } from './InternalInput';
|
|
12
12
|
import { KnobVisualHelpers } from './helpers/KnobVisualHelpers';
|
|
13
13
|
import defaultSkin from './knobdefaultskin';
|
|
14
|
-
import
|
|
14
|
+
import { getAngleForPoint } from './utils';
|
|
15
15
|
// function printDebugValues(obj) {
|
|
16
16
|
// console.log('------------')
|
|
17
17
|
// Object.keys(obj).forEach(key => {
|
|
@@ -145,7 +145,7 @@ const RotaryKnob = (props) => {
|
|
|
145
145
|
elem.classed('dragging', true);
|
|
146
146
|
onStart();
|
|
147
147
|
startPos = { x: event.x - cx, y: event.y - cy };
|
|
148
|
-
startAngle =
|
|
148
|
+
startAngle = getAngleForPoint(startPos.x, startPos.y);
|
|
149
149
|
initialAngle = convertValueToAngle(currentValue);
|
|
150
150
|
monitoring = false;
|
|
151
151
|
// ...existing setState code...
|
|
@@ -156,14 +156,14 @@ const RotaryKnob = (props) => {
|
|
|
156
156
|
if (preciseMode) {
|
|
157
157
|
if (!monitoring && distanceFromCenter >= unlockDistance) {
|
|
158
158
|
startPos = currentPos;
|
|
159
|
-
startAngle =
|
|
159
|
+
startAngle = getAngleForPoint(currentPos.x, currentPos.y);
|
|
160
160
|
monitoring = true;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
164
|
monitoring = true;
|
|
165
165
|
}
|
|
166
|
-
const currentAngle =
|
|
166
|
+
const currentAngle = getAngleForPoint(currentPos.x, currentPos.y);
|
|
167
167
|
const deltaAngle = currentAngle - startAngle;
|
|
168
168
|
let finalAngle = initialAngle + deltaAngle;
|
|
169
169
|
finalAngle = normalizeAngle(finalAngle);
|
|
@@ -241,4 +241,4 @@ const RotaryKnob = (props) => {
|
|
|
241
241
|
: null;
|
|
242
242
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: container, style: styles.container, ...rest, children: [_jsx(InternalInput, { disabled: disabled, inputRef: inputRef, style: styles.input, value: currentValue, min: min, max: max, step: step, onChange: onFormControlChange }), _jsxs(SvgLoader, { height: "100%", svgXML: skin.svg, width: "100%", onSVGReady: saveRef, children: [_jsx(SvgProxy, { selector: "#knob", transform: `$ORIGINAL rotate(${angle}, ${skin.knobX}, ${skin.knobY})` }), skinElemUpdates] })] }), state.dragging && preciseMode && (_jsx(KnobVisualHelpers, { svgRef: state.svgRef, radius: state.dragDistance, mousePos: state.mousePos, minimumDragDistance: unlockDistance, valueAngle: state.valueAngle }))] }));
|
|
243
243
|
};
|
|
244
|
-
export
|
|
244
|
+
export { RotaryKnob };
|
package/dist/rotaryKnob/utils.js
CHANGED
|
@@ -96,11 +96,7 @@ function transformBoundingClientRectToDocument(box) {
|
|
|
96
96
|
//info needed to draw line from center to mousepos
|
|
97
97
|
return { top: ttop, left: tleft, width: box.width, height: box.height };
|
|
98
98
|
}
|
|
99
|
-
export
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
getQuadrant,
|
|
104
|
-
getAngleForPoint,
|
|
105
|
-
transformBoundingClientRectToDocument,
|
|
106
|
-
};
|
|
99
|
+
export {
|
|
100
|
+
// toGlobalCoordinates,
|
|
101
|
+
// toLocalCoordinates,
|
|
102
|
+
toRadians, getQuadrant, getAngleForPoint, transformBoundingClientRectToDocument, };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './midi/ccValues';
|
|
|
2
2
|
export * from './midi/export';
|
|
3
3
|
export * from './other/DefaultTooltip';
|
|
4
4
|
export * from './other/OctavePlayer';
|
|
5
|
-
export * from './other/
|
|
5
|
+
export * from './other/SvgText';
|
|
6
6
|
export * from './pickers/ChannelMappingPicker';
|
|
7
7
|
export * from './pickers/ChannelPicker';
|
|
8
8
|
export * from './pickers/Knob';
|
|
@@ -21,7 +21,7 @@ export type * from './midi/export';
|
|
|
21
21
|
export type * from './other/DefaultTooltip';
|
|
22
22
|
export type * from './other/OctavePlayer';
|
|
23
23
|
export type * from './other/SoundFontProvider';
|
|
24
|
-
export type * from './other/
|
|
24
|
+
export type * from './other/SvgText';
|
|
25
25
|
export type * from './pickers/CCPicker';
|
|
26
26
|
export type * from './pickers/ChannelMappingPicker';
|
|
27
27
|
export type * from './pickers/ChannelPicker';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Option } from '../pickers/Select';
|
|
2
|
-
declare const
|
|
3
|
-
export
|
|
2
|
+
declare const changeControllerOptions: Option<number>[];
|
|
3
|
+
export { changeControllerOptions };
|
|
@@ -6,5 +6,5 @@ type TooltipProps = {
|
|
|
6
6
|
declare const DefaultTooltip: ({ children }: React.PropsWithoutRef<TooltipProps>) => import("react").FunctionComponentElement<{
|
|
7
7
|
children?: import("react").ReactNode | undefined;
|
|
8
8
|
}>;
|
|
9
|
-
export
|
|
9
|
+
export { DefaultTooltip };
|
|
10
10
|
export type { TooltipProps };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type Soundfont from 'soundfont-player';
|
|
2
2
|
import type { TooltipProps } from './DefaultTooltip';
|
|
3
|
+
type PianoMidiNote = {
|
|
4
|
+
accidental: boolean;
|
|
5
|
+
left: number;
|
|
6
|
+
midiNumber: number;
|
|
7
|
+
width: number;
|
|
8
|
+
};
|
|
3
9
|
type OctavePlayerProps = {
|
|
4
10
|
disabled?: boolean;
|
|
5
11
|
height: number;
|
|
@@ -10,17 +16,17 @@ type WithProviderProps = {
|
|
|
10
16
|
format?: 'mp3' | 'ogg';
|
|
11
17
|
height: number;
|
|
12
18
|
hostname?: string;
|
|
13
|
-
instrumentName
|
|
19
|
+
instrumentName?: Soundfont.InstrumentName;
|
|
14
20
|
octave?: number;
|
|
15
21
|
onChange?: (note: number) => void;
|
|
16
22
|
onClick?: (note: number) => void;
|
|
17
23
|
onDoubleClick?: (note: number) => void;
|
|
18
|
-
onKeyMouseEnter?: (note:
|
|
24
|
+
onKeyMouseEnter?: (note: PianoMidiNote) => void;
|
|
19
25
|
onKeyMouseLeave?: (note: number) => void;
|
|
20
26
|
soundfont?: 'MusyngKite' | 'FluidR3_GM';
|
|
21
27
|
Tooltip?: TooltipProps;
|
|
22
28
|
width: number;
|
|
23
29
|
};
|
|
24
30
|
declare const WithProvider: ({ format, height, hostname, instrumentName, octave, onChange, onClick, onDoubleClick, onKeyMouseEnter, onKeyMouseLeave, soundfont, Tooltip, width, }: WithProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
-
export
|
|
26
|
-
export type { OctavePlayerProps, WithProviderProps };
|
|
31
|
+
export { WithProvider as OctavePlayer };
|
|
32
|
+
export type { OctavePlayerProps, PianoMidiNote, WithProviderProps };
|
|
@@ -3,7 +3,7 @@ type SoundfontProviderProps = {
|
|
|
3
3
|
audioContext: AudioContext;
|
|
4
4
|
format?: 'mp3' | 'ogg';
|
|
5
5
|
hostname?: string;
|
|
6
|
-
instrumentName
|
|
6
|
+
instrumentName?: Soundfont.InstrumentName;
|
|
7
7
|
onChange?: (midiNumber: number) => void;
|
|
8
8
|
render: (props: {
|
|
9
9
|
isLoading: boolean;
|
|
@@ -14,5 +14,5 @@ type SoundfontProviderProps = {
|
|
|
14
14
|
soundfont?: 'MusyngKite' | 'FluidR3_GM';
|
|
15
15
|
};
|
|
16
16
|
declare const SoundfontProvider: (props: SoundfontProviderProps) => import("react").ReactNode;
|
|
17
|
-
export
|
|
17
|
+
export { SoundfontProvider };
|
|
18
18
|
export type { SoundfontProviderProps };
|
|
@@ -22,7 +22,6 @@ type TextProps = Partial<HTMLOrSVGElement> & {
|
|
|
22
22
|
x?: number;
|
|
23
23
|
y?: number;
|
|
24
24
|
};
|
|
25
|
-
declare const
|
|
26
|
-
export
|
|
27
|
-
export { MEASUREMENT_ELEMENT_ID };
|
|
25
|
+
declare const SvgText: (props: TextProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export { SvgText, MEASUREMENT_ELEMENT_ID };
|
|
28
27
|
export type { TextProps, WordWidths, WordsByLine };
|
|
@@ -3,5 +3,5 @@ import type { Option, SelectProps } from './Select';
|
|
|
3
3
|
type CCPickerProps = SelectProps<number>;
|
|
4
4
|
type CCPickerRef = SelectInstance<Option<number>, false, GroupBase<Option<number>>>;
|
|
5
5
|
declare const CCPicker: import("react").ForwardRefExoticComponent<CCPickerProps & import("react").RefAttributes<SelectInstance<Option<number>, false, GroupBase<Option<number>>>>>;
|
|
6
|
-
export
|
|
6
|
+
export { CCPicker };
|
|
7
7
|
export type { CCPickerProps, CCPickerRef };
|
|
@@ -11,5 +11,5 @@ interface ChannelMappingPickerProps extends SelectProps<InternalValue> {
|
|
|
11
11
|
}
|
|
12
12
|
type ChannelMappingPickerRef = SelectInstance<Option<number>, false, GroupBase<Option<number>>>;
|
|
13
13
|
declare const ChannelMappingPicker: import("react").ForwardRefExoticComponent<ChannelMappingPickerProps & import("react").RefAttributes<SelectInstance<Option<InternalValue>, false, GroupBase<Option<InternalValue>>>>>;
|
|
14
|
-
export
|
|
14
|
+
export { ChannelMappingPicker };
|
|
15
15
|
export type { ChannelMappingOption, ChannelMappingPickerProps, ChannelMappingPickerRef, };
|
|
@@ -4,5 +4,5 @@ type Channel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
|
|
|
4
4
|
type ChannelPickerProps = SelectProps<Channel>;
|
|
5
5
|
type ChannelPickerRef = SelectInstance<Option<Channel>, false, GroupBase<Option<Channel>>>;
|
|
6
6
|
declare const ChannelPicker: import("react").ForwardRefExoticComponent<ChannelPickerProps & import("react").RefAttributes<SelectInstance<Option<Channel>, false, GroupBase<Option<Channel>>>>>;
|
|
7
|
-
export
|
|
7
|
+
export { ChannelPicker };
|
|
8
8
|
export type { Channel, ChannelPickerProps, ChannelPickerRef };
|
|
@@ -23,5 +23,5 @@ declare const KnobPicker: import("react").ForwardRefExoticComponent<SelectProps<
|
|
|
23
23
|
wheelSensitivity?: number;
|
|
24
24
|
value: number;
|
|
25
25
|
} & import("react").RefAttributes<SelectInstance<Option<number>, false, GroupBase<Option<number>>>>>;
|
|
26
|
-
export
|
|
26
|
+
export { KnobPicker };
|
|
27
27
|
export type { KnobPickerProps, KnobPickerRef };
|