@antimatter-audio/antimatter-ui 10.16.4 → 10.17.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 (43) hide show
  1. package/dist/advanced/ModMatrix/ModMatrix.d.ts.map +1 -1
  2. package/dist/advanced/ModMatrix/ModMatrixCell.d.ts +2 -1
  3. package/dist/advanced/ModMatrix/ModMatrixCell.d.ts.map +1 -1
  4. package/dist/advanced/ModMatrix/ModMatrixComboboxCell.d.ts +1 -1
  5. package/dist/advanced/ModMatrix/ModMatrixComboboxCell.d.ts.map +1 -1
  6. package/dist/advanced/ModMatrix/ModMatrixRow.d.ts +1 -1
  7. package/dist/advanced/ModMatrix/ModMatrixRow.d.ts.map +1 -1
  8. package/dist/advanced/ModMatrix/ModMatrixToggleCell.d.ts.map +1 -1
  9. package/dist/advanced/ModMatrix/constants.d.ts +1 -0
  10. package/dist/advanced/ModMatrix/constants.d.ts.map +1 -1
  11. package/dist/context/GlobalContextProvider.d.ts +7 -3
  12. package/dist/context/GlobalContextProvider.d.ts.map +1 -1
  13. package/dist/core/Button/Button.d.ts.map +1 -1
  14. package/dist/core/Dropdown/Dropdown.d.ts +1 -1
  15. package/dist/core/Dropdown/Dropdown.d.ts.map +1 -1
  16. package/dist/hooks/useCombobox.d.ts +0 -1
  17. package/dist/hooks/useCombobox.d.ts.map +1 -1
  18. package/dist/hooks/useDropdown.d.ts +3 -2
  19. package/dist/hooks/useDropdown.d.ts.map +1 -1
  20. package/dist/hooks/useSlider.d.ts +3 -2
  21. package/dist/hooks/useSlider.d.ts.map +1 -1
  22. package/dist/index.js +316 -235
  23. package/dist/index.js.map +1 -1
  24. package/dist/src/advanced/ModMatrix/ModMatrix.d.ts.map +1 -1
  25. package/dist/src/advanced/ModMatrix/ModMatrixCell.d.ts +2 -1
  26. package/dist/src/advanced/ModMatrix/ModMatrixCell.d.ts.map +1 -1
  27. package/dist/src/advanced/ModMatrix/ModMatrixComboboxCell.d.ts +1 -1
  28. package/dist/src/advanced/ModMatrix/ModMatrixComboboxCell.d.ts.map +1 -1
  29. package/dist/src/advanced/ModMatrix/ModMatrixRow.d.ts +1 -1
  30. package/dist/src/advanced/ModMatrix/ModMatrixRow.d.ts.map +1 -1
  31. package/dist/src/advanced/ModMatrix/ModMatrixToggleCell.d.ts.map +1 -1
  32. package/dist/src/advanced/ModMatrix/constants.d.ts +1 -0
  33. package/dist/src/advanced/ModMatrix/constants.d.ts.map +1 -1
  34. package/dist/src/context/GlobalContextProvider.d.ts +7 -3
  35. package/dist/src/context/GlobalContextProvider.d.ts.map +1 -1
  36. package/dist/src/core/Button/Button.d.ts.map +1 -1
  37. package/dist/src/hooks/useCombobox.d.ts +0 -1
  38. package/dist/src/hooks/useCombobox.d.ts.map +1 -1
  39. package/dist/src/hooks/useDropdown.d.ts +3 -2
  40. package/dist/src/hooks/useDropdown.d.ts.map +1 -1
  41. package/dist/src/hooks/useSlider.d.ts +3 -2
  42. package/dist/src/hooks/useSlider.d.ts.map +1 -1
  43. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -615,19 +615,22 @@ var reducer = function(state, action) {
615
615
  allParameters: action.payload
616
616
  });
617
617
  case 'MOD_SLOTS_RECEIVED':
618
- var _action_payload;
619
618
  return _object_spread_props$4(_object_spread$k({}, state), {
620
619
  modSlotIds: action.payload.map(function(val) {
621
620
  return val[0];
622
- }),
621
+ })
622
+ });
623
+ case 'MOD_SLOT_ROW_TARGETS_RECEIVED':
624
+ var _action_payload;
625
+ return _object_spread_props$4(_object_spread$k({}, state), {
623
626
  modSlotTargets: action === null || action === void 0 ? void 0 : (_action_payload = action.payload) === null || _action_payload === void 0 ? void 0 : _action_payload.reduce(function(acc, val) {
624
627
  return _object_spread_props$4(_object_spread$k({}, acc), _define_property$k({}, val[0], val[1]));
625
628
  }, {})
626
629
  });
627
- case 'MOD_SLOT_TARGETS_UPDATED':
630
+ case 'MOD_SLOT_ROW_TARGET_UPDATED':
628
631
  var _action_payload1, _action_payload2;
629
632
  return _object_spread_props$4(_object_spread$k({}, state), {
630
- modSlotTargets: _object_spread_props$4(_object_spread$k({}, state === null || state === void 0 ? void 0 : state.modSlotTargets), _define_property$k({}, (_action_payload1 = action.payload) === null || _action_payload1 === void 0 ? void 0 : _action_payload1[0], action === null || action === void 0 ? void 0 : (_action_payload2 = action.payload) === null || _action_payload2 === void 0 ? void 0 : _action_payload2[1]))
633
+ modSlotTargets: _object_spread_props$4(_object_spread$k({}, state === null || state === void 0 ? void 0 : state.modSlotTargets), _define_property$k({}, (_action_payload1 = action.payload) === null || _action_payload1 === void 0 ? void 0 : _action_payload1.id, action === null || action === void 0 ? void 0 : (_action_payload2 = action.payload) === null || _action_payload2 === void 0 ? void 0 : _action_payload2.value))
631
634
  });
632
635
  case 'MOD_SLOT_PREVIEW_TARGET_INDEX_UPDATED':
633
636
  {
@@ -762,6 +765,18 @@ function GlobalContextProvider(param) {
762
765
  payload: modSlots
763
766
  });
764
767
  }, []);
