diff --git a/DotnetViewComponents/Component1.razor b/DotnetViewComponents/Component1.razor deleted file mode 100644 index 2be03f1c4b..0000000000 --- a/DotnetViewComponents/Component1.razor +++ /dev/null @@ -1,3 +0,0 @@ -
- This component is defined in the DotnetViewComponents library. -
diff --git a/DotnetViewComponents/Component1.razor.css b/DotnetViewComponents/Component1.razor.css deleted file mode 100644 index 34110cc870..0000000000 --- a/DotnetViewComponents/Component1.razor.css +++ /dev/null @@ -1,6 +0,0 @@ -.my-component { - border: 2px dashed red; - padding: 1em; - margin: 1em 0; - background-image: url('background.png'); -} diff --git a/DotnetViewComponents/Css/Shared/components/cancelLink.css b/DotnetViewComponents/Css/Shared/components/cancelLink.css deleted file mode 100644 index 0b0e744f79..0000000000 --- a/DotnetViewComponents/Css/Shared/components/cancelLink.css +++ /dev/null @@ -1 +0,0 @@ -.nhsuk-back-link__link{padding-left:24px}.nhsuk-icon__close{height:24px;left:-2px;position:absolute;top:-1px;width:24px}/*# sourceMappingURL=cancelLink.css.map */ diff --git a/DotnetViewComponents/Css/Shared/components/cancelLink.css.map b/DotnetViewComponents/Css/Shared/components/cancelLink.css.map deleted file mode 100644 index 08759d5d44..0000000000 --- a/DotnetViewComponents/Css/Shared/components/cancelLink.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sourceRoot":"","sources":["../../../../Styles/shared/components/cancelLink.scss"],"names":[],"mappings":"AAAA,uBACE,kBAKF,mBACE,YACA,UACA,kBACA,SACA","file":"cancelLink.css"} \ No newline at end of file diff --git a/DotnetViewComponents/DotnetViewComponents.csproj b/DotnetViewComponents/DotnetViewComponents.csproj deleted file mode 100644 index fe51c94311..0000000000 --- a/DotnetViewComponents/DotnetViewComponents.csproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - net8.0 - enable - enable - - - - - - - - - - - - diff --git a/DotnetViewComponents/ExampleJsInterop.cs b/DotnetViewComponents/ExampleJsInterop.cs deleted file mode 100644 index 1a2e030bfd..0000000000 --- a/DotnetViewComponents/ExampleJsInterop.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Microsoft.JSInterop; - -namespace DotnetViewComponents; - -// This class provides an example of how JavaScript functionality can be wrapped -// in a .NET class for easy consumption. The associated JavaScript module is -// loaded on demand when first needed. -// -// This class can be registered as scoped DI service and then injected into Blazor -// components for use. - -public class ExampleJsInterop : IAsyncDisposable -{ - private readonly Lazy> moduleTask; - - public ExampleJsInterop(IJSRuntime jsRuntime) - { - moduleTask = new (() => jsRuntime.InvokeAsync( - "import", "./_content/DotnetViewComponents/exampleJsInterop.js").AsTask()); - } - - public async ValueTask Prompt(string message) - { - var module = await moduleTask.Value; - return await module.InvokeAsync("showPrompt", message); - } - - public async ValueTask DisposeAsync() - { - if (moduleTask.IsValueCreated) - { - var module = await moduleTask.Value; - await module.DisposeAsync(); - } - } -} diff --git a/DotnetViewComponents/Extensions/StringExtensions.cs b/DotnetViewComponents/Extensions/StringExtensions.cs deleted file mode 100644 index e4e293f525..0000000000 --- a/DotnetViewComponents/Extensions/StringExtensions.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace DotnetViewComponents.Extensions -{ - using System; - - public static class StringExtensions - { - public static string RemoveWhitespace(this string str) - { - return string.Join("", str.Split(default(string[]), StringSplitOptions.RemoveEmptyEntries)); - } - } -} diff --git a/DotnetViewComponents/Helpers/ViewComponentDynamicAttributeHelper.cs b/DotnetViewComponents/Helpers/ViewComponentDynamicAttributeHelper.cs deleted file mode 100644 index f0876d3c47..0000000000 --- a/DotnetViewComponents/Helpers/ViewComponentDynamicAttributeHelper.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace DotnetViewComponents.Helpers -{ - public static class ViewComponentDynamicAttributeHelper - { - public static string? GetAriaDescribedByAttribute(this string name, bool hasError, string? hintText) - { - string? describedBy = hasError ? name + "-error" : null; - if (hintText != null) - { - describedBy = describedBy == null ? "" : describedBy += " "; - describedBy += name + "-hint"; - } - return describedBy; - } - } -} diff --git a/DotnetViewComponents/Helpers/ViewComponentValueToSetHelper.cs b/DotnetViewComponents/Helpers/ViewComponentValueToSetHelper.cs deleted file mode 100644 index af28f2fae5..0000000000 --- a/DotnetViewComponents/Helpers/ViewComponentValueToSetHelper.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace DotnetViewComponents.Helpers -{ - using System.Collections.Generic; - using System.Linq; - using Microsoft.AspNetCore.Mvc.ViewFeatures; - - public static class ViewComponentValueToSetHelper - { - public static string DeriveValueToSet(ref string aspFor, bool populateWithCurrentValue, object model, ViewDataDictionary viewData, out IEnumerable errorMessages) - { - string valueToSet; - var types = aspFor.Split('.'); - - if (types.Length == 1) - { - valueToSet = ValueToSetForSimpleType( - model, - aspFor, - populateWithCurrentValue, - viewData, - out errorMessages - ); - } - else - { - valueToSet = ValueToSetForComplexType( - model, - aspFor, - populateWithCurrentValue, - types, - viewData, - out errorMessages - ); - aspFor = types[1]; - } - - return valueToSet; - } - - public static string ValueToSetForSimpleType(object model, string aspFor, bool populateWithCurrentValue, ViewDataDictionary viewData, out IEnumerable errorMessages) - { - - var property = model.GetType().GetProperty(aspFor); - var valueToSet = populateWithCurrentValue ? property?.GetValue(model)?.ToString() : null; - - errorMessages = viewData.ModelState[property?.Name]?.Errors.Select(e => e.ErrorMessage) ?? - new string[] { }; - - return valueToSet; - } - public static string ValueToSetForComplexType(object model, string aspFor, bool populateWithCurrentValue, string[] types, ViewDataDictionary viewData, out IEnumerable errorMessages) - { - var firstProperty = model.GetType().GetProperty(types[0]); - var nestedProperty = firstProperty.PropertyType.GetProperty(types[1]); - - var valueToSetOfFirstProperty = populateWithCurrentValue ? firstProperty?.GetValue(model) : null; - var valueToSetOfNestedProperty = populateWithCurrentValue ? nestedProperty?.GetValue(valueToSetOfFirstProperty)?.ToString() : null; - - errorMessages = viewData.ModelState[firstProperty?.Name]?.Errors.Select(e => e.ErrorMessage) ?? - new string[] { }; - - return valueToSetOfNestedProperty; - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/ActionLinkViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/ActionLinkViewComponent.cs deleted file mode 100644 index 38b8579646..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/ActionLinkViewComponent.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class ActionLinkViewComponent : ViewComponent - { - public IViewComponentResult Invoke(string aspController, string aspAction, Dictionary aspAllRouteData, string linkText) - { - return View(new LinkViewModel(aspController, aspAction, linkText, aspAllRouteData)); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/BackLinkViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/BackLinkViewComponent.cs deleted file mode 100644 index 13930f4695..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/BackLinkViewComponent.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class BackLinkViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string aspController, - string aspAction, - Dictionary aspAllRouteData, - string linkText - ) - { - return View(new LinkViewModel(aspController, aspAction, linkText, aspAllRouteData)); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/CancelLinkViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/CancelLinkViewComponent.cs deleted file mode 100644 index 5a8f445ce8..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/CancelLinkViewComponent.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class CancelLinkViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string aspController, - string aspAction, - Dictionary aspAllRouteData - ) - { - return View(new LinkViewModel(aspController, aspAction, "Cancel", aspAllRouteData)); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/CheckboxesViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/CheckboxesViewComponent.cs deleted file mode 100644 index b9bb80a4cf..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/CheckboxesViewComponent.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using System.Linq; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class CheckboxesViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string label, - IEnumerable checkboxes, - bool populateWithCurrentValues, - string? errormessage, - string? hintText, - bool required, - string cssClass = default - ) - { - var checkboxList = checkboxes.Select( - c => new CheckboxItemViewModel( - c.AspFor, - c.AspFor, - c.Label, - GetValueFromModel(c.AspFor, populateWithCurrentValues), - c.HintText, - null - ) - ); - - var viewModel = new CheckboxesViewModel( - label, - string.IsNullOrEmpty(hintText) ? null : hintText, - errormessage, - checkboxList, - required, - string.IsNullOrEmpty(cssClass) ? null : cssClass - ); - - return View(viewModel); - } - - private bool GetValueFromModel(string aspFor, bool populateWithCurrentValue) - { - var model = ViewData.Model; - - var property = model.GetType().GetProperty(aspFor); - return populateWithCurrentValue && (bool)property?.GetValue(model)!; - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/DateInputViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/DateInputViewComponent.cs deleted file mode 100644 index 4c4f87e4bb..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/DateInputViewComponent.cs +++ /dev/null @@ -1,70 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using System.Linq; - using Microsoft.AspNetCore.Mvc; - using Microsoft.AspNetCore.Mvc.ModelBinding; - using DotnetViewComponents.ViewModels.NHS; - - public class DateInputViewComponent : ViewComponent - { - /// - /// Render DateInput view component. - /// - /// - /// - /// - /// - /// - /// Leave blank for no custom css class. - /// Leave blank for no hint. - /// Leave blank/false for set label as page body . - /// - public IViewComponentResult Invoke( - string id, - string label, - string dayId, - string monthId, - string yearId, - string cssClass, - IEnumerable? hintTextLines, - bool? isPageHeading = false - ) - { - var model = ViewData.Model; - - var dayProperty = model.GetType().GetProperty(dayId); - var monthProperty = model.GetType().GetProperty(monthId); - var yearProperty = model.GetType().GetProperty(yearId); - var dayValue = dayProperty?.GetValue(model)?.ToString(); - var monthValue = monthProperty?.GetValue(model)?.ToString(); - var yearValue = yearProperty?.GetValue(model)?.ToString(); - var dayErrors = ViewData.ModelState[dayProperty?.Name]?.Errors ?? new ModelErrorCollection(); - var monthErrors = ViewData.ModelState[monthProperty?.Name]?.Errors ?? new ModelErrorCollection(); - var yearErrors = ViewData.ModelState[yearProperty?.Name]?.Errors ?? new ModelErrorCollection(); - - var allErrors = dayErrors.Concat(monthErrors).Concat(yearErrors); - var nonEmptyErrors = allErrors.Where(e => !string.IsNullOrWhiteSpace(e.ErrorMessage)) - .Select(e => e.ErrorMessage); - - var viewModel = new DateInputViewModel( - id, - label, - dayId, - monthId, - yearId, - dayValue, - monthValue, - yearValue, - dayErrors?.Count > 0, - monthErrors?.Count > 0, - yearErrors?.Count > 0, - nonEmptyErrors, - string.IsNullOrEmpty(cssClass) ? null : cssClass, - hintTextLines.Any() ? hintTextLines : null, - isPageHeading - ); - return View(viewModel); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/DateRangeInputViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/DateRangeInputViewComponent.cs deleted file mode 100644 index 667f36760a..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/DateRangeInputViewComponent.cs +++ /dev/null @@ -1,129 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Linq; - using Microsoft.AspNetCore.Mvc; - using Microsoft.AspNetCore.Mvc.ModelBinding; - using DotnetViewComponents.ViewModels.NHS; - - public class DateRangeInputViewComponent : ViewComponent - { - /// - /// Render DateInput view component. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// Leave blank for no hint. - /// Leave blank for no hint. - /// - public IViewComponentResult Invoke( - string id, - string label, - string startDayId, - string startMonthId, - string startYearId, - string endDayId, - string endMonthId, - string endYearId, - string endDateCheckboxId, - string endDateCheckboxLabel, - string hintText, - string endDateCheckboxHintText - ) - { - var model = ViewData.Model; - - var (startDayValue, startDayErrors) = GetStringValueAndErrorsForProperty(model, startDayId); - var (startMonthValue, startMonthErrors) = GetStringValueAndErrorsForProperty(model, startMonthId); - var (startYearValue, startYearErrors) = GetStringValueAndErrorsForProperty(model, startYearId); - - var (endDayValue, endDayErrors) = GetStringValueAndErrorsForProperty(model, endDayId); - var (endMonthValue, endMonthErrors) = GetStringValueAndErrorsForProperty(model, endMonthId); - var (endYearValue, endYearErrors) = GetStringValueAndErrorsForProperty(model, endYearId); - - var checkboxProperty = model.GetType().GetProperty(endDateCheckboxId); - var checkboxValue = (bool)checkboxProperty?.GetValue(model)!; - - var checkboxViewModel = new CheckboxItemViewModel( - endDateCheckboxId, - endDateCheckboxId, - endDateCheckboxLabel, - checkboxValue, - endDateCheckboxHintText, - null - ); - - var allStartDateErrors = (startDayErrors ?? new ModelErrorCollection()) - .Concat(startMonthErrors ?? new ModelErrorCollection()) - .Concat(startYearErrors ?? new ModelErrorCollection()); - var nonEmptyStartDateErrors = allStartDateErrors.Where(e => !string.IsNullOrWhiteSpace(e.ErrorMessage)) - .Select(e => e.ErrorMessage); - - var startDateModel = new DateInputViewModel( - "start-date", - "Start date", - startDayId, - startMonthId, - startYearId, - startDayValue, - startMonthValue, - startYearValue, - startDayErrors?.Count > 0, - startMonthErrors?.Count > 0, - startYearErrors?.Count > 0, - nonEmptyStartDateErrors, - "nhsuk-u-margin-bottom-3" - ); - - var allEndDateErrors = (endDayErrors ?? new ModelErrorCollection()) - .Concat(endMonthErrors ?? new ModelErrorCollection()) - .Concat(endYearErrors ?? new ModelErrorCollection()); - var nonEmptyEndDateErrors = allEndDateErrors.Where(e => !string.IsNullOrWhiteSpace(e.ErrorMessage)) - .Select(e => e.ErrorMessage); - - var endDateModel = new DateInputViewModel( - "conditional-end-date", - "End date", - endDayId, - endMonthId, - endYearId, - endDayValue, - endMonthValue, - endYearValue, - endDayErrors?.Count > 0, - endMonthErrors?.Count > 0, - endYearErrors?.Count > 0, - nonEmptyEndDateErrors, - "nhsuk-checkboxes__conditional" + (!checkboxValue ? " nhsuk-checkboxes__conditional--hidden" : "") - ); - - var viewModel = new DateRangeInputViewModel( - id, - label, - startDateModel, - endDateModel, - checkboxViewModel, - string.IsNullOrEmpty(hintText) ? null : hintText - ); - return View(viewModel); - } - - private (string? Value, ModelErrorCollection? Errors) GetStringValueAndErrorsForProperty( - object model, - string propertyId - ) - { - var property = model.GetType().GetProperty(propertyId); - var value = property?.GetValue(model)?.ToString(); - var errors = ViewData.ModelState[property?.Name]?.Errors; - return (value, errors); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/ErrorSummaryViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/ErrorSummaryViewComponent.cs deleted file mode 100644 index b0bed4b404..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/ErrorSummaryViewComponent.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using System.Linq; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class ErrorSummaryViewComponent : ViewComponent - { - public IViewComponentResult Invoke(string[]? orderOfPropertyNames) - { - var errors = ViewData.ModelState - .SelectMany(kvp => kvp.Value.Errors.Select(e => new ErrorSummaryListItem(kvp.Key, e.ErrorMessage))) - .ToList(); - - var orderedErrors = GetOrderedErrors(errors, orderOfPropertyNames ?? new string[0]); - - var errorSummaryViewModel = new ErrorSummaryViewModel(orderedErrors); - return View(errorSummaryViewModel); - } - - private static List GetOrderedErrors( - List errors, - string[] orderOfPropertyNames) - { - return errors.OrderBy(e => orderOfPropertyNames.ToList().IndexOf(e.Key)).ToList(); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/FileInputViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/FileInputViewComponent.cs deleted file mode 100644 index b16018833a..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/FileInputViewComponent.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class FileInputViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string aspFor, - string label, - string? hintText, - string? cssClass - ) - { - var model = ViewData.Model; - - var property = model.GetType().GetProperty(aspFor); - - var hasError = ViewData.ModelState[property?.Name]?.Errors?.Count > 0; - var errorMessage = hasError ? ViewData.ModelState[property?.Name]?.Errors[0].ErrorMessage : null; - - var fileInputViewModel = new FileInputViewModel( - aspFor, - aspFor, - label, - cssClass, - hintText, - errorMessage, - hasError - ); - return View(fileInputViewModel); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/NumericInputViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/NumericInputViewComponent.cs deleted file mode 100644 index 01c40e7bc6..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/NumericInputViewComponent.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Linq; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class NumericInputViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string aspFor, - string label, - bool populateWithCurrentValue, - string type, - string hintText, - string cssClass, - bool required, - string? requiredClientSideErrorMessage = default, - string? regularExClientSideErrorMessage = default - ) - { - var model = ViewData.Model; - - var property = model.GetType().GetProperty(aspFor); - var valueToSet = populateWithCurrentValue ? property?.GetValue(model)?.ToString() : null; - - var errorMessages = ViewData.ModelState[property?.Name]?.Errors.Select(e => e.ErrorMessage) ?? - new string[] { }; - - var numericInputViewModel = new NumericInputViewModel( - aspFor, - aspFor, - label, - valueToSet, - type, - errorMessages, - string.IsNullOrEmpty(cssClass) ? null : cssClass, - string.IsNullOrEmpty(hintText) ? null : hintText, - required, - string.IsNullOrEmpty(requiredClientSideErrorMessage) ? null : requiredClientSideErrorMessage, - string.IsNullOrEmpty(regularExClientSideErrorMessage) ? null : regularExClientSideErrorMessage - ); - return View(numericInputViewModel); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/RadioListViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/RadioListViewComponent.cs deleted file mode 100644 index 40dd466bcb..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/RadioListViewComponent.cs +++ /dev/null @@ -1,66 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using System.Linq; - - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class RadioListViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string aspFor, - string label, - IEnumerable radios, - bool populateWithCurrentValues, - string hintText, - bool required, - string? requiredClientSideErrorMessage = default, - string cssClass = default, - string? optionalRadio = default, - bool? isPageHeading = false - ) - { - var model = ViewData.Model; - var property = model.GetType().GetProperty(aspFor); - var errorMessages = ViewData.ModelState[property?.Name]?.Errors.Select(e => e.ErrorMessage) ?? - new string[] { }; - - var radiosList = radios.Where(x=>x.Label != optionalRadio).Select( - r => new RadiosItemViewModel( - r.Value, - r.Label, - IsSelectedRadio(aspFor, r, populateWithCurrentValues), - r.HintText - ) - ); - - - var viewModel = new RadiosViewModel( - aspFor, - label, - string.IsNullOrEmpty(hintText) ? null : hintText, - radiosList, - string.IsNullOrEmpty(optionalRadio) ? null : radios.Where(x => x.Label == optionalRadio) - .Select(r => new RadiosItemViewModel(r.Value, r.Label, IsSelectedRadio(aspFor, r, populateWithCurrentValues), r.HintText)) - .FirstOrDefault(), - errorMessages, - required, - string.IsNullOrEmpty(requiredClientSideErrorMessage) ? null : requiredClientSideErrorMessage, - string.IsNullOrEmpty(cssClass) ? null : cssClass, - isPageHeading - ); - - return View(viewModel); - } - - private bool IsSelectedRadio(string aspFor, RadiosItemViewModel radioItem, bool populateWithCurrentValue) - { - var model = ViewData.Model; - var property = model.GetType().GetProperty(aspFor); - var value = property?.GetValue(model); - - return populateWithCurrentValue && value != null && value.Equals(radioItem.Value); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/SelectListViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/SelectListViewComponent.cs deleted file mode 100644 index ea70f4811e..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/SelectListViewComponent.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Collections.Generic; - using Microsoft.AspNetCore.Mvc; - using Microsoft.AspNetCore.Mvc.Rendering; - using DotnetViewComponents.ViewModels.NHS; - - public class SelectListViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string aspFor, - string label, - string value, - string? defaultOption, - IEnumerable selectListOptions, - string? hintText, - string? cssClass, - bool required, - string? requiredClientSideErrorMessage = default - ) - { - var model = ViewData.Model; - - var property = model.GetType().GetProperty(aspFor); - - var hasError = ViewData.ModelState[property?.Name]?.Errors?.Count > 0; - var errorMessage = hasError ? ViewData.ModelState[property?.Name]?.Errors[0].ErrorMessage : null; - - var selectListViewModel = new SelectListViewModel( - aspFor, - aspFor, - label, - string.IsNullOrEmpty(value) ? null : value, - selectListOptions, - string.IsNullOrEmpty(defaultOption) ? null : defaultOption, - string.IsNullOrEmpty(cssClass) ? null : cssClass, - string.IsNullOrEmpty(hintText) ? null : hintText, - errorMessage, - hasError, - required, - string.IsNullOrEmpty(requiredClientSideErrorMessage) ? null : requiredClientSideErrorMessage - ); - return View(selectListViewModel); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/SingleCheckboxViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/SingleCheckboxViewComponent.cs deleted file mode 100644 index 769a7585a3..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/SingleCheckboxViewComponent.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Linq; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class SingleCheckboxViewComponent : ViewComponent - { - public IViewComponentResult Invoke( - string aspFor, - string label, - string? hintText - ) - { - var model = ViewData.Model; - var property = model.GetType().GetProperty(aspFor); - var valueToSet = (bool)(property?.GetValue(model) ?? false); - var errorMessage = ViewData.ModelState[property?.Name]?.Errors?.FirstOrDefault()?.ErrorMessage; - - var viewModel = new CheckboxItemViewModel( - aspFor, - aspFor, - label, - valueToSet, - hintText, - errorMessage - ); - return View(viewModel); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/TextAreaViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/TextAreaViewComponent.cs deleted file mode 100644 index 60d685e5c0..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/TextAreaViewComponent.cs +++ /dev/null @@ -1,54 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using Microsoft.AspNetCore.Mvc; - using NHSUKViewComponents.Web.Helpers; - using DotnetViewComponents.ViewModels.NHS; - - public class TextAreaViewComponent : ViewComponent - { - /// - /// Render TextArea view component. - /// - /// - /// - /// - /// - /// - /// Leave blank for no hint. - /// - /// - /// - /// - public IViewComponentResult Invoke( - string aspFor, - string label, - bool populateWithCurrentValue, - int rows, - bool spellCheck, - string hintText, - string cssClass, - int? characterCount, - string? maxLengthClientSideErrorMessage = default - ) - { - var model = ViewData.Model; - - var valueToSet = ViewComponentValueToSetHelper.DeriveValueToSet(ref aspFor, populateWithCurrentValue, model, ViewData, out var errorMessages); - - var textBoxViewModel = new TextAreaViewModel( - aspFor, - aspFor, - label, - valueToSet, - rows, - spellCheck, - errorMessages, - string.IsNullOrEmpty(cssClass) ? null : cssClass, - string.IsNullOrEmpty(hintText) ? null : hintText, - characterCount, - maxLengthClientSideErrorMessage - ); - return View(textBoxViewModel); - } - } -} diff --git a/DotnetViewComponents/ViewComponents/NHS/TextInputViewComponent.cs b/DotnetViewComponents/ViewComponents/NHS/TextInputViewComponent.cs deleted file mode 100644 index 7d0ceb44a1..0000000000 --- a/DotnetViewComponents/ViewComponents/NHS/TextInputViewComponent.cs +++ /dev/null @@ -1,65 +0,0 @@ -namespace DotnetViewComponents.ViewComponents.NHS -{ - using System.Linq; - using Microsoft.AspNetCore.Mvc; - using DotnetViewComponents.ViewModels.NHS; - - public class TextInputViewComponent : ViewComponent - { - /// - /// Render TextInput view component. - /// - /// - /// - /// - /// - /// - /// Leave blank for no hint. - /// Leave blank to set no autocomplete on the input element. - /// - /// - /// - /// - /// - public IViewComponentResult Invoke( - string aspFor, - string label, - bool populateWithCurrentValue, - string type, - bool spellCheck, - string hintText, - string autocomplete, - string cssClass, - bool required, - string? placeholderText = null, - string? requiredClientSideErrorMessage = default - ) - { - var model = ViewData.Model; - - var property = model.GetType().GetProperty(aspFor); - var valueToSet = populateWithCurrentValue ? property?.GetValue(model)?.ToString() : null; - - var errorMessages = ViewData.ModelState[property?.Name]?.Errors.Select(e => e.ErrorMessage) ?? - new string[] { }; - - var textBoxViewModel = new TextInputViewModel( - aspFor, - aspFor, - label, - valueToSet, - type, - spellCheck, - string.IsNullOrEmpty(autocomplete) ? null : autocomplete, - errorMessages, - string.IsNullOrEmpty(cssClass) ? null : cssClass, - string.IsNullOrEmpty(hintText) ? null : hintText, - required, - string.IsNullOrEmpty(placeholderText) ? null : placeholderText, - string.IsNullOrEmpty(requiredClientSideErrorMessage) ? null : requiredClientSideErrorMessage - ); - return View(textBoxViewModel); - } - } - -} diff --git a/DotnetViewComponents/ViewComponents/TEL/.tel b/DotnetViewComponents/ViewComponents/TEL/.tel deleted file mode 100644 index b9f58d802d..0000000000 --- a/DotnetViewComponents/ViewComponents/TEL/.tel +++ /dev/null @@ -1 +0,0 @@ -This file serves as a place-holder \ No newline at end of file diff --git a/DotnetViewComponents/ViewModels/NHS/CheckboxItemViewModel.cs b/DotnetViewComponents/ViewModels/NHS/CheckboxItemViewModel.cs deleted file mode 100644 index eeb01cc3f0..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/CheckboxItemViewModel.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - public class CheckboxItemViewModel - { - public readonly bool HasError; - - public CheckboxItemViewModel( - string id, - string name, - string label, - bool value, - string? hintText, - string? errorMessage - ) - { - Id = id; - Name = name; - Label = label; - Value = value; - HintText = hintText; - ErrorMessage = errorMessage; - HasError = errorMessage != null; - } - - public string Id { get; set; } - - public string Name { get; set; } - - public string Label { get; set; } - - public bool Value { get; set; } - - public string? HintText { get; set; } - - public string? ErrorMessage { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/CheckboxListItemViewModel.cs b/DotnetViewComponents/ViewModels/NHS/CheckboxListItemViewModel.cs deleted file mode 100644 index 142173d9f6..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/CheckboxListItemViewModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - public class CheckboxListItemViewModel - { - public CheckboxListItemViewModel(string aspFor, string label, string? hintText) - { - AspFor = aspFor; - Label = label; - HintText = hintText; - } - - public string AspFor { get; set; } - - public string Label { get; set; } - - public string? HintText { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/CheckboxesViewModel.cs b/DotnetViewComponents/ViewModels/NHS/CheckboxesViewModel.cs deleted file mode 100644 index 41de80d6d6..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/CheckboxesViewModel.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - - public class CheckboxesViewModel - { - public CheckboxesViewModel( - string label, - string? hintText, - string? errormessage, - IEnumerable checkboxes, - bool required = false, - string? cssClass = default - ) - { - Label = label; - HintText = hintText; - Checkboxes = checkboxes; - ErrorMessage = errormessage; - Required = required; - Class = cssClass; - } - - public string Label { get; set; } - - public string? HintText { get; set; } - - public string? Class { get; set; } - - public string? ErrorMessage { get; set; } - - public IEnumerable Checkboxes { get; set; } - - public bool Required { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/DateInputViewModel.cs b/DotnetViewComponents/ViewModels/NHS/DateInputViewModel.cs deleted file mode 100644 index f7421a17f6..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/DateInputViewModel.cs +++ /dev/null @@ -1,61 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - - public class DateInputViewModel - { - public readonly bool HasDayError; - public readonly bool HasMonthError; - public readonly bool HasYearError; - - public DateInputViewModel( - string id, - string label, - string dayId, - string monthId, - string yearId, - string? dayValue, - string? monthValue, - string? yearValue, - bool hasDayError, - bool hasMonthError, - bool hasYearError, - IEnumerable errorMessages, - string? cssClass = null, - IEnumerable? hintTextLines = null, - bool? isPageHeading = false - ) - { - Id = id; - Label = label; - DayId = dayId; - MonthId = monthId; - YearId = yearId; - DayValue = dayValue; - MonthValue = monthValue; - YearValue = yearValue; - CssClass = cssClass; - HintTextLines = hintTextLines; - IsPageHeading = isPageHeading; - HasDayError = hasDayError; - HasMonthError = hasMonthError; - HasYearError = hasYearError; - ErrorMessages = errorMessages; - } - - public string Id { get; set; } - public string Label { get; set; } - public string DayId { get; set; } - public string MonthId { get; set; } - public string YearId { get; set; } - public string? DayValue { get; set; } - public string? MonthValue { get; set; } - public string? YearValue { get; set; } - public string? CssClass { get; set; } - public IEnumerable? HintTextLines { get; set; } - public bool? IsPageHeading { get; set; } - - public bool HasError => HasDayError || HasMonthError || HasYearError; - public IEnumerable ErrorMessages { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/DateRangeInputViewModel.cs b/DotnetViewComponents/ViewModels/NHS/DateRangeInputViewModel.cs deleted file mode 100644 index aa08198760..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/DateRangeInputViewModel.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - public class DateRangeInputViewModel - { - public DateRangeInputViewModel( - string id, - string label, - DateInputViewModel startDateModel, - DateInputViewModel endDateModel, - CheckboxItemViewModel endDateCheckboxViewModel, - string? hintText = null - ) - { - Id = id; - Label = label; - StartDateModel = startDateModel; - EndDateModel = endDateModel; - EndDateCheckbox = endDateCheckboxViewModel; - HintText = hintText; - } - - public string Id { get; set; } - public string Label { get; set; } - public string? HintText { get; set; } - - public DateInputViewModel StartDateModel { get; set; } - - public DateInputViewModel EndDateModel { get; set; } - - public CheckboxItemViewModel EndDateCheckbox { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/ErrorSummaryViewModel.cs b/DotnetViewComponents/ViewModels/NHS/ErrorSummaryViewModel.cs deleted file mode 100644 index f6532eae2f..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/ErrorSummaryViewModel.cs +++ /dev/null @@ -1,27 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - - public class ErrorSummaryViewModel - { - public ErrorSummaryViewModel(List errors) - { - Errors = errors; - } - - public List Errors { get; set; } - } - - public class ErrorSummaryListItem - { - public ErrorSummaryListItem(string key, string errorMessage) - { - Key = key; - ErrorMessage = errorMessage; - } - - public string Key { get; set; } - - public string ErrorMessage { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/FileInputViewModel.cs b/DotnetViewComponents/ViewModels/NHS/FileInputViewModel.cs deleted file mode 100644 index 531b87d362..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/FileInputViewModel.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - public class FileInputViewModel - { - public FileInputViewModel - ( - string id, - string name, - string label, - string? cssClass = null, - string? hintText = null, - string? errorMessage = null, - bool hasError = false - ) - { - Id = id; - Class = cssClass; - Name = name; - Label = label; - HintText = hintText; - ErrorMessage = errorMessage; - HasError = hasError; - } - - public string Id { get; set; } - public string? Class { get; set; } - public string Name { get; set; } - public string Label { get; set; } - public string? HintText { get; set; } - public string? ErrorMessage { get; set; } - public bool HasError { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/LinkViewModel.cs b/DotnetViewComponents/ViewModels/NHS/LinkViewModel.cs deleted file mode 100644 index c47f3ed8cd..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/LinkViewModel.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - - public class LinkViewModel - { - public readonly string AspAction; - - public readonly string AspController; - - public readonly string LinkText; - - public readonly Dictionary AspAllRouteData; - - public LinkViewModel(string aspController, string aspAction, string linkText, Dictionary aspAllRouteData) - { - AspAction = aspAction; - AspController = aspController; - LinkText = linkText; - AspAllRouteData = aspAllRouteData; - } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/NumericInputViewModel.cs b/DotnetViewComponents/ViewModels/NHS/NumericInputViewModel.cs deleted file mode 100644 index 3b703f0bd9..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/NumericInputViewModel.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - using System.Linq; - - public class NumericInputViewModel - { - public readonly bool HasError; - - public NumericInputViewModel( - string id, - string name, - string label, - string? value, - string type, - IEnumerable errorMessages, - string? cssClass = null, - string? hintText = null, - bool required = false, - string? requiredClientSideErrorMessage = default, - string? regularExClientSideErrorMessage = default - ) - { - var errorMessageList = errorMessages.ToList(); - - Id = id; - Class = cssClass; - Name = name; - Label = (!required && !label.EndsWith("(optional)") ? label + " (optional)" : label); - Value = value; - Type = type; - HintText = hintText; - ErrorMessages = errorMessageList; - HasError = errorMessageList.Any(); - Required = required; - RequiredClientSideErrorMessage = requiredClientSideErrorMessage; - RegularExClientSideErrorMessage = regularExClientSideErrorMessage; - } - - public string Id { get; set; } - public string? Class { get; set; } - public string Name { get; set; } - public string Label { get; set; } - public string? Value { get; set; } - public string Type { get; set; } - public string? HintText { get; set; } - public IEnumerable ErrorMessages { get; set; } - public bool Required { get; set; } - public string? RequiredClientSideErrorMessage { get; set; } - public string? RegularExClientSideErrorMessage { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/RadiosItemViewModel.cs b/DotnetViewComponents/ViewModels/NHS/RadiosItemViewModel.cs deleted file mode 100644 index 237eb60ac6..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/RadiosItemViewModel.cs +++ /dev/null @@ -1,21 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - public class RadiosItemViewModel - { - public RadiosItemViewModel(string value, string label, bool selected, string hintText) - { - Value = value; - Label = label; - Selected = selected; - HintText = hintText; - } - - public string Value { get; set; } - - public string Label { get; set; } - - public bool Selected { get; set; } - - public string HintText { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/RadiosViewModel.cs b/DotnetViewComponents/ViewModels/NHS/RadiosViewModel.cs deleted file mode 100644 index a1356b14fd..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/RadiosViewModel.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - using System.Linq; - - public class RadiosViewModel - { - public RadiosViewModel( - string aspFor, - string label, - string hintText, - IEnumerable radios, - RadiosItemViewModel optionalRadio, - IEnumerable errorMessages, - bool required, - string? requiredClientSideErrorMessage = default, - string? cssClass = default, - bool? isPageHeading = false - ) - { - var errorMessageList = errorMessages.ToList(); - AspFor = aspFor; - Label = !required && !label.EndsWith("(optional)") ? label + " (optional)" : label; - HintText = hintText; - Radios = radios; - OptionalRadio = optionalRadio; - ErrorMessages = errorMessageList; - HasError = errorMessageList.Any(); - Required = required; - RequiredClientSideErrorMessage = requiredClientSideErrorMessage; - Class = cssClass; - IsPageHeading = isPageHeading; - } - - public string AspFor { get; set; } - - public string Label { get; set; } - - public string HintText { get; set; } - public string? Class { get; set; } - public IEnumerable ErrorMessages { get; set; } - public readonly bool HasError; - - public IEnumerable Radios { get; set; } - public RadiosItemViewModel OptionalRadio { get; set; } - public bool? IsPageHeading { get; set; } - public bool Required { get; set; } - public string RequiredClientSideErrorMessage { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/SelectListViewModel.cs b/DotnetViewComponents/ViewModels/NHS/SelectListViewModel.cs deleted file mode 100644 index d3641d4fbe..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/SelectListViewModel.cs +++ /dev/null @@ -1,51 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - using Microsoft.AspNetCore.Mvc.Rendering; - - public class SelectListViewModel - { - public SelectListViewModel - ( - string id, - string name, - string label, - string? value, - IEnumerable selectListOptions, - string? defaultOption = null, - string? cssClass = null, - string? hintText = null, - string? errorMessage = null, - bool hasError = false, - bool required = false, - string? requiredClientErrorMessage = default - ) - { - Id = id; - Class = cssClass; - Name = name; - Label = (!required && !label.EndsWith("(optional)") ? label + " (optional)" : label); - Value = value; - DefaultOption = defaultOption; - SelectListOptions = selectListOptions; - HintText = hintText; - ErrorMessage = errorMessage; - HasError = hasError; - Required = required; - RequiredClientSideErrorMessage = requiredClientErrorMessage; - } - - public string Id { get; set; } - public string? Class { get; set; } - public string Name { get; set; } - public string Label { get; set; } - public string? Value { get; set; } - public string? DefaultOption { get; set; } - public IEnumerable SelectListOptions { get; set; } - public string? HintText { get; set; } - public string? ErrorMessage { get; set; } - public bool HasError { get; set; } - public bool Required { get; set; } - public string? RequiredClientSideErrorMessage { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/TextAreaViewModel.cs b/DotnetViewComponents/ViewModels/NHS/TextAreaViewModel.cs deleted file mode 100644 index 9717ab92cb..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/TextAreaViewModel.cs +++ /dev/null @@ -1,52 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - using System.Linq; - - public class TextAreaViewModel - { - public TextAreaViewModel - ( - string id, - string name, - string label, - string? value, - int rows, - bool spellCheck, - IEnumerable errorMessages, - string? cssClass = null, - string? hintText = null, - int? characterCount = null, - string? maxLengthClientSideErrorMessage = default - ) - { - var errorMessageList = errorMessages.ToList(); - - Id = id; - Class = cssClass; - Name = name; - Label = label; - Value = value; - Rows = rows; - SpellCheck = spellCheck; - HintText = hintText; - CharacterCount = characterCount; - ErrorMessages = errorMessageList; - HasError = errorMessageList.Any(); - MaxLengthClientSideErrorMessage = maxLengthClientSideErrorMessage; - } - - public string Id { get; set; } - public string? Class { get; set; } - public string Name { get; set; } - public string Label { get; set; } - public string? Value { get; set; } - public int Rows { get; set; } - public bool SpellCheck { get; set; } - public string? HintText { get; set; } - public int? CharacterCount { get; set; } - public IEnumerable ErrorMessages { get; set; } - public bool HasError { get; set; } - public string MaxLengthClientSideErrorMessage { get; set; } - } -} diff --git a/DotnetViewComponents/ViewModels/NHS/TextInputViewModel.cs b/DotnetViewComponents/ViewModels/NHS/TextInputViewModel.cs deleted file mode 100644 index 74c5c9a8ba..0000000000 --- a/DotnetViewComponents/ViewModels/NHS/TextInputViewModel.cs +++ /dev/null @@ -1,64 +0,0 @@ -namespace DotnetViewComponents.ViewModels.NHS -{ - using System.Collections.Generic; - using System.Linq; - - public class TextInputViewModel - { - public TextInputViewModel( - string id, - string name, - string label, - string? value, - string type, - bool spellCheck, - string? autocomplete, - IEnumerable errorMessages, - string? cssClass = null, - string? hintText = null, - bool required = false, - string? placeholder = null, - string? requiredSideClientErrorMessage = default - string? prefix = null - string? suffix = null - ) - { - var errorMessageList = errorMessages.ToList(); - - Id = id; - Class = cssClass; - Name = name; - Label = (!required && !label.EndsWith("(optional)") ? label + " (optional)" : label); - Value = value; - Type = type; - SpellCheck = spellCheck; - Autocomplete = autocomplete; - HintText = hintText; - Required = required; - ErrorMessages = errorMessageList; - HasError = errorMessageList.Any(); - PlaceHolder = placeholder; - RequiredClientSideErrorMessage = requiredSideClientErrorMessage; - Prefix = prefix - Suffix = suffix - } - - public string Id { get; set; } - public string? Class { get; set; } - public string Name { get; set; } - public string Label { get; set; } - public string? Value { get; set; } - public string Type { get; set; } - public bool SpellCheck { get; set; } - public string? Autocomplete { get; set; } - public string? HintText { get; set; } - public bool Required { get; set; } - public IEnumerable ErrorMessages { get; set; } - public readonly bool HasError; - public string? PlaceHolder { get; set; } - public string? RequiredClientSideErrorMessage { get; set; } - public string? Prefix { get; set; } - public string? Suffix { get; set; } - } - -} diff --git a/DotnetViewComponents/ViewModels/Shared/.shared b/DotnetViewComponents/ViewModels/Shared/.shared deleted file mode 100644 index b9f58d802d..0000000000 --- a/DotnetViewComponents/ViewModels/Shared/.shared +++ /dev/null @@ -1 +0,0 @@ -This file serves as a place-holder \ No newline at end of file diff --git a/DotnetViewComponents/ViewModels/TEL/.tel b/DotnetViewComponents/ViewModels/TEL/.tel deleted file mode 100644 index b9f58d802d..0000000000 --- a/DotnetViewComponents/ViewModels/TEL/.tel +++ /dev/null @@ -1 +0,0 @@ -This file serves as a place-holder \ No newline at end of file diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/ActionLink/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/ActionLink/Default.cshtml deleted file mode 100644 index 638a3025a0..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/ActionLink/Default.cshtml +++ /dev/null @@ -1,12 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model LinkViewModel - - diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/BackLink/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/BackLink/Default.cshtml deleted file mode 100644 index 8a5f6b1ac6..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/BackLink/Default.cshtml +++ /dev/null @@ -1,11 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model LinkViewModel - - diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/CancelLink/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/CancelLink/Default.cshtml deleted file mode 100644 index 53f5e091dc..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/CancelLink/Default.cshtml +++ /dev/null @@ -1,13 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model LinkViewModel - - - - diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/Checkboxes/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/Checkboxes/Default.cshtml deleted file mode 100644 index 5700a389ae..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/Checkboxes/Default.cshtml +++ /dev/null @@ -1,48 +0,0 @@ -@using DotnetViewComponents.Extensions -@using DotnetViewComponents.ViewModels.NHS -@model CheckboxesViewModel - -
-
- - - - - @if (Model.HintText != null) - { -
- @Html.Raw(Model.HintText) -
- } - @if ( - Model.Required - && Model.Checkboxes.Where(x => x.Value).Count() == 0 - ) - { -
- - @Model.ErrorMessage - -
- } - -
- @foreach (var checkbox in Model.Checkboxes) - { - if (!string.IsNullOrWhiteSpace(Model.Class)) - { -
- -
- } - else - { - - } - - } -
-
-
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/DateInput/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/DateInput/Default.cshtml deleted file mode 100644 index 1a76462da8..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/DateInput/Default.cshtml +++ /dev/null @@ -1,135 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model DateInputViewModel - -@{ - var errorCss = Model.HasError ? "nhsuk-form-group--error" : ""; - var dayErrorCss = Model.HasDayError ? "nhsuk-input--error" : ""; - var monthErrorCss = Model.HasMonthError ? "nhsuk-input--error" : ""; - var yearErrorCss = Model.HasYearError ? "nhsuk-input--error" : ""; - var hintTextLine = string.Empty; -} - -
-
- - @if (Model.IsPageHeading.GetValueOrDefault() == true) - { -

- @Model.Label -

- } - else - { - @Model.Label - } -
- - @if (Model.HintTextLines != null) - { - @foreach (var hintText in Model.HintTextLines) - { - hintTextLine = hintText; - } - } - -
- @hintTextLine -
- - @if (Model.HasError) - { - @foreach (var message in Model.ErrorMessages) - { - - Error: @message - - } - } - -
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- -
-
- -
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/DateRangeInput/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/DateRangeInput/Default.cshtml deleted file mode 100644 index 0f0072701c..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/DateRangeInput/Default.cshtml +++ /dev/null @@ -1,52 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model DateRangeInputViewModel -@{ - var hintText = string.Empty; - var endCheckboxhintText = string.Empty; -} - -
-
- - @Model.Label - - - @if (Model.HintText != null) - { - hintText = Model.HintText; - } - -
- @hintText -
- - -
-
- - - - @if (Model.EndDateCheckbox.HintText != null) - { - endCheckboxhintText = @Model.EndDateCheckbox.HintText; - } -
- @endCheckboxhintText -
-
- - -
- -
-
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/ErrorSummary/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/ErrorSummary/Default.cshtml deleted file mode 100644 index 7dc289a5d8..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/ErrorSummary/Default.cshtml +++ /dev/null @@ -1,40 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model ErrorSummaryViewModel - -@if (Model.Errors.Any()) -{ - - -} -else -{ - -} diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/FileInput/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/FileInput/Default.cshtml deleted file mode 100644 index d93b997227..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/FileInput/Default.cshtml +++ /dev/null @@ -1,25 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@using DotnetViewComponents.Helpers -@model FileInputViewModel -
- - @if (Model.HintText != null) { -
- @Model.HintText -
- } - @if (Model.HasError) - { - - Error: @Model.ErrorMessage - - } - -
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/NumericInput/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/NumericInput/Default.cshtml deleted file mode 100644 index 00b400cdf3..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/NumericInput/Default.cshtml +++ /dev/null @@ -1,46 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@using DotnetViewComponents.Helpers -@model NumericInputViewModel -
- - @if (Model.HintText != null) - { -
- @Html.Raw(Model.HintText) -
- } - @if (Model.HasError) - { -
- @foreach (var errorMessage in Model.ErrorMessages) - { - - Error: @errorMessage - - } -
- } - - @if(!Model.HasError) - { -
-
- } - - -
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/RadioList/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/RadioList/Default.cshtml deleted file mode 100644 index a45472903a..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/RadioList/Default.cshtml +++ /dev/null @@ -1,149 +0,0 @@ -@using DotnetViewComponents.Extensions -@using DotnetViewComponents.ViewModels.NHS - -@model RadiosViewModel -@{ - int counter = 0; - -} - -
- -
- - @if (Model.IsPageHeading.GetValueOrDefault() == true) - { -

- @Model.Label -

- } - else - { - @Model.Label - } -
- - @if (Model.HintText != null) - { -
- @Html.Raw(Model.HintText) -
- } - - @if (Model.HasError) - { -
- @foreach (var errorMessage in Model.ErrorMessages) - { - - Error: @errorMessage - - } -
- } - - @if (Model.Required && !Model.HasError) - { - - } - -
- @foreach (var (radio, index) in Model.Radios.Select((r, i) => (r, i))) - { - counter = index; - var radioId = $"{radio.Value}-{index}"; - if (!string.IsNullOrWhiteSpace(Model.Class)) - { -
-
- - - @if (radio.HintText != null) - { -
- @radio.HintText -
- } -
-
- } - else - { -
- - - @if (radio.HintText != null) - { -
- @radio.HintText -
- } -
- } - - } - @if (Model.OptionalRadio != null) - { -
or
- var radioId = $"{Model.OptionalRadio.Value}-{++counter}"; -
- - - @if (Model.OptionalRadio.HintText != null) - { -
- @Model.OptionalRadio.HintText -
- } -
- } - -
-
- -
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/SelectList/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/SelectList/Default.cshtml deleted file mode 100644 index 43d5bb2575..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/SelectList/Default.cshtml +++ /dev/null @@ -1,41 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@using DotnetViewComponents.Helpers -@model SelectListViewModel - -
- - @if (Model.HintText != null) - { -
- @Html.Raw(Model.HintText) -
- } - @if (Model.HasError) - { - - Error: @Model.ErrorMessage - - } - @if (Model.Required && !Model.HasError) - { -
-
- } - -
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/SingleCheckbox/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/SingleCheckbox/Default.cshtml deleted file mode 100644 index 8dad5c76a9..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/SingleCheckbox/Default.cshtml +++ /dev/null @@ -1,16 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model CheckboxItemViewModel - -
-
- @if (Model.HasError) - { - - Error: @Model.ErrorMessage - - } - - -
-
diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/TextArea/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/TextArea/Default.cshtml deleted file mode 100644 index 96a545b9a9..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/TextArea/Default.cshtml +++ /dev/null @@ -1,57 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@using DotnetViewComponents.Helpers -@model TextAreaViewModel -@{ - string? describedBy = ViewComponentDynamicAttributeHelper.GetAriaDescribedByAttribute(Model.Name, Model.HasError, Model.HintText); - @if (Model.CharacterCount.HasValue) - { - describedBy = describedBy == null ? "" : describedBy += " "; - describedBy += @Model.Name + "-info"; - } -} -
- - @if (Model.HintText != null) - { -
- @Html.Raw(Model.HintText) -
- } - @if (Model.HasError) - { -
- @foreach (var errorMessage in Model.ErrorMessages) - { - - Error: @errorMessage - - } -
- } - @if (Model.CharacterCount.HasValue && !Model.HasError) - { -
-
- } - - - @if (Model.CharacterCount.HasValue) - { -
- You can enter up to @Model.CharacterCount characters -
- } -
- diff --git a/DotnetViewComponents/Views/Shared/Components/NHS/TextInput/Default.cshtml b/DotnetViewComponents/Views/Shared/Components/NHS/TextInput/Default.cshtml deleted file mode 100644 index 75c9043f63..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/NHS/TextInput/Default.cshtml +++ /dev/null @@ -1,52 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@using DotnetViewComponents.Helpers -@model TextInputViewModel -
- - @if (Model.HintText != null) - { -
- @Html.Raw(Model.HintText) -
- } - @if (Model.HasError) - { -
- @foreach (var errorMessage in Model.ErrorMessages) - { - - Error: @errorMessage - - } -
- } - @if (Model.Required && !Model.HasError) - { -
-
- } - - - @if (Model.Prefix) - { - - } - - @if (Model.Suffix) - { - - } -
diff --git a/DotnetViewComponents/Views/Shared/Components/TEL/.tel b/DotnetViewComponents/Views/Shared/Components/TEL/.tel deleted file mode 100644 index b9f58d802d..0000000000 --- a/DotnetViewComponents/Views/Shared/Components/TEL/.tel +++ /dev/null @@ -1 +0,0 @@ -This file serves as a place-holder \ No newline at end of file diff --git a/DotnetViewComponents/Views/Shared/_CheckboxItem.cshtml b/DotnetViewComponents/Views/Shared/_CheckboxItem.cshtml deleted file mode 100644 index 296b5098d5..0000000000 --- a/DotnetViewComponents/Views/Shared/_CheckboxItem.cshtml +++ /dev/null @@ -1,45 +0,0 @@ -@using DotnetViewComponents.ViewModels.NHS -@model CheckboxItemViewModel -@{ - var describedBy = ""; - @if (Model.HasError) - { - describedBy = @Model.Name + "-error"; - } - @if (Model.HintText != null) - { - if (Model.HintText != "") - { - describedBy += (describedBy != "" ? " " : ""); - describedBy += @Model.Name + "-hint"; - } - } -} -
-
- - aria-describedby="@describedBy" - - } - value="true" - @if(Model.HasError) - { - aria-invalid="true" - } - @(Model.Value ? "checked" : string.Empty) /> - - @if (Model.HintText != null) - { -
- @Model.HintText -
- } -
-
diff --git a/DotnetViewComponents/_Imports.razor b/DotnetViewComponents/_Imports.razor deleted file mode 100644 index 77285129da..0000000000 --- a/DotnetViewComponents/_Imports.razor +++ /dev/null @@ -1 +0,0 @@ -@using Microsoft.AspNetCore.Components.Web diff --git a/DotnetViewComponents/wwwroot/background.png b/DotnetViewComponents/wwwroot/background.png deleted file mode 100644 index e15a3bde6e..0000000000 Binary files a/DotnetViewComponents/wwwroot/background.png and /dev/null differ diff --git a/DotnetViewComponents/wwwroot/exampleJsInterop.js b/DotnetViewComponents/wwwroot/exampleJsInterop.js deleted file mode 100644 index b178a47157..0000000000 --- a/DotnetViewComponents/wwwroot/exampleJsInterop.js +++ /dev/null @@ -1,6 +0,0 @@ -// This is a JavaScript module that is loaded on demand. It can export any number of -// functions, and may import other JavaScript modules if required. - -export function showPrompt(message) { - return prompt(message, 'Type anything here') -}