zds-pickers 4.0.12 → 4.0.14
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 +12481 -35
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/midi/ccValues.js +2 -2
- package/dist/midi/export.js +43 -1
- package/dist/other/DefaultTooltip.js +1 -1
- package/dist/other/OctavePlayer.js +4 -4
- package/dist/other/SoundFontProvider.js +1 -1
- 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 +14 -56
- package/dist/pickers/ResponseCurvePicker.js +6 -5
- 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/midi/export.d.ts +12 -1
- package/dist/types/other/DefaultTooltip.d.ts +1 -1
- package/dist/types/other/OctavePlayer.d.ts +1 -1
- package/dist/types/other/SoundFontProvider.d.ts +1 -1
- 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 +4 -15
- package/dist/types/pickers/ResponseCurvePicker.d.ts +2 -2
- 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/midi/export.ts +58 -2
- package/lib/other/DefaultTooltip.ts +1 -1
- package/lib/other/OctavePlayer.tsx +4 -4
- package/lib/other/SoundFontProvider.tsx +1 -1
- 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 +22 -75
- package/lib/pickers/ResponseCurvePicker.tsx +6 -5
- 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 -7
- 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 };
|
package/dist/midi/export.js
CHANGED
|
@@ -24,4 +24,46 @@ const extractStatusAndChannel = (status) => ({
|
|
|
24
24
|
status: (((status & MASK_STATUS) >> 4) | 8),
|
|
25
25
|
channel: status & MASK_CHANNEL,
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
const RESPONSE_CURVE_0 = 0;
|
|
28
|
+
const RESPONSE_CURVE_1 = 1;
|
|
29
|
+
const RESPONSE_CURVE_2 = 2;
|
|
30
|
+
const RESPONSE_CURVE_3 = 3;
|
|
31
|
+
const RESPONSE_CURVE_4 = 4;
|
|
32
|
+
const RESPONSE_CURVE_5 = 5;
|
|
33
|
+
const RESPONSE_CURVE_6 = 6;
|
|
34
|
+
const RESPONSE_CURVE_7 = 7;
|
|
35
|
+
const responseCurves = [
|
|
36
|
+
{
|
|
37
|
+
value: RESPONSE_CURVE_7,
|
|
38
|
+
label: 'Always maxed out.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
value: RESPONSE_CURVE_6,
|
|
42
|
+
label: 'Most sensitive.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: RESPONSE_CURVE_5,
|
|
46
|
+
label: 'Moderately sensitive.',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
value: RESPONSE_CURVE_4,
|
|
50
|
+
label: 'A little sensitive.',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: RESPONSE_CURVE_0,
|
|
54
|
+
label: 'Linear, no change.',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: RESPONSE_CURVE_1,
|
|
58
|
+
label: 'A little less sensitive.',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: RESPONSE_CURVE_2,
|
|
62
|
+
label: 'Even less sensitive.',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
value: RESPONSE_CURVE_3,
|
|
66
|
+
label: 'Least sensitive.',
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
export { combineStatusWithChannel, extractStatusAndChannel, getStatusLabel, MASK_CHANNEL, MASK_STATUS, responseCurves, Statuses, statusOptions, };
|
|
@@ -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 };
|
|
@@ -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 };
|
|
@@ -1,50 +1,9 @@
|
|
|
1
1
|
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
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const RESPONSE_CURVE_1 = 1;
|
|
8
|
-
const RESPONSE_CURVE_2 = 2;
|
|
9
|
-
const RESPONSE_CURVE_3 = 3;
|
|
10
|
-
const RESPONSE_CURVE_4 = 4;
|
|
11
|
-
const RESPONSE_CURVE_5 = 5;
|
|
12
|
-
const RESPONSE_CURVE_6 = 6;
|
|
13
|
-
const RESPONSE_CURVE_7 = 7;
|
|
14
|
-
const RESPONSE_CURVES = [
|
|
15
|
-
{
|
|
16
|
-
value: RESPONSE_CURVE_7,
|
|
17
|
-
label: 'Always maxed out.',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
value: RESPONSE_CURVE_6,
|
|
21
|
-
label: 'Most sensitive.',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
value: RESPONSE_CURVE_5,
|
|
25
|
-
label: 'Moderately sensitive.',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
value: RESPONSE_CURVE_4,
|
|
29
|
-
label: 'A little sensitive.',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
value: RESPONSE_CURVE_0,
|
|
33
|
-
label: 'Linear, no change.',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
value: RESPONSE_CURVE_1,
|
|
37
|
-
label: 'A little less sensitive.',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
value: RESPONSE_CURVE_2,
|
|
41
|
-
label: 'Even less sensitive.',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: RESPONSE_CURVE_3,
|
|
45
|
-
label: 'Least sensitive.',
|
|
46
|
-
},
|
|
47
|
-
];
|
|
4
|
+
import { responseCurves as origResponseCurves, } from '../midi/export';
|
|
5
|
+
import { DefaultTooltip } from '../other/DefaultTooltip';
|
|
6
|
+
import { SvgText } from '../other/SvgText';
|
|
48
7
|
// const width = 218
|
|
49
8
|
// const height = 150
|
|
50
9
|
const axisOffset = 20;
|
|
@@ -63,7 +22,7 @@ const ResponseCurve = (props) => {
|
|
|
63
22
|
const xMid = width / 2;
|
|
64
23
|
const yMid = height / 2;
|
|
65
24
|
const svgProps = { ref: svgRef };
|
|
66
|
-
const responseCurves =
|
|
25
|
+
const responseCurves = origResponseCurves.map(
|
|
67
26
|
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
|
|
68
27
|
({ value, label }) => {
|
|
69
28
|
let c1 = 0;
|
|
@@ -75,48 +34,48 @@ const ResponseCurve = (props) => {
|
|
|
75
34
|
let labelX = xMid;
|
|
76
35
|
let labelY = yMid;
|
|
77
36
|
switch (value) {
|
|
78
|
-
case
|
|
37
|
+
case responseCurves[0].value:
|
|
79
38
|
c1 = xMid;
|
|
80
39
|
c2 = yMid;
|
|
81
40
|
labelY += 3;
|
|
82
41
|
break;
|
|
83
|
-
case
|
|
42
|
+
case responseCurves[1].value:
|
|
84
43
|
c1 = inverted ? xMid + width * 0.13 : xMid - width * 0.13;
|
|
85
44
|
c2 = yMid - height * 0.13;
|
|
86
45
|
labelX = inverted ? xMid + width * 0.1 : xMid - width * 0.1;
|
|
87
46
|
labelY = yMid - height * 0.09;
|
|
88
47
|
break;
|
|
89
|
-
case
|
|
48
|
+
case responseCurves[2].value:
|
|
90
49
|
c1 = inverted ? xMid + width * 0.25 : xMid - width * 0.25;
|
|
91
50
|
c2 = yMid - height * 0.25;
|
|
92
51
|
labelX = inverted ? xMid + width * 0.2 : xMid - width * 0.2;
|
|
93
52
|
labelY = yMid - height * 0.17;
|
|
94
53
|
break;
|
|
95
|
-
case
|
|
54
|
+
case responseCurves[3].value:
|
|
96
55
|
c1 = inverted ? xMid + width * 0.35 : xMid - width * 0.35;
|
|
97
56
|
c2 = yMid - height * 0.35;
|
|
98
57
|
labelX = inverted ? xMid + width * 0.28 : xMid - width * 0.28;
|
|
99
58
|
labelY = yMid - height * 0.25;
|
|
100
59
|
break;
|
|
101
|
-
case
|
|
60
|
+
case responseCurves[4].value:
|
|
102
61
|
c1 = inverted ? xMid - width * 0.13 : xMid + width * 0.13;
|
|
103
62
|
c2 = yMid + height * 0.13;
|
|
104
63
|
labelX = inverted ? xMid - width * 0.1 : xMid + width * 0.1;
|
|
105
64
|
labelY = yMid + height * 0.1;
|
|
106
65
|
break;
|
|
107
|
-
case
|
|
66
|
+
case responseCurves[5].value:
|
|
108
67
|
c1 = inverted ? xMid - width * 0.25 : xMid + width * 0.25;
|
|
109
68
|
c2 = yMid + height * 0.25;
|
|
110
69
|
labelX = inverted ? xMid - width * 0.2 : xMid + width * 0.2;
|
|
111
70
|
labelY = yMid + height * 0.18;
|
|
112
71
|
break;
|
|
113
|
-
case
|
|
72
|
+
case responseCurves[6].value:
|
|
114
73
|
c1 = inverted ? xMid - width * 0.35 : xMid + width * 0.35;
|
|
115
74
|
c2 = yMid + height * 0.35;
|
|
116
75
|
labelX = inverted ? xMid - width * 0.28 : xMid + width * 0.28;
|
|
117
76
|
labelY = yMid + height * 0.25;
|
|
118
77
|
break;
|
|
119
|
-
case
|
|
78
|
+
case responseCurves[7].value:
|
|
120
79
|
x1 = inverted ? axisX1 : axisX2;
|
|
121
80
|
y1 = axisY1;
|
|
122
81
|
x2 = x1;
|
|
@@ -142,7 +101,7 @@ const ResponseCurve = (props) => {
|
|
|
142
101
|
labelY,
|
|
143
102
|
};
|
|
144
103
|
});
|
|
145
|
-
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
|
|
146
105
|
? f => f
|
|
147
106
|
: () => onChange({
|
|
148
107
|
target: {
|
|
@@ -150,5 +109,4 @@ const ResponseCurve = (props) => {
|
|
|
150
109
|
},
|
|
151
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)))] }) }));
|
|
152
111
|
};
|
|
153
|
-
export
|
|
154
|
-
export { RESPONSE_CURVES };
|
|
112
|
+
export { ResponseCurve };
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef, useCallback } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { responseCurves } from '../midi/export';
|
|
4
|
+
import { DefaultTooltip } from '../other/DefaultTooltip';
|
|
4
5
|
import { findObj } from '../utils';
|
|
5
|
-
import
|
|
6
|
-
import Select from './Select';
|
|
6
|
+
import { ResponseCurve } from './ResponseCurve';
|
|
7
|
+
import { Select } from './Select';
|
|
7
8
|
const ResponseCurvePicker = forwardRef((props, ref) => {
|
|
8
9
|
const { Tooltip = DefaultTooltip, inverted = false, onChange, value, ...rest } = props;
|
|
9
|
-
const Placeholder = useCallback(() => (_jsx("div", { className: "singleValue", children: findObj('value', value)(
|
|
10
|
+
const Placeholder = useCallback(() => (_jsx("div", { className: "singleValue", children: findObj('value', value)(responseCurves)?.label })), [value]);
|
|
10
11
|
const MenuList = useCallback(({ setValue }) => (_jsx(ResponseCurve, { autosize: true, inverted: inverted, onChange: ({ target: { value: v } }) => {
|
|
11
12
|
setValue(v);
|
|
12
13
|
onChange(v);
|
|
@@ -16,4 +17,4 @@ const ResponseCurvePicker = forwardRef((props, ref) => {
|
|
|
16
17
|
MenuList,
|
|
17
18
|
}, isSearchable: false, onChange: f => f, ref: ref, value: value }));
|
|
18
19
|
});
|
|
19
|
-
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
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import { DrawCircle } from './DrawCircle';
|
|
4
|
+
import { DrawLine } from './DrawLine';
|
|
5
|
+
import { HelpersOverlay } from './HelpersOverlay';
|
|
6
|
+
import { toRadians } from '../utils';
|
|
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, };
|