768
+ var modSlotRowTargetsReceived = useCallback(function(modSlots) {
769
+ dispatch({
770
+ type: 'MOD_SLOT_ROW_TARGETS_RECEIVED',
771
+ payload: modSlots
772
+ });
773
+ }, []);
774
+ var modSlotRowTargetUpdated = useCallback(function(modSlot) {
775
+ dispatch({
776
+ type: 'MOD_SLOT_ROW_TARGET_UPDATED',
777
+ payload: modSlot
778
+ });
779
+ }, []);
765
780
  var modSlotPreviewTargetIndexUpdated = useCallback(function(targetIndex) {
766
781
  dispatch({
767
782
  type: 'MOD_SLOT_PREVIEW_TARGET_INDEX_UPDATED',
@@ -792,12 +807,6 @@ function GlobalContextProvider(param) {
792
807
  payload: null
793
808
  });
794
809
  }, []);
795
- var modSlotTargetUpdated = useCallback(function(modSlot) {
796
- dispatch({
797
- type: 'MOD_SLOT_TARGETS_UPDATED',
798
- payload: modSlot
799
- });
800
- }, []);
801
810
  var modSlotParamsListReceived = useCallback(function(modSlotParams) {
802
811
  dispatch({
803
812
  type: 'MOD_SLOT_PARAMS_LIST_RECEIVED',
@@ -834,69 +843,104 @@ function GlobalContextProvider(param) {
834
843
  var paramIndex = state === null || state === void 0 ? void 0 : state.allParameters.indexOf(id);
835
844
  return state === null || state === void 0 ? void 0 : state.defaultParamValues[paramIndex];
836
845
  };
837
- var addModSlotRowTargetAndMakeRowEditable = function(id) {
846
+ // const setModSlotTarget = (newTarget: number, rowId: string) => {
847
+ // const comboBoxState = Juce.getComboBoxState(rowId);
848
+ // comboBoxState?.setChoiceIndex(newTarget);
849
+ // };
850
+ var refetchModSlots = function() {
851
+ return _async_to_generator$4(function() {
852
+ var getAllModSlotsFunc, modSlotsData, e;
853
+ return _ts_generator$4(this, function(_state) {
854
+ switch(_state.label){
855
+ case 0:
856
+ _state.trys.push([
857
+ 0,
858
+ 2,
859
+ ,
860
+ 3
861
+ ]);
862
+ getAllModSlotsFunc = Juce.getNativeFunction('getAllModSlots');
863
+ return [
864
+ 4,
865
+ getAllModSlotsFunc()
866
+ ];
867
+ case 1:
868
+ modSlotsData = _state.sent();
869
+ modSlotRowTargetsReceived(modSlotsData || []);
870
+ return [
871
+ 3,
872
+ 3
873
+ ];
874
+ case 2:
875
+ e = _state.sent();
876
+ console.log(e);
877
+ return [
878
+ 3,
879
+ 3
880
+ ];
881
+ case 3:
882
+ return [
883
+ 2
884
+ ];
885
+ }
886
+ });
887
+ })();
888
+ };
889
+ var setModSlotRowTargetAsPreview = function(param) {
890
+ var paramIndex = param.paramIndex, paramId = param.paramId;
838
891
  var _Object_values;
839
- var parameterIndex = state.automatableParamsList.indexOf(id);
840
- if (!((_Object_values = Object.values(state.modSlotTargets)) === null || _Object_values === void 0 ? void 0 : _Object_values.includes(parameterIndex))) {
841
- modSlotPreviewTargetIndexUpdated(parameterIndex);
892
+ // Setting a row target for a preview row enables the preview row to be interactive.
893
+ // This row target will not be saved to Juce until a user sets a new value for one of the inputs in the row.
894
+ // This function only stores the target in local state and does NOT save anything to the Juce state.
895
+ var targetIndex = paramId ? state.automatableParamsList.indexOf(paramId) : paramIndex;
896
+ if (!((_Object_values = Object.values(state.modSlotTargets)) === null || _Object_values === void 0 ? void 0 : _Object_values.includes(targetIndex))) {
897
+ setNewModSlotPreview();
898
+ modSlotPreviewTargetIndexUpdated(targetIndex);
842
899
  modSlotPreviewIsEditableUpdated(true);
843
900
  }
844
901
  };
845
- var updateModSlotTargetAndResetPreview = function(value, id) {
846
- var _state_modSlotPreview, _state_modSlotPreview1, _state_modSlotPreview2;
847
- var rowState = Juce.getComboBoxState((_state_modSlotPreview = state.modSlotPreview) === null || _state_modSlotPreview === void 0 ? void 0 : _state_modSlotPreview.slotId);
848
- var defaultParameter = getDefaultParameter(id);
849
- var refetchModSlots = function() {
850
- return _async_to_generator$4(function() {
851
- var getAllModSlotsFunc, modSlotsData, e;
852
- return _ts_generator$4(this, function(_state) {
853
- switch(_state.label){
854
- case 0:
855
- _state.trys.push([
856
- 0,
857
- 2,
858
- ,
859
- 3
860
- ]);
861
- getAllModSlotsFunc = Juce.getNativeFunction('getAllModSlots');
862
- return [
863
- 4,
864
- getAllModSlotsFunc()
865
- ];
866
- case 1:
867
- modSlotsData = _state.sent();
868
- modSlotsReceived(modSlotsData || []);
869
- return [
870
- 3,
871
- 3
872
- ];
873
- case 2:
874
- e = _state.sent();
875
- console.log(e);
876
- return [
877
- 3,
878
- 3
879
- ];
880
- case 3:
881
- return [
882
- 2
883
- ];
884
- }
885
- });
886
- })();
887
- };
888
- if (defaultParameter !== null && defaultParameter !== undefined && value !== defaultParameter && ((_state_modSlotPreview1 = state.modSlotPreview) === null || _state_modSlotPreview1 === void 0 ? void 0 : _state_modSlotPreview1.slotId) && ((_state_modSlotPreview2 = state.modSlotPreview) === null || _state_modSlotPreview2 === void 0 ? void 0 : _state_modSlotPreview2.targetIndex)) {
889
- var _state_modSlotPreview3;
890
- modSlotTargetUpdated([
891
- state.modSlotPreview.slotId,
892
- state.modSlotPreview.targetIndex
893
- ]);
894
- rowState === null || rowState === void 0 ? void 0 : rowState.setChoiceIndex((_state_modSlotPreview3 = state.modSlotPreview) === null || _state_modSlotPreview3 === void 0 ? void 0 : _state_modSlotPreview3.targetIndex);
902
+ var saveModSlotPreviewRowTargetToBackend = function(value, rowId) {
903
+ var _state_modSlotPreview, _state_modSlotPreview1;
904
+ var rowState = Juce.getComboBoxState(rowId);
905
+ // If the row is a preview row, setting a target will remove the row's preview status.
906
+ // In this scenario, we want to clear the current row's preview status and set a new preview row (if there is an unassigned mod slot available)
907
+ var defaultParameter = getDefaultParameter(rowId);
908
+ if (((_state_modSlotPreview = state.modSlotPreview) === null || _state_modSlotPreview === void 0 ? void 0 : _state_modSlotPreview.slotId) && ((_state_modSlotPreview1 = state.modSlotPreview) === null || _state_modSlotPreview1 === void 0 ? void 0 : _state_modSlotPreview1.targetIndex) && defaultParameter !== null && defaultParameter !== undefined && value !== defaultParameter) {
909
+ var _state_modSlotPreview2;
910
+ modSlotRowTargetUpdated({
911
+ id: state.modSlotPreview.slotId,
912
+ value: state.modSlotPreview.targetIndex
913
+ });
914
+ rowState === null || rowState === void 0 ? void 0 : rowState.setChoiceIndex((_state_modSlotPreview2 = state.modSlotPreview) === null || _state_modSlotPreview2 === void 0 ? void 0 : _state_modSlotPreview2.targetIndex);
895
915
  clearModSlotPreview();
896
916
  setNewModSlotPreview();
897
917
  refetchModSlots();
898
918
  }
899
919
  };
920
+ var updateModSlotRowTarget = function(value, rowId) {
921
+ // An index of 0 = 'none' in the mod slot target list.
922
+ // If the new row target value is 0, the user is deleting the row's target.
923
+ // Clear all of the values that have been set for that target on the front end and in JUCE.
924
+ console.log(value, state.modSlotPreview, rowId, 'value, state.modSlotPreview, rowId,in context');
925
+ var rowState = Juce.getComboBoxState(rowId);
926
+ rowState === null || rowState === void 0 ? void 0 : rowState.setChoiceIndex(value);
927
+ if (rowId === state.modSlotPreview.slotId) {
928
+ clearModSlotPreview();
929
+ }
930
+ if (value === 0) {
931
+ var _state_modSlotParams_rowId, _state_modSlotParams;
932
+ state === null || state === void 0 ? void 0 : (_state_modSlotParams = state.modSlotParams) === null || _state_modSlotParams === void 0 ? void 0 : (_state_modSlotParams_rowId = _state_modSlotParams[rowId]) === null || _state_modSlotParams_rowId === void 0 ? void 0 : _state_modSlotParams_rowId.forEach(function(item) {
933
+ setDefaultParameter(item);
934
+ });
935
+ clearModSlotPreview();
936
+ setNewModSlotPreview();
937
+ }
938
+ modSlotRowTargetUpdated({
939
+ id: rowId,
940
+ value: value
941
+ });
942
+ refetchModSlots();
943
+ };
900
944
  var onFire = function() {
901
945
  //@ts-expect-error
902
946
  window.__JUCE__.backend.emitEvent('setRandom', {});
@@ -922,11 +966,13 @@ function GlobalContextProvider(param) {
922
966
  setDefaultParameter: setDefaultParameter,
923
967
  getDefaultParameter: getDefaultParameter,
924
968
  modSlotsReceived: modSlotsReceived,
925
- modSlotTargetUpdated: modSlotTargetUpdated,
969
+ modSlotRowTargetsReceived: modSlotRowTargetsReceived,
970
+ // setModSlotTarget,
926
971
  modSlotParamsListReceived: modSlotParamsListReceived,
927
972
  modSlotParamLabelsReceived: modSlotParamLabelsReceived,
928
- addModSlotRowTargetAndMakeRowEditable: addModSlotRowTargetAndMakeRowEditable,
929
- updateModSlotTargetAndResetPreview: updateModSlotTargetAndResetPreview,
973
+ setModSlotRowTargetAsPreview: setModSlotRowTargetAsPreview,
974
+ saveModSlotPreviewRowTargetToBackend: saveModSlotPreviewRowTargetToBackend,
975
+ updateModSlotRowTarget: updateModSlotRowTarget,
930
976
  useRandom: useRandom
931
977
  };
932
978
  return /*#__PURE__*/ React__default.createElement(GlobalContext.Provider, {
@@ -1017,7 +1063,7 @@ function Button(param) {
1017
1063
  var _React_useState = _sliced_to_array$f(React__default.useState(false), 2), isSelected = _React_useState[0], setIsSelected = _React_useState[1];
1018
1064
  var buttonState = Juce.getToggleState(id);
1019
1065
  var isLocalhost = window.location.hostname === 'localhost';
1020
- var addModSlotRowTargetAndMakeRowEditable = useGlobalContext().addModSlotRowTargetAndMakeRowEditable;
1066
+ var setModSlotRowTargetAsPreview = useGlobalContext().setModSlotRowTargetAsPreview;
1021
1067
  // Update the local state when the ID changes
1022
1068
  useEffect(function() {
1023
1069
  setIsSelected(buttonState === null || buttonState === void 0 ? void 0 : buttonState.value);
@@ -1038,7 +1084,10 @@ function Button(param) {
1038
1084
  }
1039
1085
  });
1040
1086
  var handleMouseDown = function(e) {
1041
- addModSlotRowTargetAndMakeRowEditable(id);
1087
+ // TODO: handle this in a callback?
1088
+ setModSlotRowTargetAsPreview({
1089
+ paramId: id
1090
+ });
1042
1091
  if (!onClick) {
1043
1092
  e.preventDefault();
1044
1093
  if (type === ButtonType.momentary) {
@@ -1141,12 +1190,13 @@ function _unsupported_iterable_to_array$e(o, minLen) {
1141
1190
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$e(o, minLen);
1142
1191
  }
1143
1192
  var useDropdown = function(param) {
1144
- var id = param.id, label = param.label, _param_items = param.items, items = _param_items === void 0 ? [] : _param_items, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, filter = param.filter, onChange = param.onChange, _param_displayValInHeader = param.displayValInHeader, displayValInHeader = _param_displayValInHeader === void 0 ? true : _param_displayValInHeader;
1193
+ var id = param.id, // TODO: Is there a better way to handle mod matrix dropdowns?
1194
+ rowId = param.rowId, label = param.label, _param_items = param.items, items = _param_items === void 0 ? [] : _param_items, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, filter = param.filter, onChange = param.onChange, _param_displayValInHeader = param.displayValInHeader, displayValInHeader = _param_displayValInHeader === void 0 ? true : _param_displayValInHeader;
1145
1195
  var _properties_choices;
1146
1196
  var comboBoxState = Juce.getComboBoxState(id);
1147
1197
  var _useState = _sliced_to_array$e(useState(comboBoxState.getChoiceIndex()), 2), index = _useState[0], setIndex = _useState[1];
1148
1198
  var _useState1 = _sliced_to_array$e(useState(comboBoxState.properties), 2), properties = _useState1[0], setProperties = _useState1[1];
1149
- var _useGlobalContext = useGlobalContext(), highlightedItemChanged = _useGlobalContext.highlightedItemChanged, addModSlotRowTargetAndMakeRowEditable = _useGlobalContext.addModSlotRowTargetAndMakeRowEditable;
1199
+ var _useGlobalContext = useGlobalContext(), highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview;
1150
1200
  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 : [];
1151
1201
  var filteredChoices = filter ? choices === null || choices === void 0 ? void 0 : choices.filter(function(item) {
1152
1202
  var _item_;
@@ -1159,7 +1209,12 @@ var useDropdown = function(param) {
1159
1209
  if (choiceIndex !== prevIndex.current) {
1160
1210
  comboBoxState.setChoiceIndex(choiceIndex);
1161
1211
  setIndex(choiceIndex);
1162
- onChange && onChange(choiceIndex, id);
1212
+ // TODO: Is there a better way to do this?
1213
+ if (rowId) {
1214
+ onChange && onChange(choiceIndex, rowId);
1215
+ } else {
1216
+ onChange && onChange(choiceIndex, id);
1217
+ }
1163
1218
  // //@ts-expect-error
1164
1219
  // window.__JUCE__.backend.emitEvent('undoableActionOccurred', {});
1165
1220
  if (displayValInHeader) {
@@ -1202,7 +1257,9 @@ var useDropdown = function(param) {
1202
1257
  }
1203
1258
  };
1204
1259
  var onClick = function() {
1205
- addModSlotRowTargetAndMakeRowEditable(id);
1260
+ setModSlotRowTargetAsPreview({
1261
+ paramId: id
1262
+ });
1206
1263
  };
1207
1264
  return {
1208
1265
  value: choices[index],
@@ -1806,7 +1863,7 @@ function _unsupported_iterable_to_array$c(o, minLen) {
1806
1863
  // 20.0f, 15000.0f, 0.1f, 0.7f),800.0f
1807
1864
  // ValueType rangeStart, ValueType rangeEnd, ValueType intervalValue, ValueType skewFactor, bool useSymmetricSkew=false)
1808
1865
  var useSlider = function(param) {
1809
- var id = param.id, label = param.label, _param_displayValInHeader = param.displayValInHeader, displayValInHeader = _param_displayValInHeader === void 0 ? true : _param_displayValInHeader, _param_mockProperties = param.mockProperties, mockProperties = _param_mockProperties === void 0 ? {
1866
+ var id = param.id, rowId = param.rowId, label = param.label, _param_displayValInHeader = param.displayValInHeader, displayValInHeader = _param_displayValInHeader === void 0 ? true : _param_displayValInHeader, _param_mockProperties = param.mockProperties, mockProperties = _param_mockProperties === void 0 ? {
1810
1867
  start: 20,
1811
1868
  end: 15000,
1812
1869
  interval: 0.1,
@@ -1858,8 +1915,10 @@ var useSlider = function(param) {
1858
1915
  var scaledValueRef = useRef(null);
1859
1916
  var normalisedValueRef = useRef(null);
1860
1917
  var sliderState = Juce.getSliderState(id);
1918
+ var prevValueRef = useRef(null);
1861
1919
  // const randomValueSetCounter = useRef<number>(null);
1862
- var _useGlobalContext = useGlobalContext(), useRandom = _useGlobalContext.useRandom, highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setDefaultParameter = _useGlobalContext.setDefaultParameter, addModSlotRowTargetAndMakeRowEditable = _useGlobalContext.addModSlotRowTargetAndMakeRowEditable, _useGlobalContext_globalState = _useGlobalContext.globalState, automatableParamsList = _useGlobalContext_globalState.automatableParamsList, modSlotTargets = _useGlobalContext_globalState.modSlotTargets;
1920
+ var _useGlobalContext = useGlobalContext(), useRandom = _useGlobalContext.useRandom, highlightedItemChanged = _useGlobalContext.highlightedItemChanged, setDefaultParameter = _useGlobalContext.setDefaultParameter, setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview, _useGlobalContext_globalState = _useGlobalContext.// setModSlotRowTarget,
1921
+ globalState, automatableParamsList = _useGlobalContext_globalState.automatableParamsList, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
1863
1922
  var _useState2 = _sliced_to_array$c(useState(false), 2), isActive = _useState2[0], setIsActive = _useState2[1];
1864
1923
  useEffect(function() {
1865
1924
  document.addEventListener('click', clickListener);
@@ -1902,29 +1961,35 @@ var useSlider = function(param) {
1902
1961
  normalisedValueRef.current = mockInitialNormalisedValue;
1903
1962
  }
1904
1963
  }, []);
1905
- var changeHandler = useCallback(function(scaledValueFromState, sliderId) {
1906
- onChange && onChange(parseFloat(scaledValueFromState.toFixed(2)), sliderId);
1907
- }, [
1908
- onChange
1909
- ]);
1964
+ // TODO: take out mod slot logic
1965
+ var changeHandler = function(scaledValueFromState, sliderId) {
1966
+ if (rowId === modSlotPreview.targetIndex) {
1967
+ onChange && onChange(parseFloat(scaledValueFromState.toFixed(2)), rowId);
1968
+ } else {
1969
+ onChange && onChange(parseFloat(scaledValueFromState.toFixed(2)), sliderId);
1970
+ }
1971
+ };
1910
1972
  // Update the local state from JUCE
1911
- var updateLocalState = function(sliderState) {
1973
+ var updateLocalState = function() {
1912
1974
  var normalisedValueFromState = sliderState === null || sliderState === void 0 ? void 0 : sliderState.getNormalisedValue();
1913
1975
  var scaledValueFromState = sliderState === null || sliderState === void 0 ? void 0 : sliderState.getScaledValue();
1914
1976
  var scaledValue = parseFloat(scaledValueFromState.toFixed(2));
1915
1977
  normalisedValueRef.current = parseFloat(normalisedValueFromState.toFixed(2));
1916
- setScaledValue(scaledValue);
1917
- changeHandler(scaledValueFromState, id);
1918
- if (displayValInHeader && (scaledValueRef === null || scaledValueRef === void 0 ? void 0 : scaledValueRef.current) !== scaledValue) {
1919
- highlightedItemChanged({
1920
- label: label,
1921
- value: scaledValue
1922
- });
1978
+ if (scaledValue !== prevValueRef.current) {
1979
+ setScaledValue(scaledValue);
1980
+ rowId && changeHandler(scaledValueFromState, rowId);
1981
+ if (displayValInHeader && (scaledValueRef === null || scaledValueRef === void 0 ? void 0 : scaledValueRef.current) !== scaledValue) {
1982
+ highlightedItemChanged({
1983
+ label: label,
1984
+ value: scaledValue
1985
+ });
1986
+ }
1987
+ prevValueRef.current = scaledValue;
1923
1988
  }
1924
1989
  };
1925
1990
  // Update the local state when the ID changes
1926
1991
  useEffect(function() {
1927
- updateLocalState(sliderState);
1992
+ updateLocalState();
1928
1993
  }, [
1929
1994
  id
1930
1995
  ]);
@@ -1933,7 +1998,7 @@ var useSlider = function(param) {
1933
1998
  useEffect(function() {
1934
1999
  if (!isLocalhost) {
1935
2000
  var valueListenerId = sliderState === null || sliderState === void 0 ? void 0 : sliderState.valueChangedEvent.addListener(function() {
1936
- updateLocalState(sliderState);
2001
+ updateLocalState();
1937
2002
  });
1938
2003
  var propertiesListenerId = sliderState === null || sliderState === void 0 ? void 0 : sliderState.propertiesChangedEvent.addListener(function() {
1939
2004
  return setProperties(sliderState === null || sliderState === void 0 ? void 0 : sliderState.properties);
@@ -1998,7 +2063,11 @@ var useSlider = function(param) {
1998
2063
  var bindDrag = useGesture({
1999
2064
  onMouseDown: function(param) {
2000
2065
  param.event;
2001
- addModSlotRowTargetAndMakeRowEditable(id);
2066
+ if (id !== modSlotPreview.rowId) {
2067
+ setModSlotRowTargetAsPreview({
2068
+ paramId: id
2069
+ });
2070
+ }
2002
2071
  if (!dragInProgress) {
2003
2072
  sliderState.sliderDragStarted(id);
2004
2073
  dragInProgress = true;
@@ -4225,57 +4294,7 @@ var targetColors = [
4225
4294
  '#cb4d62'
4226
4295
  ];
4227
4296
  var ComboboxCellWidth = '217px';
4228
-
4229
- function _define_property$5(obj, key, value) {
4230
- if (key in obj) {
4231
- Object.defineProperty(obj, key, {
4232
- value: value,
4233
- enumerable: true,
4234
- configurable: true,
4235
- writable: true
4236
- });
4237
- } else {
4238
- obj[key] = value;
4239
- }
4240
- return obj;
4241
- }
4242
- function _object_spread$5(target) {
4243
- for(var i = 1; i < arguments.length; i++){
4244
- var source = arguments[i] != null ? arguments[i] : {};
4245
- var ownKeys = Object.keys(source);
4246
- if (typeof Object.getOwnPropertySymbols === "function") {
4247
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4248
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4249
- }));
4250
- }
4251
- ownKeys.forEach(function(key) {
4252
- _define_property$5(target, key, source[key]);
4253
- });
4254
- }
4255
- return target;
4256
- }
4257
- function SingleBarViz(param) {
4258
- var _param_background = param.background, background = _param_background === void 0 ? 'var(--color-brand)' : _param_background, _param_height = param.height, height = _param_height === void 0 ? '6px' : _param_height, _param_polarity = param.polarity, polarity = _param_polarity === void 0 ? Polarity.unipolar : _param_polarity, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? Orientation.horizontal : _param_orientation, value = param.value, className = param.className, style = param.style;
4259
- return /*#__PURE__*/ React__default.createElement("div", {
4260
- className: className,
4261
- style: {
4262
- width: '100%',
4263
- height: height,
4264
- background: 'var(--color-gray-600)',
4265
- position: 'relative'
4266
- }
4267
- }, /*#__PURE__*/ React__default.createElement("div", {
4268
- style: _object_spread$5({
4269
- position: 'absolute',
4270
- background: background
4271
- }, getBarTransformStyles({
4272
- polarity: polarity,
4273
- orientation: orientation,
4274
- normalisedValue: value || 0
4275
- }), style)
4276
- }));
4277
- }
4278
- SingleBarViz.polarity = Polarity;
4297
+ var DeleteButtonCellWidth = '50px';
4279
4298
 
4280
4299
  function _array_like_to_array$7(arr, len) {
4281
4300
  if (len == null || len > arr.length) len = arr.length;
@@ -4324,12 +4343,13 @@ function _unsupported_iterable_to_array$7(o, minLen) {
4324
4343
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$7(o, minLen);
4325
4344
  }
4326
4345
  var useCombobox = function(param) {
4327
- var id = param.id, filter = param.filter, onChange = param.onChange;
4346
+ var id = param.id, filter = param.filter;
4328
4347
  var _Object_values;
4329
4348
  var comboBoxState = Juce.getComboBoxState(id);
4330
4349
  var _useState = _sliced_to_array$7(useState(0), 2), value = _useState[0], setValue = _useState[1];
4331
4350
  var _useState1 = _sliced_to_array$7(useState(comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.properties), 2), properties = _useState1[0], setProperties = _useState1[1];
4332
- var _useGlobalContext = useGlobalContext(); _useGlobalContext.highlightedItemChanged; var addModSlotRowTargetAndMakeRowEditable = _useGlobalContext.addModSlotRowTargetAndMakeRowEditable, _useGlobalContext_globalState = _useGlobalContext.globalState, automatableParamLabels = _useGlobalContext_globalState.automatableParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
4351
+ var prevValue = useRef(null);
4352
+ var _useGlobalContext = useGlobalContext(); _useGlobalContext.highlightedItemChanged; var setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview, _useGlobalContext_globalState = _useGlobalContext.globalState, automatableParamLabels = _useGlobalContext_globalState.automatableParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
4333
4353
  //TODO: Filter choices for subsequent rows
4334
4354
  // const availableChoices = properties?.choices;
4335
4355
  useEffect(function() {
@@ -4341,7 +4361,7 @@ var useCombobox = function(param) {
4341
4361
  setProperties(comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.properties);
4342
4362
  });
4343
4363
  useEffect(function() {
4344
- if (modSlotPreview.slotId === id && modSlotPreview.targetIndex > 0) {
4364
+ if (modSlotPreview.slotId === id) {
4345
4365
  setValue(modSlotPreview.targetIndex);
4346
4366
  }
4347
4367
  }, [
@@ -4351,7 +4371,9 @@ var useCombobox = function(param) {
4351
4371
  useEffect(function() {
4352
4372
  var _comboBoxState_valueChangedEvent, _comboBoxState_propertiesChangedEvent;
4353
4373
  var valueListenerId = comboBoxState === null || comboBoxState === void 0 ? void 0 : (_comboBoxState_valueChangedEvent = comboBoxState.valueChangedEvent) === null || _comboBoxState_valueChangedEvent === void 0 ? void 0 : _comboBoxState_valueChangedEvent.addListener(function() {
4354
- setValue(comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.getChoiceIndex());
4374
+ if ((comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.getChoiceIndex()) !== prevValue) {
4375
+ setValue(comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.getChoiceIndex());
4376
+ }
4355
4377
  });
4356
4378
  var propertiesListenerId = comboBoxState === null || comboBoxState === void 0 ? void 0 : (_comboBoxState_propertiesChangedEvent = comboBoxState.propertiesChangedEvent) === null || _comboBoxState_propertiesChangedEvent === void 0 ? void 0 : _comboBoxState_propertiesChangedEvent.addListener(function() {
4357
4379
  setProperties(comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.properties);
@@ -4377,20 +4399,30 @@ var useCombobox = function(param) {
4377
4399
  var _item_toLowerCase;
4378
4400
  return item === null || item === void 0 ? void 0 : (_item_toLowerCase = item.toLowerCase()) === null || _item_toLowerCase === void 0 ? void 0 : _item_toLowerCase.includes(filter === null || filter === void 0 ? void 0 : filter.toLowerCase());
4379
4401
  }) : displayedLabels;
4380
- var prevValue = useRef(null);
4381
- var handleChange = function(newValue) {
4382
- if (newValue !== prevValue.current) {
4383
- var juceIndex = automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels.indexOf(newValue);
4384
- comboBoxState === null || comboBoxState === void 0 ? void 0 : comboBoxState.setChoiceIndex(juceIndex);
4385
- setValue(newValue);
4386
- onChange && onChange(juceIndex);
4387
- prevValue.current = juceIndex;
4388
- }
4389
- };
4402
+ // const prevValue = useRef<string | null>(null);
4403
+ // const handleChange = (newValue: number) => {
4404
+ // if (newValue !== prevValue.current) {
4405
+ // // const juceIndex = automatableParamLabels?.indexOf(newValue);
4406
+ // // comboBoxState?.setChoiceIndex(newValue);s
4407
+ // setValue(newValue);
4408
+ // // onChange && onChange(newValue);
4409
+ // // //@ts-expect-error
4410
+ // // window.__JUCE__.backend.emitEvent('undoableActionOccurred', {});
4411
+ // if (displayValInHeader) {
4412
+ // highlightedItemChanged({
4413
+ // label,
4414
+ // value: automatableParamLabels?.[newValue],
4415
+ // });
4416
+ // }
4417
+ // prevValue.current = newValue;
4418
+ // }
4419
+ // };
4390
4420
  var onMouseEnter = function() {
4391
4421
  };
4392
4422
  var onClick = function() {
4393
- addModSlotRowTargetAndMakeRowEditable(id);
4423
+ setModSlotRowTargetAsPreview({
4424
+ paramId: id
4425
+ });
4394
4426
  };
4395
4427
  return {
4396
4428
  value: value,
@@ -4399,8 +4431,7 @@ var useCombobox = function(param) {
4399
4431
  choices: properties === null || properties === void 0 ? void 0 : properties.choices,
4400
4432
  filteredChoices: filteredChoices,
4401
4433
  onMouseEnter: onMouseEnter,
4402
- onClick: onClick,
4403
- handleChange: handleChange
4434
+ onClick: onClick
4404
4435
  };
4405
4436
  };
4406
4437
 
@@ -4412,7 +4443,7 @@ function _array_like_to_array$6(arr, len) {
4412
4443
  function _array_with_holes$6(arr) {
4413
4444
  if (Array.isArray(arr)) return arr;
4414
4445
  }
4415
- function _define_property$4(obj, key, value) {
4446
+ function _define_property$5(obj, key, value) {
4416
4447
  if (key in obj) {
4417
4448
  Object.defineProperty(obj, key, {
4418
4449
  value: value,
@@ -4452,7 +4483,7 @@ function _iterable_to_array_limit$6(arr, i) {
4452
4483
  function _non_iterable_rest$6() {
4453
4484
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4454
4485
  }
4455
- function _object_spread$4(target) {
4486
+ function _object_spread$5(target) {
4456
4487
  for(var i = 1; i < arguments.length; i++){
4457
4488
  var source = arguments[i] != null ? arguments[i] : {};
4458
4489
  var ownKeys = Object.keys(source);
@@ -4462,7 +4493,7 @@ function _object_spread$4(target) {
4462
4493
  }));
4463
4494
  }
4464
4495
  ownKeys.forEach(function(key) {
4465
- _define_property$4(target, key, source[key]);
4496
+ _define_property$5(target, key, source[key]);
4466
4497
  });
4467
4498
  }
4468
4499
  return target;
@@ -4479,31 +4510,38 @@ function _unsupported_iterable_to_array$6(o, minLen) {
4479
4510
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$6(o, minLen);
4480
4511
  }
4481
4512
  function ModMatrixComboboxCell(param) {
4482
- var target = param.target, handleTargetChange = param.handleTargetChange, rowId = param.rowId, key = param.key, color = param.color, style = param.style;
4483
- var _SingleBarViz_polarity;
4484
- var _useState = _sliced_to_array$6(useState(), 2), targetValue = _useState[0], setTargetValue = _useState[1];
4485
- var _useState1 = _sliced_to_array$6(useState(''), 2), filterString = _useState1[0], setFilterString = _useState1[1];
4486
- var _useGlobalContext = useGlobalContext(), automatableParamLabels = _useGlobalContext.globalState.automatableParamLabels;
4513
+ var rowId = param.rowId, key = param.key, color = param.color, style = param.style;
4514
+ var _useState = _sliced_to_array$6(useState(''), 2), filterString = _useState[0], setFilterString = _useState[1];
4515
+ var _useGlobalContext = useGlobalContext(), updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, setModSlotRowTargetAsPreview = _useGlobalContext.setModSlotRowTargetAsPreview, clearModSlotPreview = _useGlobalContext.clearModSlotPreview, setNewModSlotPreview = _useGlobalContext.setNewModSlotPreview, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotPreview = _useGlobalContext_globalState.modSlotPreview, automatableParamLabels = _useGlobalContext_globalState.automatableParamLabels;
4487
4516
  var _useCombobox = useCombobox({
4488
4517
  id: rowId,
4489
- filter: filterString,
4490
- onChange: handleTargetChange
4491
- }), value = _useCombobox.value, filteredChoices = _useCombobox.filteredChoices, handleChange = _useCombobox.handleChange;
4492
- useEffect(function() {
4493
- if (target) {
4494
- var sliderState = Juce.getSliderState(target);
4495
- var scaledValue = sliderState.scaledValue;
4496
- setTargetValue(scaledValue);
4518
+ filter: filterString}), value = _useCombobox.value, filteredChoices = _useCombobox.filteredChoices;
4519
+ var previewValue = modSlotPreview.slotId === rowId ? modSlotPreview.targetIndex : null;
4520
+ var onChange = function(newValue) {
4521
+ // TODO: 'juceIndex' is needed here because the 'value' from the combobox is the string label.
4522
+ // Refactor the combobox so that the 'value' is the index number corresponding to the parameter's index in JUCE?
4523
+ // console.log(newValue, 'NV');
4524
+ var juceIndex = automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels.indexOf(newValue);
4525
+ // handleChange(juceIndex);
4526
+ if (rowId === modSlotPreview.slotId) {
4527
+ if (juceIndex > 0) {
4528
+ setModSlotRowTargetAsPreview({
4529
+ paramIndex: juceIndex
4530
+ });
4531
+ } else {
4532
+ clearModSlotPreview();
4533
+ setNewModSlotPreview();
4534
+ }
4535
+ } else {
4536
+ updateModSlotRowTarget(juceIndex, rowId);
4497
4537
  }
4498
- }, [
4499
- target
4500
- ]);
4538
+ };
4501
4539
  return /*#__PURE__*/ React__default.createElement(Box, {
4502
4540
  key: key,
4503
4541
  className: "ModMatrixCell ModMatrixComboboxCell",
4504
4542
  justifyContent: Box.justifyContent.flexEnd,
4505
4543
  flexDirection: Box.flexDirection.column,
4506
- style: _object_spread$4({
4544
+ style: _object_spread$5({
4507
4545
  color: color
4508
4546
  }, style),
4509
4547
  padding: [
@@ -4513,8 +4551,8 @@ function ModMatrixComboboxCell(param) {
4513
4551
  alignItems: Box.alignItems.flexStart,
4514
4552
  height: '2.5rem'
4515
4553
  }, /*#__PURE__*/ React__default.createElement(Combobox, {
4516
- value: value,
4517
- onChange: handleChange
4554
+ value: value || previewValue,
4555
+ onChange: onChange
4518
4556
  }, /*#__PURE__*/ React__default.createElement(Box, null, /*#__PURE__*/ React__default.createElement(ComboboxInput, {
4519
4557
  displayValue: function(item) {
4520
4558
  return value ? automatableParamLabels === null || automatableParamLabels === void 0 ? void 0 : automatableParamLabels[value] : '';
@@ -4547,17 +4585,10 @@ function ModMatrixComboboxCell(param) {
4547
4585
  key: item,
4548
4586
  value: item
4549
4587
  }, /*#__PURE__*/ React__default.createElement(Label, null, item));
4550
- }))), /*#__PURE__*/ React__default.createElement(SingleBarViz, {
4551
- value: targetValue,
4552
- polarity: SingleBarViz === null || SingleBarViz === void 0 ? void 0 : (_SingleBarViz_polarity = SingleBarViz.polarity) === null || _SingleBarViz_polarity === void 0 ? void 0 : _SingleBarViz_polarity.unipolar,
4553
- background: color,
4554
- style: {
4555
- alignSelf: 'flex-end'
4556
- }
4557
- }));
4588
+ }))));
4558
4589
  }
4559
4590
 
4560
- function _define_property$3(obj, key, value) {
4591
+ function _define_property$4(obj, key, value) {
4561
4592
  if (key in obj) {
4562
4593
  Object.defineProperty(obj, key, {
4563
4594
  value: value,
@@ -4570,7 +4601,7 @@ function _define_property$3(obj, key, value) {
4570
4601
  }
4571
4602
  return obj;
4572
4603
  }
4573
- function _object_spread$3(target) {
4604
+ function _object_spread$4(target) {
4574
4605
  for(var i = 1; i < arguments.length; i++){
4575
4606
  var source = arguments[i] != null ? arguments[i] : {};
4576
4607
  var ownKeys = Object.keys(source);
@@ -4580,28 +4611,29 @@ function _object_spread$3(target) {
4580
4611
  }));
4581
4612
  }
4582
4613
  ownKeys.forEach(function(key) {
4583
- _define_property$3(target, key, source[key]);
4614
+ _define_property$4(target, key, source[key]);
4584
4615
  });
4585
4616
  }
4586
4617
  return target;
4587
4618
  }
4588
4619
  // import * as Juce from 'juce-framework-frontend';
4589
4620
  function ModMatrixToggleCell(param) {
4590
- var modifier = param.modifier, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled; param.rowId; var color = param.color, style = param.style;
4621
+ var modifier = param.modifier, _param_isDisabled = param.isDisabled, isDisabled = _param_isDisabled === void 0 ? false : _param_isDisabled, rowId = param.rowId, color = param.color, style = param.style;
4591
4622
  var // getDefaultParameter,
4592
- updateModSlotTargetAndResetPreview = useGlobalContext().updateModSlotTargetAndResetPreview;
4623
+ saveModSlotPreviewRowTargetToBackend = useGlobalContext().saveModSlotPreviewRowTargetToBackend;
4593
4624
  // const rowState = Juce.getComboBoxState(rowId);
4594
4625
  var _useDropdown = useDropdown({
4595
4626
  id: modifier,
4627
+ rowId: rowId,
4596
4628
  isDisabled: isDisabled,
4597
- onChange: updateModSlotTargetAndResetPreview
4629
+ onChange: saveModSlotPreviewRowTargetToBackend
4598
4630
  }), index = _useDropdown.index, choices = _useDropdown.choices, handleChange = _useDropdown.handleChange;
4599
4631
  return /*#__PURE__*/ React__default.createElement(Box, {
4600
4632
  className: "ModMatrixCell ModMatrixToggleCell ".concat(isDisabled ? 'isDisabled' : ''),
4601
4633
  justifyContent: Box.justifyContent.flexEnd,
4602
4634
  alignItems: Box.alignItems.flexStart,
4603
4635
  flexDirection: Box.flexDirection.column,
4604
- style: _object_spread$3({
4636
+ style: _object_spread$4({
4605
4637
  color: color,
4606
4638
  pointerEvents: 'all'
4607
4639
  }, style),
@@ -4625,6 +4657,57 @@ function ModMatrixToggleCell(param) {
4625
4657
  }, Object.keys(Polarity)[index] || '0')));
4626
4658
  }
4627
4659
 
4660
+ function _define_property$3(obj, key, value) {
4661
+ if (key in obj) {
4662
+ Object.defineProperty(obj, key, {
4663
+ value: value,
4664
+ enumerable: true,
4665
+ configurable: true,
4666
+ writable: true
4667
+ });
4668
+ } else {
4669
+ obj[key] = value;
4670
+ }
4671
+ return obj;
4672
+ }
4673
+ function _object_spread$3(target) {
4674
+ for(var i = 1; i < arguments.length; i++){
4675
+ var source = arguments[i] != null ? arguments[i] : {};
4676
+ var ownKeys = Object.keys(source);
4677
+ if (typeof Object.getOwnPropertySymbols === "function") {
4678
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
4679
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
4680
+ }));
4681
+ }
4682
+ ownKeys.forEach(function(key) {
4683
+ _define_property$3(target, key, source[key]);
4684
+ });
4685
+ }
4686
+ return target;
4687
+ }
4688
+ function SingleBarViz(param) {
4689
+ var _param_background = param.background, background = _param_background === void 0 ? 'var(--color-brand)' : _param_background, _param_height = param.height, height = _param_height === void 0 ? '6px' : _param_height, _param_polarity = param.polarity, polarity = _param_polarity === void 0 ? Polarity.unipolar : _param_polarity, _param_orientation = param.orientation, orientation = _param_orientation === void 0 ? Orientation.horizontal : _param_orientation, value = param.value, className = param.className, style = param.style;
4690
+ return /*#__PURE__*/ React__default.createElement("div", {
4691
+ className: className,
4692
+ style: {
4693
+ width: '100%',
4694
+ height: height,
4695
+ background: 'var(--color-gray-600)',
4696
+ position: 'relative'
4697
+ }
4698
+ }, /*#__PURE__*/ React__default.createElement("div", {
4699
+ style: _object_spread$3({
4700
+ position: 'absolute',
4701
+ background: background
4702
+ }, getBarTransformStyles({
4703
+ polarity: polarity,
4704
+ orientation: orientation,
4705
+ normalisedValue: value || 0
4706
+ }), style)
4707
+ }));
4708
+ }
4709
+ SingleBarViz.polarity = Polarity;
4710
+
4628
4711
  function _define_property$2(obj, key, value) {
4629
4712
  if (key in obj) {
4630
4713
  Object.defineProperty(obj, key, {
@@ -4673,15 +4756,16 @@ function _object_spread_props(target, source) {
4673
4756
  return target;
4674
4757
  }
4675
4758
  function ModMatrixCell(param) {
4676
- var modifier = param.modifier, isDisabled = param.isDisabled, color = param.color, style = param.style;
4759
+ var modifier = param.modifier, rowId = param.rowId, isDisabled = param.isDisabled, color = param.color, style = param.style;
4677
4760
  var _SingleBarViz_polarity;
4678
- var _useGlobalContext = useGlobalContext(), setDefaultParameter = _useGlobalContext.setDefaultParameter, updateModSlotTargetAndResetPreview = _useGlobalContext.updateModSlotTargetAndResetPreview;
4761
+ var _useGlobalContext = useGlobalContext(), setDefaultParameter = _useGlobalContext.setDefaultParameter, saveModSlotPreviewRowTargetToBackend = _useGlobalContext.saveModSlotPreviewRowTargetToBackend;
4679
4762
  var _useSlider = useSlider({
4680
4763
  id: modifier,
4764
+ rowId: rowId,
4681
4765
  displayValInHeader: false,
4682
4766
  orientation: Orientation.horizontal,
4683
4767
  dragOrientation: Orientation.vertical,
4684
- onChange: updateModSlotTargetAndResetPreview,
4768
+ onChange: saveModSlotPreviewRowTargetToBackend,
4685
4769
  isDisabled: isDisabled
4686
4770
  }), bindBarSliderDrag = _useSlider.bindBarSliderDrag, normalisedValue = _useSlider.normalisedValue, scaledValue = _useSlider.scaledValue;
4687
4771
  return /*#__PURE__*/ React__default.createElement(Box, _object_spread_props(_object_spread$2({
@@ -4726,30 +4810,7 @@ function ModMatrixCell(param) {
4726
4810
  function ModMatrixRow(param) {
4727
4811
  var rowId = param.rowId, key = param.key;
4728
4812
  var _modSlotParams_rowId;
4729
- // const getModSlotsFunc = Juce.getNativeFunction('getModSlots');
4730
- var _useGlobalContext = useGlobalContext(), // modSlotTargetUpdated,
4731
- setDefaultParameter = _useGlobalContext.setDefaultParameter, modSlotPreviewIsEditableUpdated = _useGlobalContext.modSlotPreviewIsEditableUpdated, modSlotPreviewTargetIndexUpdated = _useGlobalContext.modSlotPreviewTargetIndexUpdated, setNewModSlotPreview = _useGlobalContext.setNewModSlotPreview, modSlotTargetUpdated = _useGlobalContext.modSlotTargetUpdated, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotParams = _useGlobalContext_globalState.modSlotParams, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
4732
- var handleTargetChange = function(newTarget) {
4733
- if (newTarget > 0) {
4734
- // modSlotTargetUpdated([rowId, newTarget]);
4735
- if (rowId === modSlotPreview.slotId) {
4736
- modSlotPreviewTargetIndexUpdated(newTarget);
4737
- modSlotPreviewIsEditableUpdated(true);
4738
- }
4739
- } else {
4740
- var _modSlotParams_rowId;
4741
- modSlotTargetUpdated([
4742
- rowId,
4743
- 0
4744
- ]);
4745
- modSlotParams === null || modSlotParams === void 0 ? void 0 : (_modSlotParams_rowId = modSlotParams[rowId]) === null || _modSlotParams_rowId === void 0 ? void 0 : _modSlotParams_rowId.forEach(function(item) {
4746
- setDefaultParameter(item);
4747
- });
4748
- if (!modSlotPreview.slotId) {
4749
- setNewModSlotPreview();
4750
- }
4751
- }
4752
- };
4813
+ var _useGlobalContext = useGlobalContext(), updateModSlotRowTarget = _useGlobalContext.updateModSlotRowTarget, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotParams = _useGlobalContext_globalState.modSlotParams, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
4753
4814
  return /*#__PURE__*/ React__default.createElement(Box, {
4754
4815
  className: "ModMatrixBodyRow",
4755
4816
  gap: Box.gap.medium,
@@ -4760,10 +4821,10 @@ function ModMatrixRow(param) {
4760
4821
  flexDirection: Box.flexDirection.column,
4761
4822
  style: {
4762
4823
  color: targetColors[0]
4763
- }
4824
+ },
4825
+ flex: "3"
4764
4826
  }, /*#__PURE__*/ React__default.createElement(ModMatrixComboboxCell, {
4765
- target: modSlotTargets[rowId],
4766
- handleTargetChange: handleTargetChange,
4827
+ // target={modSlotTargets[rowId]}
4767
4828
  rowId: rowId,
4768
4829
  color: targetColors[0],
4769
4830
  style: {
@@ -4778,9 +4839,10 @@ function ModMatrixRow(param) {
4778
4839
  style: {
4779
4840
  color: targetColors[i + 1]
4780
4841
  },
4781
- key: item
4842
+ key: item,
4843
+ flex: "2"
4782
4844
  }, i !== arr.length - 1 ? /*#__PURE__*/ React__default.createElement(ModMatrixCell, {
4783
- // rowId={rowId}
4845
+ rowId: rowId,
4784
4846
  modifier: modSlotParams === null || modSlotParams === void 0 ? void 0 : (_modSlotParams_rowId = modSlotParams[rowId]) === null || _modSlotParams_rowId === void 0 ? void 0 : _modSlotParams_rowId[i],
4785
4847
  color: targetColors[i + 1],
4786
4848
  isDisabled: modSlotPreview.slotId === rowId && !modSlotPreview.targetIndex
@@ -4790,7 +4852,18 @@ function ModMatrixRow(param) {
4790
4852
  color: targetColors[i + 1],
4791
4853
  isDisabled: modSlotPreview.slotId === rowId && !modSlotPreview.targetIndex
4792
4854
  }));
4793
- }));
4855
+ }), /*#__PURE__*/ React__default.createElement(Box, {
4856
+ flex: "0 0 ".concat(DeleteButtonCellWidth)
4857
+ }, /*#__PURE__*/ React__default.createElement(IconButton, {
4858
+ backgroundColor: "transparent",
4859
+ id: "delete-row",
4860
+ icon: Icon.icon.delete,
4861
+ width: "20px",
4862
+ disabled: modSlotPreview.slotId === rowId && !modSlotPreview.targetIndex,
4863
+ onClick: function() {
4864
+ return updateModSlotRowTarget(0, rowId);
4865
+ }
4866
+ })));
4794
4867
  }
4795
4868
 
4796
4869
  function _array_like_to_array$5(arr, len) {
@@ -5006,7 +5079,7 @@ function ModMatrix(param) {
5006
5079
  var getAllModSlotsFunc = Juce.getNativeFunction('getAllModSlots');
5007
5080
  var getModSlotParamsFunc = Juce.getNativeFunction('getModSlotParams');
5008
5081
  var _useState = _sliced_to_array$5(useState([]), 2), displayedModSlots = _useState[0], setDisplayedModSlots = _useState[1];
5009
- var _useGlobalContext = useGlobalContext(), automatableParamsListReceived = _useGlobalContext.automatableParamsListReceived, automatableParamLabelsReceived = _useGlobalContext.automatableParamLabelsReceived, modSlotsReceived = _useGlobalContext.modSlotsReceived, setNewModSlotPreview = _useGlobalContext.setNewModSlotPreview, modSlotParamsListReceived = _useGlobalContext.modSlotParamsListReceived, modSlotParamLabelsReceived = _useGlobalContext.modSlotParamLabelsReceived, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotParamLabels = _useGlobalContext_globalState.modSlotParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotIds = _useGlobalContext_globalState.modSlotIds, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
5082
+ var _useGlobalContext = useGlobalContext(), automatableParamsListReceived = _useGlobalContext.automatableParamsListReceived, automatableParamLabelsReceived = _useGlobalContext.automatableParamLabelsReceived, modSlotsReceived = _useGlobalContext.modSlotsReceived, modSlotRowTargetsReceived = _useGlobalContext.modSlotRowTargetsReceived, setNewModSlotPreview = _useGlobalContext.setNewModSlotPreview, modSlotParamsListReceived = _useGlobalContext.modSlotParamsListReceived, modSlotParamLabelsReceived = _useGlobalContext.modSlotParamLabelsReceived, _useGlobalContext_globalState = _useGlobalContext.globalState, modSlotParamLabels = _useGlobalContext_globalState.modSlotParamLabels, modSlotTargets = _useGlobalContext_globalState.modSlotTargets, modSlotIds = _useGlobalContext_globalState.modSlotIds, modSlotPreview = _useGlobalContext_globalState.modSlotPreview;
5010
5083
  // Empty state preview row
5011
5084
  useEffect(function() {
5012
5085
  var unassignedModSlots = modSlotIds === null || modSlotIds === void 0 ? void 0 : modSlotIds.filter(function(item) {
@@ -5020,6 +5093,10 @@ function ModMatrix(param) {
5020
5093
  modSlotIds,
5021
5094
  modSlotPreview
5022
5095
  ]);
5096
+ // console.log(
5097
+ // modSlotTargets,
5098
+ // 'modSlotTargetsmodSlotTargetsmodSlotTargetsmodSlotTargets',
5099
+ // );
5023
5100
  useEffect(function() {
5024
5101
  var _Object_keys;
5025
5102
  var displayedSlots = (_Object_keys = Object.keys(modSlotTargets)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.reduce(function(acc, item) {
@@ -5027,11 +5104,12 @@ function ModMatrix(param) {
5027
5104
  acc === null || acc === void 0 ? void 0 : acc.push(item);
5028
5105
  }
5029
5106
  return acc;
5030
- }, []).sort();
5107
+ }, []);
5108
+ // .sort();
5031
5109
  var unassignedModSlots = modSlotIds === null || modSlotIds === void 0 ? void 0 : modSlotIds.filter(function(item) {
5032
5110
  return modSlotTargets[item] <= 0;
5033
5111
  });
5034
- if (unassignedModSlots.length > 0) {
5112
+ if (unassignedModSlots.length > 0 && modSlotPreview.slotId) {
5035
5113
  setDisplayedModSlots(_to_consumable_array(displayedSlots).concat([
5036
5114
  modSlotPreview.slotId
5037
5115
  ]));
@@ -5078,6 +5156,7 @@ function ModMatrix(param) {
5078
5156
  automatableParamsListReceived(automatableParamsList === null || automatableParamsList === void 0 ? void 0 : automatableParamsList[0]);
5079
5157
  automatableParamLabelsReceived(automatableParamsList === null || automatableParamsList === void 0 ? void 0 : automatableParamsList[1]);
5080
5158
  modSlotsReceived(modSlotsData || []);
5159
+ modSlotRowTargetsReceived(modSlotsData || []);
5081
5160
  modSlotParamsListReceived(modSlotParams === null || modSlotParams === void 0 ? void 0 : modSlotParams[0]);
5082
5161
  modSlotParamLabelsReceived(modSlotParams === null || modSlotParams === void 0 ? void 0 : modSlotParams[1]);
5083
5162
  return [
@@ -5106,7 +5185,9 @@ function ModMatrix(param) {
5106
5185
  ]);
5107
5186
  var headers = [
5108
5187
  'Target'
5109
- ].concat(_to_consumable_array(modSlotParamLabels));
5188
+ ].concat(_to_consumable_array(modSlotParamLabels), [
5189
+ ''
5190
+ ]);
5110
5191
  return /*#__PURE__*/ React__default.createElement(Box, {
5111
5192
  gap: Box.gap.medium,
5112
5193
  padding: [
@@ -5125,7 +5206,7 @@ function ModMatrix(param) {
5125
5206
  return /*#__PURE__*/ React__default.createElement(Box, {
5126
5207
  style: {
5127
5208
  color: targetColors[i],
5128
- flex: i === 0 ? "0 0 ".concat(ComboboxCellWidth) : 'initial'
5209
+ flex: i === 0 ? "0 0 ".concat(ComboboxCellWidth) : i === headers.length - 1 ? "0 0 ".concat(DeleteButtonCellWidth) : '2'
5129
5210
  },
5130
5211
  key: item,
5131
5212
  className: "ModMatrixHeaderCell",
@@ -5141,7 +5222,7 @@ function ModMatrix(param) {
5141
5222
  }, (displayedModSlots === null || displayedModSlots === void 0 ? void 0 : displayedModSlots.length) ? displayedModSlots === null || displayedModSlots === void 0 ? void 0 : displayedModSlots.map(function(item, i) {
5142
5223
  return /*#__PURE__*/ React__default.createElement(ModMatrixRow, {
5143
5224
  rowId: item,
5144
- key: item
5225
+ key: "".concat(item + i)
5145
5226
  });
5146
5227
  }) : null));
5147
5228
  }