zds-pickers 3.9.18 → 3.10.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/hooks/useComponentSize.js +28 -28
- package/dist/hooks/useStateWithDynamicDefault.js +5 -5
- package/dist/index.js +43 -42
- package/dist/midi/ccValues.js +8 -3
- package/dist/midi/statuses.js +18 -18
- package/dist/other/DefaultTooltip.js +5 -5
- package/dist/other/OctavePlayer.js +121 -0
- package/dist/other/SVGText.js +47 -47
- package/dist/other/SoundFontProvider.js +29 -29
- package/dist/other/utils.js +12 -12
- package/dist/pickers/CCPicker.js +14 -14
- package/dist/pickers/ChannelMappingPicker.js +42 -42
- package/dist/pickers/ChannelPicker.js +22 -22
- package/dist/pickers/Knob.js +22 -22
- package/dist/pickers/KnobPicker.js +42 -42
- package/dist/pickers/LatchPicker.js +12 -12
- package/dist/pickers/MappingPicker.js +36 -36
- package/dist/pickers/NotePicker.js +23 -23
- package/dist/pickers/PianoPicker.js +33 -33
- package/dist/pickers/PolarityPicker.js +13 -13
- package/dist/pickers/ResponseCurve.js +56 -56
- package/dist/pickers/ResponseCurvePicker.js +28 -28
- package/dist/pickers/Select.js +58 -58
- package/dist/pickers/StatusPicker.js +13 -13
- package/dist/pickers/ValuePicker.js +33 -33
- package/dist/pickers/knobSkin10.js +5 -5
- package/dist/shapes.js +8 -8
- package/dist/stories/assets/General MIDI.js +4 -3
- package/dist/stories/assets/mapper.js +11 -11
- package/dist/stories/assets/utils.js +3 -3
- package/dist/temp/acoustic_grand_piano-mp3.js +1 -1
- package/dist/utils.js +18 -18
- package/package.json +35 -28
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";import _slicedToArray from "@babel/runtime/helpers/slicedToArray";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;} // See https://github.com/danigb/soundfont-player
|
|
2
|
+
// for more documentation on prop options.
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import Soundfont from 'soundfont-player';
|
|
6
|
+
import { isDefined } from './utils';
|
|
7
7
|
// import '../temp/acoustic_grand_piano-mp3'
|
|
8
8
|
|
|
9
9
|
var SoundfontProvider = function SoundfontProvider(props) {
|
|
@@ -17,26 +17,26 @@ var SoundfontProvider = function SoundfontProvider(props) {
|
|
|
17
17
|
|
|
18
18
|
props.audioContext,format = props.format,hostname = props.hostname,instrumentName = props.instrumentName,onChange = props.onChange,render = props.render,soundfont = props.soundfont;
|
|
19
19
|
|
|
20
|
-
var _useState =
|
|
21
|
-
var _useState3 =
|
|
22
|
-
var _useState5 =
|
|
20
|
+
var _useState = useState(true),_useState2 = _slicedToArray(_useState, 2),isLoading = _useState2[0],setIsLoading = _useState2[1];
|
|
21
|
+
var _useState3 = useState({}),_useState4 = _slicedToArray(_useState3, 2),activeAudioNodes = _useState4[0],setActiveAudioNodes = _useState4[1];
|
|
22
|
+
var _useState5 = useState(null),_useState6 = _slicedToArray(_useState5, 2),instrument = _useState6[0],setInstrument = _useState6[1];
|
|
23
23
|
|
|
24
|
-
var loadInstrument =
|
|
24
|
+
var loadInstrument = useCallback(function (nm) {
|
|
25
25
|
// Re-trigger loading state
|
|
26
26
|
setInstrument(null);
|
|
27
27
|
|
|
28
|
-
if (
|
|
28
|
+
if (isDefined(hostname)) {
|
|
29
29
|
// pull from an url
|
|
30
|
-
|
|
30
|
+
Soundfont.instrument(audioContext, nm, {
|
|
31
31
|
format: format,
|
|
32
32
|
soundfont: soundfont,
|
|
33
33
|
nameToUrl: function nameToUrl(name, sf, fmt) {return "".concat(hostname, "/").concat(sf, "/").concat(name, "-").concat(fmt, ".js");}
|
|
34
34
|
}).then(function (newInstrument) {
|
|
35
35
|
setInstrument(newInstrument);
|
|
36
36
|
});
|
|
37
|
-
} else if (
|
|
37
|
+
} else if (isDefined(instrumentName)) {
|
|
38
38
|
// the host app has already injected the soundfont into global space
|
|
39
|
-
|
|
39
|
+
Soundfont.
|
|
40
40
|
instrument(audioContext, instrumentName).
|
|
41
41
|
then(function (newInstrument) {
|
|
42
42
|
setInstrument(newInstrument);
|
|
@@ -47,12 +47,12 @@ var SoundfontProvider = function SoundfontProvider(props) {
|
|
|
47
47
|
}
|
|
48
48
|
}, [audioContext, format, hostname, instrumentName, soundfont]);
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
useEffect(function () {
|
|
51
51
|
loadInstrument(instrumentName);
|
|
52
52
|
}, [instrumentName, loadInstrument]);
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
if (
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
if (isDefined(instrumentName)) {
|
|
56
56
|
setIsLoading(!instrument);
|
|
57
57
|
}
|
|
58
58
|
}, [instrument, instrumentName]);
|
|
@@ -61,7 +61,7 @@ var SoundfontProvider = function SoundfontProvider(props) {
|
|
|
61
61
|
if (instrument) {
|
|
62
62
|
audioContext.resume().then(function () {
|
|
63
63
|
var audioNode = instrument.play(midiNumber);
|
|
64
|
-
setActiveAudioNodes(function (prev) {return _objectSpread(_objectSpread({}, prev), {}, (
|
|
64
|
+
setActiveAudioNodes(function (prev) {return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, midiNumber, audioNode));});
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
};
|
|
@@ -73,9 +73,9 @@ var SoundfontProvider = function SoundfontProvider(props) {
|
|
|
73
73
|
}
|
|
74
74
|
var audioNode = activeAudioNodes[midiNumber];
|
|
75
75
|
audioNode.stop();
|
|
76
|
-
setActiveAudioNodes(function (prev) {return _objectSpread(_objectSpread({}, prev), {}, (
|
|
76
|
+
setActiveAudioNodes(function (prev) {return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, midiNumber, null));});
|
|
77
77
|
});
|
|
78
|
-
onChange === null || onChange === void 0
|
|
78
|
+
onChange === null || onChange === void 0 || onChange(midiNumber);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
// Clear any residual notes that don't get called with stopNote
|
|
@@ -100,13 +100,13 @@ var SoundfontProvider = function SoundfontProvider(props) {
|
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
SoundfontProvider.propTypes = {
|
|
103
|
-
audioContext:
|
|
104
|
-
format:
|
|
105
|
-
hostname:
|
|
106
|
-
instrumentName:
|
|
107
|
-
onChange:
|
|
108
|
-
render:
|
|
109
|
-
soundfont:
|
|
103
|
+
audioContext: PropTypes.instanceOf(window.AudioContext),
|
|
104
|
+
format: PropTypes.oneOf(['mp3', 'ogg']),
|
|
105
|
+
hostname: PropTypes.string,
|
|
106
|
+
instrumentName: PropTypes.string,
|
|
107
|
+
onChange: PropTypes.func,
|
|
108
|
+
render: PropTypes.func.isRequired,
|
|
109
|
+
soundfont: PropTypes.oneOf(['MusyngKite', 'FluidR3_GM'])
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
SoundfontProvider.defaultProps = {
|
|
@@ -120,5 +120,5 @@ SoundfontProvider.defaultProps = {
|
|
|
120
120
|
|
|
121
121
|
// https://gleitz.github.io/midi-js-soundfonts/MusyngKite/acoustic_grand_piano-mp3.js
|
|
122
122
|
// https://gleitz.github.io/midi-js-soundfonts/FluidR3_GM/.js
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
|
|
124
|
+
export default SoundfontProvider;
|
package/dist/other/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var MEASUREMENT_ELEMENT_ID = '__react_svg_text_measurement_id';
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";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;} /* eslint-disable no-param-reassign */
|
|
2
|
+
var MEASUREMENT_ELEMENT_ID = '__react_svg_text_measurement_id';
|
|
3
3
|
|
|
4
4
|
var calculateWordsByLines = function calculateWordsByLines(words, wordWidths, maxWidth, maxHeight) {
|
|
5
5
|
var lineHeight = wordWidths.lineHeight,spaceWidth = wordWidths.spaceWidth,wordsWithComputedWidth = wordWidths.wordsWithComputedWidth;
|
|
@@ -24,19 +24,19 @@ var calculateWordsByLines = function calculateWordsByLines(words, wordWidths, ma
|
|
|
24
24
|
}
|
|
25
25
|
return result;
|
|
26
26
|
}, []);
|
|
27
|
-
};
|
|
27
|
+
};
|
|
28
28
|
|
|
29
29
|
var calculateWordWidths = function calculateWordWidths(style, textNode, words) {
|
|
30
30
|
if (style && textNode) {
|
|
31
31
|
Array.from(style).forEach(function (key) {return textNode.style.setProperty(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var wordArray = (
|
|
32
|
+
key,
|
|
33
|
+
style.getPropertyValue(key),
|
|
34
|
+
style.getPropertyPriority(key)
|
|
35
|
+
);});
|
|
36
|
+
var wordArray = _toConsumableArray(new Set(words.toString().split(/\s+/)));
|
|
37
37
|
var wordsWithComputedWidth = wordArray.reduce(function (wordMap, word) {
|
|
38
38
|
textNode.textContent = word;
|
|
39
|
-
return _objectSpread(_objectSpread({}, wordMap), {}, (
|
|
39
|
+
return _objectSpread(_objectSpread({}, wordMap), {}, _defineProperty({}, word, textNode.getBBox().width));
|
|
40
40
|
}, {});
|
|
41
41
|
textNode.textContent = "\xA0";
|
|
42
42
|
var spaceWidth = textNode.getComputedTextLength();
|
|
@@ -45,8 +45,8 @@ var calculateWordWidths = function calculateWordWidths(style, textNode, words) {
|
|
|
45
45
|
return { wordsWithComputedWidth: wordsWithComputedWidth, spaceWidth: spaceWidth, lineHeight: lineHeight };
|
|
46
46
|
}
|
|
47
47
|
return null;
|
|
48
|
-
};
|
|
49
|
-
|
|
48
|
+
};
|
|
50
49
|
|
|
50
|
+
export { calculateWordWidths, calculateWordsByLines, MEASUREMENT_ELEMENT_ID };
|
|
51
51
|
|
|
52
|
-
var isDefined = function isDefined(item) {return item !== undefined && item !== null && item !== Math.NaN;};
|
|
52
|
+
export var isDefined = function isDefined(item) {return item !== undefined && item !== null && item !== Math.NaN;};
|
package/dist/pickers/CCPicker.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";import PropTypes from 'prop-types';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import ccValues from '../midi/ccValues';
|
|
4
|
+
import Select from './Select';
|
|
5
5
|
|
|
6
|
-
var CCPicker = /*#__PURE__*/
|
|
7
|
-
|
|
8
|
-
options:
|
|
6
|
+
var CCPicker = /*#__PURE__*/forwardRef(function (props, ref) {return /*#__PURE__*/(
|
|
7
|
+
React.createElement(Select, _extends({
|
|
8
|
+
options: ccValues },
|
|
9
9
|
props, {
|
|
10
|
-
ref: ref })
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
ref: ref })
|
|
11
|
+
));}
|
|
12
|
+
);
|
|
13
13
|
|
|
14
14
|
CCPicker.propTypes = {
|
|
15
|
-
onChange:
|
|
16
|
-
value:
|
|
17
|
-
};
|
|
15
|
+
onChange: PropTypes.func.isRequired,
|
|
16
|
+
value: PropTypes.number.isRequired
|
|
17
|
+
};
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export default CCPicker;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var options =
|
|
8
|
-
|
|
9
|
-
var ChannelMappingPicker = /*#__PURE__*/
|
|
10
|
-
var formatOptionLabel =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["channels", "className"];import React, { forwardRef, useCallback } from 'react';
|
|
2
|
+
import cl from 'classnames';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { arraySequence } from '../utils';
|
|
5
|
+
import Select from './Select';
|
|
6
|
+
|
|
7
|
+
var options = arraySequence(16).map(function (value) {return { value: value, label: value };});
|
|
8
|
+
|
|
9
|
+
var ChannelMappingPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {var channels = _ref.channels,className = _ref.className,rest = _objectWithoutProperties(_ref, _excluded);
|
|
10
|
+
var formatOptionLabel = useCallback(
|
|
11
|
+
function (_ref2, _ref3) {var value = _ref2.value;var context = _ref3.context;
|
|
12
|
+
var mapping = channels[value];
|
|
13
|
+
|
|
14
|
+
return mapping ? /*#__PURE__*/
|
|
15
|
+
React.createElement("span", { className: "mapping-entry" }, /*#__PURE__*/
|
|
16
|
+
React.createElement("b", null,
|
|
17
|
+
value + 1,
|
|
18
|
+
context === 'value' && ' -'
|
|
19
|
+
), /*#__PURE__*/
|
|
20
|
+
React.createElement("span", { className: "mapping-entry-label" }, mapping)
|
|
21
|
+
) : /*#__PURE__*/
|
|
22
|
+
|
|
23
|
+
React.createElement("span", { className: "mapping-entry empty-mapping-entry" }, /*#__PURE__*/
|
|
24
|
+
React.createElement("b", null,
|
|
25
|
+
value + 1,
|
|
26
|
+
context === 'value' && ' -'
|
|
27
|
+
), /*#__PURE__*/
|
|
28
|
+
React.createElement("span", { className: "mapping-entry-label" }, "no mapping")
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
},
|
|
32
|
+
[channels]
|
|
33
|
+
);
|
|
34
34
|
|
|
35
35
|
return /*#__PURE__*/(
|
|
36
|
-
|
|
36
|
+
React.createElement(Select, _extends({},
|
|
37
37
|
rest, {
|
|
38
|
-
className: (
|
|
38
|
+
className: cl(className, 'channel-mapping-picker'),
|
|
39
39
|
formatOptionLabel: formatOptionLabel,
|
|
40
40
|
options: options,
|
|
41
|
-
ref: ref })
|
|
42
|
-
|
|
41
|
+
ref: ref })
|
|
42
|
+
));
|
|
43
43
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
ChannelMappingPicker.propTypes = {
|
|
47
|
-
channels:
|
|
48
|
-
onChange:
|
|
49
|
-
value:
|
|
50
|
-
};
|
|
47
|
+
channels: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
48
|
+
onChange: PropTypes.func.isRequired,
|
|
49
|
+
value: PropTypes.number.isRequired
|
|
50
|
+
};
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
export default ChannelMappingPicker;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["className"];import React, { forwardRef, useCallback } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import cl from 'classnames';
|
|
4
|
+
import { arraySequence } from '../utils';
|
|
5
|
+
import Select from './Select';
|
|
6
6
|
|
|
7
|
-
var options =
|
|
7
|
+
var options = arraySequence(16).map(function (value) {return {
|
|
8
8
|
value: value,
|
|
9
9
|
label: "Channel ".concat(value + 1)
|
|
10
10
|
};});
|
|
11
11
|
|
|
12
|
-
var ChannelPicker = /*#__PURE__*/
|
|
13
|
-
var formatOptionLabel =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
var ChannelPicker = /*#__PURE__*/forwardRef(function (_ref, ref) {var className = _ref.className,rest = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
var formatOptionLabel = useCallback(
|
|
14
|
+
function (option, _ref2) {var context = _ref2.context;return context === 'value' ?
|
|
15
|
+
option.label :
|
|
16
|
+
option.value + 1;},
|
|
17
|
+
[]
|
|
18
|
+
);
|
|
19
19
|
return /*#__PURE__*/(
|
|
20
|
-
|
|
20
|
+
React.createElement(Select, _extends({},
|
|
21
21
|
rest, {
|
|
22
|
-
className: (
|
|
22
|
+
className: cl(className, 'channel-picker'),
|
|
23
23
|
formatOptionLabel: formatOptionLabel,
|
|
24
24
|
options: options,
|
|
25
|
-
ref: ref })
|
|
26
|
-
|
|
25
|
+
ref: ref })
|
|
26
|
+
));
|
|
27
27
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
ChannelPicker.propTypes = {
|
|
31
|
-
className:
|
|
32
|
-
onChange:
|
|
33
|
-
value:
|
|
31
|
+
className: PropTypes.string,
|
|
32
|
+
onChange: PropTypes.func.isRequired,
|
|
33
|
+
value: PropTypes.number.isRequired
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
ChannelPicker.defaultProps = {
|
|
37
37
|
className: undefined
|
|
38
|
-
};
|
|
38
|
+
};
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
export default ChannelPicker;
|
package/dist/pickers/Knob.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";import _defineProperty from "@babel/runtime/helpers/defineProperty";import _slicedToArray from "@babel/runtime/helpers/slicedToArray";import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";var _excluded = ["disabled", "max", "min", "onChange", "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 from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Knob as RotaryKnob } from 'nebiru-react-rotary-knob';
|
|
4
|
+
import useStateWithDynamicDefault from '../hooks/useStateWithDynamicDefault';
|
|
5
|
+
import { assertRange } from '../utils';
|
|
6
|
+
import knobSkin10 from './knobSkin10';
|
|
7
7
|
|
|
8
8
|
var Knob = function Knob(props) {
|
|
9
9
|
var
|
|
@@ -15,14 +15,14 @@ var Knob = function Knob(props) {
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
props.disabled,max = props.max,min = props.min,onChange = props.onChange,initialValue = props.value,wheelEnabled = props.wheelEnabled,wheelSensitivity = props.wheelSensitivity,rest = (
|
|
18
|
+
props.disabled,max = props.max,min = props.min,onChange = props.onChange,initialValue = props.value,wheelEnabled = props.wheelEnabled,wheelSensitivity = props.wheelSensitivity,rest = _objectWithoutProperties(props, _excluded);
|
|
19
19
|
|
|
20
|
-
var _useStateWithDynamicD = (
|
|
20
|
+
var _useStateWithDynamicD = useStateWithDynamicDefault(initialValue),_useStateWithDynamicD2 = _slicedToArray(_useStateWithDynamicD, 2),value = _useStateWithDynamicD2[0],setValue = _useStateWithDynamicD2[1];
|
|
21
21
|
|
|
22
22
|
var handleChange = function handleChange(val) {
|
|
23
23
|
if (disabled) return;
|
|
24
24
|
|
|
25
|
-
var newValue =
|
|
25
|
+
var newValue = assertRange(parseInt(val, 10), max, min);
|
|
26
26
|
setValue(newValue);
|
|
27
27
|
if (onChange) {
|
|
28
28
|
onChange(newValue);
|
|
@@ -40,7 +40,7 @@ var Knob = function Knob(props) {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
return /*#__PURE__*/(
|
|
43
|
-
|
|
43
|
+
React.createElement(RotaryKnob, _extends({
|
|
44
44
|
clampMax: 320,
|
|
45
45
|
clampMin: 40,
|
|
46
46
|
className: "zds-pickers__knob-container",
|
|
@@ -56,22 +56,22 @@ var Knob = function Knob(props) {
|
|
|
56
56
|
* NOTE: we've copied the one we use into this package because the skins
|
|
57
57
|
* pack package does not work in Electron.
|
|
58
58
|
*/,
|
|
59
|
-
skin:
|
|
59
|
+
skin: knobSkin10,
|
|
60
60
|
style: { opacity: disabled ? 0.4 : 1 },
|
|
61
61
|
unlockDistance: 0 }, _objectSpread({
|
|
62
|
-
max: max, min: min, value: value }, rest))
|
|
63
|
-
|
|
62
|
+
max: max, min: min, value: value }, rest))
|
|
63
|
+
));
|
|
64
64
|
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
Knob.propTypes = {
|
|
68
|
-
disabled:
|
|
69
|
-
max:
|
|
70
|
-
min:
|
|
71
|
-
wheelEnabled:
|
|
72
|
-
onChange:
|
|
73
|
-
value:
|
|
74
|
-
wheelSensitivity:
|
|
68
|
+
disabled: PropTypes.bool,
|
|
69
|
+
max: PropTypes.number,
|
|
70
|
+
min: PropTypes.number,
|
|
71
|
+
wheelEnabled: PropTypes.bool,
|
|
72
|
+
onChange: PropTypes.func,
|
|
73
|
+
value: PropTypes.number,
|
|
74
|
+
wheelSensitivity: PropTypes.number
|
|
75
75
|
};
|
|
76
76
|
Knob.defaultProps = {
|
|
77
77
|
disabled: false,
|
|
@@ -81,6 +81,6 @@ Knob.defaultProps = {
|
|
|
81
81
|
value: 0,
|
|
82
82
|
wheelEnabled: false,
|
|
83
83
|
wheelSensitivity: 0.1
|
|
84
|
-
};
|
|
84
|
+
};
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
export default Knob;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
6
|
|
|
7
|
-
var KnobPicker = /*#__PURE__*/
|
|
7
|
+
var KnobPicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
8
8
|
var
|
|
9
9
|
disabled =
|
|
10
10
|
|
|
@@ -20,24 +20,24 @@ var KnobPicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
20
20
|
|
|
21
21
|
|
|
22
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 = (
|
|
24
|
-
|
|
25
|
-
var options = (0, _react.useMemo)(
|
|
26
|
-
function () {
|
|
27
|
-
var result = (0, _utils.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]);
|
|
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);
|
|
33
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
34
|
|
|
35
35
|
return /*#__PURE__*/(
|
|
36
|
-
|
|
37
|
-
Boolean(!shrinkLabel && Boolean(label)) && /*#__PURE__*/
|
|
38
|
-
|
|
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
39
|
Boolean(includePicker) && /*#__PURE__*/
|
|
40
|
-
|
|
40
|
+
React.createElement(Select, _objectSpread(_objectSpread({},
|
|
41
41
|
|
|
42
42
|
rest), {}, {
|
|
43
43
|
disabled: disabled,
|
|
@@ -45,12 +45,12 @@ var KnobPicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
45
45
|
onChange: onChange,
|
|
46
46
|
options: options,
|
|
47
47
|
ref: ref,
|
|
48
|
-
value: value })
|
|
49
|
-
|
|
48
|
+
value: value })
|
|
50
49
|
|
|
50
|
+
), /*#__PURE__*/
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
React.createElement(Knob, _objectSpread({
|
|
54
54
|
|
|
55
55
|
disabled: disabled,
|
|
56
56
|
max: max,
|
|
@@ -59,28 +59,28 @@ var KnobPicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
59
59
|
value: value,
|
|
60
60
|
wheelEnabled: wheelEnabled,
|
|
61
61
|
wheelSensitivity: wheelSensitivity },
|
|
62
|
-
knobProps)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
knobProps)
|
|
66
63
|
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
));
|
|
67
67
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
KnobPicker.propTypes = {
|
|
71
|
-
disabled:
|
|
72
|
-
highToLow:
|
|
73
|
-
includeLabel:
|
|
74
|
-
includePicker:
|
|
75
|
-
knobProps:
|
|
76
|
-
label:
|
|
77
|
-
max:
|
|
78
|
-
min:
|
|
79
|
-
onChange:
|
|
80
|
-
shrinkLabel:
|
|
81
|
-
value:
|
|
82
|
-
wheelEnabled:
|
|
83
|
-
wheelSensitivity:
|
|
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
84
|
};
|
|
85
85
|
|
|
86
86
|
KnobPicker.defaultProps = {
|
|
@@ -96,6 +96,6 @@ KnobPicker.defaultProps = {
|
|
|
96
96
|
value: 0,
|
|
97
97
|
wheelEnabled: false,
|
|
98
98
|
wheelSensitivity: 0.1
|
|
99
|
-
};
|
|
99
|
+
};
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
export default KnobPicker;
|