-
Notifications
You must be signed in to change notification settings - Fork 462
[dev-v5] Add SortableList #4487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vnbaaij
wants to merge
42
commits into
dev-v5
Choose a base branch
from
users/vnbaaij/dev-v5/sortable-list
base: dev-v5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
97e7ddd
Add SortableList
vnbaaij 5c0106b
Store
vnbaaij ca77226
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/sortable-list
vnbaaij 46112a9
- Update script (a11y)
vnbaaij f625c20
Initial work on making cross-list move work with keyboard
vnbaaij a765f7d
Add IMask library integration for TextInput component and update docu…
dvoituron 681148f
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/sortable-list
vnbaaij 9e6b7c6
Merge branch 'dev-v5' into users/dvoituron/dev-v5/external-js-lib
vnbaaij 0541827
Merge
vnbaaij d431123
Make it work with external lib work
vnbaaij 9235abd
Merge final external work
vnbaaij cd8c85a
- Update examples
vnbaaij 7a01caf
- Use Debug/Release setting when building script project
vnbaaij 5727e53
Process review comments
vnbaaij c584334
Use the refined loading process
vnbaaij c461b9b
Merge
vnbaaij ec349c9
Update verified files and remove old BuildConstants file
vnbaaij 6d16d16
- Add comment to generated file
vnbaaij 1d18bac
Final touches
vnbaaij d583608
Process review commetns
vnbaaij 78f8647
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/sortable-list
vnbaaij bb7ba86
Update examples/Demo/FluentUI.Demo.Client/Documentation/Components/So…
vnbaaij 04fb7c1
Update src/Core/Components/SortableList/FluentSortableList.razor.cs
vnbaaij 3b2107a
Update tests/Core/Components/SortableList/FluentSortableListTests.razor
vnbaaij 892238d
Update src/Core.Scripts/src/Components/SortableList/FluentSortableLis…
vnbaaij b0a1bcc
Update src/Core/Components/SortableList/FluentSortableList.razor.css
vnbaaij 32de924
Update examples/Demo/FluentUI.Demo.Client/Documentation/Components/So…
vnbaaij 90c5ce7
Update src/Core/Components/SortableList/FluentSortableList.razor.cs
vnbaaij 3503247
Update src/Core.Scripts/src/Components/SortableList/FluentSortableLis…
vnbaaij 5eb2a13
Update examples/Demo/FluentUI.Demo.Client/Documentation/Components/So…
vnbaaij b434a67
Update examples/Demo/FluentUI.Demo.Client/Documentation/Components/So…
vnbaaij 3c9b935
Update src/Core/Components/SortableList/FluentSortableList.razor.cs
vnbaaij 6995462
Update src/Core/Components/SortableList/FluentSortableList.razor.css
vnbaaij 9b7c15c
Update src/Core/Components/SortableList/FluentSortableList.razor
vnbaaij 5707cd2
Update src/Core/Components/SortableList/FluentSortableList.razor.cs
vnbaaij 0a7f463
Update src/Core.Scripts/src/Components/SortableList/FluentSortableLis…
vnbaaij 6cc1b19
Update src/Core.Scripts/src/Components/SortableList/FluentSortableLis…
vnbaaij 48f042f
- Remove styling parameters
vnbaaij 4fd03fd
Merge branch 'users/vnbaaij/dev-v5/sortable-list' of https://github.c…
vnbaaij 65f1033
- Add example with more than 2 lists
vnbaaij 90cbeb0
Process more review comments
vnbaaij c6157e7
Merge branch 'dev-v5' into users/vnbaaij/dev-v5/sortable-list
vnbaaij File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
...Client/Documentation/Components/SortableList/Examples/SortableListCloneBetweenLists.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| <FluentGrid Justify="JustifyContent.FlexStart" Spacing="3"> | ||
| <FluentGridItem xs="12" sm="6"> | ||
| <h5>List 1</h5> | ||
| <FluentSortableList Id="clone1" Group="cloning" Clone="true" OnUpdate="@SortListOne" OnRemove="@ListOneRemove" Items="@items1" Context="item"> | ||
| <ItemTemplate>@item.Name</ItemTemplate> | ||
| </FluentSortableList> | ||
| </FluentGridItem> | ||
| <FluentGridItem xs="12" sm="6"> | ||
| <h5>List 2</h5> | ||
| <FluentSortableList Id="clone2" Group="cloning" Clone="true" OnUpdate="@SortListTwo" OnRemove="@ListTwoRemove" Items="@items2" Context="item"> | ||
| <ItemTemplate>@item.Name</ItemTemplate> | ||
| </FluentSortableList> | ||
| </FluentGridItem> | ||
| </FluentGrid> | ||
|
|
||
| @code { | ||
| class Item | ||
| { | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } = ""; | ||
|
|
||
| public bool Disabled { get; set; } = false; | ||
| } | ||
|
|
||
| List<Item> items1 = Enumerable.Range(1, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList(); | ||
|
|
||
| List<Item> items2 = Enumerable.Range(11, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList(); | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void ListOneRemove(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // get the item at the old index in list 1 | ||
| var item = items1[args.OldIndex]; | ||
|
|
||
| var clone = item; | ||
|
|
||
| // add it to the new index in list 2 | ||
| items2.Insert(args.NewIndex, clone); | ||
| } | ||
|
|
||
| void ListTwoRemove(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // get the item at the old index in list 2 | ||
| var item = items2[args.OldIndex]; | ||
|
|
||
| // make a copy | ||
| var clone = item; | ||
|
|
||
| // add it to the new index in list 1 | ||
| items1.Insert(args.NewIndex, clone); | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| void SortListOne(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null || args.OldIndex == args.NewIndex) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var oldIndex = args.OldIndex; | ||
| var newIndex = args.NewIndex; | ||
|
|
||
| var items = this.items1; | ||
| var itemToMove = items[oldIndex]; | ||
| items.RemoveAt(oldIndex); | ||
|
|
||
| if (newIndex < items.Count) | ||
| { | ||
| items.Insert(newIndex, itemToMove); | ||
| } | ||
| else | ||
| { | ||
| items.Add(itemToMove); | ||
| } | ||
| } | ||
|
|
||
| void SortListTwo(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null || args.OldIndex == args.NewIndex) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var oldIndex = args.OldIndex; | ||
| var newIndex = args.NewIndex; | ||
|
|
||
| var items = this.items2; | ||
| var itemToMove = items[oldIndex]; | ||
| items.RemoveAt(oldIndex); | ||
|
|
||
| if (newIndex < items.Count) | ||
| { | ||
| items.Insert(newIndex, itemToMove); | ||
| } | ||
| else | ||
| { | ||
| items.Add(itemToMove); | ||
| } | ||
| } | ||
| } | ||
45 changes: 45 additions & 0 deletions
45
...ntUI.Demo.Client/Documentation/Components/SortableList/Examples/SortableListDefault.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| <FluentGrid Justify="JustifyContent.FlexStart" Spacing="3"> | ||
| <FluentGridItem xs="12" sm="6"> | ||
| <FluentSortableList Items="items" OnUpdate="@SortList"> | ||
| <ItemTemplate>@context.Name</ItemTemplate> | ||
| </FluentSortableList> | ||
| </FluentGridItem> | ||
| </FluentGrid> | ||
|
|
||
| @code { | ||
|
|
||
| class Item | ||
| { | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } = ""; | ||
|
|
||
| public bool Disabled { get; set; } = false; | ||
| } | ||
|
|
||
| List<Item> items = Enumerable.Range(1, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList(); | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| void SortList(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null || args.OldIndex == args.NewIndex) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var oldIndex = args.OldIndex; | ||
| var newIndex = args.NewIndex; | ||
|
|
||
| var items = this.items; | ||
| var itemToMove = items[oldIndex]; | ||
| items.RemoveAt(oldIndex); | ||
|
|
||
| if (newIndex < items.Count) | ||
| { | ||
| items.Insert(newIndex, itemToMove); | ||
| } | ||
| else | ||
| { | ||
| items.Add(itemToMove); | ||
| } | ||
| } | ||
| } | ||
74 changes: 74 additions & 0 deletions
74
...o.Client/Documentation/Components/SortableList/Examples/SortableListDisabledSorting.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| @page "/sortablelist-disabled-sorting/debug" | ||
| <FluentGrid Justify="JustifyContent.FlexStart" Spacing="3"> | ||
| <FluentGridItem xs="12" sm="6"> | ||
| <h5>List 1</h5> | ||
| <FluentSortableList Id="disabledOne" Group="disabledSorting" Drop="false" Sort="false" Items="items1" Context="item" OnRemove="ListOneRemove"> | ||
| <ItemTemplate>@item.Name</ItemTemplate> | ||
| </FluentSortableList> | ||
| </FluentGridItem> | ||
| <FluentGridItem xs="12" sm="6"> | ||
| <h5>List 2</h5> | ||
| <FluentSortableList Id="disabledTwo" Group="disabledSorting" Items="items2" Context="item" OnUpdate="SortList"> | ||
| <ItemTemplate>@item.Name</ItemTemplate> | ||
| </FluentSortableList> | ||
| </FluentGridItem> | ||
| </FluentGrid> | ||
|
|
||
| @code { | ||
| class Item | ||
| { | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } = ""; | ||
|
|
||
| public bool Disabled { get; set; } = false; | ||
| } | ||
|
|
||
| List<Item> items1 = Enumerable.Range(1, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList(); | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| List<Item> items2 = Enumerable.Range(11, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList(); | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void ListOneRemove(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| // get the item at the old index in list 1 | ||
| var item = items1[args.OldIndex]; | ||
|
|
||
| // add it to the new index in list 2 | ||
| items2.Insert(args.NewIndex, item); | ||
|
|
||
| // remove the item from the old index in list 1 | ||
| items1.Remove(items1[args.OldIndex]); | ||
|
|
||
| Console.WriteLine($"Moved item '{item.Name}' from list '{args.FromListId}' to list '{args.ToListId}'"); | ||
| } | ||
|
|
||
| void SortList(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null || args.OldIndex == args.NewIndex) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var oldIndex = args.OldIndex; | ||
| var newIndex = args.NewIndex; | ||
|
|
||
| var items = this.items2; | ||
| var itemToMove = items[oldIndex]; | ||
| items.RemoveAt(oldIndex); | ||
|
|
||
| if (newIndex < items2.Count) | ||
| { | ||
| items.Insert(newIndex, itemToMove); | ||
| } | ||
| else | ||
| { | ||
| items.Add(itemToMove); | ||
| } | ||
|
|
||
| StateHasChanged(); | ||
| } | ||
| } | ||
47 changes: 47 additions & 0 deletions
47
....Demo.Client/Documentation/Components/SortableList/Examples/SortableListDragHandles.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <FluentGrid Justify="JustifyContent.FlexStart" Spacing="3"> | ||
| <FluentGridItem xs="12" sm="6"> | ||
| <FluentSortableList Id="dragHandles" Handle="true" Items="items" OnUpdate="@SortList" Context="item"> | ||
| <ItemTemplate> | ||
| <div class="sortable-grab"> | ||
| <FluentIcon Value="@(new Icons.Regular.Size20.ArrowSort())" /> | ||
| </div> | ||
| <div class="sortable-item-content" style="flex-grow: 1;">@item.Name</div> | ||
| </ItemTemplate> | ||
| </FluentSortableList> | ||
| </FluentGridItem> | ||
| </FluentGrid> | ||
|
|
||
| @code { | ||
| class Item | ||
| { | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } = ""; | ||
|
|
||
| public bool Disabled { get; set; } = false; | ||
| } | ||
| List<Item> items = Enumerable.Range(1, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList(); | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| void SortList(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null || args.OldIndex == args.NewIndex) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var oldIndex = args.OldIndex; | ||
| var newIndex = args.NewIndex; | ||
|
|
||
| var items = this.items; | ||
| var itemToMove = items[oldIndex]; | ||
| items.RemoveAt(oldIndex); | ||
|
|
||
| if (newIndex < items.Count) | ||
| { | ||
| items.Insert(newIndex, itemToMove); | ||
| } | ||
| else | ||
| { | ||
| items.Add(itemToMove); | ||
| } | ||
| } | ||
| } | ||
47 changes: 47 additions & 0 deletions
47
...tUI.Demo.Client/Documentation/Components/SortableList/Examples/SortableListFallback.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <FluentGrid Justify="JustifyContent.FlexStart" Spacing="3"> | ||
| <FluentGridItem xs="12" sm="6"> | ||
| <FluentSortableList Fallback="true" Items="items" OnUpdate="@SortList"> | ||
| <ItemTemplate>@context.Name</ItemTemplate> | ||
| </FluentSortableList> | ||
| </FluentGridItem> | ||
| </FluentGrid> | ||
|
|
||
| @code { | ||
|
|
||
| class Item | ||
| { | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } = ""; | ||
|
|
||
| public bool Disabled { get; set; } = false; | ||
| } | ||
|
|
||
| List<Item> items = Enumerable.Range(1, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList(); | ||
vnbaaij marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| void SortList(FluentSortableListEventArgs args) | ||
| { | ||
| if (args is null || args.OldIndex == args.NewIndex) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| var oldIndex = args.OldIndex; | ||
| var newIndex = args.NewIndex; | ||
|
|
||
| var items = this.items; | ||
| var itemToMove = items[oldIndex]; | ||
| items.RemoveAt(oldIndex); | ||
|
|
||
| if (newIndex < items.Count) | ||
| { | ||
| items.Insert(newIndex, itemToMove); | ||
| } | ||
| else | ||
| { | ||
| items.Add(itemToMove); | ||
| } | ||
|
|
||
| StateHasChanged(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.