@antimatter-audio/antimatter-ui 10.9.6 → 10.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.
Files changed (35) hide show
  1. package/dist/advanced/ModMatrix/ModMatrix.d.ts.map +1 -1
  2. package/dist/advanced/ModMatrix/ModMatrixRow.d.ts.map +1 -1
  3. package/dist/advanced/ModuleFooter/LFOTab.d.ts.map +1 -1
  4. package/dist/advanced/ModuleHeader/ModuleHeader.d.ts.map +1 -1
  5. package/dist/common/types.d.ts +0 -5
  6. package/dist/common/types.d.ts.map +1 -1
  7. package/dist/common/utils.d.ts +23 -13
  8. package/dist/common/utils.d.ts.map +1 -1
  9. package/dist/core/Box/Box.d.ts +1 -0
  10. package/dist/core/Box/Box.d.ts.map +1 -1
  11. package/dist/core/Dropdown/Dropdown.d.ts.map +1 -1
  12. package/dist/core/Input/Input.d.ts +7 -12
  13. package/dist/core/Input/Input.d.ts.map +1 -1
  14. package/dist/core/Slider/RotarySlider.d.ts.map +1 -1
  15. package/dist/core/Slider/utils.d.ts.map +1 -1
  16. package/dist/hooks/useSlider.d.ts +5 -0
  17. package/dist/hooks/useSlider.d.ts.map +1 -1
  18. package/dist/index.js +326 -349
  19. package/dist/index.js.map +1 -1
  20. package/dist/src/advanced/ModuleFooter/LFOTab.d.ts.map +1 -1
  21. package/dist/src/advanced/ModuleHeader/ModuleHeader.d.ts.map +1 -1
  22. package/dist/src/common/types.d.ts +0 -5
  23. package/dist/src/common/types.d.ts.map +1 -1
  24. package/dist/src/common/utils.d.ts +23 -13
  25. package/dist/src/common/utils.d.ts.map +1 -1
  26. package/dist/src/core/Dropdown/Dropdown.d.ts.map +1 -1
  27. package/dist/src/core/Input/Input.d.ts +4 -5
  28. package/dist/src/core/Input/Input.d.ts.map +1 -1
  29. package/dist/src/core/Slider/RotarySlider.d.ts.map +1 -1
  30. package/dist/src/core/Slider/utils.d.ts.map +1 -1
  31. package/dist/src/hooks/useSlider.d.ts +3 -0
  32. package/dist/src/hooks/useSlider.d.ts.map +1 -1
  33. package/dist/src/index.d.ts +2 -4
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -67,12 +67,6 @@ var Width = /*#__PURE__*/ function(Width) {
67
67
  Width["auto"] = "auto";
68
68
  return Width;
69
69
  }({});
