fix(lit-components): fix rendering and interaction issues in force-graph, html-table, and draggable-dom
Build and Deploy / build-and-deploy (push) Has been cancelled
Build and Deploy / build-and-deploy (push) Has been cancelled
- lit-force-graph: Refactored for instance reuse, better lifecycle management, and added dynamic imports for AR/VR modes. - lit-html-table: Improved visual design, readability of headers, and fixed reactivity in editable mode. - lit-draggable-dom: Fixed clipping issues by switching to relative/absolute positioning and resolved a panning speed bug caused by CSS variable inheritance.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
import { RxCollection, RxDocument, RxJsonSchema } from "rxdb";
|
||||
import type { TopLevelProperty } from "rxdb/dist/types/types";
|
||||
|
||||
export interface Base {
|
||||
id: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
type BaseMethods = {};
|
||||
|
||||
type BaseStatics = {};
|
||||
|
||||
export type BaseCollection<
|
||||
T extends Base,
|
||||
M extends BaseMethods = BaseMethods,
|
||||
C extends BaseStatics = BaseStatics
|
||||
> = RxCollection<T, M, C>;
|
||||
|
||||
export type BaseDoc<T extends Base> = RxDocument<T, BaseMethods>;
|
||||
|
||||
export interface SchemaOptions {
|
||||
title: string;
|
||||
description?: string;
|
||||
version?: number;
|
||||
keyCompression?: boolean;
|
||||
properties: {
|
||||
[key: string]: TopLevelProperty;
|
||||
};
|
||||
}
|
||||
|
||||
export function buildSchema<T extends Base>(
|
||||
options: SchemaOptions
|
||||
): RxJsonSchema<T> {
|
||||
return {
|
||||
title: options.title,
|
||||
description: options?.description ?? options.title,
|
||||
version: options?.version ?? 0,
|
||||
keyCompression: options?.keyCompression ?? true,
|
||||
type: "object",
|
||||
// @ts-ignore
|
||||
properties: {
|
||||
id: {
|
||||
type: "string",
|
||||
primary: true,
|
||||
},
|
||||
...options.properties,
|
||||
},
|
||||
required: [
|
||||
"id",
|
||||
...Object.entries(options.properties)
|
||||
.filter((n) => {
|
||||
const [_, value] = n;
|
||||
return value.required;
|
||||
})
|
||||
.map((n) => {
|
||||
const [key, _] = n;
|
||||
return key;
|
||||
}),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const _methods: BaseMethods = {};
|
||||
|
||||
const _statics: BaseStatics = {};
|
||||
|
||||
export function createBase<T extends Base>(options: SchemaOptions) {
|
||||
return {
|
||||
schema: buildSchema<T>(options),
|
||||
methods: _methods,
|
||||
statics: _statics,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user