import { DynFunction, Field, FieldOptions, Form, HelpSheet, LocalizedOption, UnassembledMessages, langType } from '@gecogvidanto/shared'; /** * Builder of a collection of selector choices. */ export declare class ChoiceCollector { readonly choices: LocalizedOption[]; /** * Add a choice to the selector. * * @param choice - The choice to add. * @returns `this`. */ addChoice(choice: LocalizedOption): this; /** * Check choice identifier unicity. Throws an exception if identifier is not unique. * * @param id - The identifier to check. */ protected checkId(id: string): void; } /** * Builder of a collection of form fields. */ export declare abstract class FieldCollector { /** * Add a text field to the collector. * * @param name - The name of the field. * @param content - The initial content of the field. * @param (unnamed) - An object containing optional data. * @param (unnamed).options - The initial options of the field. * @param (unnamed).hasData - Indicate if the text field has data. * @returns `this`. */ addTextField(name: string, content: UnassembledMessages[K], { options, hasData }?: { options?: FieldOptions; hasData?: boolean; }): this; /** * Add a text input field to the collector. * * @param name - The name of the field. * @param help - A help string that UI may display as label or placeholder. * @param content - The initial content of the field. * @param (unnamed) - An object containing optional fields. * @param (unnamed).options - The initial options of the field. * @param (unnamed).minLength - The minimal lenght or undefined if no minimum. * @param (unnamed).maxLength - The maximal lenght or undefined if no maximum. * @param (unnamed).hasData - Indicate if the text field has data. * @returns `this`. */ addTextInputField(name: string, help: UnassembledMessages[K], content: string, { options, minLength, maxLength, hasData, }?: { options?: FieldOptions; minLength?: number; maxLength?: number; hasData?: boolean; }): this; /** * Add a number input field to the collector. * * @param name - The name of the field. * @param help - A help string that UI may display as label or placeholder. * @param content - The initial content of the field. * @param (unnamed) - An object containing the following optional fields. * @param (unnamed).options - The initial options of the field. * @param (unnamed).minValue - The minimal value of the field or undefined if no minimum. * @param (unnamed).maxValue - The maximal value of the field or undefined if no maximum. * @param (unnamed).incrementStep - The increment step if UI is displaying increment buttons. * @param (unnamed).hasData - Indicate if the text field has data. * @returns `this`. */ addNumberInputField(name: string, help: UnassembledMessages[K], content: number, { options, minValue, maxValue, incrementStep, hasData, }?: { options?: FieldOptions; minValue?: number; maxValue?: number; incrementStep?: number; hasData?: boolean; }): this; /** * Add a boolean input field to the collector. * * @param name - The name of the field. * @param help - A help string that UI may display as label or placeholder. * @param content - The initial content of the field. * @param (unnamed) - An object containing optional fields. * @param (unnamed).options - The initial options of the field. * @param (unnamed).hasData - Indicate if the text field has data. * @returns `this`. */ addBooleanInputField(name: string, help: UnassembledMessages[K], content: boolean, { options, hasData }?: { options?: FieldOptions; hasData?: boolean; }): this; /** * Add a select input field to the collector. * * @param name - The name of the field. * @param help - A help string that UI may display as label or placeholder. * @param content - The initial content of the field. * @param choicesBuilder - Builder for the choices which can be selected. * @param (unnamed) - An object containing optional fields. * @param (unnamed).options - The initial options of the field. * @param (unnamed).hasData - Indicate if the text field has data. * @returns `this`. */ addSelectInputField(name: string, help: UnassembledMessages[K], content: string, choicesBuilder: (collector: ChoiceCollector) => void, { options, hasData }?: { options?: FieldOptions; hasData?: boolean; }): this; /** * Add the given field to the collector. * * @param field - The field to collect. */ protected abstract collect(field: Field): void; /** * Check that the field name is unique in its form part. Must throw an exception if not. * * @param name - The name of the field. */ protected abstract checkName(name: string): void; } /** * A builder for the forms. The builder check field name unicity. @see {@link #checkName()} for more * information. */ export default class FormBuilder> extends FieldCollector { /** * The dynamic function. This function **should** be compiled into appropriate ECMAScript level for the * client. */ dynFunction?: DynFunction

; /** * The parameters to be used by the function. */ params?: P; /** * The seen field names. */ private readonly fieldNames; /** * The group currently being built. */ private currentGroup; /** * The part currently being built. */ private currentPart; /** * Parts of the form. */ private readonly parts; /** * Indicate that next fields will be inserted in given player part. * * @param player - The player identifier (-Infinity for all players). * @returns `this`. */ toPart(player: number): this; /** * Create the group. * * @param mandatory - True if group is mandatory. * @param titleBuilder - A builder callback used to create a title. * @returns `this`. */ newGroup(mandatory: boolean, titleBuilder?: (collector: FieldCollector) => void): this; /** * Add strongly linked fields. * * @param fieldsBuilder - A callback used to build the fields. * @returns `this`. */ addLinkedFields(fieldsBuilder: (collector: FieldCollector) => void): this; /** * Add the values fields for the dying player. * * @param helpSheet - The help sheet for the fields aspect. * @returns `this`. */ addDyingValues(helpSheet: HelpSheet): this; /** * Add the money fields for the dying player. * * @param helpSheet - The help sheet for the fields aspect. * @returns `this`. */ addDyingMoney(helpSheet: HelpSheet): this; /** * Builds the form using prepared data. * * @returns The created form. */ build(): Form; protected collect(field: Field): void; /** * Check field name unicity accross part. Throws an exception if name is not unique. * * @param name - The name to check. */ protected checkName(name: string): void; /** * Create a dying player result fields. * * @param label - The label to use. * @param label.title - The title label. * @param label.low - The low field label,. * @param label.medium - The medium field label,. * @param label.high - The high field label,. * @param fieldId - The field identifier to use. * @param fieldId.title - The title field identifier. * @param fieldId.low - The low field identifier. * @param fieldId.medium - The medium field identifier. * @param fieldId.high - The high field identifier. * @param helpSheet - The help sheet used to display colors. * @returns `this`. */ private addDying; /** * Convert a place content into field options. * * @param content - The place content. * @returns `this`. */ private createOptions; /** * Internally collect fields. * * @param builder - The callback building the fields to collect. * @returns Collected fields. */ private internallyCollect; }