70
- var InputErrorStates = /*#__PURE__*/ function(InputErrorStates) {
71
- InputErrorStates["exceedsMaxLength"] = "exceedsMaxLength";
72
- InputErrorStates["valueOutOfRange"] = "valueOutOfRange";
73
- InputErrorStates["invalidCharacter"] = "invalidCharacter";
74
- return InputErrorStates;
75
- }({});
76
70
  var FontSizes = /*#__PURE__*/ function(FontSizes) {
77
71
  FontSizes["xSmall"] = "xs";
78
72
  FontSizes["small"] = "sm";
@@ -170,7 +164,7 @@ function _array_like_to_array$d(arr, len) {
170
164
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
171
165
  return arr2;
172
166
  }
173
- function _array_with_holes$d(arr) {
167
+ function _array_with_holes$c(arr) {
174
168
  if (Array.isArray(arr)) return arr;
175
169
  }
176
170
  function _define_property$k(obj, key, value) {
@@ -186,7 +180,7 @@ function _define_property$k(obj, key, value) {
186
180
  }
187
181
  return obj;
188
182
  }
189
- function _iterable_to_array_limit$d(arr, i) {
183
+ function _iterable_to_array_limit$c(arr, i) {
190
184
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
191
185
  if (_i == null) return;
192
186
  var _arr = [];
@@ -210,7 +204,7 @@ function _iterable_to_array_limit$d(arr, i) {
210
204
  }
211
205
  return _arr;
212
206
  }
213
- function _non_iterable_rest$d() {
207
+ function _non_iterable_rest$c() {
214
208
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
215
209
  }
216
210
  function _object_spread$k(target) {
@@ -228,8 +222,8 @@ function _object_spread$k(target) {
228
222
  }
229
223
  return target;
230
224
  }
231
- function _sliced_to_array$d(arr, i) {
232
- return _array_with_holes$d(arr) || _iterable_to_array_limit$d(arr, i) || _unsupported_iterable_to_array$d(arr, i) || _non_iterable_rest$d();
225
+ function _sliced_to_array$c(arr, i) {
226
+ return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$d(arr, i) || _non_iterable_rest$c();
233
227
  }
234
228
  function _unsupported_iterable_to_array$d(o, minLen) {
235
229
  if (!o) return;
@@ -245,7 +239,7 @@ function Button(param) {
245
239
  ] : _param_padding, _param_margin = param.margin, margin = _param_margin === void 0 ? [
246
240
  Spacing.none
247
241
  ] : _param_margin, _param_type = param.type, type = _param_type === void 0 ? ButtonType.latch : _param_type, _param_size = param.size, size = _param_size === void 0 ? ButtonSize.large : _param_size;
248
- var _React_useState = _sliced_to_array$d(React__default.useState(false), 2), isSelected = _React_useState[0], setIsSelected = _React_useState[1];
242
+ var _React_useState = _sliced_to_array$c(React__default.useState(false), 2), isSelected = _React_useState[0], setIsSelected = _React_useState[1];
249
243
  var buttonState = Juce.getToggleState(id);
250
244
  var isLocalhost = window.location.hostname === 'localhost';
251
245
  // Update the local state when the ID changes
@@ -363,10 +357,31 @@ function useObservable(param) {
363
357
  };
364
358
  }
365
359
 
366
- var clamp = function(val) {
367
- var min = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, max = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
368
- return Math.max(min, Math.min(max, val));
369
- };
360
+ function _array_like_to_array$c(arr, len) {
361
+ if (len == null || len > arr.length) len = arr.length;
362
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
363
+ return arr2;
364
+ }
365
+ function _array_without_holes$1(arr) {
366
+ if (Array.isArray(arr)) return _array_like_to_array$c(arr);
367
+ }
368
+ function _iterable_to_array$1(iter) {
369
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
370
+ }
371
+ function _non_iterable_spread$1() {
372
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
373
+ }
374
+ function _to_consumable_array$1(arr) {
375
+ return _array_without_holes$1(arr) || _iterable_to_array$1(arr) || _unsupported_iterable_to_array$c(arr) || _non_iterable_spread$1();
376
+ }
377
+ function _unsupported_iterable_to_array$c(o, minLen) {
378
+ if (!o) return;
379
+ if (typeof o === "string") return _array_like_to_array$c(o, minLen);
380
+ var n = Object.prototype.toString.call(o).slice(8, -1);
381
+ if (n === "Object" && o.constructor) n = o.constructor.name;
382
+ if (n === "Map" || n === "Set") return Array.from(n);
383
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
384
+ }
370
385
  // export const roundUpToTwoDecimals = (val: number) => Math.ceil(val * 100) / 100;
371
386
  // mocks the `normalisedToScaledValue` internal method from JUCE
372
387
  // This will allow us to test the JS UI without needing access to the JUCE backend
@@ -381,7 +396,6 @@ function normalisedToScaled(param) {
381
396
  function scaledToNormalised(param) {
382
397
  var scaledValue = param.scaledValue, properties = param.properties;
383
398
  var start = properties.start, end = properties.end, skew = properties.skew;
384
- console.log(start, end, skew, 'start, end, skew');
385
399
  return Math.pow((scaledValue - start) / (end - start), skew);
386
400
  }
387
401
  var decimalToPercent = function(decimal) {
@@ -390,13 +404,104 @@ var decimalToPercent = function(decimal) {
390
404
  var percentToDecimal = function(percent) {
391
405
  return Math.round(0.01 * (typeof percent === 'string' ? parseFloat(percent) : percent));
392
406
  };
407
+ var inputCharacterIsValid = function(char) {
408
+ var validCharacter = /^[\d.-]$/;
409
+ return validCharacter.test(char.toString());
410
+ };
411
+ var clamp = function(val) {
412
+ var min = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, max = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
413
+ return Math.max(min, Math.min(max, val));
414
+ };
415
+ function snapToLegalValue(param) {
416
+ var value = param.value, properties = param.properties;
417
+ var interval = properties.interval, start = properties.start, end = properties.end;
418
+ if (interval == 0) return value;
419
+ var roundedInterval = parseFloat(interval === null || interval === void 0 ? void 0 : interval.toFixed(2));
420
+ var formattedValue = start + roundedInterval * Math.floor((value - start) / roundedInterval + 0.5);
421
+ return clamp(parseFloat(formattedValue.toFixed(2)), start, end);
422
+ }
423
+ // const validNumber = /^-?\.?\d+(\.\d)?$/;
424
+ // const lastNumberIsDigit = /\d$/;
425
+ var validateInputChange = function(e) {
426
+ return e.nativeEvent.data === '' || e.nativeEvent.data === null || inputCharacterIsValid(e.nativeEvent.data);
427
+ };
428
+ var getValidValueForInput = function(param) {
429
+ var value = param.value, oldValue = param.oldValue, properties = param.properties;
430
+ var _splitValueArray_;
431
+ // TODO: Clean up
432
+ var matchCriteria = /^-?(?:\d+\.\d+|\d+|\.\d+)$/g;
433
+ var splitValue = value.toString().matchAll(matchCriteria);
434
+ var splitValueArray = _to_consumable_array$1(splitValue);
435
+ var validValue = splitValueArray === null || splitValueArray === void 0 ? void 0 : (_splitValueArray_ = splitValueArray[0]) === null || _splitValueArray_ === void 0 ? void 0 : _splitValueArray_[0];
436
+ var start = properties.start, end = properties.end;
437
+ if (validValue !== null && validValue !== undefined) {
438
+ if (parseFloat(validValue) > end) {
439
+ return end;
440
+ } else if (parseFloat(validValue) < start) {
441
+ return start;
442
+ } else {
443
+ return snapToLegalValue({
444
+ value: parseFloat(validValue),
445
+ properties: properties
446
+ });
447
+ }
448
+ } else {
449
+ return oldValue;
450
+ }
451
+ };
452
+ var getBarTransformStyles = function(param) {
453
+ var polarity = param.polarity, orientation = param.orientation, normalisedValue = param.normalisedValue;
454
+ var wholeNumberNormalisedValue = normalisedValue * 100;
455
+ var linearValue = wholeNumberNormalisedValue ? parseFloat(wholeNumberNormalisedValue === null || wholeNumberNormalisedValue === void 0 ? void 0 : wholeNumberNormalisedValue.toFixed(2)) : 0;
456
+ var bipolarValue = (wholeNumberNormalisedValue - 50) / 100;
457
+ if (polarity === Polarity.linear) {
458
+ return orientation === Orientation.horizontal ? {
459
+ width: linearValue ? "100%" : '1px',
460
+ height: '100%',
461
+ transform: linearValue ? "scale(".concat(Math.ceil(linearValue) * 0.01, ", 1)") : 'none',
462
+ transformOrigin: 'center left',
463
+ top: '0',
464
+ bottom: '0',
465
+ left: '0'
466
+ } : {
467
+ width: "100%",
468
+ height: linearValue ? '100%' : '1px',
469
+ transform: "scale(1, ".concat(Math.ceil(linearValue) * 0.01, ")"),
470
+ transformOrigin: 'bottom center',
471
+ top: '0',
472
+ bottom: '0',
473
+ left: '0'
474
+ };
475
+ } else {
476
+ return orientation === Orientation.horizontal ? {
477
+ width: bipolarValue ? "100%" : '1px',
478
+ height: '100%',
479
+ transform: bipolarValue ? "scale(".concat(bipolarValue, ", 1)") : 'none',
480
+ transformOrigin: 'left center',
481
+ top: '0',
482
+ bottom: '0',
483
+ left: '50%'
484
+ } : {
485
+ width: "100%",
486
+ height: bipolarValue ? '100%' : '1px',
487
+ transform: bipolarValue ? "scale(1, ".concat(bipolarValue, ")") : 'none',
488
+ transformOrigin: 'bottom center',
489
+ bottom: '50%',
490
+ left: '0',
491
+ right: '0'
492
+ };
493
+ }
494
+ };
495
+ var randomizeValue = function(min, max) {
496
+ return Math.random() * (max - min) + min;
497
+ };
393
498
 
394
- function _array_like_to_array$c(arr, len) {
499
+ function _array_like_to_array$b(arr, len) {
395
500
  if (len == null || len > arr.length) len = arr.length;
396
501
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
397
502
  return arr2;
398
503
  }
399
- function _array_with_holes$c(arr) {
504
+ function _array_with_holes$b(arr) {
400
505
  if (Array.isArray(arr)) return arr;
401
506
  }
402
507
  function _define_property$j(obj, key, value) {
@@ -412,7 +517,7 @@ function _define_property$j(obj, key, value) {
412
517
  }
413
518
  return obj;
414
519
  }
415
- function _iterable_to_array_limit$c(arr, i) {
520
+ function _iterable_to_array_limit$b(arr, i) {
416
521
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
417
522
  if (_i == null) return;
418
523
  var _arr = [];
@@ -436,7 +541,7 @@ function _iterable_to_array_limit$c(arr, i) {
436
541
  }
437
542
  return _arr;
438
543
  }
439
- function _non_iterable_rest$c() {
544
+ function _non_iterable_rest$b() {
440
545
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
441
546
  }
442
547
  function _object_spread$j(target) {
@@ -473,16 +578,16 @@ function _object_spread_props$4(target, source) {
473
578
  }
474
579
  return target;
475
580
  }
476
- function _sliced_to_array$c(arr, i) {
477
- return _array_with_holes$c(arr) || _iterable_to_array_limit$c(arr, i) || _unsupported_iterable_to_array$c(arr, i) || _non_iterable_rest$c();
581
+ function _sliced_to_array$b(arr, i) {
582
+ return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$b(arr, i) || _non_iterable_rest$b();
478
583
  }
479
- function _unsupported_iterable_to_array$c(o, minLen) {
584
+ function _unsupported_iterable_to_array$b(o, minLen) {
480
585
  if (!o) return;
481
- if (typeof o === "string") return _array_like_to_array$c(o, minLen);
586
+ if (typeof o === "string") return _array_like_to_array$b(o, minLen);
482
587
  var n = Object.prototype.toString.call(o).slice(8, -1);
483
588
  if (n === "Object" && o.constructor) n = o.constructor.name;
484
589
  if (n === "Map" || n === "Set") return Array.from(n);
485
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$c(o, minLen);
590
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
486
591
  }
487
592
  // Initial state
488
593
  var defaultGlobalStateValue = {
@@ -567,7 +672,7 @@ function useGlobalContext(selector) {
567
672
  // Context provider
568
673
  function GlobalContextProvider(param) {
569
674
  var children = param.children;
570
- var _useReducer = _sliced_to_array$c(useReducer(reducer, defaultGlobalStateValue), 2), state = _useReducer[0], dispatch = _useReducer[1];
675
+ var _useReducer = _sliced_to_array$b(useReducer(reducer, defaultGlobalStateValue), 2), state = _useReducer[0], dispatch = _useReducer[1];
571
676
  var highlightedItemChanged = useCallback(function(highlightedItem) {
572
677
  dispatch({
573
678
  type: 'HIGHLIGHTED_ITEM_CHANGED',
@@ -675,15 +780,15 @@ function GlobalContextProvider(param) {
675
780
  }, children);
676
781
  }
677
782
 
678
- function _array_like_to_array$b(arr, len) {
783
+ function _array_like_to_array$a(arr, len) {
679
784
  if (len == null || len > arr.length) len = arr.length;
680
785
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
681
786
  return arr2;
682
787
  }
683
- function _array_with_holes$b(arr) {
788
+ function _array_with_holes$a(arr) {
684
789
  if (Array.isArray(arr)) return arr;
685
790
  }
686
- function _iterable_to_array_limit$b(arr, i) {
791
+ function _iterable_to_array_limit$a(arr, i) {
687
792
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
688
793
  if (_i == null) return;
689
794
  var _arr = [];
@@ -707,26 +812,26 @@ function _iterable_to_array_limit$b(arr, i) {
707
812
  }
708
813
  return _arr;
709
814
  }
710
- function _non_iterable_rest$b() {
815
+ function _non_iterable_rest$a() {
711
816
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
712
817
  }
713
- function _sliced_to_array$b(arr, i) {
714
- return _array_with_holes$b(arr) || _iterable_to_array_limit$b(arr, i) || _unsupported_iterable_to_array$b(arr, i) || _non_iterable_rest$b();
818
+ function _sliced_to_array$a(arr, i) {
819
+ return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$a(arr, i) || _non_iterable_rest$a();
715
820
  }
716
- function _unsupported_iterable_to_array$b(o, minLen) {
821
+ function _unsupported_iterable_to_array$a(o, minLen) {
717
822
  if (!o) return;
718
- if (typeof o === "string") return _array_like_to_array$b(o, minLen);
823
+ if (typeof o === "string") return _array_like_to_array$a(o, minLen);
719
824
  var n = Object.prototype.toString.call(o).slice(8, -1);
720
825
  if (n === "Object" && o.constructor) n = o.constructor.name;
721
826
  if (n === "Map" || n === "Set") return Array.from(n);
722
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$b(o, minLen);
827
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
723
828
  }
724
829
  var useDropdown = function(param) {
725
830
  var id = param.id, label = param.label, _param_items = param.items, items = _param_items === void 0 ? [] : _param_items, filter = param.filter, onChange = param.onChange, _param_displayValInHeader = param.displayValInHeader, displayValInHeader = _param_displayValInHeader === void 0 ? true : _param_displayValInHeader;
726
831
  var _properties_choices;
727
832
  var comboBoxState = Juce.getComboBoxState(id);
728
- var _useState = _sliced_to_array$b(useState(comboBoxState.getChoiceIndex()), 2), index = _useState[0], setIndex = _useState[1];
729
- var _useState1 = _sliced_to_array$b(useState(comboBoxState.properties), 2), properties = _useState1[0], setProperties = _useState1[1];
833
+ var _useState = _sliced_to_array$a(useState(comboBoxState.getChoiceIndex()), 2), index = _useState[0], setIndex = _useState[1];
834
+ var _useState1 = _sliced_to_array$a(useState(comboBoxState.properties), 2), properties = _useState1[0], setProperties = _useState1[1];
730
835
  var setHighlightedItem = useGlobalContext().setHighlightedItem;
731
836
  var choices = items.length ? items : (properties === null || properties === void 0 ? void 0 : (_properties_choices = properties.choices) === null || _properties_choices === void 0 ? void 0 : _properties_choices.length) ? properties === null || properties === void 0 ? void 0 : properties.choices : [];
732
837
  var filteredChoices = filter ? choices === null || choices === void 0 ? void 0 : choices.filter(function(item) {
@@ -1051,7 +1156,9 @@ function Dropdown(param) {
1051
1156
  }), value = _useDropdown.value, choices = _useDropdown.choices, onMouseEnter = _useDropdown.onMouseEnter, handleChange = _useDropdown.handleChange;
1052
1157
  return /*#__PURE__*/ React__default.createElement(Box, {
1053
1158
  flexDirection: Box.flexDirection.column,
1054
- onMouseEnter: onMouseEnter
1159
+ onMouseEnter: onMouseEnter,
1160
+ width: "100%",
1161
+ flex: "0 1 auto"
1055
1162
  }, /*#__PURE__*/ React__default.createElement(Listbox, {
1056
1163
  value: value,
1057
1164
  onChange: handleChange
@@ -1082,6 +1189,9 @@ function Dropdown(param) {
1082
1189
  }, item);
1083
1190
  }))), /*#__PURE__*/ React__default.createElement(Label, {
1084
1191
  padding: [
1192
+ Label.padding.mediumSmall,
1193
+ Label.padding.mediumSmall,
1194
+ Label.padding.none,
1085
1195
  Label.padding.mediumSmall
1086
1196
  ],
1087
1197
  fontSize: Label.fontSize.xSmall,
@@ -1092,90 +1202,15 @@ function Dropdown(param) {
1092
1202
  }));
1093
1203
  }
1094
1204
 
1095
- var validate = function(param) {
1096
- var value = param.value, minLength = param.minLength, maxLength = param.maxLength, min = param.min, max = param.max, _param_type = param.type, type = _param_type === void 0 ? InputTypes.text : _param_type;
1097
- // TODO: Clean up
1098
- var errorMessages = [];
1099
- var isIncomplete = false;
1100
- var length = value.toString().length;
1101
- if (length > maxLength && (errorMessages === null || errorMessages === void 0 ? void 0 : errorMessages.indexOf(InputErrorStates === null || InputErrorStates === void 0 ? void 0 : InputErrorStates.exceedsMaxLength)) === -1) {
1102
- errorMessages === null || errorMessages === void 0 ? void 0 : errorMessages.push(InputErrorStates === null || InputErrorStates === void 0 ? void 0 : InputErrorStates.exceedsMaxLength);
1103
- }
1104
- if (length < minLength) {
1105
- isIncomplete = true;
1106
- }
1107
- if (type === InputTypes.number) {
1108
- if (!(value === '' || /^-?[\d-.]+$/.test(value.toString()))) {
1109
- errorMessages.push(InputErrorStates.invalidCharacter);
1110
- }
1111
- if (typeof value === 'number') {
1112
- if ((value > max || value < min) && (errorMessages === null || errorMessages === void 0 ? void 0 : errorMessages.indexOf(InputErrorStates.valueOutOfRange)) === -1) {
1113
- errorMessages === null || errorMessages === void 0 ? void 0 : errorMessages.push(InputErrorStates.valueOutOfRange);
1114
- }
1115
- }
1116
- }
1117
- return {
1118
- errorMessages: errorMessages,
1119
- isIncomplete: isIncomplete,
1120
- isValid: !errorMessages.length && !isIncomplete
1121
- };
1122
- };
1123
- var getBarTransformStyles = function(param) {
1124
- var polarity = param.polarity, orientation = param.orientation, normalisedValue = param.normalisedValue;
1125
- var wholeNumberNormalisedValue = normalisedValue * 100;
1126
- var linearValue = wholeNumberNormalisedValue ? parseFloat(wholeNumberNormalisedValue === null || wholeNumberNormalisedValue === void 0 ? void 0 : wholeNumberNormalisedValue.toFixed(2)) : 0;
1127
- var bipolarValue = (wholeNumberNormalisedValue - 50) / 100;
1128
- if (polarity === Polarity.linear) {
1129
- return orientation === Orientation.horizontal ? {
1130
- width: linearValue ? "100%" : '1px',
1131
- height: '100%',
1132
- transform: linearValue ? "scale(".concat(Math.ceil(linearValue) * 0.01, ", 1)") : 'none',
1133
- transformOrigin: 'center left',
1134
- top: '0',
1135
- bottom: '0',
1136
- left: '0'
1137
- } : {
1138
- width: "100%",
1139
- height: linearValue ? '100%' : '1px',
1140
- transform: "scale(1, ".concat(Math.ceil(linearValue) * 0.01, ")"),
1141
- transformOrigin: 'bottom center',
1142
- top: '0',
1143
- bottom: '0',
1144
- left: '0'
1145
- };
1146
- } else {
1147
- return orientation === Orientation.horizontal ? {
1148
- width: bipolarValue ? "100%" : '1px',
1149
- height: '100%',
1150
- transform: bipolarValue ? "scale(".concat(bipolarValue, ", 1)") : 'none',
1151
- transformOrigin: 'left center',
1152
- top: '0',
1153
- bottom: '0',
1154
- left: '50%'
1155
- } : {
1156
- width: "100%",
1157
- height: bipolarValue ? '100%' : '1px',
1158
- transform: bipolarValue ? "scale(1, ".concat(bipolarValue, ")") : 'none',
1159
- transformOrigin: 'bottom center',
1160
- bottom: '50%',
1161
- left: '0',
1162
- right: '0'
1163
- };
1164
- }
1165
- };
1166
- var randomizeValue = function(min, max) {
1167
- return Math.random() * (max - min) + min;
1168
- };
1169
-
1170
- var css_248z$7 = ".TextInput {\n user-select: none;\n -webkit-user-select: none;\n}\n\n.TextInput::-moz-selection {\n background: transparent;\n}\n.TextInput::selection {\n background: transparent;\n}\n";
1205
+ var css_248z$7 = ".TextInput {\n pointer-events: auto;\n /* font-size: var(--text-xs); */\n}\n\n.TextInput::-moz-selection {\n background: transparent;\n}\n.TextInput::selection {\n background: transparent;\n}\n\n.TextInput.is-highlighted {\n background: var(--color-gray-600);\n border: 1px solid var(--color-gray-500);\n}\n";
1171
1206
  styleInject(css_248z$7);
1172
1207
 
1173
- function _array_like_to_array$a(arr, len) {
1208
+ function _array_like_to_array$9(arr, len) {
1174
1209
  if (len == null || len > arr.length) len = arr.length;
1175
1210
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1176
1211
  return arr2;
1177
1212
  }
1178
- function _array_with_holes$a(arr) {
1213
+ function _array_with_holes$9(arr) {
1179
1214
  if (Array.isArray(arr)) return arr;
1180
1215
  }
1181
1216
  function _define_property$f(obj, key, value) {
@@ -1191,7 +1226,7 @@ function _define_property$f(obj, key, value) {
1191
1226
  }
1192
1227
  return obj;
1193
1228
  }
1194
- function _iterable_to_array_limit$a(arr, i) {
1229
+ function _iterable_to_array_limit$9(arr, i) {
1195
1230
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1196
1231
  if (_i == null) return;
1197
1232
  var _arr = [];
@@ -1215,7 +1250,7 @@ function _iterable_to_array_limit$a(arr, i) {
1215
1250
  }
1216
1251
  return _arr;
1217
1252
  }
1218
- function _non_iterable_rest$a() {
1253
+ function _non_iterable_rest$9() {
1219
1254
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1220
1255
  }
1221
1256
  function _object_spread$f(target) {
@@ -1233,16 +1268,16 @@ function _object_spread$f(target) {
1233
1268
  }
1234
1269
  return target;
1235
1270
  }
1236
- function _sliced_to_array$a(arr, i) {
1237
- return _array_with_holes$a(arr) || _iterable_to_array_limit$a(arr, i) || _unsupported_iterable_to_array$a(arr, i) || _non_iterable_rest$a();
1271
+ function _sliced_to_array$9(arr, i) {
1272
+ return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$9(arr, i) || _non_iterable_rest$9();
1238
1273
  }
1239
- function _unsupported_iterable_to_array$a(o, minLen) {
1274
+ function _unsupported_iterable_to_array$9(o, minLen) {
1240
1275
  if (!o) return;
1241
- if (typeof o === "string") return _array_like_to_array$a(o, minLen);
1276
+ if (typeof o === "string") return _array_like_to_array$9(o, minLen);
1242
1277
  var n = Object.prototype.toString.call(o).slice(8, -1);
1243
1278
  if (n === "Object" && o.constructor) n = o.constructor.name;
1244
1279
  if (n === "Map" || n === "Set") return Array.from(n);
1245
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$a(o, minLen);
1280
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
1246
1281
  }
1247
1282
  // import { decimalToPercent, percentToDecimal } from '../../common/utils';
1248
1283
  // import debounce from 'lodash.debounce';
@@ -1252,62 +1287,85 @@ var InputTypes = /*#__PURE__*/ function(InputTypes) {
1252
1287
  return InputTypes;
1253
1288
  }({});
1254
1289
  function Input(param) {
1255
- var onComplete = param.onComplete, value = param.value, min = param.min, max = param.max, _param_type = param.type, type = _param_type === void 0 ? "text" : _param_type, _param_minLength = param.minLength, minLength = _param_minLength === void 0 ? 1 : _param_minLength, _param_maxLength = param.maxLength, maxLength = _param_maxLength === void 0 ? 20 : _param_maxLength, fontSize = param.fontSize, style = param.style, className = param.className, id = param.id, _param_textColor = param.textColor, textColor = _param_textColor === void 0 ? '#999' : _param_textColor;
1290
+ var onComplete = param.onComplete, value = param.value; param.min; param.max; var _param_fontSize = param.fontSize, fontSize = _param_fontSize === void 0 ? FontSizes.xSmall : _param_fontSize, style = param.style, className = param.className, id = param.id, _param_textColor = param.textColor, textColor = _param_textColor === void 0 ? 'var(--color-text)' : _param_textColor;
1256
1291
  var _inputRef_current;
1257
- var _useState = _sliced_to_array$a(useState(value), 2), internalValue = _useState[0], setInternalValue = _useState[1];
1258
- var _useState1 = _sliced_to_array$a(useState(false), 2), hasError = _useState1[0], setHasError = _useState1[1];
1259
- var _useState2 = _sliced_to_array$a(useState(false), 2), hasIncompleteValue = _useState2[0], setHasIncompleteValue = _useState2[1];
1292
+ var _useState = _sliced_to_array$9(useState(value), 2), internalValue = _useState[0], setInternalValue = _useState[1];
1293
+ // const [hasError, setHasError] = useState<boolean>(false);
1294
+ var _useState1 = _sliced_to_array$9(useState(false), 2), isHighlighted = _useState1[0], setIsHighlighted = _useState1[1];
1260
1295
  var valueRef = useRef(null);
1261
- var timer, timeoutVal = 2000;
1296
+ var isLocalhost = window.location.hostname === 'localhost';
1297
+ // Sets up listeners to handle changes on the backend
1298
+ useEffect(function() {
1299
+ var sliderState = Juce.getSliderState(id);
1300
+ var legalVal = snapToLegalValue({
1301
+ value: sliderState === null || sliderState === void 0 ? void 0 : sliderState.scaledValue,
1302
+ properties: sliderState.properties
1303
+ });
1304
+ setInternalValue(legalVal);
1305
+ valueRef.current = legalVal;
1306
+ }, [
1307
+ id
1308
+ ]);
1309
+ useEffect(function() {
1310
+ if (!isLocalhost) {
1311
+ var sliderState = Juce.getSliderState(id);
1312
+ var valueListenerId = sliderState === null || sliderState === void 0 ? void 0 : sliderState.valueChangedEvent.addListener(function(e) {
1313
+ var legalVal = snapToLegalValue({
1314
+ value: sliderState === null || sliderState === void 0 ? void 0 : sliderState.scaledValue,
1315
+ properties: sliderState.properties
1316
+ });
1317
+ valueRef.current = legalVal;
1318
+ setInternalValue(legalVal);
1319
+ });
1320
+ return function() {
1321
+ sliderState === null || sliderState === void 0 ? void 0 : sliderState.valueChangedEvent.removeListener(valueListenerId);
1322
+ };
1323
+ }
1324
+ return;
1325
+ }, [
1326
+ window
1327
+ ]);
1262
1328
  // (inputValue === '' || /^-?\d+$/.test(inputValue)
1263
- function handleKeyPress(e) {
1264
- window.clearTimeout(timer);
1265
- var key = e.keyCode || e.which;
1266
- if (key === 13 || key === 9) {
1267
- var newValue = e.target.value;
1268
- var _validate = validate({
1329
+ function clickListener(event) {
1330
+ if (event.target.id === id) {
1331
+ var _document_getElementById;
1332
+ (_document_getElementById = document.getElementById(id)) === null || _document_getElementById === void 0 ? void 0 : _document_getElementById.focus();
1333
+ setIsHighlighted(true);
1334
+ } else {
1335
+ var _document_getElementById1;
1336
+ setIsHighlighted(false);
1337
+ (_document_getElementById1 = document.getElementById(id)) === null || _document_getElementById1 === void 0 ? void 0 : _document_getElementById1.blur();
1338
+ }
1339
+ }
1340
+ function handleSubmit(e) {
1341
+ var newValue = e.target.value;
1342
+ var _Juce_getSliderState = Juce.getSliderState(id), scaledValue = _Juce_getSliderState.scaledValue, properties = _Juce_getSliderState.properties;
1343
+ if ((valueRef === null || valueRef === void 0 ? void 0 : valueRef.current) !== newValue && e.target.id === id) {
1344
+ var validValue = getValidValueForInput({
1269
1345
  value: newValue,
1270
- type: type,
1271
- minLength: minLength,
1272
- maxLength: maxLength,
1273
- min: min,
1274
- max: max
1275
- }), errorMessages = _validate.errorMessages, isIncomplete = _validate.isIncomplete;
1276
- if (errorMessages.length === 0 && !isIncomplete) {
1277
- setHasIncompleteValue(false);
1278
- setHasError(false);
1346
+ oldValue: scaledValue,
1347
+ properties: properties
1348
+ });
1349
+ valueRef.current = validValue;
1350
+ onComplete(validValue);
1351
+ if (validValue === valueRef.current) {
1352
+ setInternalValue(validValue);
1279
1353
  }
1280
1354
  }
1281
1355
  }
1356
+ useEffect(function() {
1357
+ document.addEventListener('click', clickListener);
1358
+ return function() {
1359
+ document.removeEventListener('click', clickListener);
1360
+ };
1361
+ }, [
1362
+ window,
1363
+ isHighlighted
1364
+ ]);
1282
1365
  function handleKeyUp(e) {
1283
- window.clearTimeout(timer); // prevent errant multiple timeouts from being generated
1284
- timer = window.setTimeout(function() {
1285
- var newValue = e.target.value;
1286
- if ((valueRef === null || valueRef === void 0 ? void 0 : valueRef.current) !== newValue) {
1287
- var _validate = validate({
1288
- value: newValue,
1289
- type: type,
1290
- minLength: minLength,
1291
- maxLength: maxLength,
1292
- min: min,
1293
- max: max
1294
- }), errorMessages = _validate.errorMessages, isIncomplete = _validate.isIncomplete;
1295
- if (errorMessages.length && !isIncomplete) {
1296
- setHasError(true);
1297
- setHasIncompleteValue(false);
1298
- }
1299
- if (isIncomplete) {
1300
- setHasIncompleteValue(true);
1301
- }
1302
- if (errorMessages.length === 0 && !isIncomplete) {
1303
- setHasIncompleteValue(false);
1304
- setHasError(false);
1305
- onComplete && onComplete(newValue);
1306
- }
1307
- onComplete && onComplete(newValue);
1308
- valueRef.current = newValue;
1309
- }
1310
- }, timeoutVal);
1366
+ if (e.key === 'Enter') {
1367
+ handleSubmit(e);
1368
+ }
1311
1369
  }
1312
1370
  var inputRef = useRef('');
1313
1371
  // detects when the user is actively typing
@@ -1315,70 +1373,34 @@ function Input(param) {
1315
1373
  // triggers a check to see if the user is actually done typing
1316
1374
  inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.addEventListener('keyup', handleKeyUp));
1317
1375
  var handleChange = useCallback(function(e) {
1318
- var newValue = e.target.value;
1319
- setHasError(false);
1320
- var _validate = validate({
1321
- value: newValue,
1322
- type: type,
1323
- minLength: minLength,
1324
- maxLength: maxLength,
1325
- min: min,
1326
- max: max
1327
- }), errorMessages = _validate.errorMessages, isValid = _validate.isValid;
1328
- if (isValid) {
1329
- setHasError(false);
1330
- setHasIncompleteValue(false);
1331
- }
1332
1376
  // Don't set the internal value if the value exceeds the max length
1333
1377
  // Don't set the internal value if the value contains an invalid character
1334
- if ((errorMessages === null || errorMessages === void 0 ? void 0 : errorMessages.indexOf(InputErrorStates === null || InputErrorStates === void 0 ? void 0 : InputErrorStates.exceedsMaxLength)) === -1 && (errorMessages === null || errorMessages === void 0 ? void 0 : errorMessages.indexOf(InputErrorStates === null || InputErrorStates === void 0 ? void 0 : InputErrorStates.invalidCharacter)) === -1) {
1335
- setInternalValue(newValue);
1378
+ if (validateInputChange(e)) {
1379
+ setInternalValue(e.target.value);
1336
1380
  }
1337
1381
  }, [
1338
- setHasError,
1339
- validate,
1382
+ getValidValueForInput,
1340
1383
  setInternalValue
1341
1384
  ]);
1342
- useEffect(function() {
1343
- setInternalValue(value);
1344
- var isValid = validate({
1345
- value: value,
1346
- type: type,
1347
- minLength: minLength,
1348
- maxLength: maxLength,
1349
- min: min,
1350
- max: max
1351
- }).isValid;
1352
- if (isValid) {
1353
- setHasError(false);
1354
- setHasIncompleteValue(false);
1355
- }
1356
- }, [
1357
- value
1358
- ]);
1385
+ // useEffect(() => {
1386
+ // setInternalValue(value);
1387
+ // }, [value]);
1359
1388
  return /*#__PURE__*/ React__default.createElement("input", {
1360
1389
  id: id,
1361
1390
  ref: inputRef,
1362
- className: classnames('TextInput', hasIncompleteValue || hasError ? 'is-blinking' : '', className),
1391
+ className: classnames('TextInput', isHighlighted ? 'is-highlighted' : '', className),
1363
1392
  style: _object_spread$f({
1364
- // TODO
1365
- // color: hasError ? 'red' : hasIncompleteValue ? '#999' : textColor
1366
- color: hasError ? 'red' : textColor,
1367
- fontSize: fontSize
1393
+ fontSize: "var(--text-".concat(fontSize),
1394
+ color: textColor
1368
1395
  }, style),
1369
1396
  value: internalValue,
1370
1397
  onKeyUp: function() {
1371
1398
  return handleKeyUp;
1372
1399
  },
1373
- onKeyDown: function() {
1374
- return handleKeyPress;
1375
- },
1376
- onBlur: function() {
1377
- return setInternalValue(internalValue);
1378
- },
1379
- onFocus: function(e) {
1380
- return e.target.select();
1400
+ onBlur: function(e) {
1401
+ return handleSubmit(e);
1381
1402
  },
1403
+ // onFocus={(e) => e.target.select()}
1382
1404
  onChange: function(e) {
1383
1405
  return handleChange(e);
1384
1406
  }
@@ -1393,15 +1415,15 @@ var SliderType = /*#__PURE__*/ function(SliderType) {
1393
1415
  return SliderType;
1394
1416
  }({});
1395
1417
 
1396
- function _array_like_to_array$9(arr, len) {
1418
+ function _array_like_to_array$8(arr, len) {
1397
1419
  if (len == null || len > arr.length) len = arr.length;
1398
1420
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1399
1421
  return arr2;
1400
1422
  }
1401
- function _array_with_holes$9(arr) {
1423
+ function _array_with_holes$8(arr) {
1402
1424
  if (Array.isArray(arr)) return arr;
1403
1425
  }
1404
- function _iterable_to_array_limit$9(arr, i) {
1426
+ function _iterable_to_array_limit$8(arr, i) {
1405
1427
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1406
1428
  if (_i == null) return;
1407
1429
  var _arr = [];
@@ -1425,19 +1447,19 @@ function _iterable_to_array_limit$9(arr, i) {
1425
1447
  }
1426
1448
  return _arr;
1427
1449
  }
1428
- function _non_iterable_rest$9() {
1450
+ function _non_iterable_rest$8() {
1429
1451
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1430
1452
  }
1431
- function _sliced_to_array$9(arr, i) {
1432
- return _array_with_holes$9(arr) || _iterable_to_array_limit$9(arr, i) || _unsupported_iterable_to_array$9(arr, i) || _non_iterable_rest$9();
1453
+ function _sliced_to_array$8(arr, i) {
1454
+ return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$8(arr, i) || _non_iterable_rest$8();
1433
1455
  }
1434
- function _unsupported_iterable_to_array$9(o, minLen) {
1456
+ function _unsupported_iterable_to_array$8(o, minLen) {
1435
1457
  if (!o) return;
1436
- if (typeof o === "string") return _array_like_to_array$9(o, minLen);
1458
+ if (typeof o === "string") return _array_like_to_array$8(o, minLen);
1437
1459
  var n = Object.prototype.toString.call(o).slice(8, -1);
1438
1460
  if (n === "Object" && o.constructor) n = o.constructor.name;
1439
1461
  if (n === "Map" || n === "Set") return Array.from(n);
1440
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$9(o, minLen);
1462
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
1441
1463
  }
1442
1464
  // 20.0f, 15000.0f, 0.1f, 0.7f),800.0f
1443
1465
  // ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue, ValueType skewFactor, bool useSymmetricSkew=false)
@@ -1448,6 +1470,28 @@ var useSlider = function(param) {
1448
1470
  interval: 0.1,
1449
1471
  skew: 0.7
1450
1472
  } : _param_mockProperties, _param_isRandomizable = param.isRandomizable, isRandomizable = _param_isRandomizable === void 0 ? false : _param_isRandomizable, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? Orientation.vertical : _param_orientation, _param_dragOrientation = param.dragOrientation, dragOrientation = _param_dragOrientation === void 0 ? Orientation.vertical : _param_dragOrientation, _param_mockInitialNormalisedValue = param.mockInitialNormalisedValue, mockInitialNormalisedValue = _param_mockInitialNormalisedValue === void 0 ? 0.0 : _param_mockInitialNormalisedValue, onChange = param.onChange;
1473
+ var clickListener = function clickListener(event) {
1474
+ var _event_target_closest;
1475
+ if (((_event_target_closest = event.target.closest('.Slider')) === null || _event_target_closest === void 0 ? void 0 : _event_target_closest.id) === id) {
1476
+ setIsActive(true);
1477
+ event.stopPropagation();
1478
+ } else {
1479
+ setIsActive(false);
1480
+ event.stopPropagation();
1481
+ }
1482
+ };
1483
+ var keyDownListener = function keyDownListener(event) {
1484
+ if (isActive) {
1485
+ if (event.key === 'ArrowLeft') {
1486
+ event.preventDefault();
1487
+ decrementValue();
1488
+ }
1489
+ if (event.key === 'ArrowRight') {
1490
+ event.preventDefault();
1491
+ incrementValue();
1492
+ }
1493
+ }
1494
+ };
1451
1495
  // const sliderState: JuceSlider = Juce.getSliderState(id);
1452
1496
  // if isLocalhost is true, the front end app is running outside of JUCE in a browser.
1453
1497
  var isLocalhost = window.location.hostname === 'localhost';
@@ -1460,13 +1504,25 @@ var useSlider = function(param) {
1460
1504
  * AudioProcessorParameter::getValue() (C++).
1461
1505
  */ // See https://github.com/juce-framework/JUCE/blob/51d11a2be6d5c97ccf12b4e5e827006e19f0555a/modules/juce_gui_extra/native/javascript/index.js#L230C1-L238C6
1462
1506
  // NOTE: We can think of this as a percentage value, in 0 to 1 format
1463
- var _useState = _sliced_to_array$9(useState(0), 2), scaledValue = _useState[0], setScaledValue = _useState[1];
1507
+ var _useState = _sliced_to_array$8(useState(0), 2), scaledValue = _useState[0], setScaledValue = _useState[1];
1464
1508
  // const [normalisedValue, setNormalisedValue] = useState(0);
1465
- var _useState1 = _sliced_to_array$9(useState(), 2), properties = _useState1[0], setProperties = _useState1[1];
1509
+ var _useState1 = _sliced_to_array$8(useState(), 2), properties = _useState1[0], setProperties = _useState1[1];
1466
1510
  var scaledValueRef = useRef(null);
1467
1511
  var normalisedValueRef = useRef(null);
1468
1512
  // const randomValueSetCounter = useRef<number>(null);
1469
1513
  var _useGlobalContext = useGlobalContext(), useRandom = _useGlobalContext.useRandom, highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setDefaultParameter = _useGlobalContext.setDefaultParameter;
1514
+ var _useState2 = _sliced_to_array$8(useState(false), 2), isActive = _useState2[0], setIsActive = _useState2[1];
1515
+ useEffect(function() {
1516
+ document.addEventListener('click', clickListener);
1517
+ document.addEventListener('keydown', keyDownListener);
1518
+ return function() {
1519
+ document.removeEventListener('click', clickListener);
1520
+ document.removeEventListener('keydown', keyDownListener);
1521
+ };
1522
+ }, [
1523
+ window,
1524
+ isActive
1525
+ ]);
1470
1526
  // Set the initial state
1471
1527
  //@ts-expect-error
1472
1528
  useEffect(function() {
@@ -1602,8 +1658,6 @@ var useSlider = function(param) {
1602
1658
  i: "".concat(0)
1603
1659
  });
1604
1660
  }
1605
- }, {
1606
- preventDefault: true
1607
1661
  });
1608
1662
  var bindBarSliderDrag = function() {
1609
1663
  var drag = useDrag(function(param) {
@@ -1680,8 +1734,10 @@ var useSlider = function(param) {
1680
1734
  setToDefaultState: setToDefaultState,
1681
1735
  incrementValue: incrementValue,
1682
1736
  decrementValue: decrementValue,
1737
+ isActive: isActive,
1683
1738
  // onChangeStarted,
1684
1739
  // onChangeCommitted,
1740
+ scaledToNormalised: scaledToNormalised,
1685
1741
  onMouseEnter: onMouseEnter,
1686
1742
  bindBarSliderDrag: bindBarSliderDrag,
1687
1743
  bindDrag: bindDrag,
@@ -1691,17 +1747,9 @@ var useSlider = function(param) {
1691
1747
  };
1692
1748
  };
1693
1749
 
1694
- var css_248z$6 = ".RotarySlider {\n position: relative;\n /* border-radius: 50%; */\n aspect-ratio: 1 / 1;\n border: 1px solid transparent;\n}\n\n.RotarySlider-Inner {\n height: 100%;\n width: 100%;\n right: 0;\n top: 0;\n bottom: 0;\n left: 0;\n background-color: var(--bg-popover);\n border-radius: 50%;\n}\n\n.RotarySlider-Indicator {\n position: absolute;\n top: 0;\n right: 0;\n left: 50%;\n width: var(--spacing-xs);\n height: 50%;\n transform: translate(-50%, 0) rotate(0) skewX(0) skewY(0) scaleX(1) scaleY(1);\n}\n\n.RotarySlider-center-marker {\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 0 5px 8px 5px;\n transform: rotate(180deg);\n padding-bottom: var(--spacing-sm);\n}\n\n.ProgressCircle-wrapper {\n position: relative;\n}\n.ProgressCircle {\n fill: none;\n}\n\n.ProgressCircle-value {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n width: 100%;\n text-align: center;\n}\n\n.ProgressCircle-bg {\n stroke-width: 3px;\n transform-origin: center;\n transform: rotate(135deg);\n stroke-linecap: round;\n font-size: var(--text-sm);\n}\n.ProgressCircle-fg {\n stroke-width: 3px;\n /* stroke-dasharray: 75; */\n /* stroke-dashoffset: calc(880 - (660 * 0) / 100); */\n transform-origin: center;\n stroke-linecap: round;\n}\n\n.corner-border {\n --b: 1px; /* thickness of the border */\n --c: var(--color-gray-500); /* color of the border */\n --w: 5px; /* width of border */\n\n border: var(--b) solid #0000; /* space for the border */\n --_g: #0000 90deg, var(--c) 0;\n --_p: var(--w) var(--w) border-box no-repeat;\n background:\n conic-gradient(from 90deg at top var(--b) left var(--b), var(--_g)) 0 0 /\n var(--_p),\n conic-gradient(from 180deg at top var(--b) right var(--b), var(--_g)) 100% 0 /\n var(--_p),\n conic-gradient(from 0deg at bottom var(--b) left var(--b), var(--_g)) 0 100% /\n var(--_p),\n conic-gradient(from -90deg at bottom var(--b) right var(--b), var(--_g))\n 100% 100% / var(--_p);\n}\n";
1750
+ var css_248z$6 = ".RotarySlider {\n /* position: relative; */\n /* border-radius: 50%; */\n display: flex;\n flex-direction: column;\n justify-content: center;\n aspect-ratio: 1 / 1;\n border: 1px solid transparent;\n}\n\n.RotarySlider-Inner {\n height: 100%;\n width: 100%;\n right: 0;\n top: 0;\n bottom: 0;\n left: 0;\n background-color: var(--bg-popover);\n border-radius: 50%;\n}\n\n.RotarySlider-Indicator {\n position: absolute;\n top: 0;\n right: 0;\n left: 50%;\n width: var(--spacing-xs);\n height: 50%;\n transform: translate(-50%, 0) rotate(0) skewX(0) skewY(0) scaleX(1) scaleY(1);\n}\n\n.RotarySlider-center-marker {\n width: 0;\n height: 0;\n border-style: solid;\n border-width: 0 5px 8px 5px;\n transform: rotate(180deg);\n padding-bottom: var(--spacing-sm);\n}\n\n.ProgressCircle-wrapper {\n position: relative;\n}\n.ProgressCircle {\n fill: none;\n pointer-events: none;\n}\n\n.ProgressCircle-value {\n text-align: center;\n margin-top: -3px;\n height: 0.8rem;\n line-height: 0.8rem;\n}\n\n.ProgressCircle-bg {\n stroke-width: 3px;\n transform-origin: center;\n transform: rotate(135deg);\n stroke-linecap: round;\n font-size: var(--text-sm);\n pointer-events: none;\n}\n.ProgressCircle-fg {\n stroke-width: 3px;\n /* stroke-dasharray: 75; */\n /* stroke-dashoffset: calc(880 - (660 * 0) / 100); */\n transform-origin: center;\n stroke-linecap: round;\n pointer-events: none;\n}\n\n.corner-border {\n --b: 1px; /* thickness of the border */\n --c: var(--color-gray-500); /* color of the border */\n --w: 5px; /* width of border */\n\n border: var(--b) solid #0000; /* space for the border */\n --_g: #0000 90deg, var(--c) 0;\n --_p: var(--w) var(--w) border-box no-repeat;\n background:\n conic-gradient(from 90deg at top var(--b) left var(--b), var(--_g)) 0 0 /\n var(--_p),\n conic-gradient(from 180deg at top var(--b) right var(--b), var(--_g)) 100% 0 /\n var(--_p),\n conic-gradient(from 0deg at bottom var(--b) left var(--b), var(--_g)) 0 100% /\n var(--_p),\n conic-gradient(from -90deg at bottom var(--b) right var(--b), var(--_g))\n 100% 100% / var(--_p);\n}\n";
1695
1751
  styleInject(css_248z$6);
1696
1752
 
1697
- function _array_like_to_array$8(arr, len) {
1698
- if (len == null || len > arr.length) len = arr.length;
1699
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1700
- return arr2;
1701
- }
1702
- function _array_with_holes$8(arr) {
1703
- if (Array.isArray(arr)) return arr;
1704
- }
1705
1753
  function _define_property$e(obj, key, value) {
1706
1754
  if (key in obj) {
1707
1755
  Object.defineProperty(obj, key, {
@@ -1715,33 +1763,6 @@ function _define_property$e(obj, key, value) {
1715
1763
  }
1716
1764
  return obj;
1717
1765
  }
1718
- function _iterable_to_array_limit$8(arr, i) {
1719
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
1720
- if (_i == null) return;
1721
- var _arr = [];
1722
- var _n = true;
1723
- var _d = false;
1724
- var _s, _e;
1725
- try {
1726
- for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
1727
- _arr.push(_s.value);
1728
- if (i && _arr.length === i) break;
1729
- }
1730
- } catch (err) {
1731
- _d = true;
1732
- _e = err;
1733
- } finally{
1734
- try {
1735
- if (!_n && _i["return"] != null) _i["return"]();
1736
- } finally{
1737
- if (_d) throw _e;
1738
- }
1739
- }
1740
- return _arr;
1741
- }
1742
- function _non_iterable_rest$8() {
1743
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1744
- }
1745
1766
  function _object_spread$e(target) {
1746
1767
  for(var i = 1; i < arguments.length; i++){
1747
1768
  var source = arguments[i] != null ? arguments[i] : {};
@@ -1776,17 +1797,6 @@ function _object_spread_props$2(target, source) {
1776
1797
  }
1777
1798
  return target;
1778
1799
  }
1779
- function _sliced_to_array$8(arr, i) {
1780
- return _array_with_holes$8(arr) || _iterable_to_array_limit$8(arr, i) || _unsupported_iterable_to_array$8(arr, i) || _non_iterable_rest$8();
1781
- }
1782
- function _unsupported_iterable_to_array$8(o, minLen) {
1783
- if (!o) return;
1784
- if (typeof o === "string") return _array_like_to_array$8(o, minLen);
1785
- var n = Object.prototype.toString.call(o).slice(8, -1);
1786
- if (n === "Object" && o.constructor) n = o.constructor.name;
1787
- if (n === "Map" || n === "Set") return Array.from(n);
1788
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$8(o, minLen);
1789
- }
1790
1800
  var ProgressCircle = function(param) {
1791
1801
  var color = param.color, bgColor = param.bgColor, _param_width = param.width, width = _param_width === void 0 ? 40 : _param_width, _param_height = param.height, height = _param_height === void 0 ? 40 : _param_height, _param_strokeWidth = param.strokeWidth, strokeWidth = _param_strokeWidth === void 0 ? 3 : _param_strokeWidth, _param_polarity = param.polarity, polarity = _param_polarity === void 0 ? Polarity.linear : _param_polarity, value = param.value;
1792
1802
  var cx = width / 2;
@@ -1847,7 +1857,7 @@ function RotarySlider(param) {
1847
1857
  end: 15000.0,
1848
1858
  interval: 0.1,
1849
1859
  skew: 0.7
1850
- } : _param_mockProperties; param.labelColor; var _param_color = param.color, color = _param_color === void 0 ? 'var(--color-gray-500)' : _param_color, _param_bgColor = param.bgColor, bgColor = _param_bgColor === void 0 ? 'var(--color-gray-200)' : _param_bgColor, _param_width = param.width, width = _param_width === void 0 ? 40 : _param_width, _param_height = param.height, height = _param_height === void 0 ? 40 : _param_height, style = param.style;
1860
+ } : _param_mockProperties; param.labelColor; var _param_color = param.color, color = _param_color === void 0 ? 'var(--color-gray-500)' : _param_color, _param_bgColor = param.bgColor, bgColor = _param_bgColor === void 0 ? 'var(--color-gray-200)' : _param_bgColor, _param_width = param.width, width = _param_width === void 0 ? 40 : _param_width, _param_height = param.height, height = _param_height === void 0 ? 38 : _param_height, style = param.style;
1851
1861
  var _useSlider = useSlider({
1852
1862
  id: id,
1853
1863
  label: label,
@@ -1855,42 +1865,12 @@ function RotarySlider(param) {
1855
1865
  mockInitialNormalisedValue: mockInitialNormalisedValue,
1856
1866
  onChange: onChange,
1857
1867
  isRandomizable: isRandomizable
1858
- }), bindDrag = _useSlider.bindDrag, normalisedValue = _useSlider.normalisedValue, scaledValue = _useSlider.scaledValue, onMouseEnter = _useSlider.onMouseEnter, setToDefaultState = _useSlider.setToDefaultState, incrementValue = _useSlider.incrementValue, decrementValue = _useSlider.decrementValue;
1859
- var _useState = _sliced_to_array$8(useState(false), 2), isActive = _useState[0], setIsActive = _useState[1];
1860
- function clickListener(event) {
1861
- var _event_target_closest;
1862
- if (((_event_target_closest = event.target.closest('.RotarySlider')) === null || _event_target_closest === void 0 ? void 0 : _event_target_closest.id) === id) {
1863
- setIsActive(true);
1864
- } else {
1865
- setIsActive(false);
1866
- }
1867
- }
1868
- function keyDownListener(event) {
1869
- if (isActive) {
1870
- if (event.key === 'ArrowLeft') {
1871
- event.preventDefault();
1872
- decrementValue();
1873
- }
1874
- if (event.key === 'ArrowRight') {
1875
- event.preventDefault();
1876
- incrementValue();
1877
- }
1878
- }
1879
- }
1880
- useEffect(function() {
1881
- document.addEventListener('click', clickListener, true);
1882
- document.addEventListener('keydown', keyDownListener);
1883
- return function() {
1884
- document.removeEventListener('click', clickListener);
1885
- document.removeEventListener('keydown', keyDownListener);
1886
- };
1887
- }, [
1888
- window,
1889
- isActive
1890
- ]);
1868
+ }), bindDrag = _useSlider.bindDrag, normalisedValue = _useSlider.normalisedValue, scaledValue = _useSlider.scaledValue, onMouseEnter = _useSlider.onMouseEnter, setToDefaultState = _useSlider.setToDefaultState, setNormalisedState = _useSlider.setNormalisedState, isActive = _useSlider.isActive, properties = _useSlider.properties;
1891
1869
  return /*#__PURE__*/ React__default.createElement(Box, {
1892
1870
  className: "RotarySlider-wrapper",
1893
- flexDirection: Box.flexDirection.column
1871
+ flexDirection: Box.flexDirection.column,
1872
+ gap: Box.gap.none,
1873
+ flex: "0 1 auto"
1894
1874
  }, polarity === Polarity.bipolar && /*#__PURE__*/ React__default.createElement("div", {
1895
1875
  style: {
1896
1876
  borderColor: "".concat(color, " transparent ").concat(color, " transparent")
@@ -1898,7 +1878,7 @@ function RotarySlider(param) {
1898
1878
  className: classnames('RotarySlider-center-marker')
1899
1879
  }), /*#__PURE__*/ React__default.createElement(Box, _object_spread_props$2(_object_spread$e({
1900
1880
  id: id,
1901
- className: classnames('RotarySlider', isActive ? 'corner-border' : '', polarity === Polarity.linear ? 'Slider-polarity-linear' : 'Slider-polarity-bipolar', className)
1881
+ className: classnames('Slider', 'RotarySlider', isActive ? 'corner-border' : '', polarity === Polarity.linear ? 'Slider-polarity-linear' : 'Slider-polarity-bipolar', className)
1902
1882
  }, bindDrag()), {
1903
1883
  onMouseEnter: onMouseEnter,
1904
1884
  onDoubleClick: function() {
@@ -1918,16 +1898,28 @@ function RotarySlider(param) {
1918
1898
  bgColor: color,
1919
1899
  width: width,
1920
1900
  height: height
1921
- }), /*#__PURE__*/ React__default.createElement(Label, {
1901
+ })) : ''), /*#__PURE__*/ React__default.createElement(Input, {
1922
1902
  className: "ProgressCircle-value",
1923
- color: "var(--color-gray-200)",
1924
- fontSize: Label.fontSize.xSmall,
1903
+ value: scaledValue,
1904
+ id: id,
1905
+ min: (properties === null || properties === void 0 ? void 0 : properties.start) || 0,
1906
+ max: (properties === null || properties === void 0 ? void 0 : properties.end) || 0,
1925
1907
  style: {
1926
- fontWeight: 'bold'
1908
+ fontWeight: 'bold',
1909
+ width: '100%',
1910
+ maxWidth: "".concat(width, "px"),
1911
+ marginBottom: 'var(--spacing-sm)'
1912
+ },
1913
+ onComplete: function(value) {
1914
+ var normalisedVal = properties && scaledToNormalised({
1915
+ scaledValue: value,
1916
+ properties: properties
1917
+ });
1918
+ normalisedVal !== undefined && setNormalisedState(normalisedVal);
1927
1919
  }
1928
- }, scaledValue)) : ''), /*#__PURE__*/ React__default.createElement(Label, {
1920
+ }), /*#__PURE__*/ React__default.createElement(Label, {
1929
1921
  padding: [
1930
- Label.padding.mediumSmall
1922
+ Label.padding.none
1931
1923
  ],
1932
1924
  fontSize: Label.fontSize.xSmall,
1933
1925
  value: label
@@ -2039,24 +2031,6 @@ Slider.sliderType = SliderType;
2039
2031
  Slider.sliderPolarity = Polarity;
2040
2032
  Slider.sliderOrientation = Orientation;
2041
2033
 
2042
- function SliderValue(param) {
2043
- var value = param.value, min = param.min, max = param.max, minLength = param.minLength, maxLength = param.maxLength, isEditable = param.isEditable, onChange = param.onChange, className = param.className, style = param.style;
2044
- return /*#__PURE__*/ React__default.createElement(React__default.Fragment, null, isEditable ? /*#__PURE__*/ React__default.createElement(Input, {
2045
- value: value,
2046
- min: min,
2047
- max: max,
2048
- minLength: minLength,
2049
- maxLength: maxLength,
2050
- style: style,
2051
- onComplete: onChange,
2052
- className: classnames('SliderValue', className)
2053
- }) : /*#__PURE__*/ React__default.createElement(Label, {
2054
- value: value,
2055
- className: classnames('SliderValue', className),
2056
- style: style
2057
- }));
2058
- }
2059
-
2060
2034
  var HeadingTags = /*#__PURE__*/ function(HeadingTags) {
2061
2035
  HeadingTags["h1"] = "h1";
2062
2036
  HeadingTags["h2"] = "h2";
@@ -3566,18 +3540,15 @@ function ModuleHeader(param) {
3566
3540
  function keydownListener(event) {
3567
3541
  var _document;
3568
3542
  var activeElement = (_document = document) === null || _document === void 0 ? void 0 : _document.activeElement;
3569
- // 8, Backspace
3570
3543
  var elements = [
3571
3544
  'input',
3572
- 'select',
3573
- 'button',
3574
- 'textarea',
3575
- 'div'
3545
+ 'textarea'
3576
3546
  ];
3547
+ var eventMatchesActiveInput = activeElement && elements.includes(activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName.toLowerCase()) && event.target.id === (activeElement === null || activeElement === void 0 ? void 0 : activeElement.id);
3577
3548
  if (event.key === 'Backspace' && activeElement && elements.indexOf(activeElement.tagName.toLowerCase()) === -1) {
3578
3549
  event.preventDefault();
3579
3550
  }
3580
- if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
3551
+ if ((event.key === 'ArrowLeft' || event.key === 'ArrowRight') && !eventMatchesActiveInput) {
3581
3552
  event.preventDefault();
3582
3553
  }
3583
3554
  }
@@ -4762,7 +4733,10 @@ function LFOTab() {
4762
4733
  return /*#__PURE__*/ React__default.createElement(Box, {
4763
4734
  className: "LFOTab",
4764
4735
  flexDirection: Box.flexDirection.column
4765
- }, /*#__PURE__*/ React__default.createElement(Box, null, /*#__PURE__*/ React__default.createElement(Dropdown, {
4736
+ }, /*#__PURE__*/ React__default.createElement(Box, {
4737
+ alignItems: Box.alignItems.flexEnd,
4738
+ justifyContent: Box.justifyContent.spaceEvenly
4739
+ }, /*#__PURE__*/ React__default.createElement(Dropdown, {
4766
4740
  labelColor: "var(--color-text)",
4767
4741
  color: "var(--color-brand)",
4768
4742
  id: "LFO1_Wave",
@@ -4806,7 +4780,10 @@ function LFOTab() {
4806
4780
  }), /*#__PURE__*/ React__default.createElement(RotarySlider, {
4807
4781
  id: "LFO1_Rand",
4808
4782
  label: "LFO1 Rand"
4809
- })), /*#__PURE__*/ React__default.createElement(Box, null, /*#__PURE__*/ React__default.createElement(Dropdown, {
4783
+ })), /*#__PURE__*/ React__default.createElement(Box, {
4784
+ alignItems: Box.alignItems.flexEnd,
4785
+ justifyContent: Box.justifyContent.spaceEvenly
4786
+ }, /*#__PURE__*/ React__default.createElement(Dropdown, {
4810
4787
  labelColor: "var(--color-text)",
4811
4788
  color: "var(--color-brand)",
4812
4789
  id: "LFO2_Wave",
@@ -5183,5 +5160,5 @@ function ModuleFooter(param) {
5183
5160
  }, isTabSelected("ModMatrix") ? /*#__PURE__*/ React__default.createElement(ModMatrixTab, null) : '', isTabSelected("InputMod") ? /*#__PURE__*/ React__default.createElement(InputModTab, null) : '', isTabSelected("LFOs") ? /*#__PURE__*/ React__default.createElement(LFOTab, null) : '', isTabSelected("Sequencer") ? /*#__PURE__*/ React__default.createElement(SequencerTab, null) : '', isTabSelected("Settings") ? /*#__PURE__*/ React__default.createElement(SettingsTab, null) : '')));
5184
5161
  }
5185
5162
 
5186
- export { Slider as BarSlider, Box, Button, Dropdown, FontSizes, GlobalContextProvider, Heading, IconButton, IndicatorLight, Input, KeyValueDisplayScreen, Label, ModuleFooter, ModuleHeader, Oscilloscope, RotarySlider, SliderValue, Spacing, Tabs, clamp, decimalToPercent, defaultGlobalStateValue as defaultValue, normalisedToScaled, percentToDecimal, randomizeValue, scaledToNormalised as scaledTonormalised, useGlobalContext, useObservable, useSlider };
5163
+ export { Slider as BarSlider, Box, Button, Dropdown, FontSizes, GlobalContextProvider, Heading, IconButton, IndicatorLight, Input, KeyValueDisplayScreen, Label, ModuleFooter, ModuleHeader, Oscilloscope, RotarySlider, Spacing, Tabs, clamp, decimalToPercent, defaultGlobalStateValue as defaultValue, normalisedToScaled, percentToDecimal, randomizeValue, scaledToNormalised as scaledTonormalised, useGlobalContext, useObservable, useSlider };
5187
5164
  //# sourceMappingURL=index.js.map