Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into heather/sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Heathermcx committed Dec 8, 2023
2 parents 5858f8b + 46d9800 commit b2094e0
Show file tree
Hide file tree
Showing 17 changed files with 386 additions and 29 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: PushToNuget
env:
NUGET_DIR: '${{ github.workspace }}/nuget'

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Pack Blazor.Diagrams.Core
working-directory: src/Blazor.Diagrams.Core
run: 'dotnet pack -p:GeneratePackageOnBuild=false --configuration Release --output ${{ env.NUGET_DIR }}'

- name: Pack Blazor.Diagrams
working-directory: src/Blazor.Diagrams
run: 'dotnet pack -p:GeneratePackageOnBuild=false --configuration Release --output ${{ env.NUGET_DIR }}'

- name: Pack Blazor.Diagrams.Algorithms
working-directory: src/Blazor.Diagrams.Algorithms
run: 'dotnet pack -p:GeneratePackageOnBuild=false --configuration Release --output ${{ env.NUGET_DIR }}'

- name: Push Blazor.Diagrams.Core
run: 'dotnet nuget push ${{ env.NUGET_DIR }}/Z.Blazor.Diagrams.Core.3.0.1.nupkg --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate'

- name: Push Blazor.Diagrams
run: 'dotnet nuget push ${{ env.NUGET_DIR }}/Z.Blazor.Diagrams.3.0.1.nupkg --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate'

- name: Push Blazor.Diagrams.Algorithms
run: 'dotnet nuget push ${{ env.NUGET_DIR }}/Z.Blazor.Diagrams.Algorithms.3.0.1.nupkg --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate'
1 change: 1 addition & 0 deletions Blazor.Diagrams.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github\workflows\build.yml = .github\workflows\build.yml
CHANGELOG.md = CHANGELOG.md
.github\workflows\main.yml = .github\workflows\main.yml
.github\workflows\push.yml = .github\workflows\push.yml
README.md = README.md
EndProjectSection
EndProject
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Diagrams (3.0.1) - 2023-10-27

### Added

- `Route` property to `BaseLinkModel` to hold the result of the executed router

### Fixed

