@tremolo-ui/react 0.0.7 → 0.0.9

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.
Files changed (133) hide show
  1. package/dist/cjs/index.js +675 -253
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/AnimationCanvas/index.d.ts +16 -9
  4. package/dist/cjs/types/components/AnimationCanvas/index.d.ts.map +1 -1
  5. package/dist/cjs/types/components/AnimationKnob/index.d.ts +53 -0
  6. package/dist/cjs/types/components/AnimationKnob/index.d.ts.map +1 -0
  7. package/dist/cjs/types/components/DragObserver/index.d.ts +19 -0
  8. package/dist/cjs/types/components/DragObserver/index.d.ts.map +1 -0
  9. package/dist/cjs/types/components/Knob/index.d.ts +26 -26
  10. package/dist/cjs/types/components/Knob/index.d.ts.map +1 -1
  11. package/dist/cjs/types/components/NumberInput/index.d.ts +2 -5
  12. package/dist/cjs/types/components/NumberInput/index.d.ts.map +1 -1
  13. package/dist/cjs/types/components/Piano/BlackKey.d.ts +3 -3
  14. package/dist/cjs/types/components/Piano/BlackKey.d.ts.map +1 -1
  15. package/dist/cjs/types/components/Piano/KeyLabel.d.ts +5 -8
  16. package/dist/cjs/types/components/Piano/KeyLabel.d.ts.map +1 -1
  17. package/dist/cjs/types/components/Piano/WhiteKey.d.ts +4 -3
  18. package/dist/cjs/types/components/Piano/WhiteKey.d.ts.map +1 -1
  19. package/dist/cjs/types/components/Piano/index.d.ts +3 -4
  20. package/dist/cjs/types/components/Piano/index.d.ts.map +1 -1
  21. package/dist/cjs/types/components/Piano/key.d.ts +4 -7
  22. package/dist/cjs/types/components/Piano/key.d.ts.map +1 -1
  23. package/dist/cjs/types/components/Piano/keyboardShortcuts.d.ts.map +1 -1
  24. package/dist/cjs/types/components/Slider/Scale.d.ts +11 -0
  25. package/dist/cjs/types/components/Slider/Scale.d.ts.map +1 -0
  26. package/dist/cjs/types/components/Slider/ScaleOption.d.ts +25 -0
  27. package/dist/cjs/types/components/Slider/ScaleOption.d.ts.map +1 -0
  28. package/dist/cjs/types/components/Slider/Thumb.d.ts +5 -13
  29. package/dist/cjs/types/components/Slider/Thumb.d.ts.map +1 -1
  30. package/dist/cjs/types/components/Slider/Track.d.ts +10 -21
  31. package/dist/cjs/types/components/Slider/Track.d.ts.map +1 -1
  32. package/dist/cjs/types/components/Slider/context.d.ts +21 -0
  33. package/dist/cjs/types/components/Slider/context.d.ts.map +1 -0
  34. package/dist/cjs/types/components/Slider/index.d.ts +18 -12
  35. package/dist/cjs/types/components/Slider/index.d.ts.map +1 -1
  36. package/dist/cjs/types/components/WheelObserver/index.d.ts +24 -0
  37. package/dist/cjs/types/components/WheelObserver/index.d.ts.map +1 -0
  38. package/dist/cjs/types/components/XYPad/Area.d.ts +13 -0
  39. package/dist/cjs/types/components/XYPad/Area.d.ts.map +1 -0
  40. package/dist/cjs/types/components/XYPad/Thumb.d.ts +19 -0
  41. package/dist/cjs/types/components/XYPad/Thumb.d.ts.map +1 -0
  42. package/dist/cjs/types/components/XYPad/index.d.ts +39 -0
  43. package/dist/cjs/types/components/XYPad/index.d.ts.map +1 -0
  44. package/dist/cjs/types/hooks/useCallbackRef.d.ts.map +1 -1
  45. package/dist/cjs/types/index.d.ts +10 -0
  46. package/dist/cjs/types/index.d.ts.map +1 -1
  47. package/dist/esm/index.js +658 -254
  48. package/dist/esm/index.js.map +1 -1
  49. package/dist/esm/types/components/AnimationCanvas/index.d.ts +16 -9
  50. package/dist/esm/types/components/AnimationCanvas/index.d.ts.map +1 -1
  51. package/dist/esm/types/components/AnimationKnob/index.d.ts +53 -0
  52. package/dist/esm/types/components/AnimationKnob/index.d.ts.map +1 -0
  53. package/dist/esm/types/components/DragObserver/index.d.ts +19 -0
  54. package/dist/esm/types/components/DragObserver/index.d.ts.map +1 -0
  55. package/dist/esm/types/components/Knob/index.d.ts +26 -26
  56. package/dist/esm/types/components/Knob/index.d.ts.map +1 -1
  57. package/dist/esm/types/components/NumberInput/index.d.ts +2 -5
  58. package/dist/esm/types/components/NumberInput/index.d.ts.map +1 -1
  59. package/dist/esm/types/components/Piano/BlackKey.d.ts +3 -3
  60. package/dist/esm/types/components/Piano/BlackKey.d.ts.map +1 -1
  61. package/dist/esm/types/components/Piano/KeyLabel.d.ts +5 -8
  62. package/dist/esm/types/components/Piano/KeyLabel.d.ts.map +1 -1
  63. package/dist/esm/types/components/Piano/WhiteKey.d.ts +4 -3
  64. package/dist/esm/types/components/Piano/WhiteKey.d.ts.map +1 -1
  65. package/dist/esm/types/components/Piano/index.d.ts +3 -4
  66. package/dist/esm/types/components/Piano/index.d.ts.map +1 -1
  67. package/dist/esm/types/components/Piano/key.d.ts +4 -7
  68. package/dist/esm/types/components/Piano/key.d.ts.map +1 -1
  69. package/dist/esm/types/components/Piano/keyboardShortcuts.d.ts.map +1 -1
  70. package/dist/esm/types/components/Slider/Scale.d.ts +11 -0
  71. package/dist/esm/types/components/Slider/Scale.d.ts.map +1 -0
  72. package/dist/esm/types/components/Slider/ScaleOption.d.ts +25 -0
  73. package/dist/esm/types/components/Slider/ScaleOption.d.ts.map +1 -0
  74. package/dist/esm/types/components/Slider/Thumb.d.ts +5 -13
  75. package/dist/esm/types/components/Slider/Thumb.d.ts.map +1 -1
  76. package/dist/esm/types/components/Slider/Track.d.ts +10 -21
  77. package/dist/esm/types/components/Slider/Track.d.ts.map +1 -1
  78. package/dist/esm/types/components/Slider/context.d.ts +21 -0
  79. package/dist/esm/types/components/Slider/context.d.ts.map +1 -0
  80. package/dist/esm/types/components/Slider/index.d.ts +18 -12
  81. package/dist/esm/types/components/Slider/index.d.ts.map +1 -1
  82. package/dist/esm/types/components/WheelObserver/index.d.ts +24 -0
  83. package/dist/esm/types/components/WheelObserver/index.d.ts.map +1 -0
  84. package/dist/esm/types/components/XYPad/Area.d.ts +13 -0
  85. package/dist/esm/types/components/XYPad/Area.d.ts.map +1 -0
  86. package/dist/esm/types/components/XYPad/Thumb.d.ts +19 -0
  87. package/dist/esm/types/components/XYPad/Thumb.d.ts.map +1 -0
  88. package/dist/esm/types/components/XYPad/index.d.ts +39 -0
  89. package/dist/esm/types/components/XYPad/index.d.ts.map +1 -0
  90. package/dist/esm/types/hooks/useCallbackRef.d.ts.map +1 -1
  91. package/dist/esm/types/index.d.ts +10 -0
  92. package/dist/esm/types/index.d.ts.map +1 -1
  93. package/dist/styles/index.css +242 -0
  94. package/package.json +5 -8
  95. package/src/components/AnimationCanvas/index.tsx +87 -57
  96. package/src/components/AnimationKnob/index.tsx +305 -0
  97. package/src/components/DragObserver/index.tsx +94 -0
  98. package/src/components/Knob/index.css +48 -0
  99. package/src/components/Knob/index.tsx +152 -165
  100. package/src/components/NumberInput/index.css +26 -0
  101. package/src/components/NumberInput/index.tsx +8 -41
  102. package/src/components/Piano/BlackKey.tsx +105 -98
  103. package/src/components/Piano/KeyLabel.tsx +18 -40
  104. package/src/components/Piano/WhiteKey.tsx +94 -87
  105. package/src/components/Piano/index.css +63 -0
  106. package/src/components/Piano/index.tsx +78 -61
  107. package/src/components/Piano/key.ts +4 -7
  108. package/src/components/Piano/keyboardShortcuts.ts +23 -4
  109. package/src/components/Slider/Scale.tsx +55 -0
  110. package/src/components/Slider/ScaleOption.tsx +103 -0
  111. package/src/components/Slider/Thumb.tsx +69 -76
  112. package/src/components/Slider/Track.tsx +37 -48
  113. package/src/components/Slider/context.tsx +66 -0
  114. package/src/components/Slider/index.css +76 -0
  115. package/src/components/Slider/index.tsx +256 -298
  116. package/src/components/WheelObserver/index.tsx +47 -0
  117. package/src/components/XYPad/Area.tsx +40 -0
  118. package/src/components/XYPad/Thumb.tsx +92 -0
  119. package/src/components/XYPad/index.css +24 -0
  120. package/src/components/XYPad/index.tsx +317 -0
  121. package/src/hooks/useCallbackRef.ts +1 -0
  122. package/src/hooks/useRefCallbackEvent.ts +1 -0
  123. package/src/index.ts +11 -0
  124. package/dist/cjs/types/components/Slider/type.d.ts +0 -7
  125. package/dist/cjs/types/components/Slider/type.d.ts.map +0 -1
  126. package/dist/cjs/types/system/pseudo.d.ts +0 -14
  127. package/dist/cjs/types/system/pseudo.d.ts.map +0 -1
  128. package/dist/esm/types/components/Slider/type.d.ts +0 -7
  129. package/dist/esm/types/components/Slider/type.d.ts.map +0 -1
  130. package/dist/esm/types/system/pseudo.d.ts +0 -14
  131. package/dist/esm/types/system/pseudo.d.ts.map +0 -1
  132. package/src/components/Slider/type.ts +0 -16
  133. package/src/system/pseudo.ts +0 -55
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var jsxRuntime = require('@emotion/react/jsx-runtime');
4
- var react = require('@emotion/react');
3
+ var jsxRuntime = require('react/jsx-runtime');
5
4
  var React = require('react');
6
5
 
