Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi committed Dec 15, 2024
2 parents 1de7374 + 4b78ed7 commit cd2fa12
Show file tree
Hide file tree
Showing 54 changed files with 233 additions and 212 deletions.
2 changes: 1 addition & 1 deletion src/Besql/Bit.Besql/wwwroot/bit-besql.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var BitBesql = window.BitBesql || {};
BitBesql.version = window['bit-besql version'] = '9.1.0-pre-13';
BitBesql.version = window['bit-besql version'] = '9.1.0';

BitBesql.init = async function init(fileName) {
const sqliteFilePath = `/${fileName}`;
Expand Down
2 changes: 1 addition & 1 deletion src/Bit.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageProjectUrl>https://github.com/bitfoundation/bitplatform</PackageProjectUrl>

<!-- Version -->
<ReleaseVersion>9.1.0-pre-13</ReleaseVersion>
<ReleaseVersion>9.1.0</ReleaseVersion>
<PackageVersion>$(ReleaseVersion)</PackageVersion>
<PackageReleaseNotes>https://github.com/bitfoundation/bitplatform/releases/tag/v-$(ReleaseVersion)</PackageReleaseNotes>
<Version Condition=" '$(Configuration)' == 'Release' ">$([System.String]::Copy($(ReleaseVersion)).Replace('-pre-', '.'))</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,23 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

if (IsRanged)
{
_inputHeight = await _js.GetClientHeight(RootElement);
_inputHeight = await GetClientHeight(RootElement);

if (Label.HasValue())
{
var titleHeight = await _js.GetClientHeight(_labelRef);
var titleHeight = await GetClientHeight(_labelRef);
_inputHeight -= titleHeight;
}

if (ShowValue)
{
var valueLabelHeight = await _js.GetClientHeight(_valueLabelRef);
var valueLabelHeight = await GetClientHeight(_valueLabelRef);
_inputHeight -= (valueLabelHeight * 2);
}
}
else
{
_inputHeight = await _js.GetClientHeight(_containerRef);
_inputHeight = await GetClientHeight(_containerRef);
}

FillSlider();
Expand Down Expand Up @@ -340,4 +340,12 @@ private void OnSetValues()

FillSlider();
}

