diff --git a/src/MatBlazor.Demo.ClientApp/MatBlazor.Demo.ClientApp.csproj b/src/MatBlazor.Demo.ClientApp/MatBlazor.Demo.ClientApp.csproj index 56667cb1..05aaa3c9 100644 --- a/src/MatBlazor.Demo.ClientApp/MatBlazor.Demo.ClientApp.csproj +++ b/src/MatBlazor.Demo.ClientApp/MatBlazor.Demo.ClientApp.csproj @@ -3,7 +3,7 @@ 9 3.0 - net5.0 + net8.0 true diff --git a/src/MatBlazor.Demo.ServerApp/MatBlazor.Demo.ServerApp.csproj b/src/MatBlazor.Demo.ServerApp/MatBlazor.Demo.ServerApp.csproj index f1a08565..d4fcc6d0 100644 --- a/src/MatBlazor.Demo.ServerApp/MatBlazor.Demo.ServerApp.csproj +++ b/src/MatBlazor.Demo.ServerApp/MatBlazor.Demo.ServerApp.csproj @@ -3,7 +3,7 @@ 9 true - net5.0;netcoreapp3.1 + net8.0 diff --git a/src/MatBlazor.Demo/Demo/DemoTable.razor b/src/MatBlazor.Demo/Demo/DemoTable.razor index 6a2b52fc..0458cc26 100644 --- a/src/MatBlazor.Demo/Demo/DemoTable.razor +++ b/src/MatBlazor.Demo/Demo/DemoTable.razor @@ -19,80 +19,74 @@ @code { - public class Car - { - public string Name { get; set; } - public double Price { get; set; } - public int Horsepower { get; set; } - - public Car(string name, double price, int horsepower) - { - Name = name; - Price = price; - Horsepower = horsepower; - } - } - - Car[] cars = new[] - { - new Car("Volkswagen Golf", 10000, 220), - new Car("Volkswagen Passat", 11000, 240), - new Car("Volkswagen Polo", 12000, 110), - new Car("Ford Focus", 13000, 200), - new Car("Ford Fiesta", 14000, 160), - new Car("Ford Fusion", 15000, 260), - new Car("Ford Mondeo", 16000, 120), - }; - - } - - - - - - Name - Price - Horsepower - - - @context.Name - @string.Format(""${0:f2}"", @context.Price) - @context.Horsepower - - - - @code + public class Car { + public string Name { get; set; } + public double Price { get; set; } + public int Horsepower { get; set; } - public class Car + public Car(string name, double price, int horsepower) { - public string Name { get; set; } - public double Price { get; set; } - public int Horsepower { get; set; } - - public Car(string name, double price, int horsepower) - { - Name = name; - Price = price; - Horsepower = horsepower; - } + Name = name; + Price = price; + Horsepower = horsepower; } + } - Car[] cars = new[] - { - new Car(""Volkswagen Golf"", 10000, 220), - new Car(""Volkswagen Passat"", 11000, 240), - new Car(""Volkswagen Polo"", 12000, 110), - new Car(""Ford Focus"", 13000, 200), - new Car(""Ford Fiesta"", 14000, 160), - new Car(""Ford Fusion"", 15000, 260), - new Car(""Ford Mondeo"", 16000, 120), - }; + Car[] cars = new[] + { + new Car("Volkswagen Golf", 10000, 220), + new Car("Volkswagen Passat", 11000, 240), + new Car("Volkswagen Polo", 12000, 110), + new Car("Ford Focus", 13000, 200), + new Car("Ford Fiesta", 14000, 160), + new Car("Ford Fusion", 15000, 260), + new Car("Ford Mondeo", 16000, 120), + }; } - ")> + + + + + Name + Price + Horsepower + + + @context.Name + @string.Format(""${0:f2}"", @context.Price) + @context.Horsepower + + + @code + { + public class Car + { + public string Name { get; set; } + public double Price { get; set; } + public int Horsepower { get; set; } + public Car(string name, double price, int horsepower) + { + Name = name; + Price = price; + Horsepower = horsepower; + } + } + Car[] cars = new[] + { + new Car(""Volkswagen Golf"", 10000, 220), + new Car(""Volkswagen Passat"", 11000, 240), + new Car(""Volkswagen Polo"", 12000, 110), + new Car(""Ford Focus"", 13000, 200), + new Car(""Ford Fiesta"", 14000, 160), + new Car(""Ford Fusion"", 15000, 260), + new Car(""Ford Mondeo"", 16000, 120), + }; + } + ")> @@ -116,57 +110,52 @@ @code { - public class Todo - { - public int UserId { get; set; } - public int Id { get; set; } - public string Title { get; set; } - public bool Completed { get; set; } - - public Todo() - { - } - } - - Todo[] todos; - } - - - - - - Id - Completed - Todo - - - @String.Format(""{0:d}"", @context.Id) - @context.Completed - @context.Title - - - - @code + public class Todo { + public int UserId { get; set; } + public int Id { get; set; } + public string Title { get; set; } + public bool Completed { get; set; } - public class Todo + public Todo() { - public int UserId { get; set; } - public int Id { get; set; } - public string Title { get; set; } - public bool Completed { get; set; } - - public Todo() - { - } } + } - Todo[] todos; + Todo[] todos; } - ")> + + + + + Id + Completed + Todo + + + @String.Format(""{0:d}"", @context.Id) + @context.Completed + @context.Title + + + @code + { + public class Todo + { + public int UserId { get; set; } + public int Id { get; set; } + public string Title { get; set; } + public bool Completed { get; set; } + public Todo() + { + } + } + Todo[] todos; + } + ")> @@ -194,161 +183,155 @@ @code { - class Dessert - { - public int Calories { get; set; } - public int Carbs { get; set; } - public int Fat { get; set; } - public string Name { get; set; } - public int Protein { get; set; } - } - - Dessert[] desserts = new[] - { - new Dessert() {Name = "Frozen yogurt", Calories = 159, Fat = 6, Carbs = 24, Protein = 4}, - new Dessert() {Name = "Ice cream sandwich", Calories = 237, Fat = 9, Carbs = 37, Protein = 4}, - new Dessert() {Name = "Eclair", Calories = 262, Fat = 16, Carbs = 24, Protein = 6}, - new Dessert() {Name = "Cupcake", Calories = 305, Fat = 4, Carbs = 67, Protein = 4}, - new Dessert() {Name = "Gingerbread", Calories = 356, Fat = 16, Carbs = 49, Protein = 4}, - }; - - void SortData(MatSortChangedEvent sort) - { - sortedData = desserts.ToArray(); - if (!(sort == null || sort.Direction == MatSortDirection.None || string.IsNullOrEmpty(sort.SortId))) - { - Comparison comparison = null; - switch (sort.SortId) - { - case "name": - comparison = (s1, s2) => string.Compare(s1.Name, s2.Name, StringComparison.InvariantCultureIgnoreCase); - break; - case "calories": - comparison = (s1, s2) => s1.Calories.CompareTo(s2.Calories); - break; - case "fat": - comparison = (s1, s2) => s1.Fat.CompareTo(s2.Fat); - break; - case "carbs": - comparison = (s1, s2) => s1.Carbs.CompareTo(s2.Carbs); - break; - case "protein": - comparison = (s1, s2) => s1.Protein.CompareTo(s2.Protein); - break; - } - if (comparison != null) - { - if (sort.Direction == MatSortDirection.Desc) - { - Array.Sort(sortedData, (s1, s2) => -1 * comparison(s1, s2)); - } - else - { - Array.Sort(sortedData, comparison); - } - } - } - } - - Dessert[] sortedData = null; - - protected override void OnInitialized() - { - base.OnInitialized(); - SortData(null); - } + class Dessert + { + public int Calories { get; set; } + public int Carbs { get; set; } + public int Fat { get; set; } + public string Name { get; set; } + public int Protein { get; set; } } - - - - - - Dessert (100g) - Calories - Fat (g) - Carbs (g) - Protein (g) - - - - @context.Name - @context.Calories - @context.Fat - @context.Carbs - @context.Protein - - - - @code + Dessert[] desserts = new[] { - class Dessert - { - public int Calories { get; set; } - public int Carbs { get; set; } - public int Fat { get; set; } - public string Name { get; set; } - public int Protein { get; set; } - } - - Dessert[] desserts = new[] - { - new Dessert() {Name = ""Frozen yogurt"", Calories = 159, Fat = 6, Carbs = 24, Protein = 4}, - new Dessert() {Name = ""Ice cream sandwich"", Calories = 237, Fat = 9, Carbs = 37, Protein = 4}, - new Dessert() {Name = ""Eclair"", Calories = 262, Fat = 16, Carbs = 24, Protein = 6}, - new Dessert() {Name = ""Cupcake"", Calories = 305, Fat = 4, Carbs = 67, Protein = 4}, - new Dessert() {Name = ""Gingerbread"", Calories = 356, Fat = 16, Carbs = 49, Protein = 4}, - }; - - void SortData(MatSortChangedEvent sort) + new Dessert() {Name = "Frozen yogurt", Calories = 159, Fat = 6, Carbs = 24, Protein = 4}, + new Dessert() {Name = "Ice cream sandwich", Calories = 237, Fat = 9, Carbs = 37, Protein = 4}, + new Dessert() {Name = "Eclair", Calories = 262, Fat = 16, Carbs = 24, Protein = 6}, + new Dessert() {Name = "Cupcake", Calories = 305, Fat = 4, Carbs = 67, Protein = 4}, + new Dessert() {Name = "Gingerbread", Calories = 356, Fat = 16, Carbs = 49, Protein = 4}, + }; + + void SortData(MatSortChangedEvent sort) + { + sortedData = desserts.ToArray(); + if (!(sort == null || sort.Direction == MatSortDirection.None || string.IsNullOrEmpty(sort.SortId))) { - sortedData = desserts.ToArray(); - if (!(sort == null || sort.Direction == MatSortDirection.None || string.IsNullOrEmpty(sort.SortId))) + Comparison comparison = null; + switch (sort.SortId) { - Comparison comparison = null; - switch (sort.SortId) + case "name": + comparison = (s1, s2) => string.Compare(s1.Name, s2.Name, StringComparison.InvariantCultureIgnoreCase); + break; + case "calories": + comparison = (s1, s2) => s1.Calories.CompareTo(s2.Calories); + break; + case "fat": + comparison = (s1, s2) => s1.Fat.CompareTo(s2.Fat); + break; + case "carbs": + comparison = (s1, s2) => s1.Carbs.CompareTo(s2.Carbs); + break; + case "protein": + comparison = (s1, s2) => s1.Protein.CompareTo(s2.Protein); + break; + } + if (comparison != null) + { + if (sort.Direction == MatSortDirection.Desc) { - case ""name"": - comparison = (s1, s2) => string.Compare(s1.Name, s2.Name, StringComparison.InvariantCultureIgnoreCase); - break; - case ""calories"": - comparison = (s1, s2) => s1.Calories.CompareTo(s2.Calories); - break; - case ""fat"": - comparison = (s1, s2) => s1.Fat.CompareTo(s2.Fat); - break; - case ""carbs"": - comparison = (s1, s2) => s1.Carbs.CompareTo(s2.Carbs); - break; - case ""protein"": - comparison = (s1, s2) => s1.Protein.CompareTo(s2.Protein); - break; + Array.Sort(sortedData, (s1, s2) => -1 * comparison(s1, s2)); } - if (comparison != null) + else { - if (sort.Direction == MatSortDirection.Desc) - { - Array.Sort(sortedData, (s1, s2) => -1 * comparison(s1, s2)); - } - else - { - Array.Sort(sortedData, comparison); - } + Array.Sort(sortedData, comparison); } } } + } - Dessert[] sortedData = null; + Dessert[] sortedData = null; - protected override void OnInitialized() - { - base.OnInitialized(); - SortData(null); - } + protected override void OnInitialized() + { + base.OnInitialized(); + SortData(null); + } } - ")> + + + + + + Dessert (100g) + Calories + Fat (g) + Carbs (g) + Protein (g) + + + + @context.Name + @context.Calories + @context.Fat + @context.Carbs + @context.Protein + + + @code + { + class Dessert + { + public int Calories { get; set; } + public int Carbs { get; set; } + public int Fat { get; set; } + public string Name { get; set; } + public int Protein { get; set; } + } + Dessert[] desserts = new[] + { + new Dessert() {Name = ""Frozen yogurt"", Calories = 159, Fat = 6, Carbs = 24, Protein = 4}, + new Dessert() {Name = ""Ice cream sandwich"", Calories = 237, Fat = 9, Carbs = 37, Protein = 4}, + new Dessert() {Name = ""Eclair"", Calories = 262, Fat = 16, Carbs = 24, Protein = 6}, + new Dessert() {Name = ""Cupcake"", Calories = 305, Fat = 4, Carbs = 67, Protein = 4}, + new Dessert() {Name = ""Gingerbread"", Calories = 356, Fat = 16, Carbs = 49, Protein = 4}, + }; + void SortData(MatSortChangedEvent sort) + { + sortedData = desserts.ToArray(); + if (!(sort == null || sort.Direction == MatSortDirection.None || string.IsNullOrEmpty(sort.SortId))) + { + Comparison comparison = null; + switch (sort.SortId) + { + case ""name"": + comparison = (s1, s2) => string.Compare(s1.Name, s2.Name, StringComparison.InvariantCultureIgnoreCase); + break; + case ""calories"": + comparison = (s1, s2) => s1.Calories.CompareTo(s2.Calories); + break; + case ""fat"": + comparison = (s1, s2) => s1.Fat.CompareTo(s2.Fat); + break; + case ""carbs"": + comparison = (s1, s2) => s1.Carbs.CompareTo(s2.Carbs); + break; + case ""protein"": + comparison = (s1, s2) => s1.Protein.CompareTo(s2.Protein); + break; + } + if (comparison != null) + { + if (sort.Direction == MatSortDirection.Desc) + { + Array.Sort(sortedData, (s1, s2) => -1 * comparison(s1, s2)); + } + else + { + Array.Sort(sortedData, comparison); + } + } + } + } + Dessert[] sortedData = null; + protected override void OnInitialized() + { + base.OnInitialized(); + SortData(null); + } + } + ")> @@ -370,113 +353,110 @@