7
6
  /******************************************************************************
@@ -69,20 +68,17 @@ function setDprConfig(canvas, context, width, height, dpr) {
69
68
  canvas.style.width = `${width}px`;
70
69
  canvas.style.height = `${height}px`;
71
70
  }
72
- /**
73
- * A simple animatable canvas with requestAnimationFrame()
74
- */
75
71
  function AnimationCanvas(_a) {
76
- var { width = 100, height = 100, style, relativeSize = false, reduceFlickering = true, options, init, draw, className } = _a, props = __rest(_a, ["width", "height", "style", "relativeSize", "reduceFlickering", "options", "init", "draw", "className"]);
72
+ var { width = 100, height = 100, relativeSize = false, reduceFlickering = true, options, init, draw, className } = _a, props = __rest(_a, ["width", "height", "relativeSize", "reduceFlickering", "options", "init", "draw", "className"]);
77
73
  const canvasRef = React.useRef(null);
78
74
  const memoCanvasRef = React.useRef(null);
79
75
  const reqIdRef = React.useRef();
80
76
  const widthRef = React.useRef(0);
81
77
  const heightRef = React.useRef(0);
82
- const loop = (context, width, height, count) => {
78
+ const loop = React.useCallback((context, width, height, count) => {
83
79
  reqIdRef.current = requestAnimationFrame(() => loop(context, width, height, count + 1));
84
80
  draw(context, width, height, count + 1);
85
- };
81
+ }, [draw]);
86
82
  React.useEffect(() => {
87
83
  if (!canvasRef.current)
88
84
  return;
@@ -96,30 +92,34 @@ function AnimationCanvas(_a) {
96
92
  if (!parent)
97
93
  throw new Error("Canvas doesn't have a parent element.");
98
94
  const memoCanvas = memoCanvasRef.current;
99
- const memoContext = memoCanvas === null || memoCanvas === undefined ? undefined : memoCanvas.getContext('2d', options);
100
- const resizeObserver = new ResizeObserver(() => {
101
- // console.log('resize')
102
- // Prevents loss of some context when the canvas is resized
103
- const contextMemo = {};
104
- for (const prop of drawingState) {
105
- contextMemo[prop] = context[prop];
106
- }
107
- const w = Math.floor(parent.clientWidth);
108
- const h = Math.floor(parent.clientHeight);
109
- if (reduceFlickering && memoCanvas && memoContext) {
110
- memoCanvas.width = w * dpr;
111
- memoCanvas.height = h * dpr;
112
- memoContext.scale(1 / dpr, 1 / dpr);
113
- memoContext.drawImage(context.canvas, 0, 0);
114
- }
115
- setDprConfig(canvas, context, w, h, dpr);
116
- widthRef.current = w;
117
- heightRef.current = h;
118
- for (const prop of drawingState) {
119
- context[prop] = contextMemo[prop];
120
- }
121
- if (reduceFlickering && memoContext) {
122
- context.drawImage(memoContext.canvas, 0, 0);
95
+ const memoContext = memoCanvas === null || memoCanvas === void 0 ? void 0 : memoCanvas.getContext('2d', options);
96
+ const resizeObserver = new ResizeObserver((entries) => {
97
+ // TODO: If the parent element has no absolute height, the height increases infinitely.
98
+ // : 親要素に絶対的な高さを持たない場合、高さは無限に増加します。
99
+ // https://zenn.dev/megeton/articles/be1c677e174c84#%E6%A0%B9%E6%9C%AC%E7%9A%84%E3%81%AB-resizeobserver-loop-limit-exceeded-%E3%81%8C%E5%87%BA%E3%82%8B%E5%95%8F%E9%A1%8C%E3%81%AB%E5%90%91%E3%81%8D%E5%90%88%E3%81%86
100
+ for (const entry of entries) {
101
+ // Prevents loss of some context when the canvas is resized
102
+ const contextMemo = {};
103
+ for (const prop of drawingState) {
104
+ contextMemo[prop] = context[prop];
105
+ }
106
+ const w = Math.floor(entry.contentRect.width);
107
+ const h = Math.floor(entry.contentRect.height);
108
+ if (reduceFlickering && memoCanvas && memoContext) {
109
+ memoCanvas.width = w * dpr;
110
+ memoCanvas.height = h * dpr;
111
+ memoContext.scale(1 / dpr, 1 / dpr);
112
+ memoContext.drawImage(context.canvas, 0, 0);
113
+ }
114
+ setDprConfig(canvas, context, w, h, dpr);
115
+ widthRef.current = w;
116
+ heightRef.current = h;
117
+ for (const prop of drawingState) {
118
+ context[prop] = contextMemo[prop];
119
+ }
120
+ if (reduceFlickering && memoContext) {
121
+ context.drawImage(memoContext.canvas, 0, 0);
122
+ }
123
123
  }
124
124
  });
125
125
  resizeObserver.observe(parent);
@@ -148,8 +148,8 @@ function AnimationCanvas(_a) {
148
148
  cancelAnimationFrame(reqIdRef.current);
149
149
  };
150
150
  }
151
- }, [loop]);
152
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("canvas", Object.assign({ className: clsx('tremolo-animation-canvas', className), width: relativeSize ? 0 : width, height: relativeSize ? 0 : height, css: react.css(style), ref: canvasRef }, props)), relativeSize && reduceFlickering && (jsxRuntime.jsx("canvas", { style: { display: 'none' }, width: relativeSize ? 0 : width, height: relativeSize ? 0 : height, ref: memoCanvasRef }))] }));
151
+ }, [loop, init, options, reduceFlickering, relativeSize]);
152
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("canvas", Object.assign({ className: clsx('tremolo-animation-canvas', className), width: relativeSize ? 0 : width, height: relativeSize ? 0 : height, ref: canvasRef }, props)), relativeSize && reduceFlickering && (jsxRuntime.jsx("canvas", { style: { display: 'none' }, ref: memoCanvasRef }))] }));
153
153
  }
154
154
 
155
155
  /**
@@ -190,7 +190,7 @@ function stepValue(value, step) {
190
190
  if (step <= 0)
191
191
  throw new RangeError('requirements: step > 0');
192
192
  const quotient = Math.floor(value / step);
193
- const decimalDigits = (_a = decimalPart$1(step)) === null || _a === undefined ? undefined : _a.length;
193
+ const decimalDigits = (_a = decimalPart$1(step)) === null || _a === void 0 ? void 0 : _a.length;
194
194
  const v = toFixed$2(quotient * step, decimalDigits);
195
195
  const next = toFixed$2((quotient + 1) * step, decimalDigits);
196
196
  return Math.abs(value - v) < Math.abs(value - next) ? v : next;
@@ -246,12 +246,31 @@ function styleHelper(value, op, influencer) {
246
246
  * @category Utility
247
247
  */
248
248
  function mod(n, m) {
249
- return (((n % m) + m) % m);
249
+ return ((n % m) + m) % m;
250
+ }
251
+ /**
252
+ * @category Utility
253
+ */
254
+ function xor(a = false, b = false) {
255
+ return (a || b) && a != b;
250
256
  }
251
257
  /**
252
258
  * @category MIDI
253
259
  */
254
- const noteNames = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
260
+ const noteNames = [
261
+ 'C',
262
+ 'C#',
263
+ 'D',
264
+ 'D#',
265
+ 'E',
266
+ 'F',
267
+ 'F#',
268
+ 'G',
269
+ 'G#',
270
+ 'A',
271
+ 'A#',
272
+ 'B',
273
+ ];
255
274
  /**
256
275
  * @category MIDI
257
276
  */
@@ -271,7 +290,7 @@ function parseNoteName(noteName) {
271
290
  * @category MIDI
272
291
  */
273
292
  function noteNumber(noteName) {
274
- const { letter, accidental, octave, } = parseNoteName(noteName);
293
+ const { letter, accidental, octave } = parseNoteName(noteName);
275
294
  const noteIndex = noteNames.indexOf(letter.toLocaleUpperCase());
276
295
  const accidentalValue = (accidental[0] == 'b' ? -1 : 1) * accidental.length;
277
296
  return noteIndex + 12 * (Number(octave) + 1) + accidentalValue;
@@ -310,13 +329,14 @@ function useCallbackRef(callback, deps = []) {
310
329
  React.useInsertionEffect(() => {
311
330
  callbackRef.current = callback;
312
331
  });
313
- return React.useCallback((...args) => { var _a; return (_a = callbackRef.current) === null || _a === undefined ? undefined : _a.call(callbackRef, ...args); }, deps);
332
+ // eslint-disable-next-line react-hooks/exhaustive-deps
333
+ return React.useCallback((...args) => { var _a; return (_a = callbackRef.current) === null || _a === void 0 ? void 0 : _a.call(callbackRef, ...args); }, deps);
314
334
  }
315
335
 
316
336
  function useEventListener(target, event, handler, options) {
317
337
  const listener = useCallbackRef(handler);
318
338
  React.useEffect(() => {
319
- const node = typeof target === 'function' ? target() : (target !== null && target !== undefined ? target : document);
339
+ const node = typeof target === 'function' ? target() : (target !== null && target !== void 0 ? target : document);
320
340
  if (!handler || !node)
321
341
  return;
322
342
  node.addEventListener(event, listener, options);
@@ -325,8 +345,8 @@ function useEventListener(target, event, handler, options) {
325
345
  };
326
346
  }, [event, target, options, listener, handler]);
327
347
  return () => {
328
- const node = typeof target === 'function' ? target() : (target !== null && target !== undefined ? target : document);
329
- node === null || node === undefined ? undefined : node.removeEventListener(event, listener, options);
348
+ const node = typeof target === 'function' ? target() : (target !== null && target !== void 0 ? target : document);
349
+ node === null || node === void 0 ? void 0 : node.removeEventListener(event, listener, options);
330
350
  };
331
351
  }
332
352
 
@@ -335,7 +355,7 @@ function useRefCallbackEvent(event, handler, options, deps = []) {
335
355
  let cleanup;
336
356
  return (node) => {
337
357
  if (!node) {
338
- cleanup === null || cleanup === undefined ? undefined : cleanup();
358
+ cleanup === null || cleanup === void 0 ? void 0 : cleanup();
339
359
  return;
340
360
  }
341
361
  node.addEventListener(event, handler, options);
@@ -343,6 +363,7 @@ function useRefCallbackEvent(event, handler, options, deps = []) {
343
363
  node.removeEventListener(event, handler, options);
344
364
  };
345
365
  };
366
+ // eslint-disable-next-line react-hooks/exhaustive-deps
346
367
  }, deps);
347
368
  }
348
369
 
@@ -353,34 +374,17 @@ function removeNoSelect() {
353
374
  document.body.classList.remove('tremolo-no-select');
354
375
  }
355
376
 
356
- const defaultOptions = {
357
- active: '#7998ec',
358
- inactive: '#eee',
359
- bg: '#ccc',
360
- thumb: '#4e76e6',
361
- lineWeight: 6,
362
- thumbWeight: 4,
363
- };
364
377
  /**
365
378
  * simple rotary Knob.
366
379
  */
