@implements IDisposable @using TuringMachine.Core @inject IJSRuntime JS @inject LocalizationService Loc

@Loc["label.actionTable"]

@{ int rowIndex = 0; } @foreach (var item in Transitions.Items) { var isActive = CurrentState == item.Key.State && (CurrentReadSymbol == item.Key.ReadSymbol); var rowId = $"row-{rowIndex}"; rowIndex++; if (isActive) { activeRowId = rowId; } }
@Loc["table.no"] @Loc["table.currentState"] @Loc["table.read"] @Loc["table.newState"] @Loc["table.write"] @Loc["table.move"] @Loc["table.comment"]
@rowIndex @item.Key.State @item.Key.ReadSymbol @item.Value.NewState @item.Value.WriteSymbol @item.Value.MoveDirection @item.Value.Comment
@code { [Parameter] public TransitionTable Transitions { get; set; } = new(); [Parameter] public string CurrentState { get; set; } = string.Empty; [Parameter] public char CurrentReadSymbol { get; set; } private ElementReference tableContainer; private string? activeRowId; protected override void OnInitialized() { Loc.OnLanguageChanged += OnLanguageChanged; } protected override async Task OnAfterRenderAsync(bool firstRender) { if (!string.IsNullOrEmpty(activeRowId)) { await JS.InvokeVoidAsync("scrollToElement", activeRowId); } } private void OnLanguageChanged() => InvokeAsync(StateHasChanged); public void Dispose() { Loc.OnLanguageChanged -= OnLanguageChanged; } }