- Constraints not checked when using `RemoveControl` (thanks to @[K0369](https://github.com/K0369))
- NRE Exception on the landing page demo when dragging a new link and not linking it to something (thanks to @[K0369](https://github.com/K0369))
- `LinkVertexWidgetTests` failing on cultures that are not using a dot as decimal separator (thanks to @[K0369](https://github.com/K0369))
- NRE exception in the Diagram Demo project (thanks to @[Suraj0500](https://github.com/Suraj0500))

## Diagrams (3.0.0) - 2023-08-14

Finally, the new documentation website is here!
Expand Down
2 changes: 1 addition & 1 deletion docs/Diagram-Demo/Pages/Diagrams.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ or it will not be rendered.
</div>

@code {
private Diagram Diagram { get; set; }
private BlazorDiagram Diagram { get; set; }

protected override void OnInitialized()
{
Expand Down
14 changes: 10 additions & 4 deletions site/Site/Components/Landing/LandingShowcaseDiagram.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,24 @@ private void OnLinkAdded(BaseLinkModel link)
link.TargetChanged += OnLinKTargetChanged;
}

private void OnLinKTargetChanged(BaseLinkModel link, Anchor? oldTarget, Anchor? newTarget)
private void OnLinKTargetChanged(BaseLinkModel link, Anchor oldTarget, Anchor newTarget)
{
if (oldTarget == null && newTarget != null) // First attach
// only refresh on the first time the link is attached
if (oldTarget is PositionAnchor
&& newTarget.Model is PortModel targetModel
&& link.IsAttached)
{
(newTarget.Model as PortModel)!.Parent.Refresh();
targetModel.Parent.Refresh();
}
}

private void OnLinkRemoved(BaseLinkModel link)
{
(link.Source.Model as PortModel)!.Parent.Refresh();
if (link.Target != null) (link.Target.Model as PortModel)!.Parent.Refresh();
if (link.Target is SinglePortAnchor anchor && anchor.Model is PortModel portModel)
{
portModel.Parent.Refresh();
}
link.TargetChanged -= OnLinKTargetChanged;
}
}
10 changes: 6 additions & 4 deletions site/Site/Pages/Documentation/Links/PathGenerators.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ link.PathGenerator = new SmoothPathGenerator();
<h2>Straight Path Generator</h2>

<p>
The <code>StraightPathGenerator</code> generates straight lines.
The <code>StraightPathGenerator</code> generates straight lines.<br />
You can also choose a radius for when the path contains vertices or direction changes.
</p>

<h3>Usage</h3>
Expand Down Expand Up @@ -78,12 +79,13 @@ link.PathGenerator = new StraightPathGenerator();
// Straight Path Generator
var stpgNode1 = _stpgDiagram.Nodes.Add(new NodeModel(new Point(150, 50)));
var stpgNode2 = _stpgDiagram.Nodes.Add(new NodeModel(new Point(450, 110)));
var stpgBottomPort1 = stpgNode1.AddPort(PortAlignment.BottomRight);
var stpgBottomPort1 = stpgNode1.AddPort(PortAlignment.Bottom);
var stpgRightPort1 = stpgNode1.AddPort(PortAlignment.Right);
var stpgBottomPort2 = stpgNode2.AddPort(PortAlignment.BottomLeft);
var stpgLeftPort2 = stpgNode2.AddPort(PortAlignment.Left);
_stpgDiagram.Links.Add(new LinkModel(stpgBottomPort1, stpgBottomPort2)).PathGenerator = new StraightPathGenerator();
_stpgDiagram.Links.Add(new LinkModel(stpgRightPort1, stpgLeftPort2)).PathGenerator = new StraightPathGenerator();

var link = _stpgDiagram.Links.Add(new LinkModel(stpgBottomPort1, stpgBottomPort2));
link.PathGenerator = new StraightPathGenerator(10);
link.AddVertex(new Point(200, 250));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>zHaytam</Authors>
<Description>Algorithms for Z.Blazor.Diagrams</Description>
<AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>3.0.0</FileVersion>
<AssemblyVersion>3.0.1</AssemblyVersion>
<FileVersion>3.0.1</FileVersion>
<RepositoryUrl>https://github.com/zHaytam/Blazor.Diagrams</RepositoryUrl>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<PackageId>Z.Blazor.Diagrams.Algorithms</PackageId>
<PackageTags>blazor diagrams diagramming svg drag algorithms layouts</PackageTags>
<Product>Z.Blazor.Diagrams.Algorithms</Product>
Expand Down
6 changes: 3 additions & 3 deletions src/Blazor.Diagrams.Core/Blazor.Diagrams.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>zHaytam</Authors>
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
<AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>3.0.0</FileVersion>
<AssemblyVersion>3.0.1</AssemblyVersion>
<FileVersion>3.0.1</FileVersion>
<RepositoryUrl>https://github.com/Blazor-Diagrams/Blazor.Diagrams</RepositoryUrl>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<PackageId>Z.Blazor.Diagrams.Core</PackageId>
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
<Product>Z.Blazor.Diagrams.Core</Product>
Expand Down
36 changes: 31 additions & 5 deletions src/Blazor.Diagrams.Core/Controls/Default/RemoveControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,44 @@ public RemoveControl(IPositionProvider positionProvider)

public override Point? GetPosition(Model model) => _positionProvider.GetPosition(model);

public override ValueTask OnPointerDown(Diagram diagram, Model model, PointerEventArgs _)
public override async ValueTask OnPointerDown(Diagram diagram, Model model, PointerEventArgs _)
{
switch (model)
if (await ShouldDeleteModel(diagram, model))
{
DeleteModel(diagram, model);
}
}

private static void DeleteModel(Diagram diagram, Model model)
{
switch (model)
{
case GroupModel group:
diagram.Groups.Delete(group);
return;
case NodeModel node:
diagram.Nodes.Remove(node);
break;
return;

case BaseLinkModel link:
diagram.Links.Remove(link);
break;
return;
}
}

private static async ValueTask<bool> ShouldDeleteModel(Diagram diagram, Model model)
{
if (model.Locked)
{
return false;
}

return ValueTask.CompletedTask;
return model switch
{
GroupModel group => await diagram.Options.Constraints.ShouldDeleteGroup.Invoke(group),
NodeModel node => await diagram.Options.Constraints.ShouldDeleteNode.Invoke(node),
BaseLinkModel link => await diagram.Options.Constraints.ShouldDeleteLink.Invoke(link),
_ => false,
};
}
}
3 changes: 3 additions & 0 deletions src/Blazor.Diagrams.Core/Models/Base/BaseLinkModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected BaseLinkModel(string id, Anchor source, Anchor target) : base(id)
public Anchor Source { get; private set; }
public Anchor Target { get; private set; }
public Diagram? Diagram { get; internal set; }
public Point[]? Route { get; private set; }
public PathGeneratorResult? PathGeneratorResult { get; private set; }
public bool IsAttached => Source is not PositionAnchor && Target is not PositionAnchor;
public Router? Router { get; set; }
Expand Down Expand Up @@ -129,11 +130,13 @@ private void GeneratePath()
var target = Target.GetPosition(this, route);
if (source != null && target != null)
{
Route = route;
PathGeneratorResult = pathGenerator.GetResult(Diagram, this, route, source, target);
return;
}
}

Route = null;
PathGeneratorResult = null;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Blazor.Diagrams/Blazor.Diagrams.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<Nullable>enable</Nullable>
<Authors>zHaytam</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AssemblyVersion>3.0.0</AssemblyVersion>
<FileVersion>3.0.0</FileVersion>
<AssemblyVersion>3.0.1</AssemblyVersion>
<FileVersion>3.0.1</FileVersion>
<RepositoryUrl>https://github.com/Blazor-Diagrams/Blazor.Diagrams</RepositoryUrl>
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
<PackageId>Z.Blazor.Diagrams</PackageId>
Expand Down
4 changes: 2 additions & 2 deletions src/Blazor.Diagrams/Components/LinkWidget.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private RenderFragment GetSelectionHelperPath(string color, string d, int index)
builder.AddAttribute(3, "stroke-width", 12);
builder.AddAttribute(4, "d", d);
builder.AddAttribute(5, "stroke-linecap", "butt");
builder.AddAttribute(6, "stroke-opacity", _hovered ? 0.05 : 0);
builder.AddAttribute(6, "stroke-opacity", _hovered ? "0.05" : "0");
builder.AddAttribute(7, "fill", "none");
builder.AddAttribute(8, "onmouseenter", EventCallback.Factory.Create<MouseEventArgs>(this, OnMouseEnter));
builder.AddAttribute(9, "onmouseleave", EventCallback.Factory.Create<MouseEventArgs>(this, OnMouseLeave));
Expand Down Expand Up @@ -59,4 +59,4 @@ private LinkVertexModel CreateVertex(double clientX, double clientY, int index)
Link.Refresh();
return vertex;
}
}
}
5 changes: 3 additions & 2 deletions src/Blazor.Diagrams/wwwroot/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ var s = {
}
},
unobserve: (element, id) => {
if (!element) return;
s.ro.unobserve(element);
if (element) {
s.ro.unobserve(element);
}
delete s.tracked[id];
delete s.canvases[id];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Blazor.Diagrams/wwwroot/script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified src/Blazor.Diagrams/wwwroot/script.min.js.gz
Binary file not shown.
Loading

0 comments on commit b2094e0

Please sign in to comment.