mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 16:38:20 +01:00
72 lines
1.6 KiB
TypeScript
72 lines
1.6 KiB
TypeScript
export interface PreferenceOptions<ValueType> {
|
|
name: string;
|
|
description?: string;
|
|
category?: string;
|
|
defaultValue: ValueType;
|
|
}
|
|
|
|
export abstract class Preference<ValueType> {
|
|
public abstract options: PreferenceOptions<ValueType>;
|
|
}
|
|
|
|
export class TextPreference extends Preference<string> {
|
|
constructor(public options: PreferenceOptions<string>) {
|
|
super();
|
|
}
|
|
}
|
|
|
|
export class NumberPreference extends Preference<number> {
|
|
constructor(
|
|
public options: PreferenceOptions<number> & {
|
|
integer?: boolean;
|
|
step?: number;
|
|
min?: number;
|
|
max?: number;
|
|
},
|
|
) {
|
|
super();
|
|
}
|
|
}
|
|
|
|
export class BooleanPreference extends Preference<boolean> {
|
|
constructor(public options: PreferenceOptions<boolean>) {
|
|
super();
|
|
}
|
|
}
|
|
|
|
export class SelectPreference<T extends string> extends Preference<T> {
|
|
constructor(
|
|
public options: PreferenceOptions<T> & {
|
|
options: Record<T, string>;
|
|
},
|
|
) {
|
|
super();
|
|
}
|
|
}
|
|
|
|
export class CodePreference extends Preference<string> {
|
|
constructor(
|
|
public options: PreferenceOptions<string> & {
|
|
language?: "css";
|
|
},
|
|
) {
|
|
super();
|
|
}
|
|
}
|
|
|
|
export class MultiSelectPreference<T extends string> extends Preference<T[]> {
|
|
constructor(
|
|
public options: PreferenceOptions<T[]> & {
|
|
options: Record<T, string>;
|
|
},
|
|
) {
|
|
super();
|
|
}
|
|
}
|
|
|
|
export class UrlPreference extends Preference<string> {
|
|
constructor(public options: PreferenceOptions<string>) {
|
|
super();
|
|
}
|
|
}
|