forked from CodeBeamOrg/CodeBeam.MudBlazor.Extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMudDateWheelPicker.razor
More file actions
73 lines (69 loc) · 5.7 KB
/
MudDateWheelPicker.razor
File metadata and controls
73 lines (69 loc) · 5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@namespace MudExtensions
@inherits MudBaseInput<DateTime?>
<CascadingValue Name="SubscribeToParentForm" Value="false" IsFixed="true">
<div>
<MudInputControl Label="@Label" Variant="@Variant" HelperText="@HelperText" HelperTextOnFocus="@HelperTextOnFocus" FullWidth="@FullWidth" Margin="@Margin" Class="@Classname" Style="@Style"
Error="@Error" ErrorText="@ErrorText" ErrorId="@ErrorId" Disabled="@Disabled" @onclick="@(Editable ? null : ToggleMenu)" Required="@Required" ForId="@FieldId">
<InputContent>
<MudInput @ref="InputReference" Margin="@Margin" Placeholder="@Placeholder" Label="@Label"
Variant="@Variant" InputType="InputType.Text"
TextUpdateSuppression="false"
Value="@(Text)" Underline="@Underline"
Disabled="@Disabled" ReadOnly="!Editable" Error="@Error" ErrorId="@ErrorId"
OnAdornmentClick="HandleAdornmentClick" AdornmentIcon="@InputAdornmentIcon" Adornment="@InputAdornment"
AdornmentColor="@AdornmentColor" IconSize="@IconSize" OnBlur="HandleOnBlur"
Clearable="@Clearable" OnClearButtonClick="HandleClearButtonClick"
@attributes="UserAttributes" />
<MudPopover Class="@PopoverClass" Style="@PopoverStyle" Open=@(_isOpen) MaxHeight="@MaxHeight" AnchorOrigin="@AnchorOrigin" TransformOrigin="@TransformOrigin" RelativeWidth="DropdownWidth.Relative">
@if (ShowToolbar || SubmitOnClose == false)
{
<div class="d-flex">
@if (SubmitOnClose == false)
{
<MudIconButton Icon="@Icons.Material.Filled.Done" Color="@Color" OnClick="@(() => CloseMenu(true))" />
}
<MudSpacer />
@if (ShowToolbar)
{
<MudIconButton Icon="@Icons.Material.Filled.Sync" Color="@Color" Disabled="@(DateView == DateView.Both)" OnClick="@(() => ToggleDateView())" />
<MudIconButton Icon="@(DateView == DateView.Both ? Icons.Material.Filled.ChevronLeft : Icons.Material.Filled.ChevronRight)" Color="@Color" OnClick="@(() => ExpandDateView())" />
}
</div>
}
<div class="d-flex">
@if (DateView == DateView.Date || DateView == DateView.Both)
{
string dateFormat = new string(DateFormat);
foreach (var ch in dateFormat.Distinct())
{
switch (ch)
{
case 'd':
<MudWheel Class="mud-width-full" @bind-Value="_day" ItemCollection="Days" Sensitivity="@Sensitivity" Label="@(ShowHeader ? LocalizedStrings.Day : null)" ToStringFunc="new Func<int, string>(NumberToString)" Dense="@Dense" Color="@Color" Disabled="FixDay" />
break;
case 'M':
<MudWheel Class="mud-width-full" Value="_month" ValueChanged=@((int m) => OnMonthChanged(m)) ItemCollection="Months" Sensitivity="@Sensitivity" Label="@(ShowHeader ? LocalizedStrings.Month : null)" ToStringFunc="new Func<int, string>(NumberToString)" Dense="@Dense" Color="@Color" Disabled="FixMonth" />
break;
case 'y':
<MudWheel Class="mud-width-full" @bind-Value:get="_year" @bind-Value:set="@((int y) => OnYearChanged(y))" ItemCollection="Years" Sensitivity="@Sensitivity" Label="@(ShowHeader ? LocalizedStrings.Year : null)" Dense="@Dense" Color="@Color" Disabled="FixYear" />
break;
}
}
}
@if (DateView == DateView.Time || DateView == DateView.Both)
{
<MudWheel Class="mud-width-full" @bind-Value="_hour" ItemCollection="Hours" Sensitivity="@Sensitivity" Label="@(ShowHeader ? LocalizedStrings.Hour : null)" ToStringFunc="new Func<int, string>(NumberToString)" Dense="@Dense" Color="@(ColorTime == Color.Inherit ? Color : ColorTime)" Disabled="FixHour" />
<MudWheel Class="mud-width-full" @bind-Value="_minute" ItemCollection="Minutes" Sensitivity="@Sensitivity" Label="@(ShowHeader ? LocalizedStrings.Minute : null)" ToStringFunc="new Func<int, string>(NumberToString)" Dense="@Dense" Color="@(ColorTime == Color.Inherit ? Color : ColorTime)" Disabled="FixMinute" />
@if (HasSeconds())
{
<MudWheel Class="mud-width-full" @bind-Value="_second" ItemCollection="Seconds" Sensitivity="@Sensitivity" Label="@(ShowHeader ? LocalizedStrings.Second : null)" ToStringFunc="new Func<int, string>(NumberToString)" Dense="@Dense" Color="@(ColorTime == Color.Inherit ? Color : ColorTime)" Disabled="FixSecond" />
}
}
</div>
</MudPopover>
</InputContent>
</MudInputControl>
</div>
</CascadingValue>
<!-- mousedown instead of click needed to close the menu before OnLostFocus runs -->
<MudOverlay Visible="_isOpen" @onpointerdown="@(() => CloseMenu(SubmitOnClose))" LockScroll="@LockScroll" />