From d96f444a6b2cecfaa49eeb6df75546e84b3eb03c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 19 Jul 2019 12:32:55 -0700 Subject: [PATCH] Add support for type="number" and type="date" --- .../ref/Microsoft.AspNetCore.Components.netstandard2.0.cs | 2 ++ src/Components/Components/src/BindAttributes.cs | 6 ++++++ .../testassets/BasicTestApp/GlobalizationBindCases.razor | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs index 1221e96b0a..432c5563e1 100644 --- a/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -19,6 +19,8 @@ namespace Microsoft.AspNetCore.Components [Microsoft.AspNetCore.Components.BindElementAttribute("select", null, "value", "onchange")] [Microsoft.AspNetCore.Components.BindElementAttribute("textarea", null, "value", "onchange")] [Microsoft.AspNetCore.Components.BindInputElementAttribute("checkbox", null, "checked", "onchange", false, null)] + [Microsoft.AspNetCore.Components.BindInputElementAttribute("date", null, "value", "onchange", true, "yyyy-MM-dd")] + [Microsoft.AspNetCore.Components.BindInputElementAttribute("number", null, "value", "onchange", true, null)] [Microsoft.AspNetCore.Components.BindInputElementAttribute("text", null, "value", "onchange", false, null)] [Microsoft.AspNetCore.Components.BindInputElementAttribute(null, "value", "value", "onchange", false, null)] [Microsoft.AspNetCore.Components.BindInputElementAttribute(null, null, "value", "onchange", false, null)] diff --git a/src/Components/Components/src/BindAttributes.cs b/src/Components/Components/src/BindAttributes.cs index 7a571e1b0e..79a6266c0b 100644 --- a/src/Components/Components/src/BindAttributes.cs +++ b/src/Components/Components/src/BindAttributes.cs @@ -22,6 +22,12 @@ namespace Microsoft.AspNetCore.Components [BindInputElement("checkbox", null, "checked", "onchange", isInvariantCulture: false, format: null)] [BindInputElement("text", null, "value", "onchange", isInvariantCulture: false, format: null)] + // type="number" is invariant culture + [BindInputElement("number", null, "value", "onchange", isInvariantCulture: true, format: null)] + + // type="date" is invariant culture with a specific format + [BindInputElement("date", null, "value", "onchange", isInvariantCulture: true, format: "yyyy-MM-dd")] + [BindElement("select", null, "value", "onchange")] [BindElement("textarea", null, "value", "onchange")] public static class BindAttributes diff --git a/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor b/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor index 41877e417d..bc7a53c4a3 100644 --- a/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor +++ b/src/Components/test/testassets/BasicTestApp/GlobalizationBindCases.razor @@ -30,11 +30,11 @@

Numbers using bind in number fields

- int: + int: @inputTypeNumberInt
- decimal: + decimal: @inputTypeNumberDecimal
@@ -43,12 +43,12 @@

Dates using bind in date fields

DateTime: - + @inputTypeDateDateTime
DateTimeOffset: - + @inputTypeDateDateTimeOffset