Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageVersion Include="MudBlazor" Version="9.12.0" />
<PackageVersion Include="MessageFormat" Version="8.0.0" />
<PackageVersion Include="xunit.v3" Version="4.0.2" />
<PackageVersion Include="bunit" Version="2.13.3" />
<PackageVersion Include="bunit" Version="2.14.0" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="10.11.0" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.11.0" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.12.0" />
Expand Down
24 changes: 21 additions & 3 deletions docs/en/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,26 @@ await Act.RunAsync(() => Store.DeleteAsync(order), done: "Order deleted");
```

- A `PanelException(message)` shows its message to the user as is, and so does any exception registered with [`ShowMessageOf`](errors.md). Any other exception shows a general message and is logged.
- After a successful action, everything on the page that reports to `CurrentPage` reloads. Pass `Refresh="false"` (`refresh: false`) to skip it.
- `RunAsync` returns whether the action ran to the end.
- After a successful or a failed action, everything on the page that reports to `CurrentPage` reloads: a failure often means the data has changed under the user, such as a record deleted elsewhere. A declined confirmation and a cancelled action leave the page alone. Pass `Refresh="false"` (`refresh: false`) to skip it.
- `RunAsync` returns an `ActResult`, so the caller can tell the cases apart.

| `ActResult` | What happened | Page reloaded |
| ----------- | ---------------------------------------------------------------- | ------------- |
| `Done` | The action ran to the end. | Yes |
| `Declined` | The user declined the `Confirm` question; nothing ran. | No |
| `Cancelled` | The action was cancelled, for example the user left the page. | No |
| `Failed` | The action threw; the user has been told. | Yes |

Confirmation belongs to `Act` too, so there is no need to ask separately and reload by hand:

```csharp
var result = await Act.RunAsync(
() => Store.IssueAsync(client),
confirm: new Confirm("Reissue the key?", "The old key stops working.", "Reissue"));

