zds-pickers 3.11.2 → 4.0.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/dist/index.cjs.js +196 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +23698 -0
- package/dist/index.es.js.map +1 -0
- package/dist/main.d.ts +232 -0
- package/package.json +56 -65
- package/dist/hooks/useComponentSize.js +0 -54
- package/dist/hooks/useStateWithDynamicDefault.js +0 -11
- package/dist/index.js +0 -43
- package/dist/midi/ccValues.js +0 -137
- package/dist/midi/statuses.js +0 -33
- package/dist/other/DefaultTooltip.js +0 -8
- package/dist/other/OctavePlayer.js +0 -121
- package/dist/other/SVGText.js +0 -116
- package/dist/other/SoundFontProvider.js +0 -124
- package/dist/other/utils.js +0 -52
- package/dist/pickers/CCPicker.js +0 -19
- package/dist/pickers/ChannelMappingPicker.js +0 -79
- package/dist/pickers/ChannelPicker.js +0 -40
- package/dist/pickers/Knob.js +0 -86
- package/dist/pickers/KnobPicker.js +0 -101
- package/dist/pickers/LatchPicker.js +0 -23
- package/dist/pickers/MappingPicker.js +0 -61
- package/dist/pickers/NotePicker.js +0 -83
- package/dist/pickers/PianoPicker.js +0 -104
- package/dist/pickers/PolarityPicker.js +0 -32
- package/dist/pickers/ResponseCurve.js +0 -263
- package/dist/pickers/ResponseCurvePicker.js +0 -58
- package/dist/pickers/Select.js +0 -174
- package/dist/pickers/StatusPicker.js +0 -22
- package/dist/pickers/ValuePicker.js +0 -57
- package/dist/pickers/knobSkin10.js +0 -94
- package/dist/shapes.js +0 -11
- package/dist/stories/assets/General MIDI.js +0 -69
- package/dist/stories/assets/mapper.js +0 -82
- package/dist/stories/assets/utils.js +0 -6
- package/dist/temp/acoustic_grand_piano-mp3.js +0 -94
- package/dist/utils.js +0 -45
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["disabled", "highToLow", "includeLabel", "includePicker", "knobProps", "label", "max", "min", "onChange", "shrinkLabel", "value", "wheelEnabled", "wheelSensitivity"];function ownKeys(e, r) {var t = Object.keys(e);if (Object.getOwnPropertySymbols) {var o = Object.getOwnPropertySymbols(e);r && (o = o.filter(function (r) {return Object.getOwnPropertyDescriptor(e, r).enumerable;})), t.push.apply(t, o);}return t;}function _objectSpread(e) {for (var r = 1; r < arguments.length; r++) {var t = null != arguments[r] ? arguments[r] : {};r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {_defineProperty(e, r, t[r]);}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));});}return e;}import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { arraySequence } from '../utils';
|
|
4
|
-
import Select from './Select';
|
|
5
|
-
import Knob from './Knob';
|
|
6
|
-
|
|
7
|
-
var KnobPicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
8
|
-
var
|
|
9
|
-
disabled =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
props.disabled,highToLow = props.highToLow,includeLabel = props.includeLabel,includePicker = props.includePicker,knobProps = props.knobProps,label = props.label,max = props.max,min = props.min,onChange = props.onChange,shrinkLabel = props.shrinkLabel,value = props.value,wheelEnabled = props.wheelEnabled,wheelSensitivity = props.wheelSensitivity,rest = _objectWithoutProperties(props, _excluded);
|
|
24
|
-
|
|
25
|
-
var options = useMemo(
|
|
26
|
-
function () {
|
|
27
|
-
var result = arraySequence(max - min + 1).
|
|
28
|
-
map(function (i) {return min + i;}).
|
|
29
|
-
map(function (i) {return { value: i, label: i };});
|
|
30
|
-
return highToLow ? result.reverse() : result;
|
|
31
|
-
},
|
|
32
|
-
[highToLow, max, min]
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
return /*#__PURE__*/(
|
|
36
|
-
React.createElement("div", { className: "zds-pickers__container" },
|
|
37
|
-
Boolean(!shrinkLabel && Boolean(label)) && /*#__PURE__*/React.createElement("span", { className: "zds-pickers__label" }, label), /*#__PURE__*/
|
|
38
|
-
React.createElement("div", { style: { display: 'inline-flex', gap: 10, alignItems: 'center' } },
|
|
39
|
-
Boolean(includePicker) && /*#__PURE__*/
|
|
40
|
-
React.createElement(Select, _objectSpread(_objectSpread({},
|
|
41
|
-
|
|
42
|
-
rest), {}, {
|
|
43
|
-
disabled: disabled,
|
|
44
|
-
isDisabled: disabled,
|
|
45
|
-
onChange: onChange,
|
|
46
|
-
options: options,
|
|
47
|
-
ref: ref,
|
|
48
|
-
value: value })
|
|
49
|
-
|
|
50
|
-
), /*#__PURE__*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
React.createElement(Knob, _objectSpread({
|
|
54
|
-
|
|
55
|
-
disabled: disabled,
|
|
56
|
-
max: max,
|
|
57
|
-
min: min,
|
|
58
|
-
onChange: onChange,
|
|
59
|
-
value: value,
|
|
60
|
-
wheelEnabled: wheelEnabled,
|
|
61
|
-
wheelSensitivity: wheelSensitivity },
|
|
62
|
-
knobProps)
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
)
|
|
66
|
-
));
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
KnobPicker.propTypes = {
|
|
71
|
-
disabled: PropTypes.bool,
|
|
72
|
-
highToLow: PropTypes.bool,
|
|
73
|
-
includeLabel: PropTypes.bool,
|
|
74
|
-
includePicker: PropTypes.bool,
|
|
75
|
-
knobProps: PropTypes.object,
|
|
76
|
-
label: PropTypes.string,
|
|
77
|
-
max: PropTypes.number,
|
|
78
|
-
min: PropTypes.number,
|
|
79
|
-
onChange: PropTypes.func.isRequired,
|
|
80
|
-
shrinkLabel: PropTypes.bool,
|
|
81
|
-
value: PropTypes.number,
|
|
82
|
-
wheelEnabled: PropTypes.bool,
|
|
83
|
-
wheelSensitivity: PropTypes.number
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
KnobPicker.defaultProps = {
|
|
87
|
-
disabled: false,
|
|
88
|
-
highToLow: false,
|
|
89
|
-
includeLabel: true,
|
|
90
|
-
includePicker: false,
|
|
91
|
-
knobProps: undefined,
|
|
92
|
-
label: undefined,
|
|
93
|
-
max: 127,
|
|
94
|
-
min: 0,
|
|
95
|
-
shrinkLabel: false,
|
|
96
|
-
value: 0,
|
|
97
|
-
wheelEnabled: false,
|
|
98
|
-
wheelSensitivity: 0.1
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export default KnobPicker;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";import PropTypes from 'prop-types';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
3
|
-
import Select from './Select';
|
|
4
|
-
|
|
5
|
-
var options = [
|
|
6
|
-
{ value: 0, label: 'Momentary' },
|
|
7
|
-
{ value: 1, label: 'Latching' }];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var LatchPicker = /*#__PURE__*/forwardRef(function (props, ref) {return /*#__PURE__*/(
|
|
11
|
-
React.createElement(Select, _extends({},
|
|
12
|
-
props, {
|
|
13
|
-
options: options,
|
|
14
|
-
ref: ref })
|
|
15
|
-
));}
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
LatchPicker.propTypes = {
|
|
19
|
-
onChange: PropTypes.func.isRequired,
|
|
20
|
-
value: PropTypes.number.isRequired
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default LatchPicker;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["allowClearing"];import React, { forwardRef, useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { getStockNames, getUserMappingNames } from 'zds-mappings';
|
|
4
|
-
import Select from './Select';
|
|
5
|
-
|
|
6
|
-
var MappingPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {var allowClearing = _ref.allowClearing,rest = _objectWithoutProperties(_ref, _excluded);
|
|
7
|
-
var stockMappings = getStockNames();
|
|
8
|
-
var userMappings = getUserMappingNames();
|
|
9
|
-
|
|
10
|
-
var options = useMemo(function () {
|
|
11
|
-
var result = allowClearing ?
|
|
12
|
-
[{
|
|
13
|
-
value: 'No Mapping',
|
|
14
|
-
label: /*#__PURE__*/React.createElement("span", { className: "zds-mappings-clear-mapping" }, "No Mapping")
|
|
15
|
-
}] :
|
|
16
|
-
[];
|
|
17
|
-
|
|
18
|
-
return [].concat(
|
|
19
|
-
result, [
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
label: allowClearing ? /*#__PURE__*/React.createElement("hr", null) : '',
|
|
23
|
-
options: userMappings.map(function (label) {return {
|
|
24
|
-
value: label,
|
|
25
|
-
label: /*#__PURE__*/React.createElement("span", { className: "zds-mappings-user-mapping" }, label)
|
|
26
|
-
};})
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
label: userMappings.length ? /*#__PURE__*/
|
|
31
|
-
React.createElement("hr", null) :
|
|
32
|
-
allowClearing ? /*#__PURE__*/React.createElement("hr", null) : '',
|
|
33
|
-
options: stockMappings.map(function (label) {return {
|
|
34
|
-
label: label,
|
|
35
|
-
value: label
|
|
36
|
-
};})
|
|
37
|
-
}]);
|
|
38
|
-
|
|
39
|
-
}, [allowClearing, stockMappings, userMappings]);
|
|
40
|
-
|
|
41
|
-
return /*#__PURE__*/(
|
|
42
|
-
React.createElement(Select, _extends({},
|
|
43
|
-
rest, {
|
|
44
|
-
options: options,
|
|
45
|
-
ref: ref })
|
|
46
|
-
));
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
MappingPicker.propTypes = {
|
|
51
|
-
allowClearing: PropTypes.bool,
|
|
52
|
-
onChange: PropTypes.func.isRequired,
|
|
53
|
-
value: PropTypes.string
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
MappingPicker.defaultProps = {
|
|
57
|
-
allowClearing: true,
|
|
58
|
-
value: 'General MIDI'
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default MappingPicker;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";import _slicedToArray from "@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["channel", "disabled", "isMelodicMode", "mapping", "onChange", "value"];import React, { forwardRef, useCallback, useMemo } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { emptyMapping } from 'zds-mappings';
|
|
4
|
-
import { Midi } from 'tonal';
|
|
5
|
-
import { mappingShape } from '../shapes';
|
|
6
|
-
import { assertRange } from '../utils';
|
|
7
|
-
import useStateWithDynamicDefault from '../hooks/useStateWithDynamicDefault';
|
|
8
|
-
import Select from './Select';
|
|
9
|
-
|
|
10
|
-
var midiToNoteName = Midi.midiToNoteName;
|
|
11
|
-
|
|
12
|
-
var formattedMapEntry = function formattedMapEntry(_ref) {var note = _ref.note,name = _ref.name;return "".concat(note, " ").concat(name.length ? '-' : '', " ").concat(name);};
|
|
13
|
-
var formattedListEntry = function formattedListEntry(label, idx) {return { label: label, value: idx + 1 };};
|
|
14
|
-
|
|
15
|
-
var NotePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
16
|
-
var
|
|
17
|
-
channel =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
props.channel,disabled = props.disabled,isMelodicMode = props.isMelodicMode,mapping = props.mapping,onChange = props.onChange,initialValue = props.value,rest = _objectWithoutProperties(props, _excluded);
|
|
25
|
-
|
|
26
|
-
var options = useMemo(function () {
|
|
27
|
-
if (isMelodicMode) {
|
|
28
|
-
return emptyMapping().
|
|
29
|
-
map(function (_ref2) {var note = _ref2.note;
|
|
30
|
-
var midiNoteName = midiToNoteName(note, { sharps: false }).
|
|
31
|
-
replace('b', '♭').
|
|
32
|
-
replace('#', '♯');
|
|
33
|
-
return "".concat(midiNoteName, " (#").concat(note, ")");
|
|
34
|
-
}).
|
|
35
|
-
map(formattedListEntry);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return (mapping || emptyMapping()).
|
|
39
|
-
map(formattedMapEntry).
|
|
40
|
-
map(formattedListEntry);
|
|
41
|
-
}, [isMelodicMode, mapping]);
|
|
42
|
-
|
|
43
|
-
var _useStateWithDynamicD = useStateWithDynamicDefault(initialValue),_useStateWithDynamicD2 = _slicedToArray(_useStateWithDynamicD, 2),value = _useStateWithDynamicD2[0],setValue = _useStateWithDynamicD2[1];
|
|
44
|
-
|
|
45
|
-
var handleChange = useCallback(function (v) {
|
|
46
|
-
var possibleNoteNumber = assertRange(v, 128, 0);
|
|
47
|
-
|
|
48
|
-
if (possibleNoteNumber > 0) {
|
|
49
|
-
onChange(possibleNoteNumber);
|
|
50
|
-
}
|
|
51
|
-
setValue(v);
|
|
52
|
-
}, [onChange, setValue]);
|
|
53
|
-
|
|
54
|
-
return /*#__PURE__*/(
|
|
55
|
-
React.createElement(Select, _extends({},
|
|
56
|
-
rest, {
|
|
57
|
-
disabled: disabled,
|
|
58
|
-
isDisabled: disabled,
|
|
59
|
-
onChange: handleChange,
|
|
60
|
-
options: options,
|
|
61
|
-
ref: ref,
|
|
62
|
-
value: value })
|
|
63
|
-
));
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
NotePicker.propTypes = {
|
|
68
|
-
channel: PropTypes.number.isRequired,
|
|
69
|
-
disabled: PropTypes.bool,
|
|
70
|
-
isMelodicMode: PropTypes.bool,
|
|
71
|
-
mapping: PropTypes.arrayOf(mappingShape),
|
|
72
|
-
onChange: PropTypes.func.isRequired,
|
|
73
|
-
value: PropTypes.number
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
NotePicker.defaultProps = {
|
|
77
|
-
disabled: false,
|
|
78
|
-
isMelodicMode: false,
|
|
79
|
-
mapping: undefined,
|
|
80
|
-
value: undefined
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default NotePicker;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["height", "width"];import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { Piano as ReactPiano } from 'zds-react-piano';
|
|
4
|
-
import SoundfontProvider from '../other/SoundFontProvider';
|
|
5
|
-
import DefaultTooltip from '../other/DefaultTooltip';
|
|
6
|
-
|
|
7
|
-
var firstNote = 21;
|
|
8
|
-
var lastNote = 108;
|
|
9
|
-
var numNotes = lastNote - firstNote - 1;
|
|
10
|
-
|
|
11
|
-
var whiteNotes = numNotes * 0.7; // approx
|
|
12
|
-
|
|
13
|
-
var audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
14
|
-
|
|
15
|
-
var PianoPicker = function PianoPicker(_ref) {var height = _ref.height,width = _ref.width,rest = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
-
var keyWidth = width / whiteNotes + 2;
|
|
17
|
-
var keyWidthToHeight = keyWidth / height;
|
|
18
|
-
|
|
19
|
-
return /*#__PURE__*/(
|
|
20
|
-
React.createElement("div", null, /*#__PURE__*/
|
|
21
|
-
React.createElement(ReactPiano, _extends({
|
|
22
|
-
keyWidthToHeight: keyWidthToHeight,
|
|
23
|
-
noteRange: { first: firstNote, last: lastNote },
|
|
24
|
-
width: width },
|
|
25
|
-
rest)
|
|
26
|
-
)
|
|
27
|
-
));
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var WithProvider = function WithProvider(_ref2) {var
|
|
32
|
-
format = _ref2.format,
|
|
33
|
-
height = _ref2.height,
|
|
34
|
-
hostname = _ref2.hostname,
|
|
35
|
-
instrumentName = _ref2.instrumentName,
|
|
36
|
-
onChange = _ref2.onChange,
|
|
37
|
-
onClick = _ref2.onClick,
|
|
38
|
-
onDoubleClick = _ref2.onDoubleClick,
|
|
39
|
-
onKeyMouseEnter = _ref2.onKeyMouseEnter,
|
|
40
|
-
onKeyMouseLeave = _ref2.onKeyMouseLeave,
|
|
41
|
-
soundfont = _ref2.soundfont,
|
|
42
|
-
width = _ref2.width;return /*#__PURE__*/(
|
|
43
|
-
|
|
44
|
-
React.createElement(SoundfontProvider, {
|
|
45
|
-
|
|
46
|
-
audioContext: audioContext,
|
|
47
|
-
format: format,
|
|
48
|
-
hostname: hostname,
|
|
49
|
-
instrumentName: instrumentName,
|
|
50
|
-
onChange: onChange,
|
|
51
|
-
soundfont: soundfont,
|
|
52
|
-
|
|
53
|
-
render: function render(_ref3) {var isLoading = _ref3.isLoading,playNote = _ref3.playNote,stopNote = _ref3.stopNote;return /*#__PURE__*/(
|
|
54
|
-
React.createElement(PianoPicker, {
|
|
55
|
-
disabled: isLoading,
|
|
56
|
-
|
|
57
|
-
height: height,
|
|
58
|
-
onClick: onClick,
|
|
59
|
-
onDoubleClick: onDoubleClick,
|
|
60
|
-
onKeyMouseEnter: onKeyMouseEnter,
|
|
61
|
-
onKeyMouseLeave: onKeyMouseLeave,
|
|
62
|
-
playNote: playNote,
|
|
63
|
-
stopNote: stopNote,
|
|
64
|
-
width: width }
|
|
65
|
-
|
|
66
|
-
));} }
|
|
67
|
-
|
|
68
|
-
));};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
PianoPicker.propTypes = {
|
|
72
|
-
height: PropTypes.number.isRequired,
|
|
73
|
-
width: PropTypes.number.isRequired
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
WithProvider.propTypes = {
|
|
77
|
-
format: PropTypes.oneOf(['mp3', 'ogg']),
|
|
78
|
-
height: PropTypes.number.isRequired,
|
|
79
|
-
hostname: PropTypes.string,
|
|
80
|
-
instrumentName: PropTypes.string,
|
|
81
|
-
onChange: PropTypes.func,
|
|
82
|
-
onClick: PropTypes.func,
|
|
83
|
-
onDoubleClick: PropTypes.func,
|
|
84
|
-
onKeyMouseEnter: PropTypes.func,
|
|
85
|
-
onKeyMouseLeave: PropTypes.func,
|
|
86
|
-
soundfont: PropTypes.oneOf(['MusyngKite', 'FluidR3_GM']),
|
|
87
|
-
Tooltip: PropTypes.elementType,
|
|
88
|
-
width: PropTypes.number.isRequired
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
WithProvider.defaultProps = {
|
|
92
|
-
format: undefined, // 'mp3',
|
|
93
|
-
hostname: undefined,
|
|
94
|
-
instrumentName: undefined,
|
|
95
|
-
onChange: undefined,
|
|
96
|
-
onClick: undefined,
|
|
97
|
-
onDoubleClick: undefined,
|
|
98
|
-
onKeyMouseEnter: undefined,
|
|
99
|
-
onKeyMouseLeave: undefined,
|
|
100
|
-
soundfont: undefined, // 'MusyngKite',
|
|
101
|
-
Tooltip: DefaultTooltip
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export default WithProvider;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["labelOff", "labelOn"];import PropTypes from 'prop-types';
|
|
2
|
-
import React, { forwardRef } from 'react';
|
|
3
|
-
import Select from './Select';
|
|
4
|
-
|
|
5
|
-
var PolarityPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {var labelOff = _ref.labelOff,labelOn = _ref.labelOn,rest = _objectWithoutProperties(_ref, _excluded);
|
|
6
|
-
var options = [
|
|
7
|
-
{ value: 0, label: labelOff },
|
|
8
|
-
{ value: 1, label: labelOn }];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return /*#__PURE__*/(
|
|
12
|
-
React.createElement(Select, _extends({},
|
|
13
|
-
rest, {
|
|
14
|
-
options: options,
|
|
15
|
-
ref: ref })
|
|
16
|
-
));
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
PolarityPicker.propTypes = {
|
|
21
|
-
labelOff: PropTypes.string,
|
|
22
|
-
labelOn: PropTypes.string,
|
|
23
|
-
onChange: PropTypes.func.isRequired,
|
|
24
|
-
value: PropTypes.number.isRequired
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
PolarityPicker.defaultProps = {
|
|
28
|
-
labelOn: 'Normally On',
|
|
29
|
-
labelOff: 'Normally Off'
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export default PolarityPicker;
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import useComponentSize from '../hooks/useComponentSize';
|
|
4
|
-
import SVGText from '../other/SVGText';
|
|
5
|
-
import DefaultTooltip from '../other/DefaultTooltip';
|
|
6
|
-
|
|
7
|
-
var RESPONSE_CURVE_0 = 0;
|
|
8
|
-
var RESPONSE_CURVE_1 = 1;
|
|
9
|
-
var RESPONSE_CURVE_2 = 2;
|
|
10
|
-
var RESPONSE_CURVE_3 = 3;
|
|
11
|
-
var RESPONSE_CURVE_4 = 4;
|
|
12
|
-
var RESPONSE_CURVE_5 = 5;
|
|
13
|
-
var RESPONSE_CURVE_6 = 6;
|
|
14
|
-
var RESPONSE_CURVE_7 = 7;
|
|
15
|
-
|
|
16
|
-
export var RESPONSE_CURVES = [
|
|
17
|
-
{
|
|
18
|
-
value: RESPONSE_CURVE_7,
|
|
19
|
-
label: 'Always maxed out.'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
value: RESPONSE_CURVE_6,
|
|
23
|
-
label: 'Most sensitive.'
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
value: RESPONSE_CURVE_5,
|
|
27
|
-
label: 'Moderately sensitive.'
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
value: RESPONSE_CURVE_4,
|
|
31
|
-
label: 'A little sensitive.'
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
value: RESPONSE_CURVE_0,
|
|
35
|
-
label: 'Linear, no change.'
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
value: RESPONSE_CURVE_1,
|
|
39
|
-
label: 'A little less sensitive.'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
value: RESPONSE_CURVE_2,
|
|
43
|
-
label: 'Even less sensitive.'
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
value: RESPONSE_CURVE_3,
|
|
47
|
-
label: 'Least sensitive.'
|
|
48
|
-
}];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// const width = 218
|
|
52
|
-
// const height = 150
|
|
53
|
-
var axisOffset = 20;
|
|
54
|
-
var buttonSize = 15;
|
|
55
|
-
|
|
56
|
-
var axisX1 = axisOffset;
|
|
57
|
-
var axisY1 = axisOffset;
|
|
58
|
-
|
|
59
|
-
var ResponseCurve = function ResponseCurve(props) {
|
|
60
|
-
var Tooltip = props.Tooltip,autosize = props.autosize,disabled = props.disabled,inverted = props.inverted,onChange = props.onChange,responseCurve = props.value;
|
|
61
|
-
|
|
62
|
-
var ref = useRef(null);
|
|
63
|
-
var svgRef = useRef(null);
|
|
64
|
-
var _useComponentSize = useComponentSize(ref),ourHeight = _useComponentSize.height,ourWidth = _useComponentSize.width;
|
|
65
|
-
|
|
66
|
-
var width = autosize ? ourWidth || 218 : 218;
|
|
67
|
-
var height = autosize ? ourHeight || 150 : 150;
|
|
68
|
-
|
|
69
|
-
var axisX2 = width - axisOffset;
|
|
70
|
-
var axisY2 = height - axisOffset;
|
|
71
|
-
|
|
72
|
-
var xMid = width / 2;
|
|
73
|
-
var yMid = height / 2;
|
|
74
|
-
|
|
75
|
-
var svgProps = { ref: svgRef };
|
|
76
|
-
|
|
77
|
-
var responseCurves = RESPONSE_CURVES.map(function (_ref) {var value = _ref.value,label = _ref.label;
|
|
78
|
-
var c1;
|
|
79
|
-
var c2;
|
|
80
|
-
var x1 = axisX1;
|
|
81
|
-
var y1 = inverted ? axisY1 : axisY2;
|
|
82
|
-
var x2 = axisX2;
|
|
83
|
-
var y2 = inverted ? axisY2 : axisY1;
|
|
84
|
-
var labelX = xMid;
|
|
85
|
-
var labelY = yMid;
|
|
86
|
-
switch (value) {
|
|
87
|
-
case RESPONSE_CURVE_0:
|
|
88
|
-
c1 = xMid;
|
|
89
|
-
c2 = yMid;
|
|
90
|
-
labelY += 3;
|
|
91
|
-
|
|
92
|
-
break;
|
|
93
|
-
case RESPONSE_CURVE_1:
|
|
94
|
-
c1 = inverted ? xMid + width * 0.13 : xMid - width * 0.13;
|
|
95
|
-
c2 = yMid - height * 0.13;
|
|
96
|
-
labelX = inverted ? xMid + width * 0.1 : xMid - width * 0.1;
|
|
97
|
-
labelY = yMid - height * 0.09;
|
|
98
|
-
break;
|
|
99
|
-
|
|
100
|
-
case RESPONSE_CURVE_2:
|
|
101
|
-
c1 = inverted ? xMid + width * 0.25 : xMid - width * 0.25;
|
|
102
|
-
c2 = yMid - height * 0.25;
|
|
103
|
-
labelX = inverted ? xMid + width * 0.2 : xMid - width * 0.2;
|
|
104
|
-
labelY = yMid - height * 0.17;
|
|
105
|
-
break;
|
|
106
|
-
|
|
107
|
-
case RESPONSE_CURVE_3:
|
|
108
|
-
c1 = inverted ? xMid + width * 0.35 : xMid - width * 0.35;
|
|
109
|
-
c2 = yMid - height * 0.35;
|
|
110
|
-
labelX = inverted ? xMid + width * 0.28 : xMid - width * 0.28;
|
|
111
|
-
labelY = yMid - height * 0.25;
|
|
112
|
-
break;
|
|
113
|
-
|
|
114
|
-
case RESPONSE_CURVE_4:
|
|
115
|
-
c1 = inverted ? xMid - width * 0.13 : xMid + width * 0.13;
|
|
116
|
-
c2 = yMid + height * 0.13;
|
|
117
|
-
labelX = inverted ? xMid - width * 0.1 : xMid + width * 0.1;
|
|
118
|
-
labelY = yMid + height * 0.1;
|
|
119
|
-
break;
|
|
120
|
-
|
|
121
|
-
case RESPONSE_CURVE_5:
|
|
122
|
-
c1 = inverted ? xMid - width * 0.25 : xMid + width * 0.25;
|
|
123
|
-
c2 = yMid + height * 0.25;
|
|
124
|
-
labelX = inverted ? xMid - width * 0.2 : xMid + width * 0.2;
|
|
125
|
-
labelY = yMid + height * 0.18;
|
|
126
|
-
break;
|
|
127
|
-
|
|
128
|
-
case RESPONSE_CURVE_6:
|
|
129
|
-
c1 = inverted ? xMid - width * 0.35 : xMid + width * 0.35;
|
|
130
|
-
c2 = yMid + height * 0.35;
|
|
131
|
-
labelX = inverted ? xMid - width * 0.28 : xMid + width * 0.28;
|
|
132
|
-
labelY = yMid + height * 0.25;
|
|
133
|
-
break;
|
|
134
|
-
|
|
135
|
-
case RESPONSE_CURVE_7:
|
|
136
|
-
x1 = inverted ? axisX1 : axisX2;
|
|
137
|
-
y1 = axisY1;
|
|
138
|
-
x2 = x1;
|
|
139
|
-
y2 = axisY2;
|
|
140
|
-
c1 = x1;
|
|
141
|
-
c2 = yMid;
|
|
142
|
-
labelX = x1 - 5;
|
|
143
|
-
labelY = height - 30;
|
|
144
|
-
break;
|
|
145
|
-
|
|
146
|
-
default:
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
value: value,
|
|
151
|
-
label: label,
|
|
152
|
-
c1: c1,
|
|
153
|
-
c2: c2,
|
|
154
|
-
x1: x1,
|
|
155
|
-
y1: y1,
|
|
156
|
-
x2: x2,
|
|
157
|
-
y2: y2,
|
|
158
|
-
labelX: labelX,
|
|
159
|
-
labelY: labelY
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
return /*#__PURE__*/(
|
|
164
|
-
React.createElement("div", {
|
|
165
|
-
className: "response-curve-picker",
|
|
166
|
-
ref: ref }, /*#__PURE__*/
|
|
167
|
-
|
|
168
|
-
React.createElement("svg", svgProps, /*#__PURE__*/
|
|
169
|
-
React.createElement("rect", {
|
|
170
|
-
className: "container",
|
|
171
|
-
height: height,
|
|
172
|
-
rx: 3,
|
|
173
|
-
ry: 3,
|
|
174
|
-
width: width,
|
|
175
|
-
x: 0,
|
|
176
|
-
y: 0 }
|
|
177
|
-
), /*#__PURE__*/
|
|
178
|
-
|
|
179
|
-
React.createElement(SVGText, {
|
|
180
|
-
className: "axis",
|
|
181
|
-
textAnchor: "middle",
|
|
182
|
-
transform: "translate(".concat(axisX1 - 14, " ").concat(height / 2, ") rotate(90)"),
|
|
183
|
-
x: 0,
|
|
184
|
-
y: 0 },
|
|
185
|
-
"Applied force"
|
|
186
|
-
|
|
187
|
-
), /*#__PURE__*/
|
|
188
|
-
React.createElement(SVGText, {
|
|
189
|
-
className: "axis",
|
|
190
|
-
textAnchor: "middle",
|
|
191
|
-
transform: "translate(".concat(width / 2, " ").concat(axisY2 + 13, ")"),
|
|
192
|
-
x: 0,
|
|
193
|
-
y: 0 },
|
|
194
|
-
"Output (velocity)"
|
|
195
|
-
|
|
196
|
-
), /*#__PURE__*/
|
|
197
|
-
|
|
198
|
-
React.createElement("line", {
|
|
199
|
-
className: "axis",
|
|
200
|
-
x1: axisX1,
|
|
201
|
-
x2: axisX1,
|
|
202
|
-
y1: axisY1,
|
|
203
|
-
y2: axisY2 }
|
|
204
|
-
), /*#__PURE__*/
|
|
205
|
-
React.createElement("line", {
|
|
206
|
-
className: "axis",
|
|
207
|
-
x1: axisX1,
|
|
208
|
-
x2: axisX2,
|
|
209
|
-
y1: axisY2,
|
|
210
|
-
y2: axisY2 }
|
|
211
|
-
),
|
|
212
|
-
|
|
213
|
-
responseCurves.map(function (_ref2) {var value = _ref2.value,label = _ref2.label,x1 = _ref2.x1,y1 = _ref2.y1,x2 = _ref2.x2,y2 = _ref2.y2,c1 = _ref2.c1,c2 = _ref2.c2,labelX = _ref2.labelX,labelY = _ref2.labelY;return /*#__PURE__*/(
|
|
214
|
-
React.createElement("g", { key: value }, /*#__PURE__*/
|
|
215
|
-
React.createElement("path", {
|
|
216
|
-
className: value === responseCurve ? 'curve-selected' : 'curve',
|
|
217
|
-
d: "M".concat(x1, " ").concat(y1, " C ").concat(c1, " ").concat(c2, ", ").concat(c1, " ").concat(c2, ", ").concat(x2, " ").concat(y2) }
|
|
218
|
-
), /*#__PURE__*/
|
|
219
|
-
|
|
220
|
-
React.createElement(Tooltip, {
|
|
221
|
-
placement: "left",
|
|
222
|
-
title: label }, /*#__PURE__*/
|
|
223
|
-
|
|
224
|
-
React.createElement("rect", {
|
|
225
|
-
className: value === responseCurve ? 'button-selected' : 'button',
|
|
226
|
-
height: buttonSize,
|
|
227
|
-
onClick: disabled ? null : function () {return onChange({ target: { value: value } });},
|
|
228
|
-
transform: "translate(".concat(labelX + 3, " ").concat(labelY - buttonSize / 1.05, ") rotate(45)"),
|
|
229
|
-
width: buttonSize }
|
|
230
|
-
)
|
|
231
|
-
), /*#__PURE__*/
|
|
232
|
-
|
|
233
|
-
React.createElement("text", {
|
|
234
|
-
className: value === responseCurve ? 'button-selected' : 'button',
|
|
235
|
-
transform: "translate(".concat(labelX, " ").concat(labelY, ")") },
|
|
236
|
-
|
|
237
|
-
value, /*#__PURE__*/
|
|
238
|
-
React.createElement("title", null, label)
|
|
239
|
-
)
|
|
240
|
-
));}
|
|
241
|
-
)
|
|
242
|
-
)
|
|
243
|
-
));
|
|
244
|
-
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
ResponseCurve.propTypes = {
|
|
248
|
-
autosize: PropTypes.bool,
|
|
249
|
-
disabled: PropTypes.bool,
|
|
250
|
-
inverted: PropTypes.bool,
|
|
251
|
-
onChange: PropTypes.func.isRequired,
|
|
252
|
-
Tooltip: PropTypes.elementType,
|
|
253
|
-
value: PropTypes.number.isRequired
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
ResponseCurve.defaultProps = {
|
|
257
|
-
autosize: false,
|
|
258
|
-
disabled: false,
|
|
259
|
-
inverted: false,
|
|
260
|
-
Tooltip: DefaultTooltip
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
export default ResponseCurve;
|