Skip to content
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

Revert some commits about SSR and refactor for adapting SSR #519

Merged
merged 11 commits into from
Dec 18, 2023
3 changes: 1 addition & 2 deletions src/Component/BlazorComponent.Web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"build:drawflow": "rollup --config rollup.config.drawflow.ts",
"build:swiper": "rollup --config rollup.config.swiper.ts",
"build:intersect": "rollup --config rollup.config.intersect.ts",
"build:resize": "rollup --config rollup.config.resize.ts",
"build:ssr": "rollup --config rollup.config.ssr.ts"
"build:resize": "rollup --config rollup.config.resize.ts"
},
"author": "",
"license": "MIT",
Expand Down
25 changes: 0 additions & 25 deletions src/Component/BlazorComponent.Web/rollup.config.ssr.ts

This file was deleted.

4 changes: 1 addition & 3 deletions src/Component/BlazorComponent.Web/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as slider from "./components/slider";
import * as interop from "./interop";
import * as overlayable from "./mixins/overlayable";
import * as ssr from "./ssr";

declare global {
interface Window {
Expand All @@ -14,8 +13,7 @@ window.BlazorComponent = {
interop: {
...interop,
...overlayable,
...slider,
ssr
...slider
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class OutsideClick {
}

removeListeners() {
document.removeEventListener("click", this.listener);
document.removeEventListener("mousedown", this.mousedownListener);
document.removeEventListener("click", this.listener, true);
document.removeEventListener("mousedown", this.mousedownListener, true);
}

resetListener() {
Expand All @@ -46,12 +46,14 @@ class OutsideClick {

checkEvent(e: MouseEvent) {
return this.excludedSelectors.some((selector) => {
const el = document.querySelector(selector);
if (!el) return false;

return el.contains(e.target as HTMLElement);
const elements = Array.from(document.querySelectorAll(selector));
return elements.some(el => el.contains(e.target as HTMLElement));
});
}

unbind() {
this.removeListeners();
}
}

function init(dotNetHelper: DotNet.DotNetObject, excludeSelectors: string[]) {
Expand Down
123 changes: 0 additions & 123 deletions src/Component/BlazorComponent.Web/src/ssr/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions src/Component/BlazorComponent.Web/src/ssr/page-script.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/Component/BlazorComponent.Web/src/ssr/ssr-state-restore.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ protected BDomComponentBase()
{
_watcher = new PropertyWatcher(GetType());

CssProvider = new(() => Class, () => Style);
AbstractProvider = new();
}

Expand All @@ -24,26 +23,12 @@ protected BDomComponentBase()
[Parameter]
public string Id { get; set; } = null!;

/// <summary>
/// Specifies one or more class names for an DOM element.
/// </summary>
[Parameter]
public string? Class { get; set; }

/// <summary>
/// Specifies an inline style for an DOM element.
/// </summary>
[Parameter]
public string? Style { get; set; }

/// <summary>
/// Custom attributes
/// </summary>
[Parameter(CaptureUnmatchedValues = true)]
public virtual IDictionary<string, object?> Attributes { get; set; } = new Dictionary<string, object?>();

protected const int BROWSER_RENDER_INTERVAL = 16;

private readonly PropertyWatcher _watcher;

private ElementReference _ref;
Expand All @@ -54,8 +39,6 @@ protected BDomComponentBase()

protected ILogger Logger => LoggerFactory.CreateLogger(GetType());

public ComponentCssProvider CssProvider { get; }

public ComponentAbstractProvider AbstractProvider { get; }

/// <summary>
Expand Down Expand Up @@ -88,7 +71,6 @@ protected override void OnInitialized()
{
Id ??= ComponentIdGenerator.Generate(this); // TODO: v2 remove this?
base.OnInitialized();
SetComponentClass();
}

protected override void OnAfterRender(bool firstRender)
Expand Down Expand Up @@ -117,10 +99,6 @@ protected virtual Task OnElementReferenceChangedAsync()
return Task.CompletedTask;
}

protected virtual void SetComponentClass()
{
}

/// <summary>
/// Register watchers at the first render.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using BlazorComponent.Abstracts;

namespace BlazorComponent;

public class CssProviderComponentBase : ComponentBase
{
protected CssProviderComponentBase()
{
CssProvider = new(() => Class, () => Style);
}

public ComponentCssProvider CssProvider { get; }

/// <summary>
/// Specifies one or more class names for an DOM element.
/// </summary>
[Parameter]
public string? Class { get; set; }

/// <summary>
/// Specifies an inline style for an DOM element.
/// </summary>
[Parameter]
public string? Style { get; set; }

protected override void OnInitialized()
{
base.OnInitialized();

SetComponentClass();
SetComponentCss();
}

[Obsolete("Use SetComponentCss instead")]
protected virtual void SetComponentClass()
{
}

protected virtual void SetComponentCss()
{
}
}
Loading
Loading