import { Field, type FieldBaseProperties } from "./Field"; import { WidgetAnnotation, type WidgetProperties } from "../Annotations/WidgetAnnotation"; import { type Rect } from "../../Types"; import { type PdfPage } from "../PdfPage"; /** * Represents an item displayed in {@link ChoiceField}. */ export type ChoiceFieldItemProperties = { /** * The text used to display an item. */ text: string; /** * The value of item, if not specified or empty then 'text' will be used as value. */ value: string | null; }; /** * Defines common properties for {@link ComboBoxFieldProperties} and {@link ListBoxFieldProperties}. */ export type ChoiceFieldProperties = FieldBaseProperties & { /** * Defines the position and dimensions of the field on the page using a bounding rectangle. * * Note: If a widget is specified via the 'widget' property, * its 'rect' value takes precedence and will override this rectangle definition. */ rect?: Rect; /** * The widget annotation defining view properties of the checkbox field. */ widget?: WidgetAnnotation | WidgetProperties; /** * The index of selected item. * Note, if both {@link FieldBaseProperties#value} and 'selectedIndex' are specified then * 'selectedIndex' preffered. */ selectedIndex?: number; /** * The index of item selected by default. * Note, if both {@link FieldBaseProperties#value} and 'defaultSelectedIndex' are specified then * 'defaultSelectedIndex' preffered. */ defaultSelectedIndex?: number; /** * The list of items displayed in field. */ items?: (ChoiceFieldItemProperties | string)[]; /** * Indicating whether the field's option items should be sorted alphabetically. * This flag is intended for use by form authoring tools, not by PDF viewer applications. * Viewers should simply display the options in the order in which they occur in the Opt array */ sort?: boolean; /** * Indicating whether the text entered in the field is spell-checked. */ spellCheck?: boolean; /** * Indicating whether the new value is committed as soon as a selection is made * with the pointing device. * This option enables applications to perform an action once a selection is made, * without requiring the user to exit the field. * If false, the new value is not committed until the user exits the field. */ commitOnSelChange?: boolean; }; /** * Base class for choice fields: ComboBox and ListBox. */ export declare abstract class ChoiceField extends Field { /** * Gets the {@link WidgetAnnotation} defining view properties of the text field. */ get widget(): WidgetAnnotation; /** * Gets or sets the {@link PdfPage} containing this field. * This property wraps the {@link WidgetAnnotation#page} property * and functions identically to: * this.widget.page = value; * * Note that a field may have multiple associated annotations across different pages. * These can be added and configured using the {@link Field@widgets} property. * * @see {@link WidgetAnnotation#page} */ get page(): PdfPage | null; /** * Gets or sets the {@link PdfPage} containing this field. * This property wraps the {@link WidgetAnnotation#page} property * and functions identically to: * this.widget.page = value; * * Note that a field may have multiple associated annotations across different pages. * These can be added and configured using the {@link Field@widgets} property. * * @see {@link WidgetAnnotation#page} */ set page(value: PdfPage | null); /** * Gets or sets the rectangle that defines the location and size of the field on a page. * This property wraps the {@link WidgetAnnotation#rect} property * and functions identically to: * this.widget.rect = value; * * Note that a field may have multiple associated annotations across different pages. * These can be added and configured using the {@link Field@widgets} property. * * @see {@link WidgetAnnotation#rect} */ get rect(): Rect; /** * Gets or sets the rectangle that defines the location and size of the field on a page. * This property wraps the {@link WidgetAnnotation#rect} property * and functions identically to: * this.widget.rect = value; * * Note that a field may have multiple associated annotations across different pages. * These can be added and configured using the {@link Field@widgets} property. * * @see {@link WidgetAnnotation#rect} */ set rect(value: Rect); /** * Gets or sets the index of selected item. */ get selectedIndex(): number; /** * Gets or sets the index of selected item. */ set selectedIndex(value: number); /** * Gets or sets the index of item selected by default. */ get defaultSelectedIndex(): number; /** * Gets or sets the index of item selected by default. */ set defaultSelectedIndex(value: number); /** * Gets the list of items displayed in field. */ get items(): (ChoiceFieldItemProperties | string)[]; /** * Gets the list of items displayed in field. */ set items(value: (ChoiceFieldItemProperties | string)[] | null); /** * Gets or sets a value indicating whether the field's option items should be sorted alphabetically. * This flag is intended for use by form authoring tools, not by PDF viewer applications. * Viewers should simply display the options in the order in which they occur in the Opt array */ get sort(): boolean; /** * Gets or sets a value indicating whether the field's option items should be sorted alphabetically. * This flag is intended for use by form authoring tools, not by PDF viewer applications. * Viewers should simply display the options in the order in which they occur in the Opt array */ set sort(value: boolean); /** * Gets or sets a value indicating whether the text entered in the field is spell-checked. */ get spellCheck(): boolean; /** * Gets or sets a value indicating whether the text entered in the field is spell-checked. */ set spellCheck(value: boolean); /** * Gets or sets a value indicating whether the new value is committed as soon as a selection is made * with the pointing device. * This option enables applications to perform an action once a selection is made, * without requiring the user to exit the field. * If false, the new value is not committed until the user exits the field. */ get commitOnSelChange(): boolean; /** * Gets or sets a value indicating whether the new value is committed as soon as a selection is made * with the pointing device. * This option enables applications to perform an action once a selection is made, * without requiring the user to exit the field. * If false, the new value is not committed until the user exits the field. */ set commitOnSelChange(value: boolean); }