@_currentSelectedTask

@code { - private string _currentSelectedTask; - public class Task - { - public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - - public Task(int id, string name, string description) - { - Id = id; - Name = name; - Description = description; - } - } + private string _currentSelectedTask; + public class Task + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } - Task[] tasks = new[] - { - new Task(1, "T1", "Do something..."), - new Task(2, "T2", "Do something..."), - new Task(3, "T3", "Do something..."), - new Task(4, "T4", "Do something..."), - new Task(5, "T5", "Do something..."), - new Task(6, "T6", "Do something..."), - new Task(7, "T7", "Do something..."), - }; - public void SelectionChangedEvent(object row) + public Task(int id, string name, string description) { - if (row == null) - { - _currentSelectedTask = ""; - } - else - { - _currentSelectedTask = string.Format("Task Nr. {0} has been selected", ((Task)row).Id); - } - - this.StateHasChanged(); + Id = id; + Name = name; + Description = description; } } - - - - - Id - Name - Description - - - @context.Id - @context.Name - @context.Description - - -

@_currentSelectedTask

- @code + Task[] tasks = new[] { - private string _currentSelectedTask; - public class Task + new Task(1, "T1", "Do something..."), + new Task(2, "T2", "Do something..."), + new Task(3, "T3", "Do something..."), + new Task(4, "T4", "Do something..."), + new Task(5, "T5", "Do something..."), + new Task(6, "T6", "Do something..."), + new Task(7, "T7", "Do something..."), + }; + public void SelectionChangedEvent(object row) + { + if (row == null) { - public int Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } - - public Task(int id, string name, string description) - { - Id = id; - Name = name; - Description = description; - } + _currentSelectedTask = ""; } - - Task[] tasks = new[] - { - new Task(1, ""T1"", ""Do something...""), - new Task(2, ""T2"", ""Do something...""), - new Task(3, ""T3"", ""Do something...""), - new Task(4, ""T4"", ""Do something...""), - new Task(5, ""T5"", ""Do something...""), - new Task(6, ""T6"", ""Do something...""), - new Task(7, ""T7"", ""Do something...""), - }; - public void SelectionChangedEvent(object row) + else { - if (row == null) - { - _currentSelectedTask = """"; - } - else - { - _currentSelectedTask = string.Format(""Task Nr. {0} has been selected"", ((Task)row).Id); - } - - this.StateHasChanged(); + _currentSelectedTask = string.Format("Task Nr. {0} has been selected", ((Task)row).Id); } + + this.StateHasChanged(); + } } - ")>
+ + + + + Id + Name + Description + + + @context.Id + @context.Name + @context.Description + + +

@_currentSelectedTask

+ @code + { + private string _currentSelectedTask; + public class Task + { + public int Id { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public Task(int id, string name, string description) + { + Id = id; + Name = name; + Description = description; + } + } + Task[] tasks = new[] + { + new Task(1, ""T1"", ""Do something...""), + new Task(2, ""T2"", ""Do something...""), + new Task(3, ""T3"", ""Do something...""), + new Task(4, ""T4"", ""Do something...""), + new Task(5, ""T5"", ""Do something...""), + new Task(6, ""T6"", ""Do something...""), + new Task(7, ""T7"", ""Do something...""), + }; + public void SelectionChangedEvent(object row) + { + if (row == null) + { + _currentSelectedTask = """"; + } + else + { + _currentSelectedTask = string.Format(""Task Nr. {0} has been selected"", ((Task)row).Id); + } + this.StateHasChanged(); + } + } + ")>
Select row, with returning selected item example
- @@ -493,95 +473,90 @@

You have double clicked on @_currentSelectedPerson

@code { - private string _currentSelectedPerson = "noone"; - public class Person - { - public int Id { get; set; } - public string Firstname { get; set; } - public string Lastname { get; set; } - - public Person(int id, string firstname, string lastname) - { - Id = id; - Firstname = firstname; - Lastname = lastname; - } - } - - Person[] people = new[] - { - new Person(1, "Gerda", "Mugwort"), - new Person(2, "Mattalic", "Burrowes"), - new Person(3, "Hal", "Smallburrow"), - }; + private string _currentSelectedPerson = "noone"; + public class Person + { + public int Id { get; set; } + public string Firstname { get; set; } + public string Lastname { get; set; } - void OnPersonDbClicked(object item) + public Person(int id, string firstname, string lastname) { - var person = item as Person; - if (person == null) - { - _currentSelectedPerson = "noone"; - return; - } - - _currentSelectedPerson = $"{person.Firstname} {person.Lastname}"; + Id = id; + Firstname = firstname; + Lastname = lastname; } } -
- - - - Id - Firstname - Lastname - - - @context.Id - @context.Firstname - @context.Lastname - - -

You have double clicked on @_currentSelectedPerson

- @code - { - private string _currentSelectedPerson = ""noone""; - public class Person - { - public int Id { get; set; } - public string Firstname { get; set; } - public string Lastname { get; set; } - - public Person(int id, string firstname, string lastname) - { - Id = id; - Firstname = firstname; - Lastname = lastname; - } - } - Person[] people = new[] - { - new Person(1, ""Gerda"", ""Mugwort""), - new Person(2, ""Mattalic"", ""Burrowes""), - new Person(3, ""Hal"", ""Smallburrow""), - }; + Person[] people = new[] + { + new Person(1, "Gerda", "Mugwort"), + new Person(2, "Mattalic", "Burrowes"), + new Person(3, "Hal", "Smallburrow"), + }; - void OnPersonDbClicked(object item) + void OnPersonDbClicked(Person person) + { + if (person == null) { - var person = item as Person; - if (person == null) - { - _currentSelectedPerson = ""noone""; - return; - } - - _currentSelectedPerson = $""{person.Firstname} {person.Lastname}""; + _currentSelectedPerson = "noone"; + return; } + + _currentSelectedPerson = $"{person.Firstname} {person.Lastname}"; } - ")>
+ } + + + + + Id + Firstname + Lastname + + + @context.Id + @context.Firstname + @context.Lastname + + +

You have double clicked on @_currentSelectedPerson

+ @code + { + private string _currentSelectedPerson = ""noone""; + public class Person + { + public int Id { get; set; } + public string Firstname { get; set; } + public string Lastname { get; set; } + public Person(int id, string firstname, string lastname) + { + Id = id; + Firstname = firstname; + Lastname = lastname; + } + } + Person[] people = new[] + { + new Person(1, ""Gerda"", ""Mugwort""), + new Person(2, ""Mattalic"", ""Burrowes""), + new Person(3, ""Hal"", ""Smallburrow""), + }; + void OnPersonDbClicked(object item) + { + var person = item as Person; + if (person == null) + { + _currentSelectedPerson = ""noone""; + return; + } + _currentSelectedPerson = $""{person.Firstname} {person.Lastname}""; + } + } + ")>
\ No newline at end of file diff --git a/src/MatBlazor.Demo/MatBlazor.Demo.csproj b/src/MatBlazor.Demo/MatBlazor.Demo.csproj index 53b8a8e4..ec04abf1 100644 --- a/src/MatBlazor.Demo/MatBlazor.Demo.csproj +++ b/src/MatBlazor.Demo/MatBlazor.Demo.csproj @@ -6,22 +6,11 @@ 9 3.0 true - net5.0;netstandard2.1 + net8.0 - - - - - - - - - - - diff --git a/src/MatBlazor.DevUtils/MatBlazor.DevUtils.csproj b/src/MatBlazor.DevUtils/MatBlazor.DevUtils.csproj index aa9f645a..d74cc3ed 100644 --- a/src/MatBlazor.DevUtils/MatBlazor.DevUtils.csproj +++ b/src/MatBlazor.DevUtils/MatBlazor.DevUtils.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net8.0 Exe MatBlazor.DevUtils.Program diff --git a/src/MatBlazor.Web/deploy.df b/src/MatBlazor.Web/deploy.df index b94c3b92..c3e81bbc 100644 --- a/src/MatBlazor.Web/deploy.df +++ b/src/MatBlazor.Web/deploy.df @@ -1,8 +1,9 @@ -FROM node +FROM node:12.22.12-bullseye-slim WORKDIR src COPY package.json . COPY .babelrc . COPY .eslintrc.js . RUN npm install COPY . . +RUN npm rebuild RUN npm run build \ No newline at end of file diff --git a/src/MatBlazor.Web/package.json b/src/MatBlazor.Web/package.json index b6cb8d57..9bff09a3 100644 --- a/src/MatBlazor.Web/package.json +++ b/src/MatBlazor.Web/package.json @@ -45,6 +45,8 @@ "@material/theme": "7.0.0", "@material/top-app-bar": "7.0.0", "@material/typography": "7.0.0", + "@types/body-parser": "ts3.7", + "@types/node": "ts3.7", "babel-polyfill": "^6.26.0", "flatpickr": "^4.6.3", "install": "^0.13.0", diff --git a/src/MatBlazor.Web/src/matButton/matButton.scss b/src/MatBlazor.Web/src/matButton/matButton.scss index 4a5330e4..e90549b5 100644 --- a/src/MatBlazor.Web/src/matButton/matButton.scss +++ b/src/MatBlazor.Web/src/matButton/matButton.scss @@ -1,7 +1,7 @@ @import "@material/button/mdc-button"; .mat-button__icon--trailing { - margin: 0 -4px 0 4px !important; + margin: 0 -4px 0 4px !important; } .mat-button-link { @@ -13,16 +13,92 @@ } .mat-button-link:not([href]) { - color: rgba(0,0,0,.38) !important; + color: rgba(0, 0, 0, .38) !important; cursor: default; pointer-events: none; background-color: transparent; } .mat-button-link.mdc-button--raised:not([href]) { - box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0,0,0,.12); + box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2), 0px 0px 0px 0px rgba(0, 0, 0, 0.14), 0px 0px 0px 0px rgba(0, 0, 0, .12); } -.mat-button-link.mdc-button--raised:not([href]), .mat-button-link.mdc-button--unelevated:not([href]) { - background-color: rgba(0,0,0,.12); +.mat-button-link.mdc-button--raised:not([href]), +.mat-button-link.mdc-button--unelevated:not([href]) { + background-color: rgba(0, 0, 0, .12); } + +.mdc-button--primary.mdc-button--outlined:not(button[disabled=""]) { + border-color: var(--mdc-theme-primary); +} + +.mdc-button--secondary.mdc-button:not(button[disabled=""]) { + color: var(--mdc-theme-secondary); +} + +.mdc-button--secondary.mdc-button--raised:not(button[disabled=""]) { + background-color: var(--mdc-theme-secondary); + color: var(--mdc-theme-on-secondary) !important; +} + +.mdc-button--secondary.mdc-button--outlined:not(button[disabled=""]) { + border-color: var(--mdc-theme-secondary); +} + +.mdc-button--success.mdc-button:not(button[disabled=""]) { + color: var(--success); +} + +.mdc-button--success.mdc-button--raised:not(button[disabled=""]) { + background-color: var(--success); + color: var(--mdc-theme-text-primary-on-dark) !important; +} + +.mdc-button--success.mdc-button--outlined:not(button[disabled=""]) { + border-color: var(--success); +} + +.mdc-button--danger.mdc-button:not(button[disabled=""]) { + color: var(--danger); +} + +.mdc-button--danger.mdc-button--raised:not(button[disabled=""]) { + background-color: var(--danger); + color: var(--mdc-theme-text-primary-on-dark) !important; +} + +.mdc-button--danger.mdc-button--outlined:not(button[disabled=""]) { + border-color: var(--danger); +} + +.mdc-button--warning.mdc-button:not(button[disabled=""]) { + color: var(--warning); +} + +.mdc-button--warning.mdc-button--raised:not(button[disabled=""]) { + background-color: var(--warning); + color: var(--mdc-theme-text-primary-on-light) !important; +} + +.mdc-button--warning.mdc-button--outlined:not(button[disabled=""]) { + border-color: var(--warning); +} + +.mdc-button--info.mdc-button:not(button[disabled=""]) { + color: var(--info); +} + +.mdc-button--info.mdc-button--raised:not(button[disabled=""]) { + background-color: var(--info); + color: var(--mdc-theme-text-primary-on-dark) !important; +} + +.mdc-button--info.mdc-button--outlined:not(button[disabled=""]) { + border-color: var(--info); +} + +.mdc-button--dense { + height: 28px !important; + padding: 0 8px !important; + letter-spacing: 0.04em; +} \ No newline at end of file diff --git a/src/MatBlazor.Web/src/matCheckbox/matCheckbox.scss b/src/MatBlazor.Web/src/matCheckbox/matCheckbox.scss index 2f544d34..2460fe99 100644 --- a/src/MatBlazor.Web/src/matCheckbox/matCheckbox.scss +++ b/src/MatBlazor.Web/src/matCheckbox/matCheckbox.scss @@ -1,2 +1,18 @@ @import "@material/form-field/mdc-form-field"; -@import "@material/checkbox/mdc-checkbox"; \ No newline at end of file +@import "@material/checkbox/mdc-checkbox"; + +.mdc-checkbox--primary { + --mdc-theme-secondary: var(--mdc-theme-primary) !important; +} + +.mdc-checkbox--danger { + --mdc-theme-secondary: var(--mdc-theme-danger) !important; +} + +.mdc-checkbox--warning { + --mdc-theme-secondary: var(--mdc-theme-warning) !important; +} + +.mdc-checkbox--info { + --mdc-theme-secondary: var(--mdc-theme-info) !important; +} \ No newline at end of file diff --git a/src/MatBlazor.Web/src/matIconButton/matIconButton.scss b/src/MatBlazor.Web/src/matIconButton/matIconButton.scss index 9eaa2f64..65e4394f 100644 --- a/src/MatBlazor.Web/src/matIconButton/matIconButton.scss +++ b/src/MatBlazor.Web/src/matIconButton/matIconButton.scss @@ -1 +1,7 @@ @import "@material/icon-button/mdc-icon-button"; + +.mdc-icon-button-match-size { + height: 36px; + width: 36px; + padding: 6px; +} \ No newline at end of file diff --git a/src/MatBlazor.Web/src/theme/theme.scss b/src/MatBlazor.Web/src/theme/theme.scss index e949867c..8cbcdad5 100644 --- a/src/MatBlazor.Web/src/theme/theme.scss +++ b/src/MatBlazor.Web/src/theme/theme.scss @@ -8,3 +8,27 @@ left: 0; top: 0; } + +.mdc-text-primary { + color: var(--mdc-theme-primary) !important; +} + +.mdc-text-secondary { + color: var(--mdc-theme-secondary) !important; +} + +.mdc-text-success { + color: var(--success) !important; +} + +.mdc-text-warning { + color: var(--warning) !important; +} + +.mdc-text-danger { + color: var(--danger) !important; +} + +.mdc-text-info { + color: var(--info) !important; +} \ No newline at end of file diff --git a/src/MatBlazor.Web/webpack/prod.config.js b/src/MatBlazor.Web/webpack/prod.config.js index f2caa304..8c9edb5a 100644 --- a/src/MatBlazor.Web/webpack/prod.config.js +++ b/src/MatBlazor.Web/webpack/prod.config.js @@ -15,12 +15,25 @@ module.exports = { ] }, optimization: { - minimize: !debugMode + minimize: !debugMode, + minimizer: [ + new UglifyJsPlugin({ + parallel: true, + uglifyOptions: { + compress: { + drop_debugger: !debugMode + }, + mangle: debugMode, + output: { + comments: debugMode, + beautify: debugMode + } + } + }) + ] }, output: { - filename: "matBlazor.js", - // path: path.resolve(__dirname, '../dist'), - path: path.resolve(__dirname, '../../MatBlazor/wwwroot/dist'), + filename: "../../MatBlazor/wwwroot/dist/matBlazor.js" }, @@ -72,21 +85,7 @@ module.exports = { plugins: [ new MiniCssExtractPlugin({ - filename: 'matBlazor.css', - path: path.resolve(__dirname, '../../MatBlazor/wwwroot/dist') - }), - new UglifyJsPlugin({ - parallel: true, - uglifyOptions: { - compress: { - drop_debugger: !debugMode - }, - mangle: debugMode, - output: { - comments: debugMode, - beautify: debugMode - } - } + filename: '../../MatBlazor/wwwroot/dist/matBlazor.css' }), ], }; diff --git a/src/MatBlazor/Components/Base/BaseMatComponent.cs b/src/MatBlazor/Components/Base/BaseMatComponent.cs index daa80650..ce9b0307 100644 --- a/src/MatBlazor/Components/Base/BaseMatComponent.cs +++ b/src/MatBlazor/Components/Base/BaseMatComponent.cs @@ -98,6 +98,16 @@ protected async Task JsInvokeAsync(string code, params object[] args) } } + protected async Task JsInvokeVoidAsync(string code, params object[] args) + { + try + { + await Js.InvokeVoidAsync(code, args); + } + catch (JSDisconnectedException) { } // Do nothing + catch (Exception) { throw; } + } + #region Hack to fix https: //github.com/aspnet/AspNetCore/issues/11159 public static object CreateDotNetObjectRefSyncObj = new object(); diff --git a/src/MatBlazor/Components/Base/BaseMatInputComponent.cs b/src/MatBlazor/Components/Base/BaseMatInputComponent.cs index 0aee34a8..84b53699 100644 --- a/src/MatBlazor/Components/Base/BaseMatInputComponent.cs +++ b/src/MatBlazor/Components/Base/BaseMatInputComponent.cs @@ -52,7 +52,7 @@ public T Value } } - [Obsolete("Please use OnValueChanged(oldValue, newValue)")] + protected virtual void OnValueChanged(bool changed) { } @@ -96,10 +96,19 @@ protected virtual T CurrentValue { _value = value; ValueChanged.InvokeAsync(value); + ClearValidationErrors(); EditContext?.NotifyFieldChanged(FieldIdentifier); } } } + /// + /// Clears validation errors + /// Used when value is set programatically, removing parse errors + /// + protected virtual void ClearValidationErrors() + { + + } protected virtual bool ValidateCurrentValue(T value) diff --git a/src/MatBlazor/Components/Base/BaseMatInputTextElementComponent.cs b/src/MatBlazor/Components/Base/BaseMatInputTextElementComponent.cs index c74479b0..200ec6f5 100644 --- a/src/MatBlazor/Components/Base/BaseMatInputTextElementComponent.cs +++ b/src/MatBlazor/Components/Base/BaseMatInputTextElementComponent.cs @@ -10,6 +10,12 @@ public abstract class BaseMatInputTextElementComponent : BaseMatInputElementC private ValidationMessageStore _parsingValidationMessages; + + protected override void ClearValidationErrors() + { + _parsingValidationMessages?.Clear(); + } + /// /// Gets or sets the current value of the input, represented as a string. /// diff --git a/src/MatBlazor/Components/MatAccordion/MatExpansionPanelSummary.razor.cs b/src/MatBlazor/Components/MatAccordion/MatExpansionPanelSummary.razor.cs index aa6aef83..b3306709 100644 --- a/src/MatBlazor/Components/MatAccordion/MatExpansionPanelSummary.razor.cs +++ b/src/MatBlazor/Components/MatAccordion/MatExpansionPanelSummary.razor.cs @@ -16,7 +16,7 @@ protected override void OnInitialized() { base.OnInitialized(); ClassMapper.Add("mat-expansion-panel__summary").Add("mdc-ripple-surface"); - CallAfterRender(async () => { await JsInvokeAsync("matBlazor.matAccordion.initSummary", Ref); }); + CallAfterRender(async () => { await JsInvokeVoidAsync("matBlazor.matAccordion.initSummary", Ref); }); } protected async Task OnClickHandler(MouseEventArgs e) diff --git a/src/MatBlazor/Components/MatAppBar/MatAppBar.razor.cs b/src/MatBlazor/Components/MatAppBar/MatAppBar.razor.cs index dab27ec9..21691b99 100644 --- a/src/MatBlazor/Components/MatAppBar/MatAppBar.razor.cs +++ b/src/MatBlazor/Components/MatAppBar/MatAppBar.razor.cs @@ -26,7 +26,7 @@ public MatAppBar() protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matAppBar.init", Ref); + await JsInvokeVoidAsync("matBlazor.matAppBar.init", Ref); } } diff --git a/src/MatBlazor/Components/MatButton/MatButton.razor.cs b/src/MatBlazor/Components/MatButton/MatButton.razor.cs index 5f93cc91..f3dfcbe6 100644 --- a/src/MatBlazor/Components/MatButton/MatButton.razor.cs +++ b/src/MatBlazor/Components/MatButton/MatButton.razor.cs @@ -18,7 +18,11 @@ partial class MatButton : BaseMatDomComponent protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matButton.init", Ref); + try + { + await JsInvokeVoidAsync("matBlazor.matButton.init", Ref); + } + catch (Exception) { } // Disposed } public MatButton() @@ -28,7 +32,14 @@ public MatButton() .If("mdc-button--raised", () => Raised) .If("mdc-button--unelevated", () => Unelevated) .If("mdc-button--outlined", () => Outlined) - .If("mdc-button--dense", () => this.Dense); + .If("mdc-button--dense", () => this.Dense) + .If("mdc-button--primary", () => Color == MatComponentColor.Primary) + .If("mdc-button--secondary", () => Color == MatComponentColor.Secondary) + .If("mdc-button--success", () => Color == MatComponentColor.Success) + .If("mdc-button--warning", () => Color == MatComponentColor.Warning) + .If("mdc-button--danger", () => Color == MatComponentColor.Danger) + .If("mdc-button--info", () => Color == MatComponentColor.Info); + } /// @@ -133,6 +144,11 @@ public MatButton() [Parameter] public string Label { get; set; } + /// + /// Button color + /// + [Parameter] + public MatComponentColor Color { get; set; } /// /// Inline label of Button. @@ -142,13 +158,14 @@ public MatButton() protected async Task OnClickHandler(MouseEventArgs ev) { + if (Disabled) return; if (Link != null) { if (!string.IsNullOrEmpty(Target)) { try { - await JsInvokeAsync("matBlazor.matButton.openLink", new object[2] { Link, Target }); + await JsInvokeVoidAsync("open", Link, Target); } catch (TaskCanceledException ex) { diff --git a/src/MatBlazor/Components/MatButtonLink/BaseMatLink.cs b/src/MatBlazor/Components/MatButtonLink/BaseMatLink.cs index bc13bc8e..52b4407f 100644 --- a/src/MatBlazor/Components/MatButtonLink/BaseMatLink.cs +++ b/src/MatBlazor/Components/MatButtonLink/BaseMatLink.cs @@ -13,7 +13,7 @@ public class BaseMatButtonLink: BaseMatDomComponent protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matButton.init", Ref); + await JsInvokeVoidAsync("matBlazor.matButton.init", Ref); } public BaseMatButtonLink() diff --git a/src/MatBlazor/Components/MatCheckbox/BaseMatCheckboxInternal.cs b/src/MatBlazor/Components/MatCheckbox/BaseMatCheckboxInternal.cs index 054ebbc0..1c4c1e70 100644 --- a/src/MatBlazor/Components/MatCheckbox/BaseMatCheckboxInternal.cs +++ b/src/MatBlazor/Components/MatCheckbox/BaseMatCheckboxInternal.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Components; +using System; using System.Threading.Tasks; namespace MatBlazor @@ -15,11 +16,17 @@ public BaseMatCheckboxInternal() { ClassMapper .Add("mat-checkbox") - .Add("mdc-form-field"); + .Add("mdc-form-field") + .If("mdc-checkbox--primary", () => Color == MatComponentColor.Primary) + .If("mdc-checkbox--secondary", () => Color == MatComponentColor.Secondary) + .If("mdc-checkbox--success", () => Color == MatComponentColor.Success) + .If("mdc-checkbox--warning", () => Color == MatComponentColor.Warning) + .If("mdc-checkbox--danger", () => Color == MatComponentColor.Danger) + .If("mdc-checkbox--info", () => Color == MatComponentColor.Info); CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matCheckbox.init", Ref, ComponentRef); + await JsInvokeVoidAsync("matBlazor.matCheckbox.init", Ref, ComponentRef); }); } @@ -39,6 +46,9 @@ public BaseMatCheckboxInternal() [Parameter] public string InputValue { get; set; } + [Parameter] + public MatComponentColor Color { get; set; } + protected override async Task OnParametersSetAsync() { await base.OnParametersSetAsync(); @@ -48,13 +58,26 @@ protected override async Task OnParametersSetAsync() } CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matCheckbox.setIndeterminate", Ref, CurrentValue == null); + await JsInvokeVoidAsync("matBlazor.matCheckbox.setIndeterminate", Ref, CurrentValue == null); }); } protected void ChangeHandler(ChangeEventArgs e) { - CurrentValue = SwitchT.FromBoolNull((bool) e.Value, Indeterminate); + var newValue = (bool)e.Value; + if (Indeterminate) + { + CurrentValue = CurrentValue switch + { + true => SwitchT.FromBoolNull(false, Indeterminate), + false => SwitchT.FromBoolNull(null, Indeterminate), + _ => SwitchT.FromBoolNull(true, Indeterminate) + }; + } + else + { + CurrentValue = SwitchT.FromBoolNull(newValue, Indeterminate); + } } } } \ No newline at end of file diff --git a/src/MatBlazor/Components/MatChip/MatChip.cs b/src/MatBlazor/Components/MatChip/MatChip.cs index 65c74132..b8856824 100644 --- a/src/MatBlazor/Components/MatChip/MatChip.cs +++ b/src/MatBlazor/Components/MatChip/MatChip.cs @@ -56,7 +56,7 @@ public bool IsSelected this.StateHasChanged(); if (ChipSet != null && _isSelected) { - ChipSet.HandleChipSelected(this); + _ = ChipSet.HandleChipSelected(this); } IsSelectedChanged.InvokeAsync(_isSelected); } @@ -100,7 +100,7 @@ protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); _dotNetObjectRef ??= CreateDotNetObjectRef(this); // needed to call into this object from Javascript - await JsInvokeAsync("matBlazor.matChip.init", Ref, _dotNetObjectRef); + await JsInvokeVoidAsync("matBlazor.matChip.init", Ref, _dotNetObjectRef); if (_isSelected && ChipSet != null) { await ChipSet.HandleChipSelected(this); diff --git a/src/MatBlazor/Components/MatChipSet/MatChipSet.cs b/src/MatBlazor/Components/MatChipSet/MatChipSet.cs index 0ab7c35d..20a211b1 100644 --- a/src/MatBlazor/Components/MatChipSet/MatChipSet.cs +++ b/src/MatBlazor/Components/MatChipSet/MatChipSet.cs @@ -18,7 +18,7 @@ public MatChipSet() protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matChipSet.init", Ref); + await JsInvokeVoidAsync("matBlazor.matChipSet.init", Ref); } [Parameter] diff --git a/src/MatBlazor/Components/MatDatePicker/BaseMatDatePickerInternal.cs b/src/MatBlazor/Components/MatDatePicker/BaseMatDatePickerInternal.cs index 9b27263f..143d109e 100644 --- a/src/MatBlazor/Components/MatDatePicker/BaseMatDatePickerInternal.cs +++ b/src/MatBlazor/Components/MatDatePicker/BaseMatDatePickerInternal.cs @@ -70,6 +70,7 @@ public BaseMatDatePickerInternal() OnChangeAction = (value) => { var v = value.FirstOrDefault(); + if (v != null) v = v.Value.ToLocalTime(); CurrentValue = SwitchT.FromDateTimeNull(v); InvokeStateHasChanged(); }, @@ -111,7 +112,6 @@ protected override bool ValidateCurrentValue(TValue value) return false; } } - return true; } @@ -125,7 +125,7 @@ protected void OnClickIconHandler() { dotNetObjectRef ??= CreateDotNetObjectRef(dotNetObject); - await JsInvokeAsync("matBlazor.matDatePicker.open", Ref, flatpickrInputRef, dotNetObjectRef, + await JsInvokeVoidAsync("matBlazor.matDatePicker.open", Ref, flatpickrInputRef, dotNetObjectRef, new FlatpickrOptions { EnableTime = this.EnableTime, diff --git a/src/MatBlazor/Components/MatDialog/BaseMatDialog.cs b/src/MatBlazor/Components/MatDialog/BaseMatDialog.cs index a0cdd7b3..aa80220b 100644 --- a/src/MatBlazor/Components/MatDialog/BaseMatDialog.cs +++ b/src/MatBlazor/Components/MatDialog/BaseMatDialog.cs @@ -29,7 +29,7 @@ public bool IsOpen _isOpen = value; CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matDialog.setIsOpen", Ref, value); + await JsInvokeVoidAsync("matBlazor.matDialog.setIsOpen", Ref, value); }); } } @@ -56,7 +56,7 @@ public bool CanBeClosed _canBeClosed = value; CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matDialog.setCanBeClosed", Ref, value); + await JsInvokeVoidAsync("matBlazor.matDialog.setCanBeClosed", Ref, value); }); } } @@ -87,7 +87,7 @@ public BaseMatDialog() CallAfterRender(async () => { dotNetObjectRef ??= CreateDotNetObjectRef(this); - await JsInvokeAsync("matBlazor.matDialog.init", Ref, dotNetObjectRef); + await JsInvokeVoidAsync("matBlazor.matDialog.init", Ref, dotNetObjectRef); }); } diff --git a/src/MatBlazor/Components/MatDrawer/BaseMatDrawer.cs b/src/MatBlazor/Components/MatDrawer/BaseMatDrawer.cs index 32b8004d..bdbde79b 100644 --- a/src/MatBlazor/Components/MatDrawer/BaseMatDrawer.cs +++ b/src/MatBlazor/Components/MatDrawer/BaseMatDrawer.cs @@ -34,7 +34,7 @@ public bool Opened this.CallAfterRender(async () => { - await this.JsInvokeAsync("matBlazor.matDrawer.setOpened", Ref, _opened); + await this.JsInvokeVoidAsync("matBlazor.matDrawer.setOpened", Ref, _opened); }); OpenedChanged.InvokeAsync(value); @@ -58,7 +58,7 @@ public BaseMatDrawer() this.CallAfterRender(async () => { dotNetObjectRef ??= CreateDotNetObjectRef(this); - await JsInvokeAsync("matBlazor.matDrawer.init", Ref, dotNetObjectRef); + await JsInvokeVoidAsync("matBlazor.matDrawer.init", Ref, dotNetObjectRef); }); } diff --git a/src/MatBlazor/Components/MatHidden/BaseMatHidden.cs b/src/MatBlazor/Components/MatHidden/BaseMatHidden.cs index 5c6a0038..9561c200 100644 --- a/src/MatBlazor/Components/MatHidden/BaseMatHidden.cs +++ b/src/MatBlazor/Components/MatHidden/BaseMatHidden.cs @@ -63,7 +63,7 @@ protected override async Task OnFirstAfterRenderAsync() CallAfterRender(async () => { dotNetObjectRef ??= CreateDotNetObjectRef(this); - await JsInvokeAsync("matBlazor.matHidden.init", Id, dotNetObjectRef); + await JsInvokeVoidAsync("matBlazor.matHidden.init", Id, dotNetObjectRef); isInitialized = true; await UpdateVisible(); }); @@ -84,7 +84,7 @@ public override void Dispose() { InvokeAsync(async () => { - await JsInvokeAsync("matBlazor.matHidden.destroy", Id); + await JsInvokeVoidAsync("matBlazor.matHidden.destroy", Id); }); } diff --git a/src/MatBlazor/Components/MatIcon/BaseMatIcon.cs b/src/MatBlazor/Components/MatIcon/BaseMatIcon.cs index a69918fc..99115c65 100644 --- a/src/MatBlazor/Components/MatIcon/BaseMatIcon.cs +++ b/src/MatBlazor/Components/MatIcon/BaseMatIcon.cs @@ -14,6 +14,9 @@ public class BaseMatIcon : BaseMatDomComponent [Parameter] public RenderFragment ChildContent { get; set; } + [Parameter] + public string Tooltip { get; set; } + public BaseMatIcon() { ClassMapper.Add("material-icons"); diff --git a/src/MatBlazor/Components/MatIcon/MatIcon.razor b/src/MatBlazor/Components/MatIcon/MatIcon.razor index e57c2f25..3fd5228e 100644 --- a/src/MatBlazor/Components/MatIcon/MatIcon.razor +++ b/src/MatBlazor/Components/MatIcon/MatIcon.razor @@ -1,4 +1,5 @@ @namespace MatBlazor @inherits BaseMatIcon @using Microsoft.AspNetCore.Components -@Icon@ChildContent +@Icon@ChildContent diff --git a/src/MatBlazor/Components/MatIconButton/BaseMatIconButton.cs b/src/MatBlazor/Components/MatIconButton/BaseMatIconButton.cs index f8455a97..da405cd5 100644 --- a/src/MatBlazor/Components/MatIconButton/BaseMatIconButton.cs +++ b/src/MatBlazor/Components/MatIconButton/BaseMatIconButton.cs @@ -60,10 +60,23 @@ public class BaseMatIconButton : BaseMatDomComponent [Parameter] public bool Disabled { get; set; } + [Parameter] + public MatComponentColor Color { get; set; } = MatComponentColor.Default; + + [Parameter] + public bool MatchButtonSize { get; set; } + public BaseMatIconButton() { ClassMapper - .Add("mdc-icon-button"); + .Add("mdc-icon-button") + .If("mdc-icon-button-match-size", () => MatchButtonSize) + .If("mdc-text-primary", () => Color == MatComponentColor.Primary) + .If("mdc-text-secondary", () => Color == MatComponentColor.Secondary) + .If("mdc-text-success", () => Color == MatComponentColor.Success) + .If("mdc-text-danger", () => Color == MatComponentColor.Danger) + .If("mdc-text-warning", () => Color == MatComponentColor.Warning) + .If("mdc-text-info", () => Color == MatComponentColor.Info); } /// @@ -97,7 +110,7 @@ public BaseMatIconButton() protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matIconButton.init", Ref); + await JsInvokeVoidAsync("matBlazor.matIconButton.init", Ref); } protected async Task OnClickHandler(MouseEventArgs ev) @@ -109,7 +122,7 @@ protected async Task OnClickHandler(MouseEventArgs ev) { if (!string.IsNullOrEmpty(Target)) { - await JsInvokeAsync("open", Link, Target); + await JsInvokeVoidAsync("open", Link, Target); } else { diff --git a/src/MatBlazor/Components/MatList/BaseMatList.cs b/src/MatBlazor/Components/MatList/BaseMatList.cs index 1ebd134e..a98c9920 100644 --- a/src/MatBlazor/Components/MatList/BaseMatList.cs +++ b/src/MatBlazor/Components/MatList/BaseMatList.cs @@ -44,7 +44,7 @@ public async Task SetSelectedIndex(int index) { if (_selectedIndex != index) { - await JsInvokeAsync("matBlazor.matList.setSelectedIndex", this.Ref, index); + await JsInvokeVoidAsync("matBlazor.matList.setSelectedIndex", this.Ref, index); _selectedIndex = index; } } @@ -52,7 +52,7 @@ public async Task SetSelectedIndex(int index) protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matList.init", this.Ref, new MatListJsOptions() + await JsInvokeVoidAsync("matBlazor.matList.init", this.Ref, new MatListJsOptions() { SingleSelection = SingleSelection }); diff --git a/src/MatBlazor/Components/MatMenu/BaseMatMenu.cs b/src/MatBlazor/Components/MatMenu/BaseMatMenu.cs index 2cd8be3f..6006b3c1 100644 --- a/src/MatBlazor/Components/MatMenu/BaseMatMenu.cs +++ b/src/MatBlazor/Components/MatMenu/BaseMatMenu.cs @@ -21,36 +21,36 @@ public BaseMatMenu() public ForwardRef TargetForwardRef { get; set; } public async Task SetAnchorElementAsync(ElementReference anchorElement) { - await JsInvokeAsync("matBlazor.matMenu.setAnchorElement", Ref, anchorElement); + await JsInvokeVoidAsync("matBlazor.matMenu.setAnchorElement", Ref, anchorElement); } public async Task OpenAsync(ElementReference anchorElement) { - await JsInvokeAsync("matBlazor.matMenu.setAnchorElement", Ref, anchorElement); - await JsInvokeAsync("matBlazor.matMenu.open", Ref); + await JsInvokeVoidAsync("matBlazor.matMenu.setAnchorElement", Ref, anchorElement); + await JsInvokeVoidAsync("matBlazor.matMenu.open", Ref); } public async Task CloseAsync() { - await JsInvokeAsync("matBlazor.matMenu.close", Ref); + await JsInvokeVoidAsync("matBlazor.matMenu.close", Ref); } public async Task OpenAsync() { - await JsInvokeAsync("matBlazor.matMenu.setAnchorElement", Ref, TargetForwardRef.Current); - await JsInvokeAsync("matBlazor.matMenu.open", Ref); + await JsInvokeVoidAsync("matBlazor.matMenu.setAnchorElement", Ref, TargetForwardRef.Current); + await JsInvokeVoidAsync("matBlazor.matMenu.open", Ref); } public async Task SetState(bool open) { - await JsInvokeAsync("matBlazor.matMenu.setAnchorElement", Ref, TargetForwardRef.Current); - await JsInvokeAsync("matBlazor.matMenu.setState", Ref, open); + await JsInvokeVoidAsync("matBlazor.matMenu.setAnchorElement", Ref, TargetForwardRef.Current); + await JsInvokeVoidAsync("matBlazor.matMenu.setState", Ref, open); } protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matMenu.init", Ref); + await JsInvokeVoidAsync("matBlazor.matMenu.init", Ref); } } } \ No newline at end of file diff --git a/src/MatBlazor/Components/MatNavMenu/BaseMatNavItem.cs b/src/MatBlazor/Components/MatNavMenu/BaseMatNavItem.cs index ac525adf..0e804c28 100644 --- a/src/MatBlazor/Components/MatNavMenu/BaseMatNavItem.cs +++ b/src/MatBlazor/Components/MatNavMenu/BaseMatNavItem.cs @@ -99,7 +99,7 @@ protected async Task OnClickHandler(MouseEventArgs e) return; } - if (AllowSelection) + if (AllowSelection && !e.CtrlKey && !e.ShiftKey) { await ToggleSelectedAsync(); } diff --git a/src/MatBlazor/Components/MatNavMenu/MatNavSubMenuHeader.razor b/src/MatBlazor/Components/MatNavMenu/MatNavSubMenuHeader.razor index fa5aa7d7..fbab9dbc 100644 --- a/src/MatBlazor/Components/MatNavMenu/MatNavSubMenuHeader.razor +++ b/src/MatBlazor/Components/MatNavMenu/MatNavSubMenuHeader.razor @@ -32,11 +32,11 @@ .Add("mdc-ripple-surface") .Add("mdc-nav-sub-menu-header") .Add("mdc-list--non-interactive"); - CallAfterRender(async () => { await JsInvokeAsync("matBlazor.matAccordion.initSummary", Ref); }); + CallAfterRender(async () => { await JsInvokeVoidAsync("matBlazor.matAccordion.initSummary", Ref); }); } - protected void OnClickHandler(MouseEventArgs e) + protected async Task OnClickHandler(MouseEventArgs e) { - this.NavSubMenu.ToggleAsync(); + await this.NavSubMenu.ToggleAsync(); } } \ No newline at end of file diff --git a/src/MatBlazor/Components/MatPaginator/BaseMatPaginator.cs b/src/MatBlazor/Components/MatPaginator/BaseMatPaginator.cs index c5e6dc09..ee1590be 100644 --- a/src/MatBlazor/Components/MatPaginator/BaseMatPaginator.cs +++ b/src/MatBlazor/Components/MatPaginator/BaseMatPaginator.cs @@ -90,7 +90,7 @@ public async Task NavigateToPage(MatPaginatorAction direction, int pageSize) { page = ((PageIndex * PageSize) / pageSize); } - catch (OverflowException e) + catch (OverflowException) { } } @@ -120,7 +120,7 @@ public async Task NavigateToPage(MatPaginatorAction direction, int pageSize) } } } - catch (Exception e) + catch (Exception) { } diff --git a/src/MatBlazor/Components/MatPaginator/MatPaginator.razor b/src/MatBlazor/Components/MatPaginator/MatPaginator.razor index de526c1f..2bd6de21 100644 --- a/src/MatBlazor/Components/MatPaginator/MatPaginator.razor +++ b/src/MatBlazor/Components/MatPaginator/MatPaginator.razor @@ -13,11 +13,11 @@
@PageLabel @(PageIndex + 1) / @TotalPages
- NavigateToPage(MatPaginatorAction.First, PageSize)) Disabled=@(PageIndex <= 0)> - NavigateToPage(MatPaginatorAction.Previous, PageSize)) Disabled=@(PageIndex <= 0)> + await NavigateToPage(MatPaginatorAction.First, PageSize)) Disabled=@(PageIndex <= 0)> + await NavigateToPage(MatPaginatorAction.Previous, PageSize)) Disabled=@(PageIndex <= 0)> - - NavigateToPage(MatPaginatorAction.Last, PageSize)) Disabled=@(TotalPages - PageIndex <= 1)> + + await NavigateToPage(MatPaginatorAction.Last, PageSize)) Disabled=@(TotalPages - PageIndex <= 1)>
diff --git a/src/MatBlazor/Components/MatProgressBar/BaseMatProgressBar.cs b/src/MatBlazor/Components/MatProgressBar/BaseMatProgressBar.cs index 599d17de..89fe7582 100644 --- a/src/MatBlazor/Components/MatProgressBar/BaseMatProgressBar.cs +++ b/src/MatBlazor/Components/MatProgressBar/BaseMatProgressBar.cs @@ -32,7 +32,7 @@ public double Progress _progress = value; CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matProgressBar.setProgress", Ref, value); + await JsInvokeVoidAsync("matBlazor.matProgressBar.setProgress", Ref, value); }); } } @@ -50,7 +50,7 @@ public double Buffer CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matProgressBar.setBuffer", Ref, value); + await JsInvokeVoidAsync("matBlazor.matProgressBar.setBuffer", Ref, value); }); } } @@ -65,7 +65,7 @@ public BaseMatProgressBar() .If("mdc-linear-progress--indeterminate", () => this.Indeterminate) .If("mdc-linear-progress--reversed", () => this.Reversed) .If("mdc-linear-progress--closed", () => Closed); - CallAfterRender(async () => { await JsInvokeAsync("matBlazor.matProgressBar.init", Ref); }); + CallAfterRender(async () => { await JsInvokeVoidAsync("matBlazor.matProgressBar.init", Ref); }); } protected override Task OnParametersSetAsync() diff --git a/src/MatBlazor/Components/MatProgressCircle/BaseMatProgressCircle.cs b/src/MatBlazor/Components/MatProgressCircle/BaseMatProgressCircle.cs index 70745153..a941946b 100644 --- a/src/MatBlazor/Components/MatProgressCircle/BaseMatProgressCircle.cs +++ b/src/MatBlazor/Components/MatProgressCircle/BaseMatProgressCircle.cs @@ -62,7 +62,7 @@ public double Progress if (Math.Abs(value - _progress) > double.Epsilon) { _progress = value; - CallAfterRender(async () => await JsInvokeAsync("matBlazor.matProgressCircle.setProgress", Ref, value)); + CallAfterRender(async () => await JsInvokeVoidAsync("matBlazor.matProgressCircle.setProgress", Ref, value)); } } } @@ -90,7 +90,7 @@ public BaseMatProgressCircle() .If("mdc-circular-progress--determinate", () => !this.Indeterminate) .If("mdc-circular-progress--closed", () => this.Closed); - CallAfterRender(async () => { await JsInvokeAsync("matBlazor.matProgressCircle.init", Ref); }); + CallAfterRender(async () => { await JsInvokeVoidAsync("matBlazor.matProgressCircle.init", Ref); }); } protected override void OnParametersSet() diff --git a/src/MatBlazor/Components/MatRadioButton/BaseMatRadioButtonInternal.cs b/src/MatBlazor/Components/MatRadioButton/BaseMatRadioButtonInternal.cs index 0a4a9c7b..4a8e5bae 100644 --- a/src/MatBlazor/Components/MatRadioButton/BaseMatRadioButtonInternal.cs +++ b/src/MatBlazor/Components/MatRadioButton/BaseMatRadioButtonInternal.cs @@ -60,7 +60,7 @@ protected void OnChangeHandler(ChangeEventArgs e) protected async override Task OnFirstAfterRenderAsync() { await base.OnFirstAfterRenderAsync(); - await JsInvokeAsync("matBlazor.matRadioButton.init", Ref, FormFieldRef); + await JsInvokeVoidAsync("matBlazor.matRadioButton.init", Ref, FormFieldRef); } public BaseMatRadioButtonInternal() diff --git a/src/MatBlazor/Components/MatRipple/BaseMatRipple.cs b/src/MatBlazor/Components/MatRipple/BaseMatRipple.cs index 1c003b7a..74c48101 100644 --- a/src/MatBlazor/Components/MatRipple/BaseMatRipple.cs +++ b/src/MatBlazor/Components/MatRipple/BaseMatRipple.cs @@ -19,7 +19,7 @@ public BaseMatRipple() .Add("mdc-ripple-surface") .If("mdc-ripple-surface--primary", () => Color == MatRippleColor.Primary) .If("mdc-ripple-surface--accent", () => Color == MatRippleColor.Secondary); - CallAfterRender(async () => { await JsInvokeAsync("matBlazor.matRipple.init", Ref); }); + CallAfterRender(async () => { await JsInvokeVoidAsync("matBlazor.matRipple.init", Ref); }); } } } \ No newline at end of file diff --git a/src/MatBlazor/Components/MatSelect/BaseCoreMatSelect.cs b/src/MatBlazor/Components/MatSelect/BaseCoreMatSelect.cs index 2ed95de7..3b8b9361 100644 --- a/src/MatBlazor/Components/MatSelect/BaseCoreMatSelect.cs +++ b/src/MatBlazor/Components/MatSelect/BaseCoreMatSelect.cs @@ -2,6 +2,8 @@ using Microsoft.AspNetCore.Components.Web; using Microsoft.JSInterop; using System; +using System.Diagnostics; +using System.Threading.Tasks; namespace MatBlazor { @@ -14,7 +16,9 @@ public class BaseCoreMatSelect : BaseMatInputComponent, IB private DotNetObjectReference jsHelperReference; internal MatBlazorSwitchT switchTK = MatBlazorSwitchT.Get(); - + private bool _disabled; + private bool _initialized; + public BaseCoreMatSelect() { jsHelper = new MatSelectJsHelper(); @@ -26,7 +30,8 @@ public BaseCoreMatSelect() .If("mdc-select--filled", () => !Outlined) .If("mdc-select--outlined", () => Outlined) .If("mdc-select--disabled", () => Disabled) - .If("mdc-select--with-leading-icon", () => Icon != null); + .If("mdc-select--with-leading-icon", () => Icon != null) + .If("select-dense-alt", () => Dense); StyleMapper .If("width: 100%", () => FullWidth); @@ -37,15 +42,18 @@ public BaseCoreMatSelect() .If("mdc-text-field-helper-text--validation-msg", () => HelperTextValidation); - CallAfterRender(async () => - { - jsHelperReference ??= DotNetObjectReference.Create(jsHelper); - await JsInvokeAsync("matBlazor.matSelect.init", Ref, jsHelperReference, - switchTK.FormatValueAsString(GetKeyFromValue(CurrentValue), null), new MatSelectInitOptions() - { - FullWidth = FullWidth, - }); - }); + CallAfterRender(InitializeJs); + } + + private async Task InitializeJs() + { + jsHelperReference ??= DotNetObjectReference.Create(jsHelper); + await JsInvokeVoidAsync("matBlazor.matSelect.init", Ref, jsHelperReference, + switchTK.FormatValueAsString(GetKeyFromValue(CurrentValue), null), new MatSelectInitOptions() + { + FullWidth = FullWidth, + }); + _initialized = true; } private void JsHelper_SetValueEvent(object sender, string value) @@ -56,7 +64,7 @@ private void JsHelper_SetValueEvent(object sender, string value) protected void OnChangeEventHandler(ChangeEventArgs e) { - SetValueEvent((string) e.Value); + SetValueEvent((string)e.Value); } @@ -71,7 +79,7 @@ protected override void OnValueChanged(TValue oldValue, TValue newValue) { CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matSelect.setValue", Ref, switchTK.FormatValueAsString(GetKeyFromValue(newValue), null)); + await JsInvokeVoidAsync("matBlazor.matSelect.setValue", Ref, switchTK.FormatValueAsString(GetKeyFromValue(newValue), null)); }); } } @@ -88,8 +96,8 @@ protected virtual TKey GetKeyFromValue(TValue value) protected ClassMapper HelperTextClassMapper { get; } = new ClassMapper(); -// [Parameter] -// public RenderFragment ChildContent { get; set; } + // [Parameter] + // public RenderFragment ChildContent { get; set; } protected virtual RenderFragment GetChildContent() @@ -112,7 +120,24 @@ public bool Enhanced public bool Outlined { get; set; } [Parameter] - public bool Disabled { get; set; } + public bool Disabled + { + get => _disabled; set + { + if (_disabled!= value) + { + _disabled=value; + if (_initialized) + { + _ = Task.Run(async () => + { + await InvokeAsync(StateHasChanged).ConfigureAwait(false); + await InitializeJs().ConfigureAwait(false); + }); + } + } + } + } [Parameter] public string Label { get; set; } @@ -135,10 +160,13 @@ public bool Enhanced [Parameter] public bool FullWidth { get; set; } + [Parameter] + public bool Dense { get; set; } + [Parameter] public EventCallback IconOnClick { get; set; } - + public MatBlazorSwitchT SwitchTypeKey => switchTK; } diff --git a/src/MatBlazor/Components/MatSelect/BaseCoreMatSelectValue.cs b/src/MatBlazor/Components/MatSelect/BaseCoreMatSelectValue.cs index 626ecbc4..1db2982f 100644 --- a/src/MatBlazor/Components/MatSelect/BaseCoreMatSelectValue.cs +++ b/src/MatBlazor/Components/MatSelect/BaseCoreMatSelectValue.cs @@ -14,6 +14,9 @@ public abstract class BaseCoreMatSelectValue : CoreMatSelect -
+
    @GetChildContent()
diff --git a/src/MatBlazor/Components/MatSelect/CoreMatSelectValue.razor b/src/MatBlazor/Components/MatSelect/CoreMatSelectValue.razor index c14dea0b..b41ca53d 100644 --- a/src/MatBlazor/Components/MatSelect/CoreMatSelectValue.razor +++ b/src/MatBlazor/Components/MatSelect/CoreMatSelectValue.razor @@ -10,24 +10,44 @@ protected override RenderFragment GetChildContent() { return - @ - @if (Items != null) + @ + @if (Items != null) + { + if (!Virtualize) { + for (int i = 0; i < Items.Count; i++) { var item = Items[i]; @if (ItemTemplate == null) - { - @item - } - else - { - @ItemTemplate(item) - } - + { + @item + } + else + { + @ItemTemplate(item) + } + } } - ; + else + { + + + @if (ItemTemplate == null) + { + @item.item + } + else + { + @ItemTemplate(item.item) + } + + + + } + } + ; } } \ No newline at end of file diff --git a/src/MatBlazor/Components/MatSlideToggle/BaseMatSlideToggle.cs b/src/MatBlazor/Components/MatSlideToggle/BaseMatSlideToggle.cs index 796ed7d1..86733b35 100644 --- a/src/MatBlazor/Components/MatSlideToggle/BaseMatSlideToggle.cs +++ b/src/MatBlazor/Components/MatSlideToggle/BaseMatSlideToggle.cs @@ -19,7 +19,7 @@ public BaseMatSlideToggle() .If("mdc-switch--checked", () => Checked); CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matSlideToggle.init", Ref); + await JsInvokeVoidAsync("matBlazor.matSlideToggle.init", Ref); }); } diff --git a/src/MatBlazor/Components/MatSlider/BaseMatSlider.cs b/src/MatBlazor/Components/MatSlider/BaseMatSlider.cs index 9ece8463..dbed9263 100644 --- a/src/MatBlazor/Components/MatSlider/BaseMatSlider.cs +++ b/src/MatBlazor/Components/MatSlider/BaseMatSlider.cs @@ -32,7 +32,7 @@ public BaseMatSlider() .If("mdc-slider--display-markers", () => Discrete && Markers); CallAfterRender(async () => { - await JsInvokeAsync("matBlazor.matSlider.init", Ref, jsHelper.Reference, Immediate); + await JsInvokeVoidAsync("matBlazor.matSlider.init", Ref, jsHelper.Reference, Immediate); }); } diff --git a/src/MatBlazor/Components/MatSnackbar/BaseMatSnackbar.cs b/src/MatBlazor/Components/MatSnackbar/BaseMatSnackbar.cs index 6c585891..3b979f6f 100644 --- a/src/MatBlazor/Components/MatSnackbar/BaseMatSnackbar.cs +++ b/src/MatBlazor/Components/MatSnackbar/BaseMatSnackbar.cs @@ -62,7 +62,7 @@ public bool IsOpen return; } _isOpen = false; - SetIsOpen(false); + _ = SetIsOpen(false); }); } } @@ -71,7 +71,7 @@ public bool IsOpen private async Task SetIsOpen(bool value) { - await JsInvokeAsync("matBlazor.matSnackbar.setIsOpen", Ref, value); + await JsInvokeVoidAsync("matBlazor.matSnackbar.setIsOpen", Ref, value); } /// @@ -99,7 +99,7 @@ public BaseMatSnackbar() CallAfterRender(async () => { _dotNetObjectRef ??= CreateDotNetObjectRef(this); - await JsInvokeAsync("matBlazor.matSnackbar.init", Ref, _dotNetObjectRef); + await JsInvokeVoidAsync("matBlazor.matSnackbar.init", Ref, _dotNetObjectRef); }); } diff --git a/src/MatBlazor/Components/MatSort/BaseMatSortHeader.cs b/src/MatBlazor/Components/MatSort/BaseMatSortHeader.cs index 83cbdbda..7c151154 100644 --- a/src/MatBlazor/Components/MatSort/BaseMatSortHeader.cs +++ b/src/MatBlazor/Components/MatSort/BaseMatSortHeader.cs @@ -74,8 +74,8 @@ protected string GetIcon() return Parent.Direction switch { MatSortDirection.None => null, - MatSortDirection.Asc => MatIconNames.Arrow_downward, - MatSortDirection.Desc => MatIconNames.Arrow_upward, + MatSortDirection.Asc => MatIconNames.Arrow_upward, + MatSortDirection.Desc => MatIconNames.Arrow_downward, _ => throw new ArgumentOutOfRangeException(), }; } diff --git a/src/MatBlazor/Components/MatTabBar/BaseMatTabBar.cs b/src/MatBlazor/Components/MatTabBar/BaseMatTabBar.cs index f3086e1a..93e4adc9 100644 --- a/src/MatBlazor/Components/MatTabBar/BaseMatTabBar.cs +++ b/src/MatBlazor/Components/MatTabBar/BaseMatTabBar.cs @@ -86,7 +86,7 @@ await InvokeAsync(() => public BaseMatTabBar() { ClassMapper.Add("mdc-tab-bar"); -// this.CallAfterRender(async () => { await this.JsInvokeAsync("matBlazor.matTabBar.init", Ref); }); +// this.CallAfterRender(async () => { await this.JsInvokeVoidAsync("matBlazor.matTabBar.init", Ref); }); } } } \ No newline at end of file diff --git a/src/MatBlazor/Components/MatTabLabel/BaseMatTabLabel.cs b/src/MatBlazor/Components/MatTabLabel/BaseMatTabLabel.cs index bf274a52..5492b0f7 100644 --- a/src/MatBlazor/Components/MatTabLabel/BaseMatTabLabel.cs +++ b/src/MatBlazor/Components/MatTabLabel/BaseMatTabLabel.cs @@ -37,7 +37,7 @@ protected override void OnInitialized() public override void Dispose() { disposed = true; - Parent.TabDisposed(this); + _ = Parent.TabDisposed(this); } public bool IsActive diff --git a/src/MatBlazor/Components/MatTable/BaseMatTable.cs b/src/MatBlazor/Components/MatTable/BaseMatTable.cs index 806f8f54..65c4932f 100644 --- a/src/MatBlazor/Components/MatTable/BaseMatTable.cs +++ b/src/MatBlazor/Components/MatTable/BaseMatTable.cs @@ -8,11 +8,11 @@ namespace MatBlazor /// /// Mat Table display a table data. /// - public class BaseMatTable : BaseMatDomComponent + public class BaseMatTable : BaseMatDomComponent { private string _searchTermFieldPlaceHolder = null; private string _searchTermFieldLabel = null; - public BaseTableRow Current { get; private set; } + public BaseTableRow Current { get; private set; } #region Private Fields protected int TotalPages { get; set; } @@ -69,7 +69,7 @@ public class BaseMatTable : BaseMatDomComponent #endregion [Parameter] - public Action SelectionChanged { get; set; } + public Action SelectionChanged { get; set; } /// /// Specifies a custom class for the MatTableHeader row @@ -214,10 +214,10 @@ public BaseMatTable() /// Action to execute on row item /// [Parameter] - public EventCallback OnRowDbClick { get; set; } + public EventCallback OnRowDbClick { get; set; } #region Helpers - public async Task ToggleSelectedAsync(BaseTableRow row) + public async Task ToggleSelectedAsync(BaseTableRow row) { if (row.Selected) { @@ -232,7 +232,7 @@ public async Task ToggleSelectedAsync(BaseTableRow row) } else { - SelectionChanged?.Invoke(null); + SelectionChanged?.Invoke(default); } } @@ -305,7 +305,7 @@ public class PageSizeStructure #region events - protected void OnRowDbClickHandler(object item) + protected void OnRowDbClickHandler(TItem item) { if (OnRowDbClick.HasDelegate) { diff --git a/src/MatBlazor/Components/MatTable/BaseTableRow.cs b/src/MatBlazor/Components/MatTable/BaseTableRow.cs index b2a35ba3..20f6b1cc 100644 --- a/src/MatBlazor/Components/MatTable/BaseTableRow.cs +++ b/src/MatBlazor/Components/MatTable/BaseTableRow.cs @@ -7,10 +7,10 @@ namespace MatBlazor /// /// Mat Table Row display a table row /// - public class BaseTableRow : BaseMatDomComponent + public class BaseTableRow : BaseMatDomComponent { [CascadingParameter] - public BaseMatTable Table { get; set; } + public BaseMatTable Table { get; set; } [Parameter] public RenderFragment ChildContent { get; set; } @@ -22,7 +22,7 @@ public class BaseTableRow : BaseMatDomComponent public bool AllowSelection { get; set; } [Parameter] - public object RowItem { get; set; } + public TItem RowItem { get; set; } [Parameter] public EventCallback SelectedChanged { get; set; } @@ -45,7 +45,7 @@ public BaseTableRow() protected async Task OnClickHandler(MouseEventArgs _) { - if (AllowSelection) + if (AllowSelection && !Selected) { await ToggleSelectedAsync(); } diff --git a/src/MatBlazor/Components/MatTable/MatTable.razor b/src/MatBlazor/Components/MatTable/MatTable.razor index f3e07d73..3d0601d2 100644 --- a/src/MatBlazor/Components/MatTable/MatTable.razor +++ b/src/MatBlazor/Components/MatTable/MatTable.razor @@ -1,5 +1,5 @@ @namespace MatBlazor -@inherits BaseMatTable +@inherits BaseMatTable @typeparam TableItem @inject System.Net.Http.HttpClient Http @@ -30,7 +30,7 @@ { @foreach (var item in ItemList) { - >(itemsString, opt); - + Items = items; int count = root.GetProperty(PagingRecordsCountPropertyName).GetInt32(); RecordsFrom = (CurrentPage - 1) * PageSize; @@ -341,15 +341,17 @@ ItemList = PageSize <= 0 ? filteredCollection : filteredCollection.Skip(RecordsFrom).Take(PageSize); } - else + else if (Items != null) { ItemList = PageSize <= 0 ? Items : Items.Skip(RecordsFrom).Take(PageSize); RecordsTo = (RecordsFrom + PageSize < Items.Count()) ? RecordsFrom + PageSize : Items.Count(); TotalPages = Math.Max(1, (int)Math.Ceiling(Items.Count() / (decimal)PageSize)); EndPage = TotalPages; } + else { } // Do nothing + SetPageSize(PageDirection.Next); - StateHasChanged(); + _ = InvokeAsync(StateHasChanged); } catch (Exception ex) { diff --git a/src/MatBlazor/Components/MatTable/TableRow.razor b/src/MatBlazor/Components/MatTable/TableRow.razor index 67b974fe..4d370510 100644 --- a/src/MatBlazor/Components/MatTable/TableRow.razor +++ b/src/MatBlazor/Components/MatTable/TableRow.razor @@ -1,5 +1,6 @@ @namespace MatBlazor -@inherits BaseTableRow +@inherits BaseTableRow +@typeparam TItem @using Microsoft.AspNetCore.Components diff --git a/src/MatBlazor/Components/MatTextField/BaseMatInputTextComponent.cs b/src/MatBlazor/Components/MatTextField/BaseMatInputTextComponent.cs index a0c9417f..6fa72347 100644 --- a/src/MatBlazor/Components/MatTextField/BaseMatInputTextComponent.cs +++ b/src/MatBlazor/Components/MatTextField/BaseMatInputTextComponent.cs @@ -58,6 +58,9 @@ public abstract class BaseMatInputTextComponent : BaseMatInputTextElemen [Parameter] public bool Disabled { get; set; } + [Parameter] + public string BindEvent { get; set; } = "onchange"; + /// /// When true, it specifies that an input field is read-only. /// @@ -165,7 +168,7 @@ bool TextOrPlaceHolderVisible() // .If("_mdc-text-field--upgraded", () => !string.IsNullOrEmpty(CurrentValueAsString)) .If("mat-hide-clearbutton", () => this.HideClearButton); - CallAfterRender(async () => { await JsInvokeAsync("matBlazor.matTextField.init", Ref); }); + CallAfterRender(async () => { await JsInvokeVoidAsync("matBlazor.matTextField.init", Ref); }); } } } diff --git a/src/MatBlazor/Components/MatTextField/MatInputTextComponent.razor b/src/MatBlazor/Components/MatTextField/MatInputTextComponent.razor index 3c1b5840..638f5dfc 100644 --- a/src/MatBlazor/Components/MatTextField/MatInputTextComponent.razor +++ b/src/MatBlazor/Components/MatTextField/MatInputTextComponent.razor @@ -16,11 +16,11 @@ @if (TextArea) { -