private async ValueTask<int> GetClientHeight(ElementReference element)
{
var height = await _js.GetProperty(element, "clientHeight");
return height.HasNoValue()
? 0
: int.Parse(height);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
namespace BitBlazorUI {
class BitController {
id: string = BitBlazorUI.Utils.uuidv4();
controller = new AbortController();
dotnetObj: DotNetObject | undefined;
}

export class CircularTimePicker {
private static _bitControllers: BitController[] = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
namespace BitBlazorUI {
class BitController {
id: string = BitBlazorUI.Utils.uuidv4();
controller = new AbortController();
dotnetObj: DotNetObject | undefined;
}

export class ColorPicker {
private static _bitControllers: BitController[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

internal static class UtilsJsRuntimeExtensions
{
internal static ValueTask Log(this IJSRuntime jsRuntime, object value)
{
return jsRuntime.InvokeVoid("console.log", value);
}


internal static ValueTask<decimal> GetBodyWidth(this IJSRuntime jsRuntime)
{
return jsRuntime.Invoke<decimal>("BitBlazorUI.Utils.getBodyWidth");
Expand All @@ -26,12 +20,6 @@ internal static ValueTask<string> GetProperty(this IJSRuntime jsRuntime, Element
}


internal static ValueTask<int> GetClientHeight(this IJSRuntime jsRuntime, ElementReference element)
{
return jsRuntime.Invoke<int>("BitBlazorUI.Utils.getClientHeight", element);
}


internal static ValueTask<BoundingClientRect> GetBoundingClientRect(this IJSRuntime jsRuntime, ElementReference element)
{
return jsRuntime.Invoke<BoundingClientRect>("BitBlazorUI.Utils.getBoundingClientRect", element);
Expand All @@ -56,18 +44,6 @@ internal static ValueTask SetStyle(this IJSRuntime jsRuntime, ElementReference e
}


internal static ValueTask PreventDefault(this IJSRuntime jsRuntime, ElementReference element, string @event)
{
return jsRuntime.InvokeVoid("BitBlazorUI.Utils.preventDefault", element, @event);
}


internal static ValueTask<TransformMatrix> GetComputedTransform(this IJSRuntime jsRuntime, ElementReference element)
{
return jsRuntime.Invoke<TransformMatrix>("BitBlazorUI.Utils.getComputedTransform", element);
}


internal static ValueTask<int> ToggleOverflow(this IJSRuntime jsRuntime, string scrollerSelector, bool isHidden)
{
return jsRuntime.Invoke<int>("BitBlazorUI.Utils.toggleOverflow", scrollerSelector, isHidden);
Expand Down
2 changes: 1 addition & 1 deletion src/BlazorUI/Bit.BlazorUI/Scripts/Observers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
});
observer.observe(element);

const id = BitBlazorUI.Utils.uuidv4();
const id = Utils.uuidv4();
Observers._resizeObservers[id] = observer;

return id;
Expand Down
125 changes: 63 additions & 62 deletions src/BlazorUI/Bit.BlazorUI/Scripts/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

return (...args: any[]) => {
if (timeoutItd === null) {
fn(...args);
try { fn(...args); } catch (e) { console.error("BitBlazorUI.Utils.throttle:", e); }
if (delay > 0) {
timeoutItd = setTimeout(() => {
timeoutItd = null;
Expand All @@ -23,101 +23,102 @@
}

public static isTouchDevice() {
const matchMedia = window.matchMedia("(pointer: coarse)").matches;
const maxTouchPoints = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0);

return matchMedia || maxTouchPoints;
try {
const matchMedia = window.matchMedia("(pointer: coarse)").matches;
const maxTouchPoints = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0);
return matchMedia || maxTouchPoints;
} catch (e) {
console.error("BitBlazorUI.Utils.isTouchDevice:", e);
return false;
}
}

public static setProperty(element: Record<string, any>, property: string, value: any): void {
if (!element) return;
element[property] = value;

try {
element[property] = value;
} catch (e) { console.error("BitBlazorUI.Utils.setProperty:", e); }
}

public static getProperty(element: Record<string, any>, property: string): string | null {
return element?.[property];
}
if (!element) return null;

public static getClientHeight(element: HTMLElement): number {
return element?.clientHeight;
try {
return element[property].toString();
} catch (e) {
console.error("BitBlazorUI.Utils.getProperty:", e);
return '';
}
}

public static getBoundingClientRect(element: HTMLElement): DOMRect {
return element?.getBoundingClientRect();
public static getBoundingClientRect(element: HTMLElement): Partial<DOMRect> {
if (!element) return {};

try {
return element.getBoundingClientRect();
} catch (e) {
console.error("BitBlazorUI.Utils.getBoundingClientRect:", e);
return {};
}
}

public static scrollElementIntoView(targetElementId: string) {
const element = document.getElementById(targetElementId);
if (!element) return;

element.scrollIntoView({
behavior: "smooth",
block: "start",
inline: "nearest"
});
try {
element.scrollIntoView({
behavior: "smooth",
block: "start",
inline: "nearest"
});
} catch (e) { console.error("BitBlazorUI.Utils.scrollElementIntoView:", e); }
}

public static selectText(element: HTMLInputElement) {
element?.select();
if (!element) return;

try {
element.select();
} catch (e) { console.error("BitBlazorUI.Utils.selectText:", e); }
}

public static setStyle(element: HTMLElement, key: string, value: string) {
if (!element || !element.style) return;
(element.style as any)[key] = value;
}

public static preventDefault(element: HTMLElement, event: string) {
element?.addEventListener(event, e => e.preventDefault(), { passive: false });
}

public static getComputedTransform(element: HTMLElement) {
const computedStyle = window.getComputedStyle(element);
const matrix = computedStyle.getPropertyValue('transform');
const matched = matrix.match(/matrix\((.+)\)/);

if (matched && matched.length > 1) {
const splitted = matched[1].split(',');
return {
ScaleX: +splitted[0],
SkewY: +splitted[1],
SkewX: +splitted[2],
ScaleY: +splitted[3],
TranslateX: +splitted[4],
TranslateY: +splitted[5]
}
}

return null;
}

public static registerResizeObserver(element: HTMLElement, obj: DotNetObject, method: string = "resized") {
const observer = new ResizeObserver(entries => {
const entry = entries[0];
if (!entry) return;
obj.invokeMethodAsync(method, entry.contentRect);
});

observer.observe(element);
try {
(element.style as any)[key] = value;
} catch (e) { console.error("BitBlazorUI.Utils.setStyle:", e); }
}

public static toggleOverflow(selector: string, isHidden: boolean) {
const element = document.querySelector(selector) as HTMLElement;

if (!element) return 0;

element.style.overflow = isHidden ? "hidden" : "";

return element.scrollTop;
try {
element.style.overflow = isHidden ? "hidden" : "";
return element.scrollTop;
} catch (e) {
console.error("BitBlazorUI.Utils.toggleOverflow:", e);
return 0;
}
}

public static uuidv4(): string {
const result = this.guidTemplate.replace(/[018]/g, (c) => {
const n = +c;
const random = crypto.getRandomValues(new Uint8Array(1));
const result = (n ^ random[0] & 15 >> n / 4);
return result.toString(16);
});
return result;
try {
const result = this.guidTemplate.replace(/[018]/g, (c) => {
const n = +c;
const random = crypto.getRandomValues(new Uint8Array(1));
const result = (n ^ random[0] & 15 >> n / 4);
return result.toString(16);
});
return result;
} catch (e) {
console.error("BitBlazorUI.Utils.uuidv4:", e);
return '';
}
}
// https://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid/#2117523
private static guidTemplate = '10000000-1000-4000-8000-100000000000';
Expand Down
12 changes: 10 additions & 2 deletions src/BlazorUI/Bit.BlazorUI/Scripts/general.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(BitBlazorUI as any).version = (window as any)['bit-blazorui version'] = '9.1.0-pre-13';
(BitBlazorUI as any).version = (window as any)['bit-blazorui version'] = '9.1.0';

interface DotNetObject {
invokeMethod<T>(methodIdentifier: string, ...args: any[]): T;
Expand All @@ -21,4 +21,12 @@ window.addEventListener('resize', (e: any) => {
if (window.innerWidth < BitBlazorUI.Utils.MAX_MOBILE_WIDTH && resizeTriggeredByOpenningKeyboard) return;

BitBlazorUI.Callouts.replaceCurrent();
}, true);
}, true);

namespace BitBlazorUI {
export class BitController {
id: string = Utils.uuidv4();
controller = new AbortController();
dotnetObj: DotNetObject | undefined;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0-pre-13">
<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0-pre-13">
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0-pre-13">
<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0-pre-13">
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<Content Remove="appsettings.json" />
<EmbeddedResource Include="appsettings.json" />

<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0-pre-13">
<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0-pre-13">
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0-pre-13">
<PackageReference Include="Bit.CodeAnalyzers" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.6" />
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0-pre-13">
<PackageReference Include="Bit.SourceGenerators" Version="9.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Loading

0 comments on commit cd2fa12

Please sign in to comment.