mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-07 17:04:58 +01:00
42 lines
789 B
TypeScript
42 lines
789 B
TypeScript
import {LazyStreams} from "lstream/lazyStreams";
|
|
import {state} from "lstream";
|
|
|
|
export interface ModelAttributes {
|
|
hidden: boolean;
|
|
label: string;
|
|
color: string;
|
|
}
|
|
|
|
export class AttributesService {
|
|
|
|
streams = new LazyStreams<ModelAttributes>(id => ({
|
|
hidden: false,
|
|
label: null,
|
|
color: null
|
|
}));
|
|
|
|
displayOptionsEditors$ = state<EditorSet>({});
|
|
|
|
attributesEditors$ = state<EditorSet>({});
|
|
|
|
openDisplayOptionsEditor(modelIds: string[], e: any) {
|
|
this.displayOptionsEditors$.mutate(editors => {
|
|
const copy = [...modelIds].sort();
|
|
editors[copy.join(':')] = {
|
|
x: e.pageX,
|
|
y: e.pageY,
|
|
models: copy
|
|
};
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
export type EditorSet = {
|
|
[key: string]: {
|
|
x: number,
|
|
y: number,
|
|
models: string[]
|
|
}
|
|
}
|
|
|