if (result is ActResult.Done)
await Dialogs.ShowConnectionAsync(client);
```

## Button parameters

Expand All @@ -29,7 +47,7 @@ await Act.RunAsync(() => Store.DeleteAsync(order), done: "Order deleted");
| `OnClick` | The action. The button is disabled and shows that it is busy until it ends. |
| `Confirm` | `Confirm(Question, Message, Yes, Danger)` asked before the action. |
| `Done` | Message shown after success. |
| `Refresh` | Reloads the page's blocks after success. Default `true`. |
| `Refresh` | Reloads the page's blocks after success or failure. Default `true`. |
| `Submit` | Renders a submit button and leaves the work to the form. |
| `Busy`, `Disabled` | Show the button as busy or disabled from outside. |

Expand Down
51 changes: 50 additions & 1 deletion docs/en/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `Facts`, `Fact` | A record's labelled values: `<Fact Label="Total" Value="order.Total" />`, formatted by `ViewerTime.Of`, or own content. |
| `Tag` | A status label with `Tone`: `Neutral`, `Good`, `Warn` or `Bad`. |
| `Notice` | An inline message with `Tone`, `Title`, content and `Actions`. Warnings and errors are announced as alerts. |
| `Banner` | A `Notice` for the top of a page, square and tinted. `Dismissible` adds a close button; `OnDismiss` tells the host, which decides whether to remember it. |
| `Menu`, `MenuItem` | A "⋯" menu for row actions, e.g. in a `Slot`. A `MenuItem` runs `OnClick` through `Act` and takes `Confirm`, `Done`, `Refresh`, `Danger` and `Disabled` like `Button`. For links use `MudMenuItem`. |
| `Steps` | A vertical progress of a process from `Step(Title, State, Detail)`; `State` is `Pending`, `Current`, `Done` or `Failed`. |
| `Wizard`, `WizardStep` | A multi-step flow: `Steps` and the open `WizardStep` (`Title`, `Detail`, `OnLeave`) with Back, Next and Finish. `@bind-Current`, `OnFinish`, `Done`, `Confirm`. See below. |
| `Tabs`, `Tab` | Tabs whose choice lives in the address (`tab=`, or `Name`). A `Tab` has `Title` and optional `Name`; only the open tab renders. |
| `Timeline` | Events from `TimelineEntry(At, Text, Who, Tone)`, newest first, in the viewer's time zone. |
| `Pane` | A titled section of a page with `Hint` and `Actions`. |
Expand All @@ -17,13 +22,15 @@
| `Placeholder` | Skeleton for content that is still loading. |
| `AutoRefresh` | Invokes `OnTick` every `AutoRefreshInterval` while the tab is visible. |
| `Sheet` | Layout for a sheet: `ChildContent` and `Actions`. |
| `Figure` | Large number with two caption lines (`First`, `Second`). `Alarm` marks it red. `Change` (a share: `0.12` is +12%) shows the change to the previous period, good when it grows unless `LowerIsBetter`. Group in `<div class="figs">`. |
| `Figure` | Large number with two caption lines (`First`, `Second`). `Alarm` marks it red. `Change` (a share: `0.12` is +12%) shows the change to the previous period, good when it grows unless `LowerIsBetter`. `Spark` adds a small line of recent values. Group in `<div class="figs">`. |
| `Chart` | A line or bar chart over time from `Trend(Name, Readings)` of `Reading(At, Value)`. See below. |
| `Strips` | Horizontal bars for a ranking, from `Strip(Label, Value, Shown)`. |
| `Sparkline` | A tiny chart for a table cell or a caption from `Values`: a line with its last point marked, or `Bars`. `Tone` colors it; `Summary` makes it an image for screen readers, without it it is decoration. |
| `Meter` | `Used / Limit` with a bar that turns ochre at 90% and red at 100%. |
| `Crumb` | Removable filter chip that links to the address without the filter. |
| `CopyLine`, `CopyButton` | A value with a copy button. |
| `Output` | A bordered box for logs and command output: `Text` and `Empty`, the line shown when there is no text. |
| `CodeEditor` | A code editor on CodeMirror: `Value` is the initial text, `Language` (`python`) turns on highlighting, `ReadOnly` locks it. `OnChange` fires on every edit; read the text with `GetValueAsync()`, replace it with `SetValueAsync()`. The height is set by `.code-editor`. |
| `Adder` | A one-line add form: `Placeholder`, `OnAdd` with the trimmed text, `Done`, and the button label as content. Enter adds too. |
| `KeyField` | A secret token in groups, with a copy button. |
| `EntranceLayout` | Full-screen layout without navigation, for sign-in pages: `@layout EntranceLayout`. |
Expand Down Expand Up @@ -110,3 +117,45 @@ Without a `Limit` it shows the number alone.
```

The open tab is `?tab=history` in the address, so a link opens the page on the right tab and Back works as expected. Two `Tabs` on one page need distinct `Name`s.


## Row menu

A `Menu` is a "⋯" button for the actions of one row. Put it in a `Slot`; clicking it does not open the row. An item runs through `Act` like a `Button`, so a confirmation, the "done" message, failure handling and the page refresh come with it:

```razor
<Slot Title="">
<Menu>
<MenuItem OnClick="() => ArchiveAsync(context)" Done="Archived">Archive</MenuItem>
<MenuItem OnClick="() => DeleteAsync(context)" Danger
Confirm="@(new Confirm("Delete the order?", "It cannot be restored.", "Delete", Danger: true))">Delete</MenuItem>
</Menu>
</Slot>
```

`Label` names the button for screen readers (default "Row actions"). For a link, use `MudMenuItem Href`.

## Wizard

A `Wizard` shows `Steps` next to the open step and the buttons that move between them. Only the open `WizardStep` renders. `Current` is the index of the open step; bind it with `@bind-Current` to read or set it, or leave it out and the wizard keeps it itself.

