|
| 1 | +/// <reference path="../../../LLSEAids/dts/llaids/src/index.d.ts" /> |
| 2 | +export declare const NAME = "FormAPIEx"; |
| 3 | +export declare const VERSION: readonly [0, 2, 2]; |
| 4 | +export declare const AUTHOR = "student_2333 <[email protected]>"; |
| 5 | +export declare const LICENSE = "Apache-2.0"; |
| 6 | +export declare function sendModalFormAsync(player: Player, title: string, content: string, confirmButton?: string, cancelButton?: string): Promise<boolean | null | undefined>; |
| 7 | +export declare function sendFormAsync(player: Player, form: SimpleForm): Promise<number | null | undefined>; |
| 8 | +export declare function sendFormAsync(player: Player, form: CustomForm): Promise<(string | boolean | number)[] | null | undefined>; |
| 9 | +export interface CustomFormLabelObject { |
| 10 | + type: 'label'; |
| 11 | + text: string; |
| 12 | +} |
| 13 | +export interface CustomFormInputObject { |
| 14 | + type: 'input'; |
| 15 | + title: string; |
| 16 | + placeholder?: string; |
| 17 | + defaultVal?: string; |
| 18 | +} |
| 19 | +export interface CustomFormSwitchObject { |
| 20 | + type: 'switch'; |
| 21 | + title: string; |
| 22 | + defaultVal?: boolean; |
| 23 | +} |
| 24 | +export interface CustomFormDropdownObject { |
| 25 | + type: 'dropdown'; |
| 26 | + title: string; |
| 27 | + items: string[]; |
| 28 | + defaultVal?: number; |
| 29 | +} |
| 30 | +export interface CustomFormSliderObject { |
| 31 | + type: 'slider'; |
| 32 | + title: string; |
| 33 | + min: number; |
| 34 | + max: number; |
| 35 | + step?: number; |
| 36 | + defaultVal?: number; |
| 37 | +} |
| 38 | +export interface CustomFormStepSliderObject { |
| 39 | + type: 'stepSlider'; |
| 40 | + title: string; |
| 41 | + items: string[]; |
| 42 | + defaultVal?: number; |
| 43 | +} |
| 44 | +export type CustomFormObject = CustomFormLabelObject | CustomFormInputObject | CustomFormSwitchObject | CustomFormDropdownObject | CustomFormSliderObject | CustomFormStepSliderObject; |
| 45 | +export declare function buildCustomForm(formTitle: string, objects: CustomFormObject[]): CustomForm; |
| 46 | +export type CustomFormObjectReturnType<T extends CustomFormObject> = T extends CustomFormInputObject ? string : T extends CustomFormSwitchObject ? boolean : T extends CustomFormDropdownObject | CustomFormSliderObject | CustomFormStepSliderObject ? number : undefined; |
| 47 | +export type CustomFormReturn<T extends { |
| 48 | + [id: string]: CustomFormObject; |
| 49 | +}> = { |
| 50 | + [k in keyof T]: CustomFormObjectReturnType<T[k]>; |
| 51 | +}; |
| 52 | +export declare class CustomFormEx<T extends { |
| 53 | + [id: string]: CustomFormObject; |
| 54 | +} = {}> { |
| 55 | + #private; |
| 56 | + title: string; |
| 57 | + constructor(title?: string); |
| 58 | + get objects(): [string | undefined, CustomFormObject][]; |
| 59 | + setTitle(val: string): this; |
| 60 | + push<TObj extends CustomFormObject, TId extends TObj extends CustomFormLabelObject ? string | undefined : string>(id: TId, obj: TObj): CustomFormEx<T & (TId extends string ? { |
| 61 | + [k in TId]: TObj; |
| 62 | + } : {})>; |
| 63 | + unshift<TObj extends CustomFormObject, TId extends TObj extends CustomFormLabelObject ? string | undefined : string>(id: TId, obj: TObj): CustomFormEx<T & (TId extends string ? { |
| 64 | + [k in TId]: TObj; |
| 65 | + } : {})>; |
| 66 | + insert<TObj extends CustomFormObject, TId extends TObj extends CustomFormLabelObject ? string | undefined : string>(index: number, id: TId, obj: TObj): CustomFormEx<T & (TId extends string ? { |
| 67 | + [k in TId]: TObj; |
| 68 | + } : {})>; |
| 69 | + remove<TId extends keyof T>(id: TId): CustomFormEx<Omit<T, TId>>; |
| 70 | + get<TId extends keyof T>(id: TId): T[TId] | null; |
| 71 | + addLabel(text: string): CustomFormEx<T>; |
| 72 | + addLabel<TId extends string>(id: TId, text: string): CustomFormEx<T & { |
| 73 | + [k in TId]: CustomFormLabelObject; |
| 74 | + }>; |
| 75 | + addInput<TId extends string>(id: TId, title: string, options?: { |
| 76 | + placeholder?: string; |
| 77 | + default?: string; |
| 78 | + }): CustomFormEx<T & { |
| 79 | + [k in TId]: CustomFormInputObject; |
| 80 | + }>; |
| 81 | + addSwitch<TId extends string>(id: TId, title: string, defaultVal?: boolean): CustomFormEx<T & { |
| 82 | + [k in TId]: CustomFormSwitchObject; |
| 83 | + }>; |
| 84 | + addDropdown<TId extends string>(id: TId, title: string, items: string[], defaultVal?: number): CustomFormEx<T & { |
| 85 | + [k in TId]: CustomFormDropdownObject; |
| 86 | + }>; |
| 87 | + addSlider<TId extends string>(id: TId, title: string, min: number, max: number, options?: { |
| 88 | + step?: number; |
| 89 | + default?: number; |
| 90 | + }): CustomFormEx<T & { |
| 91 | + [k in TId]: CustomFormSliderObject; |
| 92 | + }>; |
| 93 | + addStepSlider<TId extends string>(id: TId, title: string, items: string[], defaultVal?: number): CustomFormEx<T & { |
| 94 | + [k in TId]: CustomFormStepSliderObject; |
| 95 | + }>; |
| 96 | + private parseReturn; |
| 97 | + sendAsync(player: Player): Promise<CustomFormReturn<T> | null>; |
| 98 | +} |
| 99 | +export declare class SimpleFormAsync { |
| 100 | + title: string; |
| 101 | + content: string; |
| 102 | + /** [ text, image ] */ |
| 103 | + buttons: [string, string?][]; |
| 104 | + constructor(options?: { |
| 105 | + title?: string; |
| 106 | + content?: string; |
| 107 | + buttons?: [string, string?][]; |
| 108 | + }); |
| 109 | + setTitle(val: string): this; |
| 110 | + setContent(val: string): this; |
| 111 | + addButton(text: string, image?: string): this; |
| 112 | + sendAsync(player: Player): Promise<number | null | undefined>; |
| 113 | +} |
| 114 | +export declare class SimpleFormEx<T> { |
| 115 | + title: string; |
| 116 | + /** |
| 117 | + * {{currentPage}} - 当前页数 |
| 118 | + * {{maxPage}} - 最大页数 |
| 119 | + * {{count}} - 条目总数 |
| 120 | + */ |
| 121 | + content: string; |
| 122 | + buttons: T[]; |
| 123 | + /** @returns [ text, image ] */ |
| 124 | + formatter: (v: T, index: number, array: T[]) => [string, string?]; |
| 125 | + canTurnPage: boolean; |
| 126 | + canJumpPage: boolean; |
| 127 | + maxPageNum: number; |
| 128 | + hasSearchButton: boolean; |
| 129 | + searcher: (buttons: T[], param: string) => T[]; |
| 130 | + constructor(buttons?: T[]); |
| 131 | + formatButtons(buttons?: T[]): [string, string?][]; |
| 132 | + getMaxPageNum(): number; |
| 133 | + getPage(page?: number): T[]; |
| 134 | + /** |
| 135 | + * @returns null 为没搜到, false 为取消搜索 |
| 136 | + */ |
| 137 | + sendSearchForm(player: Player, defaultVal?: string): Promise<T | null | false>; |
| 138 | + sendAsync(player: Player, page?: number): Promise<T | null>; |
| 139 | +} |
0 commit comments