@polyipseity/obsidian-plugin-library
Version:
Library for Obsidian plugins.
90 lines • 4.49 kB
TypeScript
import { type Instruction, Modal, type Setting, type ValueComponent } from "obsidian";
import type { DeepReadonly, DeepWritable } from "ts-essentials";
import { type StatusUI, UpdatableUI } from "./obsidian.js";
import type { Fixer } from "./fixers.js";
import type { PluginContext } from "./plugin.js";
export declare function makeModalDynamicWidth(ui: UpdatableUI, element: HTMLElement): void;
export declare function getDefaultSuggestModalInstructions(context: PluginContext): readonly Instruction[];
export declare class ListModal<T> extends Modal {
#private;
protected readonly context: PluginContext;
protected readonly inputter: (setting: Setting, editable: boolean, getter: () => T, setter: (setter: (item: T, index: number, data: T[]) => unknown) => unknown) => void;
protected readonly placeholder: () => T;
protected readonly modalUI: UpdatableUI;
protected readonly ui: UpdatableUI;
protected readonly data: T[];
constructor(context: PluginContext, inputter: (setting: Setting, editable: boolean, getter: () => T, setter: (setter: (item: T, index: number, data: T[]) => unknown) => unknown) => void, placeholder: () => T, data: readonly T[], options?: ListModal.Options<T>);
static stringInputter<T>(transformer: {
readonly forth: (value: T) => string;
readonly back: (value: string) => T;
}): (setting: Setting, editable: boolean, getter: () => T, setter: (setter: (item: T, index: number, data: T[]) => unknown) => unknown, input?: (setting: Setting, callback: (component: ValueComponent<string> & {
readonly onChange: (callback: (value: string) => unknown) => unknown;
}) => unknown) => void) => void;
onOpen(): void;
onClose(): void;
protected postMutate(): Promise<void>;
protected setupListSubUI(ui: UpdatableUI, element: HTMLElement): void;
}
export declare namespace ListModal {
const EDITABLES: readonly ["edit", "append", "prepend", "remove", "moveUp", "moveDown"];
interface Options<T> {
readonly callback?: (data_: T[]) => unknown;
readonly editables?: readonly typeof EDITABLES[number][];
readonly title?: () => string;
readonly description?: () => string;
readonly namer?: (value: T, index: number, data: readonly T[]) => string;
readonly descriptor?: (value: T, index: number, data: readonly T[]) => string;
readonly presets?: readonly {
readonly name: string;
readonly value: T;
}[];
readonly presetPlaceholder?: (action: "append" | "prepend") => string;
readonly dynamicWidth?: boolean;
}
}
export declare class EditDataModal<T extends object> extends Modal {
#private;
protected readonly context: PluginContext;
protected readonly protodata: DeepReadonly<T>;
protected readonly fixer: Fixer<T>;
protected readonly modalUI: UpdatableUI;
protected readonly ui: UpdatableUI;
protected readonly data: DeepWritable<T>;
constructor(context: PluginContext, protodata: DeepReadonly<T>, fixer: Fixer<T>, options?: EditDataModal.Options<T>);
onOpen(): void;
onClose(): void;
protected draw(ui: UpdatableUI, element: HTMLElement, errorEl: StatusUI): void;
protected postMutate(reset?: boolean): Promise<void>;
protected replaceData(data: typeof this.data): void;
}
export declare namespace EditDataModal {
const ELEMENTS: readonly ["export", "import", "data"];
interface Options<T> {
readonly callback?: (data: DeepWritable<T>) => unknown;
readonly dynamicWidth?: boolean;
readonly elements?: readonly typeof ELEMENTS[number][];
readonly title?: () => string;
readonly description?: () => string;
}
}
export declare class DialogModal extends Modal {
#private;
protected readonly context: PluginContext;
protected readonly modalUI: UpdatableUI;
protected readonly ui: UpdatableUI;
constructor(context: PluginContext, options?: {
cancel?: (close: () => void) => unknown;
confirm?: (close: () => void) => unknown;
title?: () => string;
description?: () => string;
draw?: (ui: UpdatableUI, element: HTMLElement) => void;
doubleConfirmTimeout?: number;
dynamicWidth?: boolean;
});
onOpen(): void;
onClose(): void;
close(): void;
protected confirm(close: () => void): Promise<void>;
protected cancel(close: () => void): Promise<void>;
}
//# sourceMappingURL=modals.d.ts.map