```razor
<Wizard @bind-Current="_step" OnFinish="CreateAsync" Done="Order created">
<WizardStep Title="Customer" Detail="@_draft.Customer" OnLeave="CheckCustomer">
<MudTextField @bind-Value="_draft.Customer" Label="Customer" />
</WizardStep>
<WizardStep Title="Delivery">
<MudTextField @bind-Value="_draft.Address" Label="Address" />
</WizardStep>
</Wizard>

@code {
private void CheckCustomer()
{
if (string.IsNullOrWhiteSpace(_draft.Customer))
throw new PanelException("Enter the customer");
}
}
```

`OnLeave` runs when the user presses "Next", or "Finish" on the last step. A `PanelException` keeps the user on the step, marks it failed in the header and shows its message. "Next" never reloads the page. "Finish" runs `OnFinish` through `Act`, so `Done`, `Confirm` and `Refresh` work as on a `Button`; `Finish` changes its label. Back is always free.
1 change: 1 addition & 0 deletions docs/en/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ builder.Services.AddEnfilade(shell => shell.Appearance = Appearance.System);
| Option | Default | Description |
| ----------------------- | ------------ | ----------------------------------------------- |
| `Brand` | `Enfilade` | Name in the navigation and document titles. |
| `ShowVersion` | `true` | Shows the Enfilade version under the brand. |
| `Favicon` | — | Static asset path of the icon. |
| `Language` | `en` | Default language. Must be one of `Languages`. |
| `Languages` | — | Languages offered in the switch. |
Expand Down
24 changes: 21 additions & 3 deletions docs/ru/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,26 @@ await Act.RunAsync(() => Store.DeleteAsync(order), done: "Order deleted");
```

- `PanelException(message)` показывает своё сообщение пользователю как есть. Так же ведёт себя любое исключение, зарегистрированное через [`ShowMessageOf`](errors.md). Остальные исключения показывают общее сообщение и попадают в лог.
- После успешного действия перезагружается всё на странице, что отчитывается перед `CurrentPage`. Чтобы пропустить это, передайте `Refresh="false"` (`refresh: false`).
- `RunAsync` возвращает, дошло ли действие до конца.
- После успешного или упавшего действия перезагружается всё на странице, что отчитывается перед `CurrentPage`: ошибка часто значит, что данные изменились у пользователя за спиной, например запись удалили в другом месте. Отказ в подтверждении и отменённое действие страницу не трогают. Чтобы пропустить перезагрузку, передайте `Refresh="false"` (`refresh: false`).
- `RunAsync` возвращает `ActResult`, чтобы вызывающий код различал случаи.

| `ActResult` | Что произошло | Страница перезагружена |
| ----------- | ---------------------------------------------------------------- | ---------------------- |
| `Done` | Действие дошло до конца. | Да |
| `Declined` | Пользователь отказался в вопросе `Confirm`, ничего не выполнялось. | Нет |
| `Cancelled` | Действие отменено, например пользователь ушёл со страницы. | Нет |
| `Failed` | Действие выбросило исключение, пользователь об этом уведомлён. | Да |

Подтверждение тоже выполняет `Act`, поэтому спрашивать отдельно и перезагружать вручную не нужно:

```csharp
var result = await Act.RunAsync(
() => Store.IssueAsync(client),
confirm: new Confirm("Reissue the key?", "The old key stops working.", "Reissue"));

if (result is ActResult.Done)
await Dialogs.ShowConnectionAsync(client);
```

## Параметры Button

Expand All @@ -29,7 +47,7 @@ await Act.RunAsync(() => Store.DeleteAsync(order), done: "Order deleted");
| `OnClick` | Действие. Пока оно идёт, кнопка отключена и показывает занятость. |
| `Confirm` | `Confirm(Question, Message, Yes, Danger)` — вопрос перед действием. |
| `Done` | Сообщение после успеха. |
| `Refresh` | Перезагружает блоки страницы после успеха. По умолчанию `true`. |
| `Refresh` | Перезагружает блоки страницы после успеха или ошибки. По умолчанию `true`. |
| `Submit` | Рисует кнопку отправки и оставляет работу форме. |
| `Busy`, `Disabled` | Показывают кнопку занятой или отключённой снаружи. |

Expand Down
Loading