367
- function Knob(_a) {
368
- var { value, min, max, defaultValue = min, startValue = min, step = 1, skew = 1, size, width = 50, height = 50, options = defaultOptions, draw, bodyNoSelect = true, wheel, enableDoubleClickDefault = true, style, className, onChange, _active, _focus, _hover } = _a, props = __rest(_a, ["value", "min", "max", "defaultValue", "startValue", "step", "skew", "size", "width", "height", "options", "draw", "bodyNoSelect", "wheel", "enableDoubleClickDefault", "style", "className", "onChange", "_active", "_focus", "_hover"]);
380
+ function AnimationKnob(_a) {
381
+ var { value, min, max, defaultValue = min, startValue = min, step = 1, skew = 1, size, width = 50, height = 50, activeColor = '#7998ec', inactiveColor = '#eee', bg = '#ccc', thumb = '#4e76e6', lineWeight = 6, thumbWeight = 4, draw, bodyNoSelect = true, wheel = ['raw', 1], keyboard = ['raw', 1], enableDoubleClickDefault = true, style, className, onChange } = _a, props = __rest(_a, ["value", "min", "max", "defaultValue", "startValue", "step", "skew", "size", "width", "height", "activeColor", "inactiveColor", "bg", "thumb", "lineWeight", "thumbWeight", "draw", "bodyNoSelect", "wheel", "keyboard", "enableDoubleClickDefault", "style", "className", "onChange"]);
369
382
  // -- state and ref ---
370
383
  // const [privateValue, setPrivateValue] = useState(value);
371
384
  const dragOffsetY = React.useRef(undefined);
372
385
  // --- interpret props ---
373
- const opts = Object.assign(Object.assign({}, defaultOptions), options);
374
386
  // const percent = normalizeValue(value, min, max, skew)
375
- const isRelativeSize = typeof (size !== null && size !== undefined ? size : width) == 'string';
376
- const adaptSize = (size) => {
377
- if (typeof size == 'string') {
378
- return Number(size.slice(0, -1));
379
- }
380
- else {
381
- return size;
382
- }
383
- };
387
+ const isRelativeSize = typeof (size !== null && size !== void 0 ? size : width) == 'string' || typeof height == 'string';
384
388
  const handleEvent = (event) => {
385
389
  const isTouch = event instanceof TouchEvent;
386
390
  if (isTouch && event.cancelable)
@@ -390,6 +394,8 @@ function Knob(_a) {
390
394
  addNoSelect();
391
395
  const screenY = isTouch ? event.touches[0].screenY : event.screenY;
392
396
  const delta = dragOffsetY.current - screenY;
397
+ if (Math.abs(delta) < 1)
398
+ return;
393
399
  dragOffsetY.current = screenY;
394
400
  const n = normalizeValue(value, min, max, skew);
395
401
  const v = rawValue(n + delta / 100, min, max, skew);
@@ -398,6 +404,24 @@ function Knob(_a) {
398
404
  onChange(v2);
399
405
  }
400
406
  };
407
+ const handleKeyDown = React.useCallback((event) => {
408
+ if (!keyboard || !onChange)
409
+ return;
410
+ const key = event.key;
411
+ if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown'].includes(key)) {
412
+ event.preventDefault();
413
+ const x = key == 'ArrowRight' || key == 'ArrowUp' ? keyboard[1] : -keyboard[1];
414
+ let v;
415
+ if (keyboard[0] == 'normalized') {
416
+ const n = normalizeValue(value, min, max, skew);
417
+ v = rawValue(n + x, min, max, skew);
418
+ }
419
+ else {
420
+ v = value + x;
421
+ }
422
+ onChange(clamp(stepValue(v, step), min, max));
423
+ }
424
+ }, [value, min, max, step, skew, keyboard, onChange]);
401
425
  // --- hooks ---
402
426
  const wheelRefCallback = useRefCallbackEvent('wheel', (event) => {
403
427
  if (!wheel)
@@ -422,24 +446,24 @@ function Knob(_a) {
422
446
  if (bodyNoSelect)
423
447
  removeNoSelect();
424
448
  });
425
- return (jsxRuntime.jsxs("div", Object.assign({ className: clsx('tremolo-knob', className), ref: (div) => {
449
+ return (jsxRuntime.jsx("div", Object.assign({ className: clsx('tremolo-animation-knob', className), ref: (div) => {
426
450
  wheelRefCallback(div);
427
451
  touchMoveRefCallback(div);
428
- }, role: "slider", tabIndex: 0, "aria-valuenow": value, "aria-valuemax": max, "aria-valuemin": min, css: react.css(Object.assign(Object.assign({ display: 'inline-block', width: size !== null && size !== undefined ? size : width, height: size !== null && size !== undefined ? size : height, cursor: 'pointer' }, style), { ':active': Object.assign({}, _active), ':focus': Object.assign({}, _focus), ':hover': Object.assign({}, _hover) })), onPointerDown: (event) => {
452
+ }, role: "slider", tabIndex: 0, "aria-valuenow": value, "aria-valuemax": max, "aria-valuemin": min, style: Object.assign({ display: 'inline-block', width: size !== null && size !== void 0 ? size : width, height: size !== null && size !== void 0 ? size : height, cursor: 'pointer', WebkitTapHighlightColor: 'transparent' }, style), onPointerDown: (event) => {
429
453
  dragOffsetY.current = event.screenY;
430
454
  handleEvent(event);
431
455
  }, onDoubleClick: () => {
432
456
  if (enableDoubleClickDefault && onChange) {
433
457
  onChange(defaultValue);
434
458
  }
435
- } }, props, { children: [jsxRuntime.jsx(react.Global, { styles: {
436
- '.no-select': {
437
- userSelect: 'none',
438
- },
439
- } }), jsxRuntime.jsx(AnimationCanvas, { width: adaptSize(size !== null && size !== undefined ? size : width), height: adaptSize(size !== null && size !== undefined ? size : height), relativeSize: isRelativeSize,
440
- // TODO
441
- // reduceFlickering={false}
442
- draw: draw ? draw : (ctx, width, height) => {
459
+ }, onKeyDown: handleKeyDown, onContextMenu: (e) => e.preventDefault() }, props, { children: jsxRuntime.jsx(AnimationCanvas, Object.assign({}, (isRelativeSize
460
+ ? { relativeSize: true }
461
+ : {
462
+ width: size !== null && size !== void 0 ? size : width,
463
+ height: size !== null && size !== void 0 ? size : height,
464
+ }), { draw: draw
465
+ ? draw
466
+ : (ctx, width, height) => {
443
467
  const p = normalizeValue(value, min, max, skew);
444
468
  const startP = normalizeValue(startValue, min, max, skew);
445
469
  const w = width.current, cx = w / 2;
@@ -452,33 +476,172 @@ function Knob(_a) {
452
476
  ctx.lineCap = 'butt';
453
477
  // bg
454
478
  ctx.beginPath();
455
- ctx.fillStyle = opts.bg;
479
+ ctx.fillStyle = bg;
456
480
  ctx.arc(cx, cy, r - 0.5, 0, 2 * Math.PI);
457
481
  ctx.fill();
458
- ctx.lineCap = 'round';
459
- ctx.lineWidth = opts.lineWeight;
482
+ ctx.lineWidth = lineWeight;
460
483
  // inactive rotary
461
484
  ctx.beginPath();
462
- ctx.strokeStyle = opts.inactive;
463
- ctx.arc(cx, cy, r - 0.5 - opts.lineWeight / 2, radian(135), radian(45));
485
+ ctx.strokeStyle = inactiveColor;
486
+ ctx.arc(cx, cy, r - 0.5 - lineWeight / 2, radian(135), radian(45));
464
487
  ctx.stroke();
465
488
  // active rotary
466
489
  ctx.beginPath();
467
- ctx.strokeStyle = opts.active;
468
- ctx.arc(cx, cy, r - 0.5 - opts.lineWeight / 2, radian(135 + 270 * startP), radian(135 + 270 * p), p < startP);
490
+ ctx.strokeStyle = activeColor;
491
+ ctx.arc(cx, cy, r - 0.5 - lineWeight / 2, radian(135 + 270 * startP), radian(135 + 270 * p), p < startP);
469
492
  ctx.stroke();
470
493
  // thumb
494
+ ctx.lineCap = 'round';
471
495
  ctx.beginPath();
472
496
  ctx.moveTo(cx, cy);
473
497
  ctx.lineTo(cx +
474
498
  Math.cos(radian(135 + 270 * p)) *
475
- (r - 0.5 - opts.thumbWeight / 2), cy +
499
+ (r - 0.5 - thumbWeight / 2), cy +
476
500
  Math.sin(radian(135 + 270 * p)) *
477
- (r - 0.5 - opts.thumbWeight / 2));
478
- ctx.strokeStyle = opts.thumb;
479
- ctx.lineWidth = opts.thumbWeight;
501
+ (r - 0.5 - thumbWeight / 2));
502
+ ctx.strokeStyle = thumb;
503
+ ctx.lineWidth = thumbWeight;
480
504
  ctx.stroke();
481
- } })] })));
505
+ } })) })));
506
+ }
507
+
508
+ function DragObserver(props) {
509
+ const { children, onDrag, onDragStart, onDragEnd, as: Component = 'div' } = props, attributes = __rest(props, ["children", "onDrag", "onDragStart", "onDragEnd", "as"]);
510
+ const dragOffsetX = React.useRef(undefined);
511
+ const dragOffsetY = React.useRef(undefined);
512
+ const handleEvent = (event) => {
513
+ const isTouch = event instanceof TouchEvent;
514
+ if (isTouch && event.cancelable)
515
+ event.preventDefault();
516
+ const screenX = isTouch ? event.touches[0].screenX : event.screenX;
517
+ const screenY = isTouch ? event.touches[0].screenY : event.screenY;
518
+ let deltaX = 0, deltaY = 0;
519
+ if (dragOffsetX.current) {
520
+ deltaX = screenX - dragOffsetX.current;
521
+ dragOffsetX.current = screenX;
522
+ }
523
+ if (dragOffsetY.current) {
524
+ deltaY = screenY - dragOffsetY.current;
525
+ dragOffsetY.current = screenY;
526
+ }
527
+ if (Math.abs(deltaX) < 1 && Math.abs(deltaY) < 1)
528
+ return;
529
+ if (onDrag)
530
+ onDrag(deltaX, deltaY);
531
+ };
532
+ const touchMoveRefCallback = useRefCallbackEvent('touchmove', handleEvent, { passive: false }, [onDrag]);
533
+ useEventListener(window, 'mousemove', handleEvent);
534
+ useEventListener(window, 'pointerup', () => {
535
+ dragOffsetX.current = undefined;
536
+ dragOffsetY.current = undefined;
537
+ onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd();
538
+ });
539
+ return (jsxRuntime.jsx(Component, Object.assign({ ref: touchMoveRefCallback, onPointerDown: (event) => {
540
+ dragOffsetX.current = event.screenX;
541
+ dragOffsetY.current = event.screenY;
542
+ handleEvent(event);
543
+ onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart();
544
+ } }, attributes, { children: children })));
545
+ }
546
+
547
+ function Knob(_a) {
548
+ var { value, min, max, step = 1, skew = 1, defaultValue = min, startValue = min, size = 50, bodyNoSelect = true, wheel = ['raw', 1], keyboard = ['raw', 1], enableDoubleClickDefault = true, disabled = false, readonly = false, activeLine, inactiveLine, thumb, thumbLine, onChange, className, classes } = _a, props = __rest(_a, ["value", "min", "max", "step", "skew", "defaultValue", "startValue", "size", "bodyNoSelect", "wheel", "keyboard", "enableDoubleClickDefault", "disabled", "readonly", "activeLine", "inactiveLine", "thumb", "thumbLine", "onChange", "className", "classes"]);
549
+ // -- state and ref ---
550
+ const dragOffsetY = React.useRef(undefined);
551
+ // --- interpret props ---
552
+ const padding = 8; // %
553
+ const thumbLineWeight = 6; // %
554
+ const thumbLength = 35; // %
555
+ const lineWeight = 3; // px
556
+ const p = normalizeValue(value, min, max, skew);
557
+ const s = normalizeValue(startValue, min, max, skew);
558
+ // --- internal functions ---
559
+ const handleEvent = (event) => {
560
+ if (!onChange || readonly)
561
+ return;
562
+ const isTouch = event instanceof TouchEvent;
563
+ if (isTouch && event.cancelable)
564
+ event.preventDefault();
565
+ if (dragOffsetY.current) {
566
+ if (bodyNoSelect)
567
+ addNoSelect();
568
+ const screenY = isTouch ? event.touches[0].screenY : event.screenY;
569
+ const delta = dragOffsetY.current - screenY;
570
+ if (Math.abs(delta) < 1)
571
+ return;
572
+ dragOffsetY.current = screenY;
573
+ const n = normalizeValue(value, min, max, skew);
574
+ const v = rawValue(n + delta / 100, min, max, skew);
575
+ const v2 = clamp(stepValue(v, step), min, max);
576
+ onChange(v2);
577
+ }
578
+ };
579
+ const handleKeyDown = React.useCallback((event) => {
580
+ if (!keyboard || !onChange || readonly)
581
+ return;
582
+ const key = event.key;
583
+ if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown'].includes(key)) {
584
+ event.preventDefault();
585
+ const x = key == 'ArrowRight' || key == 'ArrowUp' ? keyboard[1] : -keyboard[1];
586
+ let v;
587
+ if (keyboard[0] == 'normalized') {
588
+ const n = normalizeValue(value, min, max, skew);
589
+ v = rawValue(n + x, min, max, skew);
590
+ }
591
+ else {
592
+ v = value + x;
593
+ }
594
+ onChange(clamp(stepValue(v, step), min, max));
595
+ }
596
+ }, [value, min, max, step, skew, keyboard, readonly, onChange]);
597
+ // --- hooks ---
598
+ const wheelRefCallback = useRefCallbackEvent('wheel', (event) => {
599
+ if (!wheel)
600
+ return;
601
+ event.preventDefault();
602
+ const x = event.deltaY > 0 ? -wheel[1] : wheel[1];
603
+ let v;
604
+ if (wheel[0] == 'normalized') {
605
+ const n = normalizeValue(value, min, max, skew);
606
+ v = rawValue(n + x, min, max, skew);
607
+ }
608
+ else {
609
+ v = value + x;
610
+ }
611
+ if (onChange)
612
+ onChange(clamp(stepValue(v, step), min, max));
613
+ }, { passive: false }, [wheel, value, min, max, skew, step, onChange]);
614
+ const touchMoveRefCallback = useRefCallbackEvent('touchmove', handleEvent, { passive: false }, [value, min, max, skew, step, onChange, bodyNoSelect]);
615
+ useEventListener(window, 'mousemove', handleEvent);
616
+ useEventListener(window, 'pointerup', () => {
617
+ dragOffsetY.current = undefined;
618
+ if (bodyNoSelect)
619
+ removeNoSelect();
620
+ });
621
+ const center = size / 2;
622
+ const r1 = -135;
623
+ const r2 = -135 + Math.min(p, s) * 270;
624
+ const r3 = -135 + Math.max(p, s) * 270;
625
+ const r4 = 135;
626
+ const x1 = center + center * Math.cos(radian(r1 - 90));
627
+ const y1 = center + center * Math.sin(radian(r1 - 90));
628
+ const x2 = center + center * Math.cos(radian(r2 - 90));
629
+ const y2 = center + center * Math.sin(radian(r2 - 90));
630
+ const x3 = center + center * Math.cos(radian(r3 - 90));
631
+ const y3 = center + center * Math.sin(radian(r3 - 90));
632
+ const x4 = center + center * Math.cos(radian(r4 - 90));
633
+ const y4 = center + center * Math.sin(radian(r4 - 90));
634
+ return (jsxRuntime.jsxs("svg", Object.assign({ className: clsx('tremolo-knob', className), ref: (div) => {
635
+ wheelRefCallback(div);
636
+ touchMoveRefCallback(div);
637
+ }, width: size, height: size, tabIndex: 0, "aria-valuenow": value, "aria-valuemin": min, "aria-valuemax": max, "aria-disabled": disabled, "aria-readonly": readonly, onPointerDown: (event) => {
638
+ dragOffsetY.current = event.screenY;
639
+ handleEvent(event);
640
+ }, onDoubleClick: () => {
641
+ if (enableDoubleClickDefault && onChange) {
642
+ onChange(defaultValue);
643
+ }
644
+ }, onKeyDown: handleKeyDown, onContextMenu: (e) => e.preventDefault() }, props, { children: [startValue > min && (jsxRuntime.jsx("path", { className: clsx('tremolo-knob-inactive-line', classes === null || classes === void 0 ? void 0 : classes.inactiveLine), d: `M ${x1} ${y1} A ${center} ${center} -135 ${r2 - r1 > 180 ? 1 : 0} 1 ${x2}, ${y2}`, fill: "none", stroke: inactiveLine || 'currentColor', strokeWidth: lineWeight })), jsxRuntime.jsx("path", { className: clsx('tremolo-knob-active-line', classes === null || classes === void 0 ? void 0 : classes.activeLine), d: `M ${x2} ${y2} A ${center} ${center} -135 ${r3 - r2 > 180 ? 1 : 0} 1 ${x3}, ${y3}`, fill: "none", stroke: activeLine || 'currentColor', strokeWidth: lineWeight }), startValue < max && (jsxRuntime.jsx("path", { className: clsx('tremolo-knob-inactive-line', classes === null || classes === void 0 ? void 0 : classes.inactiveLine), d: `M ${x3} ${y3} A ${center} ${center} -135 ${r4 - r3 > 180 ? 1 : 0} 1 ${x4}, ${y4}`, fill: "none", stroke: inactiveLine || 'currentColor', strokeWidth: lineWeight })), jsxRuntime.jsxs("svg", { className: clsx('tremolo-knob-thumb', classes === null || classes === void 0 ? void 0 : classes.thumb), children: [jsxRuntime.jsx("circle", { cx: "50%", cy: "50%", r: `${50 - padding}%`, fill: thumb || 'currentColor' }), jsxRuntime.jsx("line", { className: clsx('tremolo-knob-thumb-line', classes === null || classes === void 0 ? void 0 : classes.thumbLine), x1: "50%", y1: `${padding}%`, x2: "50%", y2: `${thumbLength}%`, stroke: thumbLine || 'currentColor', strokeWidth: `${thumbLineWeight}%`, transform: `rotate(${ -135 + p * 270})`, "transform-origin": "50% 50%" })] })] })));
482
645
  }
483
646
 
484
647
  /**
@@ -495,7 +658,7 @@ function toFixed$1(x, fractionDigits) {
495
658
 
496
659
  /**
497
660
  * @module NumberInput
498
- */
661
+ */
499
662
  function selectUnit(units, value) {
500
663
  if (typeof units == 'string')
501
664
  return [units, 1];
@@ -558,14 +721,13 @@ function parseValue(inputString, units, digit, defaultValue = 0) {
558
721
  * Input with some useful functions for entering numerical values.
559
722
  */
560
723
  function NumberInput(_a) {
561
- var { value, min, max, step, defaultValue = min, units, disabled = false, placeholder, readOnly, tabIndex, typeNumber = false, digit, selectWithFocus = 'none', blurWithEnter = true, className, style, onChange, onFocus, onBlur } = _a, props = __rest(_a, ["value", "min", "max", "step", "defaultValue", "units", "disabled", "placeholder", "readOnly", "tabIndex", "typeNumber", "digit", "selectWithFocus", "blurWithEnter", "className", "style", "onChange", "onFocus", "onBlur"]);
724
+ var { value, min, max, step, defaultValue = min, units, disabled = false, placeholder, readOnly, tabIndex, typeNumber = false, digit, selectWithFocus = 'none', blurWithEnter = true, className, onChange, onFocus, onBlur } = _a, props = __rest(_a, ["value", "min", "max", "step", "defaultValue", "units", "disabled", "placeholder", "readOnly", "tabIndex", "typeNumber", "digit", "selectWithFocus", "blurWithEnter", "className", "onChange", "onFocus", "onBlur"]);
562
725
  const [showValue, setShowValue] = React.useState(parseValue(String(value), units, digit, defaultValue).formatValue);
563
726
  const calculatedTypeNumber = units ? false : typeNumber;
564
- const { _active, _focus, _hover } = props, rest = __rest(props, ["_active", "_focus", "_hover"]);
565
- return (jsxRuntime.jsx("input", Object.assign({ className: clsx('tremolo-number-input', className), value: showValue, min: min, max: max, step: step, type: calculatedTypeNumber ? 'number' : 'text', spellCheck: 'false', disabled: disabled, placeholder: placeholder, readOnly: readOnly, tabIndex: tabIndex, css: react.css(Object.assign(Object.assign({ display: 'inline-block', font: 'inherit', margin: 0, paddingTop: 6, paddingBottom: 6, paddingLeft: 10, paddingRight: 10, borderStyle: 'solid', borderWidth: 1, borderColor: '#bbb', borderRadius: 4, outline: 0, transition: 'all 0.1s linear', appearance: 'textfield', '&:hover': Object.assign({ borderColor: 'var(--tremolo-theme-color)' }, _hover), '&:focus': Object.assign({ borderColor: 'var(--tremolo-theme-color)', boxShadow: '0px 0px 0px 2px rgba(var(--tremolo-theme-color-rgb), 0.1)' }, _focus) }, (_active && { '&:active': Object.assign({}, _active) })), style)), onChange: (event) => {
727
+ return (jsxRuntime.jsx("input", Object.assign({ className: clsx('tremolo-number-input', className), value: showValue, min: min, max: max, step: step, type: calculatedTypeNumber ? 'number' : 'text', spellCheck: 'false', disabled: disabled, placeholder: placeholder, readOnly: readOnly, tabIndex: tabIndex, onChange: (event) => {
566
728
  const v = event.currentTarget.value;
567
729
  setShowValue(v);
568
- const newValue = clamp(parseValue(v, units, digit, defaultValue).rawValue, min !== null && min !== undefined ? min : -Infinity, max !== null && max !== undefined ? max : Infinity);
730
+ const newValue = clamp(parseValue(v, units, digit, defaultValue).rawValue, min !== null && min !== void 0 ? min : -Infinity, max !== null && max !== void 0 ? max : Infinity);
569
731
  if (onChange)
570
732
  onChange(newValue, event);
571
733
  }, onFocus: (event) => {
@@ -590,16 +752,20 @@ function NumberInput(_a) {
590
752
  if (blurWithEnter && event.key == 'Enter') {
591
753
  event.currentTarget.blur();
592
754
  }
593
- } }, rest)));
755
+ } }, props)));
594
756
  }
595
757
 
596
- function KeyLabel({ label, className, style, wrapperStyle, __note, __index, __label, }) {
597
- const content = label ? label(__note, __index) : __label && __label(__note, __index);
598
- return ((content != undefined || content != null) &&
599
- jsxRuntime.jsx("div", { className: 'tremolo-piano-key-label-wrapper', css: react.css(Object.assign({ display: 'flex', justifyContent: 'center', alignItems: 'end', height: '100%' }, wrapperStyle)), children: jsxRuntime.jsx("div", { className: clsx('tremolo-piano-key-label', className), css: react.css(Object.assign({ display: 'flex', justifyContent: 'center', alignItems: 'center', fontSize: '0.6rem', height: 10, marginBottom: 10, padding: 4, borderRadius: 4, borderStyle: 'solid', borderWidth: 1, borderColor: '#888', aspectRatio: 1, maxWidth: 'calc(100% - 16px)' }, style)), children: content }) }));
758
+ function KeyLabel(_a) {
759
+ var { label, className, wrapperClassName, wrapperStyle, __note, __index, __label } = _a, props = __rest(_a, ["label", "className", "wrapperClassName", "wrapperStyle", "__note", "__index", "__label"]);
760
+ const content = label
761
+ ? label(__note, __index)
762
+ : __label && __label(__note, __index);
763
+ return ((content != undefined || content != null) && (jsxRuntime.jsx("div", { className: clsx('tremolo-piano-key-label-wrapper', wrapperClassName), style: wrapperStyle, children: jsxRuntime.jsx("div", Object.assign({ className: clsx('tremolo-piano-key-label', className) }, props, { children: content })) })));
600
764
  }
601
765
 
602
- const WhiteKey = React.forwardRef(({ width = 40, height = '100%', bg = 'white', activeBg = '#ccc', style, children, __glissando, __position, __note, __disabled, __index, __fill, __width, __playNote, __stopNote, __label, }, ref) => {
766
+ const defaultWhiteKeyWidth = 40;
767
+ const WhiteKey = React.forwardRef((_a, ref) => {
768
+ var { width = defaultWhiteKeyWidth, height = '100%', className, style, children, __glissando, __position, __note, __disabled, __index, __fill, __width, __playNote, __stopNote, __label } = _a, props = __rest(_a, ["width", "height", "className", "style", "children", "__glissando", "__position", "__note", "__disabled", "__index", "__fill", "__width", "__playNote", "__stopNote", "__label"]);
603
769
  const [played, setPlayed] = React.useState(false);
604
770
  React.useImperativeHandle(ref, () => {
605
771
  return {
@@ -617,11 +783,10 @@ const WhiteKey = React.forwardRef(({ width = 40, height = '100%', bg = 'white',
617
783
  },
618
784
  played() {
619
785
  return played;
620
- }
786
+ },
621
787
  };
622
- }, []);
623
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
624
- let keyLabelProps;
788
+ }, [__disabled, __note, __playNote, __stopNote, played]);
789
+ let keyLabelProps = {};
625
790
  if (children != undefined) {
626
791
  React.Children.forEach(children, (child) => {
627
792
  if (React.isValidElement(child)) {
@@ -637,7 +802,7 @@ const WhiteKey = React.forwardRef(({ width = 40, height = '100%', bg = 'white',
637
802
  }
638
803
  });
639
804
  }
640
- return (jsxRuntime.jsx("div", { className: `tremolo-piano-white-key`, "aria-disabled": __disabled, css: react.css(Object.assign({ position: 'absolute', backgroundColor: played ? activeBg : bg, color: 'black', left: __position, width: __fill ? __width : (width !== null && width !== undefined ? width : __width), height: height, border: '1px solid #555', borderRadius: '0 0 8px 8px', cursor: __disabled ? 'not-allowed' : 'pointer', zIndex: 1 }, style)), onPointerDown: () => {
805
+ return (jsxRuntime.jsx("div", Object.assign({ className: clsx(`tremolo-piano-white-key`, className), "aria-disabled": __disabled, "data-active": played, style: Object.assign({ left: __position, width: __fill ? __width : (width !== null && width !== void 0 ? width : __width), height: height }, style), onPointerDown: () => {
641
806
  if (__disabled)
642
807
  return;
643
808
  setPlayed(true);
@@ -663,10 +828,11 @@ const WhiteKey = React.forwardRef(({ width = 40, height = '100%', bg = 'white',
663
828
  setPlayed(false);
664
829
  if (__stopNote)
665
830
  __stopNote(__note);
666
- }, children: jsxRuntime.jsx(KeyLabel, Object.assign({ __note: __note, __label: __label, __index: __index }, keyLabelProps)) }));
831
+ } }, props, { children: jsxRuntime.jsx(KeyLabel, Object.assign({ __note: __note, __label: __label, __index: __index }, keyLabelProps)) })));
667
832
  });
668
833
 
669
- const BlackKey = React.forwardRef(({ width = 40 * 0.65, height = '60%', bg = '#333', activeBg = '#666', style, children, __glissando, __position, __note, __disabled, __index, __fill, __width, __playNote, __stopNote, __label, }, ref) => {
834
+ const BlackKey = React.forwardRef((_a, ref) => {
835
+ var { width = defaultWhiteKeyWidth * 0.65, height = '60%', className, style, children, __glissando, __position, __note, __disabled, __index, __fill, __width, __playNote, __stopNote, __label } = _a, props = __rest(_a, ["width", "height", "className", "style", "children", "__glissando", "__position", "__note", "__disabled", "__index", "__fill", "__width", "__playNote", "__stopNote", "__label"]);
670
836
  const [played, setPlayed] = React.useState(false);
671
837
  React.useImperativeHandle(ref, () => {
672
838
  return {
@@ -684,11 +850,10 @@ const BlackKey = React.forwardRef(({ width = 40 * 0.65, height = '60%', bg = '#3
684
850
  },
685
851
  played() {
686
852
  return played;
687
- }
853
+ },
688
854
  };
689
- }, []);
690
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
691
- let keyLabelProps;
855
+ }, [__disabled, __note, __playNote, __stopNote, played]);
856
+ let keyLabelProps = {};
692
857
  if (children != undefined) {
693
858
  React.Children.forEach(children, (child) => {
694
859
  if (React.isValidElement(child)) {
@@ -704,7 +869,7 @@ const BlackKey = React.forwardRef(({ width = 40 * 0.65, height = '60%', bg = '#3
704
869
  }
705
870
  });
706
871
  }
707
- return (jsxRuntime.jsx("div", { className: `tremolo-piano-black-key`, "aria-disabled": __disabled, css: react.css(Object.assign({ position: 'absolute', backgroundColor: played ? activeBg : bg, color: 'white', left: __position, width: __fill ? __width : (width !== null && width !== undefined ? width : __width), height: height, border: '1px solid #555', borderRadius: '0 0 8px 8px', cursor: __disabled ? 'not-allowed' : 'pointer', zIndex: 2 }, style)), onPointerDown: () => {
872
+ return (jsxRuntime.jsx("div", Object.assign({ className: clsx(`tremolo-piano-black-key`, className), "aria-disabled": __disabled, "data-active": played, style: Object.assign({ left: __position, width: __fill ? __width : (width !== null && width !== void 0 ? width : __width), height: height }, style), onPointerDown: () => {
708
873
  if (__disabled)
709
874
  return;
710
875
  setPlayed(true);
@@ -730,16 +895,35 @@ const BlackKey = React.forwardRef(({ width = 40 * 0.65, height = '60%', bg = '#3
730
895
  setPlayed(false);
731
896
  if (__stopNote)
732
897
  __stopNote(__note);
733
- }, children: jsxRuntime.jsx(KeyLabel, Object.assign({ __note: __note, __label: __label, __index: __index }, keyLabelProps)) }));
898
+ } }, props, { children: jsxRuntime.jsx(KeyLabel, Object.assign({ __note: __note, __label: __label, __index: __index }, keyLabelProps)) })));
734
899
  });
735
900
 
736
901
  const Shortcuts = {
737
902
  HOME_ROW: {
738
- keys: ['a', 'w', 's', 'e', 'd', 'f', 't', 'g', 'y', 'h', 'u', 'j', 'k', 'o', 'l', 'p', ';']
739
- }
903
+ keys: [
904
+ 'a',
905
+ 'w',
906
+ 's',
907
+ 'e',
908
+ 'd',
909
+ 'f',
910
+ 't',
911
+ 'g',
912
+ 'y',
913
+ 'h',
914
+ 'u',
915
+ 'j',
916
+ 'k',
917
+ 'o',
918
+ 'l',
919
+ 'p',
920
+ ';',
921
+ ],
922
+ },
740
923
  };
741
924
 
742
- function Piano({ noteRange, glissando = true, midiMax = 127, keyboardShortcuts, fill = false, height = fill ? '100%' : 160, style, playNote, stopNote, label, children, }) {
925
+ function Piano(_a) {
926
+ var { noteRange, glissando = true, midiMax = 127, keyboardShortcuts, fill = false, height = fill ? '100%' : 160, style, className, playNote, stopNote, label, children } = _a, props = __rest(_a, ["noteRange", "glissando", "midiMax", "keyboardShortcuts", "fill", "height", "style", "className", "playNote", "stopNote", "label", "children"]);
743
927
  // -- state and ref ---
744
928
  const [pressed, setPressed] = React.useState(false);
745
929
  const [whiteNoteWidth, setWhiteNoteWidth] = React.useState(-1);
@@ -751,8 +935,7 @@ function Piano({ noteRange, glissando = true, midiMax = 127, keyboardShortcuts,
751
935
  // --- interpret props ---
752
936
  const noteRangeArray = Array.from({ length: noteRange.last - noteRange.first + 1 }, (_, i) => i + noteRange.first);
753
937
  const whiteNoteCount = noteRangeArray.filter((v) => isWhiteKey(v)).length;
754
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
755
- let whiteKeyProps, blackKeyProps;
938
+ let whiteKeyProps = {}, blackKeyProps = {};
756
939
  if (children != undefined) {
757
940
  React.Children.forEach(children, (child) => {
758
941
  if (React.isValidElement(child)) {
@@ -812,9 +995,9 @@ function Piano({ noteRange, glissando = true, midiMax = 127, keyboardShortcuts,
812
995
  resizeObserver.observe(parent);
813
996
  }
814
997
  else {
815
- setWhiteNoteWidth((whiteKeyProps === null || whiteKeyProps === undefined ? undefined : whiteKeyProps.width) || 40);
998
+ setWhiteNoteWidth((whiteKeyProps === null || whiteKeyProps === void 0 ? void 0 : whiteKeyProps.width) || defaultWhiteKeyWidth);
816
999
  }
817
- }, []);
1000
+ }, [fill, whiteKeyProps === null || whiteKeyProps === void 0 ? void 0 : whiteKeyProps.width, whiteNoteCount]);
818
1001
  useEventListener(window, 'keydown', (e) => {
819
1002
  var _a, _b, _c, _d;
820
1003
  if (e.repeat)
@@ -823,8 +1006,8 @@ function Piano({ noteRange, glissando = true, midiMax = 127, keyboardShortcuts,
823
1006
  return;
824
1007
  const index = keyboardShortcuts.keys.indexOf(e.key);
825
1008
  if (index != -1) {
826
- if (!((_b = (_a = keyRefs.current[index]) === null || _a === undefined ? undefined : _a.current) === null || _b === undefined ? undefined : _b.played())) {
827
- (_d = (_c = keyRefs.current[index]) === null || _c === undefined ? undefined : _c.current) === null || _d === undefined ? undefined : _d.play();
1009
+ if (!((_b = (_a = keyRefs.current[index]) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.played())) {
1010
+ (_d = (_c = keyRefs.current[index]) === null || _c === void 0 ? void 0 : _c.current) === null || _d === void 0 ? void 0 : _d.play();
828
1011
  }
829
1012
  }
830
1013
  });
@@ -836,18 +1019,48 @@ function Piano({ noteRange, glissando = true, midiMax = 127, keyboardShortcuts,
836
1019
  return;
837
1020
  const index = keyboardShortcuts.keys.indexOf(e.key);
838
1021
  if (index != -1) {
839
- (_b = (_a = keyRefs.current[index]) === null || _a === undefined ? undefined : _a.current) === null || _b === undefined ? undefined : _b.stop();
1022
+ (_b = (_a = keyRefs.current[index]) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.stop();
840
1023
  }
841
1024
  });
842
- return (jsxRuntime.jsx("div", { ref: pianoRef, className: "tremolo-piano", css: react.css(Object.assign({ display: 'inline-block', boxSizing: 'border-box', userSelect: 'none', width: fill ? '100%' : undefined, height: height, position: 'relative' }, style)), onPointerDown: () => {
1025
+ return (jsxRuntime.jsx("div", Object.assign({ ref: pianoRef, className: clsx('tremolo-piano', className), style: Object.assign({ width: fill ? '100%' : (whiteNoteWidth + 3) * whiteNoteCount, height: height }, style), onPointerDown: (e) => {
1026
+ if (props.onPointerDown)
1027
+ props.onPointerDown(e);
843
1028
  setPressed(true);
844
- }, onPointerUp: () => {
1029
+ }, onPointerUp: (e) => {
1030
+ if (props.onPointerUp)
1031
+ props.onPointerUp(e);
845
1032
  setPressed(false);
846
- }, children: noteRangeArray.map((note, index) => {
847
- return (isWhiteKey(note) ? (jsxRuntime.jsx(WhiteKey, Object.assign({ ref: keyRefs.current[index], __glissando: glissando && pressed, __position: notePosition(note), __note: note, __disabled: note > midiMax, __index: index, __fill: fill, __width: whiteNoteWidth, __playNote: playNote, __stopNote: stopNote, __label: label }, whiteKeyProps), note)) : (jsxRuntime.jsx(BlackKey, Object.assign({ ref: keyRefs.current[index], __glissando: glissando && pressed, __position: notePosition(note), __note: note, __disabled: note > midiMax, __index: index, __fill: fill, __width: whiteNoteWidth * 0.65, __playNote: playNote, __stopNote: stopNote, __label: label }, blackKeyProps), note)));
848
- }) }));
1033
+ } }, props, { children: noteRangeArray.map((note, index) => {
1034
+ return isWhiteKey(note) ? (jsxRuntime.jsx(WhiteKey, Object.assign({ ref: keyRefs.current[index], __glissando: glissando && pressed, __position: notePosition(note), __note: note, __disabled: note > midiMax, __index: index, __fill: fill, __width: whiteNoteWidth, __playNote: playNote, __stopNote: stopNote, __label: label }, whiteKeyProps), note)) : (jsxRuntime.jsx(BlackKey, Object.assign({ ref: keyRefs.current[index], __glissando: glissando && pressed, __position: notePosition(note), __note: note, __disabled: note > midiMax, __index: index, __fill: fill, __width: whiteNoteWidth * 0.65, __playNote: playNote, __stopNote: stopNote, __label: label }, blackKeyProps), note));
1035
+ }) })));
849
1036
  }
850
1037
 
1038
+ const minContext = React.createContext(0);
1039
+ const maxContext = React.createContext(0);
1040
+ const stepContext = React.createContext(0);
1041
+ const skewContext = React.createContext(0);
1042
+ const verticalContext = React.createContext(false);
1043
+ const reverseContext = React.createContext(false);
1044
+ const disabledContext = React.createContext(false);
1045
+ function SliderValuesProvider({ min: _min, max: _max, step: _step, skew: _skew, vertical: _vertical, reverse: _reverse, disabled: _disabled, children, }) {
1046
+ const [min] = React.useState(_min);
1047
+ const [max] = React.useState(_max);
1048
+ const [step] = React.useState(_step);
1049
+ const [skew] = React.useState(_skew);
1050
+ const [vertical] = React.useState(_vertical);
1051
+ const [reverse] = React.useState(_reverse);
1052
+ const [disabled] = React.useState(_disabled);
1053
+ return (jsxRuntime.jsx(minContext.Provider, { value: min, children: jsxRuntime.jsx(maxContext.Provider, { value: max, children: jsxRuntime.jsx(stepContext.Provider, { value: step, children: jsxRuntime.jsx(skewContext.Provider, { value: skew, children: jsxRuntime.jsx(verticalContext.Provider, { value: vertical, children: jsxRuntime.jsx(reverseContext.Provider, { value: reverse, children: jsxRuntime.jsx(disabledContext.Provider, { value: disabled, children: children }) }) }) }) }) }) }));
1054
+ }
1055
+ const useMin = () => React.useContext(minContext);
1056
+ const useMax = () => React.useContext(maxContext);
1057
+ const useStep = () => React.useContext(stepContext);
1058
+ const useSkew = () => React.useContext(skewContext);
1059
+ const useVertical = () => React.useContext(verticalContext);
1060
+ // export const useSetVertical = () => useContext(setVerticalContext)
1061
+ const useReverse = () => React.useContext(reverseContext);
1062
+ const useDisabled = () => React.useContext(disabledContext);
1063
+
851
1064
  /**
852
1065
  * clamp value between min and max
853
1066
  * @category Math
@@ -869,105 +1082,119 @@ function decimalPart(x) {
869
1082
 
870
1083
  /**
871
1084
  * @module Slider
872
- */
873
- function isHorizontal(d) {
874
- return d == 'right' || d == 'left';
875
- }
876
- function isVertical(d) {
877
- return d == 'up' || d == 'down';
878
- }
879
- function isReversed(d) {
880
- return d == 'left' || d == 'up';
881
- }
882
- function gradientDirection(d) {
883
- if (d == 'left' || d == 'right')
884
- return d;
885
- if (d == 'up')
886
- return 'top';
887
- if (d == 'down')
888
- return 'bottom';
889
- }
890
- function parseScaleOrderList(scale, min, max, step) {
1085
+ */
1086
+ function generateOptionsList(options, min, max, step) {
891
1087
  var _a;
892
- let scalesList = [];
893
- if (!scale) ;
894
- else if (typeof scale[0] == 'object') {
895
- scalesList = scale;
896
- }
897
- else {
898
- const per = scale[0] == 'step' ? step : scale[0];
899
- const count = Math.floor(max / per) - Math.ceil(min / per) + 1;
900
- for (let i = 0; i < count; i++) {
901
- const at = toFixed(per * (Math.ceil(min / per) + i), (_a = decimalPart(per)) === null || _a === undefined ? undefined : _a.length);
902
- scalesList.push({ at: at, type: scale[1] });
903
- }
1088
+ const optionsList = [];
1089
+ const per = options[0] == 'step' ? step : options[0];
1090
+ const count = Math.floor(max / per) - Math.ceil(min / per) + 1;
1091
+ for (let i = 0; i < count; i++) {
1092
+ const value = toFixed(per * (Math.ceil(min / per) + i), (_a = decimalPart(per)) === null || _a === void 0 ? void 0 : _a.length);
1093
+ optionsList.push({ value: value, type: options[1] });
904
1094
  }
905
- return scalesList;
1095
+ return optionsList;
1096
+ }
1097
+
1098
+ function ScaleOption(_a) {
1099
+ var { value, type = 'mark-number', label, thickness = 1, length = '0.5rem', gap = 2, labelWidth, classes, styles, className, style } = _a, props = __rest(_a, ["value", "type", "label", "thickness", "length", "gap", "labelWidth", "classes", "styles", "className", "style"]);
1100
+ const min = useMin();
1101
+ const max = useMax();
1102
+ const skew = useSkew();
1103
+ const vertical = useVertical();
1104
+ const reverse = useReverse();
1105
+ const calcPercent = React.useCallback((rawValue) => {
1106
+ return toFixed$2(xor(vertical, reverse)
1107
+ ? 100 - normalizeValue(rawValue, min, max, skew) * 100
1108
+ : normalizeValue(rawValue, min, max, skew) * 100);
1109
+ }, [vertical, reverse, max, min, skew]);
1110
+ return (jsxRuntime.jsxs("div", Object.assign({ className: clsx('tremolo-slider-scale-option', className), style: Object.assign({ left: !vertical ? `${calcPercent(value)}%` : undefined, top: vertical ? `${calcPercent(value)}%` : undefined }, style), "data-vertical": vertical }, props, { children: [type != 'number' && (jsxRuntime.jsx("div", { className: clsx('tremolo-slider-scale-option-mark', classes === null || classes === void 0 ? void 0 : classes.mark), style: Object.assign({ width: !vertical ? thickness : length, height: vertical ? thickness : length, marginBottom: !vertical ? gap : undefined, marginRight: vertical ? gap : undefined }, styles === null || styles === void 0 ? void 0 : styles.mark), "data-vertical": vertical })), type != 'mark' && (jsxRuntime.jsx("div", { className: clsx('tremolo-slider-scale-option-label', classes === null || classes === void 0 ? void 0 : classes.label), style: Object.assign({ width: labelWidth }, styles === null || styles === void 0 ? void 0 : styles.label), children: label || value }))] })));
906
1111
  }
907
1112
 
908
- const SliderThumb = React.forwardRef(({ size, width = 22, height = 22, color = '#4e76e6', hoverColor = color, disabledColor = '#5d6478', disabledHoverColor = disabledColor, zIndex = 100, children, className, style, __disabled, __css, }, ref) => {
1113
+ function Scale(_a) {
1114
+ var { gap = 6, options, children, className, style } = _a, props = __rest(_a, ["gap", "options", "children", "className", "style"]);
1115
+ const min = useMin();
1116
+ const max = useMax();
1117
+ const step = useStep();
1118
+ const vertical = useVertical();
1119
+ const reverse = useReverse();
1120
+ const optionsList = options
1121
+ ? generateOptionsList(options, min, max, step)
1122
+ : [];
1123
+ if (xor(vertical, reverse))
1124
+ optionsList.reverse();
1125
+ return (jsxRuntime.jsx("div", Object.assign({ className: clsx('tremolo-slider-scale', className), style: Object.assign({ marginLeft: vertical ? gap : undefined, marginTop: !vertical ? gap : undefined }, style) }, props, { children: options
1126
+ ? optionsList.map(({ value, type }, index) => {
1127
+ return jsxRuntime.jsx(ScaleOption, { value: value, type: type }, index);
1128
+ })
1129
+ : children })));
1130
+ }
1131
+
1132
+ const defaultThumbSize = 22;
1133
+ const SliderThumb = React.forwardRef(({ size, width = defaultThumbSize, height = defaultThumbSize, children, className, style, __percent, }, ref) => {
909
1134
  const wrapperRef = React.useRef(null);
1135
+ const vertical = useVertical();
1136
+ const disabled = useDisabled();
910
1137
  React.useImperativeHandle(ref, () => {
911
1138
  return {
912
1139
  focus() {
913
1140
  var _a;
914
- (_a = wrapperRef.current) === null || _a === undefined ? undefined : _a.focus();
1141
+ (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.focus();
915
1142
  },
916
1143
  blur() {
917
1144
  var _a;
918
- (_a = wrapperRef.current) === null || _a === undefined ? undefined : _a.blur();
1145
+ (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.blur();
919
1146
  },
920
1147
  };
921
1148
  }, []);
922
- return (jsxRuntime.jsx("div", { className: "tremolo-slider-thumb-wrapper", css: react.css(Object.assign({ position: 'absolute', translate: '-50% -50%', zIndex: zIndex }, __css)), children: children ? (children) : (
1149
+ return (jsxRuntime.jsx("div", { className: "tremolo-slider-thumb-wrapper", style: {
1150
+ top: vertical ? `${__percent}%` : '50%',
1151
+ left: !vertical ? `${__percent}%` : '50%',
1152
+ }, children: children ? (children) : (
923
1153
  // default slider thumb
924
1154
  jsxRuntime.jsx("div", { ref: wrapperRef, className: clsx('tremolo-slider-thumb', className),
925
1155
  // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
926
- tabIndex: 0, css: react.css(Object.assign({ background: __disabled ? disabledColor : color, width: size !== null && size !== undefined ? size : width, height: size !== null && size !== undefined ? size : height, borderRadius: '50%', outline: 'none', '&:hover': {
927
- background: __disabled ? disabledHoverColor : hoverColor
928
- }, '&:focus': !__disabled && {
929
- boxShadow: '0px 0px 0px 3px rgba(var(--tremolo-theme-color-rgb), 0.2)',
930
- } }, style)) })) }));
1156
+ tabIndex: 0, "aria-disabled": disabled, style: Object.assign({ width: size !== null && size !== void 0 ? size : width, height: size !== null && size !== void 0 ? size : height }, style) })) }));
931
1157
  });
932
1158
 
933
- function SliderTrack({ length = 140, thickness = 10, activeBg = '#7998ec', inactiveBg = '#eee', activeHoverBg = '#6387e9', inactiveHoverBg = '#e0e0e0', disabledActiveBg = '#858890', disabledInactiveBg = '#ddd', disabledActiveHoverBg = disabledActiveBg, disabledInactiveHoverBg = disabledInactiveBg, children, className, style, __thumb, __direction, __disabled, __percent, }) {
934
- const active = __disabled ? disabledActiveBg : activeBg;
935
- const inactive = __disabled ? disabledInactiveBg : inactiveBg;
936
- const activeHover = __disabled ? disabledActiveHoverBg : activeHoverBg;
937
- const inactiveHover = __disabled ? disabledInactiveHoverBg : inactiveHoverBg;
938
- return (jsxRuntime.jsxs("div", { className: clsx('tremolo-slider-track', className), css: react.css(Object.assign({ position: 'relative', background: `linear-gradient(to ${gradientDirection(__direction)}, ${active} ${__percent}%, ${inactive} ${__percent}%)`, borderRadius: styleHelper(thickness, '/', 2), width: isHorizontal(__direction) ? length : thickness, height: isHorizontal(__direction) ? thickness : length, ':hover': {
939
- background: `linear-gradient(to ${gradientDirection(__direction)}, ${activeHover} ${__percent}%, ${inactiveHover} ${__percent}%)`
940
- } }, style)), children: [children, __thumb] }));
1159
+ const defaultLength = 140;
1160
+ const defaultThickness = 10;
1161
+ function SliderTrack({ length = defaultLength, thickness = defaultThickness, active, inactive, children, className, style, __thumb, __percent, }) {
1162
+ const vertical = useVertical();
1163
+ const reverse = useReverse();
1164
+ const disabled = useDisabled();
1165
+ const direction = vertical ? 'bottom' : 'right';
1166
+ const colors = {
1167
+ '--active': active,
1168
+ '--inactive': inactive,
1169
+ };
1170
+ return (jsxRuntime.jsxs("div", { className: clsx('tremolo-slider-track', className), "aria-disabled": disabled, style: Object.assign(Object.assign(Object.assign({}, colors), { background: xor(vertical, reverse)
1171
+ ? `linear-gradient(to ${direction}, var(--inactive, #eee) ${__percent}%, var(--active, #7998ec) ${__percent}%)`
1172
+ : `linear-gradient(to ${direction}, var(--active, #7998ec) ${__percent}%, var(--inactive, #eee) ${__percent}%)`, borderRadius: styleHelper(thickness, '/', 2), width: !vertical ? length : thickness, height: vertical ? length : thickness }), style), children: [children, __thumb] }));
941
1173
  }
942
1174
 
943
1175
  /**
944
1176
  * Customizable slider
945
1177
  */
946
1178
  const Slider = React.forwardRef((_a, ref) => {
947
- var _b, _c, _d, _e, _f, _g, _h;
948
- var { value, min, max, step = 1, skew = 1, direction = 'right', scale, scaleOption, className, style, bodyNoSelect = true, wheel = ['raw', 1], keyboard = ['raw', 1], disabled = false, readonly = false, onChange, children } = _a; __rest(_a, ["value", "min", "max", "step", "skew", "direction", "scale", "scaleOption", "className", "style", "bodyNoSelect", "wheel", "keyboard", "disabled", "readonly", "onChange", "children"]);
1179
+ var _b, _c, _d;
1180
+ var { value, min, max, step = 1, skew = 1, vertical = false, reverse = false, className, style, bodyNoSelect = true, wheel = ['raw', 1], keyboard = ['raw', 1], disabled = false, readonly = false, onChange, children } = _a, props = __rest(_a, ["value", "min", "max", "step", "skew", "vertical", "reverse", "className", "style", "bodyNoSelect", "wheel", "keyboard", "disabled", "readonly", "onChange", "children"]);
949
1181
  // -- state and ref ---
950
1182
  const trackElementRef = React.useRef(null);
951
1183
  const thumbRef = React.useRef(null);
952
1184
  const thumbDragged = React.useRef(false);
953
- const percent = toFixed$2(normalizeValue(value, min, max, skew) * 100);
954
- const percentRev = isReversed(direction) ? toFixed$2(100 - percent) : percent;
955
- const calcPercent = (v) => {
956
- return toFixed$2(isReversed(direction)
957
- ? 100 - normalizeValue(v, min, max, skew) * 100
958
- : normalizeValue(v, min, max, skew) * 100);
959
- };
960
- if (wheel.length != 2) {
961
- throw new Error(`Slider.wheel expect ['normalized' | 'raw', number]`);
962
- }
963
- if (keyboard.length != 2) {
964
- throw new Error(`Slider.keyboard expect ['normalized' | 'raw', number]`);
965
- }
966
- const scalesList = parseScaleOrderList(scale, min, max, step);
967
- if (isReversed(direction))
968
- scalesList.reverse();
969
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
970
- let trackProps, thumbProps;
1185
+ // --- interpret props ---
1186
+ const p = toFixed$2(normalizeValue(value, min, max, skew) * 100);
1187
+ const rev = toFixed$2(100 - p);
1188
+ // NOTE
1189
+ // normal -> normal (right)
1190
+ // vertical -> rev (up)
1191
+ // reverse -> rev (left)
1192
+ // vertical & reverse -> normal (down)
1193
+ const displayReversed = React.useMemo(() => xor(vertical, reverse), [vertical, reverse]);
1194
+ const percent = displayReversed ? rev : p;
1195
+ let trackProps = {};
1196
+ let thumbProps = {};
1197
+ let scaleComponent = undefined;
971
1198
  if (children != undefined) {
972
1199
  React.Children.forEach(children, (child) => {
973
1200
  if (React.isValidElement(child)) {
@@ -977,6 +1204,9 @@ const Slider = React.forwardRef((_a, ref) => {
977
1204
  else if (child.type == SliderTrack) {
978
1205
  trackProps = child.props;
979
1206
  }
1207
+ else if (child.type == Scale) {
1208
+ scaleComponent = child;
1209
+ }
980
1210
  else {
981
1211
  throw new Error('only <SliderThumb> or <SliderTrack>');
982
1212
  }
@@ -988,8 +1218,12 @@ const Slider = React.forwardRef((_a, ref) => {
988
1218
  }
989
1219
  // --- internal functions ---
990
1220
  const handleValue = (event) => {
991
- if (!trackElementRef.current || !thumbDragged.current || !onChange || readonly)
1221
+ if (!trackElementRef.current ||
1222
+ !thumbDragged.current ||
1223
+ !onChange ||
1224
+ readonly) {
992
1225
  return;
1226
+ }
993
1227
  const isTouch = event instanceof TouchEvent;
994
1228
  if (isTouch && event.cancelable)
995
1229
  event.preventDefault();
@@ -998,10 +1232,10 @@ const Slider = React.forwardRef((_a, ref) => {
998
1232
  const { left: x1, top: y1, right: x2, bottom: y2, } = trackElementRef.current.getBoundingClientRect();
999
1233
  const mouseX = isTouch ? event.touches[0].clientX : event.clientX;
1000
1234
  const mouseY = isTouch ? event.touches[0].clientY : event.clientY;
1001
- const n = isHorizontal(direction)
1002
- ? normalizeValue(mouseX, x1, x2)
1003
- : normalizeValue(mouseY, y1, y2);
1004
- const v = rawValue(isReversed(direction) ? 1 - n : n, min, max, skew);
1235
+ const n = vertical
1236
+ ? normalizeValue(mouseY, y1, y2)
1237
+ : normalizeValue(mouseX, x1, x2);
1238
+ const v = rawValue(displayReversed ? 1 - n : n, min, max, skew);
1005
1239
  onChange(clamp(stepValue(v, step), min, max));
1006
1240
  };
1007
1241
  const handleKeyDown = React.useCallback((event) => {
@@ -1010,8 +1244,8 @@ const Slider = React.forwardRef((_a, ref) => {
1010
1244
  const key = event.key;
1011
1245
  if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown'].includes(key)) {
1012
1246
  event.preventDefault();
1013
- let x = (key == 'ArrowRight' || key == 'ArrowUp') ? keyboard[1] : -keyboard[1];
1014
- if (direction == 'down' || direction == 'left')
1247
+ let x = key == 'ArrowRight' || key == 'ArrowUp' ? keyboard[1] : -keyboard[1];
1248
+ if (reverse)
1015
1249
  x *= -1;
1016
1250
  let v;
1017
1251
  if (keyboard[0] == 'normalized') {
@@ -1023,15 +1257,23 @@ const Slider = React.forwardRef((_a, ref) => {
1023
1257
  }
1024
1258
  onChange(clamp(stepValue(v, step), min, max));
1025
1259
  }
1026
- }, [value, min, max, step, skew, direction, keyboard, onChange, readonly]);
1260
+ }, [value, min, max, step, skew, reverse, keyboard, onChange, readonly]);
1027
1261
  // --- hooks ---
1028
- const touchMoveRefCallback = useRefCallbackEvent('touchmove', handleValue, { passive: false }, [min, max, skew, step, direction, onChange, readonly]);
1262
+ const touchMoveRefCallback = useRefCallbackEvent('touchmove', handleValue, { passive: false }, [min, max, skew, step, vertical, reverse, onChange, readonly]);
1029
1263
  const wheelRefCallback = useRefCallbackEvent('wheel', (event) => {
1030
1264
  if (!wheel || !onChange || readonly)
1031
1265
  return;
1032
1266
  event.preventDefault();
1033
- let x = event.deltaY > 0 ? wheel[1] : -wheel[1];
1034
- if (isReversed(direction) || isHorizontal(direction))
1267
+ let x;
1268
+ if (!vertical && event.deltaX != 0) {
1269
+ x = event.deltaX > 0 ? wheel[1] : -wheel[1];
1270
+ }
1271
+ else {
1272
+ if (event.deltaY == 0)
1273
+ return;
1274
+ x = event.deltaY > 0 ? -wheel[1] : wheel[1];
1275
+ }
1276
+ if (vertical && reverse)
1035
1277
  x *= -1;
1036
1278
  let v;
1037
1279
  if (wheel[0] == 'normalized') {
@@ -1057,76 +1299,256 @@ const Slider = React.forwardRef((_a, ref) => {
1057
1299
  return {
1058
1300
  focus() {
1059
1301
  var _a;
1060
- (_a = thumbRef.current) === null || _a === undefined ? undefined : _a.focus();
1302
+ (_a = thumbRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1303
+ },
1304
+ blur() {
1305
+ var _a;
1306
+ (_a = thumbRef.current) === null || _a === void 0 ? void 0 : _a.blur();
1307
+ },
1308
+ };
1309
+ }, []);
1310
+ return (jsxRuntime.jsx(SliderValuesProvider, { min: min, max: max, step: step, skew: skew, vertical: vertical, reverse: reverse, disabled: disabled, children: jsxRuntime.jsx("div", Object.assign({ className: clsx('tremolo-slider', className), ref: (div) => {
1311
+ wheelRefCallback(div);
1312
+ touchMoveRefCallback(div);
1313
+ }, tabIndex: -1, role: "slider", "aria-valuenow": value, "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": vertical ? 'vertical' : 'horizontal', "aria-disabled": disabled, "aria-readonly": readonly, style: Object.assign({ margin: `calc(${styleHelper((_b = thumbProps === null || thumbProps === void 0 ? void 0 : thumbProps.size) !== null && _b !== void 0 ? _b : 22)} / 2)` }, style), onPointerDown: (event) => {
1314
+ thumbDragged.current = true;
1315
+ handleValue(event);
1316
+ }, onKeyDown: handleKeyDown, onFocus: (_c = thumbRef.current) === null || _c === void 0 ? void 0 : _c.focus, onBlur: (_d = thumbRef.current) === null || _d === void 0 ? void 0 : _d.blur }, props, { children: jsxRuntime.jsxs("div", { style: {
1317
+ display: 'flex',
1318
+ flexDirection: vertical ? 'row' : 'column',
1319
+ }, children: [jsxRuntime.jsx("div", { className: "tremolo-slider-track-wrapper", ref: trackElementRef, children: jsxRuntime.jsx(SliderTrack, Object.assign({ __percent: percent, __thumb: jsxRuntime.jsx(SliderThumb, Object.assign({ ref: thumbRef, __percent: percent }, thumbProps)) }, trackProps)) }), scaleComponent] }) })) }));
1320
+ });
1321
+
1322
+ function WheelObserver(props) {
1323
+ const { children, onWheel, as: Component = 'div' } = props, attributes = __rest(props, ["children", "onWheel", "as"]);
1324
+ const wheelRefCallback = useRefCallbackEvent('wheel', (event) => {
1325
+ if (onWheel)
1326
+ onWheel(event);
1327
+ }, { passive: false }, [onWheel]);
1328
+ return (jsxRuntime.jsx(Component, Object.assign({ ref: wheelRefCallback }, attributes, { children: children })));
1329
+ }
1330
+
1331
+ function XYPadArea({ width = 120, height = 120, bg = '#eee', children, className, style, __thumb, }) {
1332
+ return (jsxRuntime.jsxs("div", { className: clsx('tremolo-xy-pad-area', className), style: Object.assign({ position: 'relative', width: width, height: height, background: bg }, style), children: [children, __thumb] }));
1333
+ }
1334
+
1335
+ const XYPadThumb = React.forwardRef(({ size, width = 22, height = 22, children, wrapperClassName, wrapperStyle, className, style, __disabled, __css, }, ref) => {
1336
+ const wrapperRef = React.useRef(null);
1337
+ React.useImperativeHandle(ref, () => {
1338
+ return {
1339
+ focus() {
1340
+ var _a;
1341
+ (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1061
1342
  },
1062
1343
  blur() {
1063
1344
  var _a;
1064
- (_a = thumbRef.current) === null || _a === undefined ? undefined : _a.blur();
1345
+ (_a = wrapperRef.current) === null || _a === void 0 ? void 0 : _a.blur();
1065
1346
  },
1066
1347
  };
1067
1348
  }, []);
1068
- return (jsxRuntime.jsxs("div", { className: clsx('tremolo-slider', className), ref: (div) => {
1349
+ return (jsxRuntime.jsx("div", { className: clsx('tremolo-xy-pad-thumb-wrapper', wrapperClassName), style: Object.assign(Object.assign({}, __css), wrapperStyle), children: children ? (children) : (
1350
+ // default thumb
1351
+ jsxRuntime.jsx("div", { ref: wrapperRef, className: clsx('tremolo-xy-pad-thumb', className),
1352
+ // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
1353
+ tabIndex: 0, "aria-disabled": __disabled, style: Object.assign({ width: size !== null && size !== void 0 ? size : width, height: size !== null && size !== void 0 ? size : height }, style) })) }));
1354
+ });
1355
+
1356
+ const defaultValueOptions = {
1357
+ skew: 1,
1358
+ step: 1,
1359
+ reverse: false,
1360
+ wheel: ['raw', 1],
1361
+ keyboard: ['raw', 1],
1362
+ };
1363
+ /**
1364
+ * Simple XYPad
1365
+ */
1366
+ const XYPad = React.forwardRef((_a, ref) => {
1367
+ var _b, _c, _d;
1368
+ var { x: _x, y: _y, className, style, bodyNoSelect = true, disabled = false, readonly = false, onChange, children } = _a, props = __rest(_a, ["x", "y", "className", "style", "bodyNoSelect", "disabled", "readonly", "onChange", "children"]);
1369
+ const x = React.useMemo(() => {
1370
+ return Object.assign(Object.assign({}, defaultValueOptions), _x);
1371
+ }, [_x]);
1372
+ const y = React.useMemo(() => {
1373
+ return Object.assign(Object.assign({}, defaultValueOptions), _y);
1374
+ }, [_y]);
1375
+ // -- state and ref ---
1376
+ const areaElementRef = React.useRef(null);
1377
+ const thumbRef = React.useRef(null);
1378
+ const thumbDragged = React.useRef(false);
1379
+ // --- interpret props ---
1380
+ const nx = normalizeValue(x.value, x.min, x.max, x.skew);
1381
+ const ny = normalizeValue(y.value, y.min, y.max, y.skew);
1382
+ const percentX = toFixed$2((x.reverse ? 1 - nx : nx) * 100);
1383
+ const percentY = toFixed$2((y.reverse ? 1 - ny : ny) * 100);
1384
+ let areaProps = {}, thumbProps = {};
1385
+ if (children != undefined) {
1386
+ React.Children.forEach(children, (child) => {
1387
+ if (React.isValidElement(child)) {
1388
+ if (child.type == XYPadThumb) {
1389
+ thumbProps = child.props;
1390
+ }
1391
+ else if (child.type == XYPadArea) {
1392
+ areaProps = child.props;
1393
+ }
1394
+ else {
1395
+ throw new Error('only <XYPadThumb> or <XYPadArea>');
1396
+ }
1397
+ }
1398
+ else {
1399
+ throw new Error('children is an invalid element.');
1400
+ }
1401
+ });
1402
+ }
1403
+ // --- internal functions ---
1404
+ const handleValue = (event) => {
1405
+ if (!areaElementRef.current ||
1406
+ !thumbDragged.current ||
1407
+ !onChange ||
1408
+ readonly)
1409
+ return;
1410
+ const isTouch = event instanceof TouchEvent;
1411
+ if (isTouch && event.cancelable)
1412
+ event.preventDefault();
1413
+ if (bodyNoSelect)
1414
+ addNoSelect();
1415
+ const { left: x1, top: y1, right: x2, bottom: y2, } = areaElementRef.current.getBoundingClientRect();
1416
+ const mouseX = isTouch ? event.touches[0].clientX : event.clientX;
1417
+ const mouseY = isTouch ? event.touches[0].clientY : event.clientY;
1418
+ const nx = normalizeValue(mouseX, x1, x2);
1419
+ const ny = normalizeValue(mouseY, y1, y2);
1420
+ const vx = rawValue(x.reverse ? 1 - nx : nx, x.min, x.max, x.skew);
1421
+ const vy = rawValue(y.reverse ? 1 - ny : ny, y.min, y.max, y.skew);
1422
+ const newX = clamp(stepValue(vx, x.step), x.min, x.max);
1423
+ const newY = clamp(stepValue(vy, y.step), y.min, y.max);
1424
+ onChange(newX, newY);
1425
+ };
1426
+ const handleKeyDown = React.useCallback((event) => {
1427
+ if (!onChange || readonly)
1428
+ return;
1429
+ const key = event.key;
1430
+ if (['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown'].includes(key)) {
1431
+ const isHorizontal = key == 'ArrowRight' || key == 'ArrowLeft';
1432
+ const target = isHorizontal ? x : y;
1433
+ if (!target.keyboard)
1434
+ return;
1435
+ event.preventDefault();
1436
+ let delta = target.keyboard[1];
1437
+ if (key == 'ArrowLeft' || key == 'ArrowUp')
1438
+ delta *= -1;
1439
+ if (target.reverse)
1440
+ delta *= -1;
1441
+ let v;
1442
+ if (target.keyboard[0] == 'normalized') {
1443
+ const n = normalizeValue(target.value, target.min, target.max, target.skew);
1444
+ v = rawValue(n + delta, target.min, target.max, target.skew);
1445
+ }
1446
+ else {
1447
+ v = target.value + delta;
1448
+ }
1449
+ const newValue = clamp(stepValue(v, target.step), target.min, target.max);
1450
+ if (isHorizontal) {
1451
+ onChange(newValue, y.value);
1452
+ }
1453
+ else {
1454
+ onChange(x.value, newValue);
1455
+ }
1456
+ }
1457
+ }, [x, y, onChange, readonly]);
1458
+ // --- hooks ---
1459
+ const touchMoveRefCallback = useRefCallbackEvent('touchmove', handleValue, { passive: false }, [x, onChange, readonly]);
1460
+ const wheelRefCallback = useRefCallbackEvent('wheel', (event) => {
1461
+ if (!onChange || readonly)
1462
+ return;
1463
+ const target = event.shiftKey ? x : y;
1464
+ if (!target.wheel)
1465
+ return;
1466
+ event.preventDefault();
1467
+ let delta = target.wheel[1];
1468
+ if (event.deltaY < 0)
1469
+ delta *= -1;
1470
+ if (target.reverse)
1471
+ delta *= -1;
1472
+ let v;
1473
+ if (target.wheel[0] == 'normalized') {
1474
+ const n = normalizeValue(target.value, target.min, target.max, target.skew);
1475
+ v = rawValue(n + delta, target.min, target.max, target.skew);
1476
+ }
1477
+ else {
1478
+ v = target.value + delta;
1479
+ }
1480
+ const newValue = clamp(stepValue(v, target.step), target.min, target.max);
1481
+ if (event.shiftKey) {
1482
+ onChange(newValue, y.value);
1483
+ }
1484
+ else {
1485
+ onChange(x.value, newValue);
1486
+ }
1487
+ }, {
1488
+ passive: false,
1489
+ }, [x, y]);
1490
+ useEventListener(window, 'mousemove', (event) => {
1491
+ handleValue(event);
1492
+ });
1493
+ useEventListener(window, 'mouseup', () => {
1494
+ thumbDragged.current = false;
1495
+ if (bodyNoSelect)
1496
+ removeNoSelect();
1497
+ });
1498
+ React.useImperativeHandle(ref, () => {
1499
+ return {
1500
+ focus() {
1501
+ var _a;
1502
+ (_a = thumbRef.current) === null || _a === void 0 ? void 0 : _a.focus();
1503
+ },
1504
+ blur() {
1505
+ var _a;
1506
+ (_a = thumbRef.current) === null || _a === void 0 ? void 0 : _a.blur();
1507
+ },
1508
+ };
1509
+ }, []);
1510
+ return (
1511
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
1512
+ jsxRuntime.jsx("div", Object.assign({ className: clsx('tremolo-xy-pad', className), ref: (div) => {
1069
1513
  wheelRefCallback(div);
1070
1514
  touchMoveRefCallback(div);
1071
- }, tabIndex: -1, role: "slider", "aria-valuenow": value, "aria-valuemin": min, "aria-valuemax": max, "aria-orientation": isHorizontal(direction) ? 'horizontal' : 'vertical', "aria-disabled": disabled, "aria-readonly": readonly, css: react.css(Object.assign({ display: 'inline-block', margin: `calc(${styleHelper((_b = thumbProps === null || thumbProps === undefined ? undefined : thumbProps.size) !== null && _b !== undefined ? _b : 22)} / 2)`, cursor: readonly ? 'not-allowed' : 'pointer', outline: 0 }, style)), onPointerDown: (event) => {
1515
+ }, tabIndex: -1, "aria-disabled": disabled, "aria-readonly": readonly, style: Object.assign({ margin: `calc(${styleHelper((_b = thumbProps === null || thumbProps === void 0 ? void 0 : thumbProps.size) !== null && _b !== void 0 ? _b : 22)} / 2)`, cursor: readonly ? 'not-allowed' : 'pointer', WebkitTapHighlightColor: 'transparent' }, style), onPointerDown: (event) => {
1072
1516
  thumbDragged.current = true;
1073
1517
  handleValue(event);
1074
- }, onKeyDown: handleKeyDown, onFocus: (_c = thumbRef.current) === null || _c === undefined ? undefined : _c.focus, onBlur: (_d = thumbRef.current) === null || _d === undefined ? undefined : _d.blur, children: [jsxRuntime.jsx(react.Global, { styles: {
1075
- '.no-select': {
1076
- userSelect: 'none',
1077
- },
1078
- } }), jsxRuntime.jsxs("div", { css: react.css({
1079
- display: 'flex',
1080
- flexDirection: isHorizontal(direction) ? 'column' : 'row',
1081
- }), children: [jsxRuntime.jsx("div", { className: "tremolo-slider-track-wrapper", ref: trackElementRef, children: jsxRuntime.jsx(SliderTrack, Object.assign({ __direction: direction, __disabled: disabled, __percent: percent, __thumb: jsxRuntime.jsx(SliderThumb, Object.assign({ ref: thumbRef, __disabled: disabled, __css: {
1082
- top: isHorizontal(direction) ? '50%' : `${percentRev}%`,
1083
- left: isHorizontal(direction) ? `${percentRev}%` : '50%',
1084
- } }, thumbProps)) }, trackProps)) }), scale && (jsxRuntime.jsx("div", { className: "tremolo-slider-scale-wrapper", css: react.css(Object.assign({ display: 'block', position: 'relative', marginLeft: isVertical(direction)
1085
- ? ((_e = scaleOption === null || scaleOption === undefined ? undefined : scaleOption.gap) !== null && _e !== undefined ? _e : `calc((22px - ${styleHelper((_f = trackProps === null || trackProps === undefined ? undefined : trackProps.thickness) !== null && _f !== undefined ? _f : 10)}) / 2)`)
1086
- : undefined, marginTop: isHorizontal(direction)
1087
- ? ((_g = scaleOption === null || scaleOption === undefined ? undefined : scaleOption.gap) !== null && _g !== undefined ? _g : `calc((22px - ${styleHelper((_h = trackProps === null || trackProps === undefined ? undefined : trackProps.thickness) !== null && _h !== undefined ? _h : 10)}) / 2)`)
1088
- : undefined }, scaleOption === null || scaleOption === undefined ? undefined : scaleOption.style)), children: scalesList.map((item, index) => {
1089
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1090
- return (jsxRuntime.jsxs("div", { css: react.css({
1091
- display: 'flex',
1092
- flexDirection: isHorizontal(direction) ? 'column' : 'row',
1093
- justifyContent: 'center',
1094
- alignItems: 'center',
1095
- position: 'absolute',
1096
- left: isHorizontal(direction) ? `${calcPercent(item.at)}%` : undefined,
1097
- top: isVertical(direction) ? `${calcPercent(item.at)}%` : undefined,
1098
- translate: isHorizontal(direction) ? '-50% 0' : '0 -50%',
1099
- zIndex: 10,
1100
- }), children: [((_b = (_a = item.type) !== null && _a !== undefined ? _a : scaleOption === null || scaleOption === undefined ? undefined : scaleOption.defaultType) !== null && _b !== undefined ? _b : 'mark-number') !=
1101
- 'number' && (jsxRuntime.jsx("div", { className: "tremolo-slider-scale-mark", css: react.css({
1102
- width: isHorizontal(direction)
1103
- ? ((_d = (_c = item.style) === null || _c === undefined ? undefined : _c.thickness) !== null && _d !== undefined ? _d : 1)
1104
- : ((_f = (_e = item.style) === null || _e === undefined ? undefined : _e.length) !== null && _f !== undefined ? _f : '0.5rem'),
1105
- height: isVertical(direction)
1106
- ? ((_h = (_g = item.style) === null || _g === undefined ? undefined : _g.thickness) !== null && _h !== undefined ? _h : 1)
1107
- : ((_k = (_j = item.style) === null || _j === undefined ? undefined : _j.length) !== null && _k !== undefined ? _k : '0.5rem'),
1108
- backgroundColor: (_o = (_m = (_l = item.style) === null || _l === undefined ? undefined : _l.markColor) !== null && _m !== undefined ? _m : scaleOption === null || scaleOption === undefined ? undefined : scaleOption.markColor) !== null && _o !== undefined ? _o : '#222',
1109
- marginBottom: isHorizontal(direction) ? 2 : undefined,
1110
- marginRight: isVertical(direction) ? 2 : undefined,
1111
- }) })), ((_q = (_p = item.type) !== null && _p !== undefined ? _p : scaleOption === null || scaleOption === undefined ? undefined : scaleOption.defaultType) !== null && _q !== undefined ? _q : 'mark-number') !=
1112
- 'mark' && (jsxRuntime.jsx("div", { className: "tremolo-slider-scale-number", css: react.css({
1113
- color: (_s = (_r = item.style) === null || _r === undefined ? undefined : _r.labelColor) !== null && _s !== undefined ? _s : scaleOption === null || scaleOption === undefined ? undefined : scaleOption.labelColor,
1114
- width: scaleOption === null || scaleOption === undefined ? undefined : scaleOption.labelWidth,
1115
- textAlign: 'right',
1116
- }), children: (_t = item.text) !== null && _t !== undefined ? _t : item.at }))] }, index));
1117
- }) }))] })] }));
1518
+ }, onKeyDown: handleKeyDown, onFocus: (_c = thumbRef.current) === null || _c === void 0 ? void 0 : _c.focus, onBlur: (_d = thumbRef.current) === null || _d === void 0 ? void 0 : _d.blur }, props, { children: jsxRuntime.jsx("div", { className: "tremolo-xy-pad-area-wrapper", ref: areaElementRef, children: jsxRuntime.jsx(XYPadArea, Object.assign({ __thumb: jsxRuntime.jsx(XYPadThumb, Object.assign({ ref: thumbRef, __disabled: disabled, __css: {
1519
+ top: `${percentY}%`,
1520
+ left: `${percentX}%`,
1521
+ } }, thumbProps)) }, areaProps)) }) })));
1118
1522
  });
1119
1523
 
1120
1524
  exports.AnimationCanvas = AnimationCanvas;
1525
+ exports.AnimationKnob = AnimationKnob;
1121
1526
  exports.BlackKey = BlackKey;
1527
+ exports.DragObserver = DragObserver;
1122
1528
  exports.KeyLabel = KeyLabel;
1123
1529
  exports.Knob = Knob;
1124
1530
  exports.NumberInput = NumberInput;
1125
1531
  exports.Piano = Piano;
1532
+ exports.Scale = Scale;
1533
+ exports.ScaleOption = ScaleOption;
1126
1534
  exports.Shortcuts = Shortcuts;
1127
1535
  exports.Slider = Slider;
1128
1536
  exports.SliderThumb = SliderThumb;
1129
1537
  exports.SliderTrack = SliderTrack;
1538
+ exports.SliderValuesProvider = SliderValuesProvider;
1539
+ exports.WheelObserver = WheelObserver;
1130
1540
  exports.WhiteKey = WhiteKey;
1131
- exports.gradientDirection = gradientDirection;
1541
+ exports.XYPad = XYPad;
1542
+ exports.XYPadArea = XYPadArea;
1543
+ exports.XYPadThumb = XYPadThumb;
1544
+ exports.defaultLength = defaultLength;
1545
+ exports.defaultThickness = defaultThickness;
1546
+ exports.defaultThumbSize = defaultThumbSize;
1547
+ exports.useDisabled = useDisabled;
1548
+ exports.useMax = useMax;
1549
+ exports.useMin = useMin;
1550
+ exports.useReverse = useReverse;
1551
+ exports.useSkew = useSkew;
1552
+ exports.useStep = useStep;
1553
+ exports.useVertical = useVertical;
1132
1554
  //# sourceMappingURL=index.js.map