import * as text from "./textUtilities"; import type { FormComponent } from "./FormComponent"; import type { ElementTuple } from "./FormDefinition"; import type * as defs from "./FormDefinition"; import type { FormElementProps } from "./index"; import type { Theme } from "@vertigis/react-ui/styles"; export interface DebounceResult { /** Do not invoke the scheduled function at all. */ cancel: () => void; /** Invoke the scheduled function immediately, without any further delay. */ now: () => void; } /** * Constraints for a property that may specify a default value and bounds. */ export interface PropertyConstraints { default?: T; maximum?: T; minimum?: T; } /** * Constraints for a property that specifies a default value. */ export interface PropertyConstraintsWithDefault extends PropertyConstraints { default: T; } /** * Constraints for a property that specifies a maximum value. */ export interface PropertyConstraintsWithMaximum extends PropertyConstraints { maximum: T; } /** * Constraints for a property that specifies a minimum value. */ export interface PropertyConstraintsWithMinimum extends PropertyConstraints { minimum: T; } export interface FormElementPropertyConstraints { [key: string]: PropertyConstraints | undefined; } /** * Exporting text since it was split out from here into it's own file as part of the designer * CRA migration. This was necessary since babel does not support namespaces. **/ export { text }; export declare function makeId(): string; /** A type that includes an optional `index` property. */ interface Indexwise { index?: number; } /** * Performs key/item sorting. */ /** * This function attempts to sort and filter a collection of items. * * The sorted is limited as the result is an object, so the order of the keys is not entirely configurable. * * The filtering is achieved via the predicate. Any item that causes a non-numeric return value from the predicate * is dropped from the resulting items. * * @param items The items to be sorted and filtered. * @param predicate The function to call for each item to determine its new index. If this returns something other than a number, the item is excluded from the result. * @returns A sorted and filtered version of the items. * @product This is intended for internal use only within VertiGIS Studio products. */ export declare function sortAndFilter(items: Record | undefined, predicate?: (item: T, index: number) => number | undefined): Record; /** * Details returned by `inspectItems()`. */ type InspectItemsResult = { /** The index of the now-selected item, based on the new value of `items`. */ current: string | undefined; /** The sorted and filtered items. */ items: Record; /** The new `label` of the element, based on the new value of `current`. */ label: defs.Text | undefined; /** The new `value` of the element, based on the new value of `current`. */ value: defs.Value | undefined; }; /** * This function iterates through the items of the supplied element in preparation for use. * * It does the following: * * 1. Provides a new set of items. * 1. They are sorted and filters to exclude any where `visible` is `false`. * 2. Unlike the other values returned, this one should not be updated on the element. * This is because we want to be able to change an invisible item back to visible in future, * and they are omitted from the returned items. * 2. Provides a new value for `element.current`\ * **IMPORTANT: This should be ignored when using a `defs.ItemsRef` as the value.** * 1. It must refer to a visible item. * 2. If absent, items' values are compared with `element.value` to find a match. If found, that is the new `current`. * 3. Provides a new value for `element.label`.\ * **IMPORTANT: This should be ignored when using a `defs.ItemsRef` as the value.** * 1. This is the label of the item specified by `current`. * 4. Provides a new value for `element.value`.\ * **IMPORTANT: This should be ignored when using a `defs.ItemsRef` as the value.** * 1. This is the value of the item specified by `current`. * @param current The id of the current item, equivalent to `element.current`. * @param items The items, equivalent to `element.items`. * @param value The current value, equivalent to `element.value`. * @returns A sorted and filtered set if items, along with some other properties that can be updated on `element`. */ export declare function inspectItems(current: string | undefined, items: Record | undefined, value: defs.Value | undefined): InspectItemsResult; /** @product This is intended for internal use only within VertiGIS Studio products. */ export declare function makeSafeClassName(elementName: string | undefined): string; /** @public */ export declare function makeUniqueId(elementName: string | undefined): string; export declare function getAccessibleDescriptionId(elementId: string): string; export declare function getDescriptionId(elementId: string): string; export declare function getInputId(elementId: string): string; export declare function getLabelId(elementId: string): string; /** * Returns `true` if the element has a `type` of `"Section"`. * @param element The element to be inspected. */ export declare function isSection(element?: defs.Element): element is defs.Element; /** * Returns `true` if the element has a `type` of `"Section"` and a `format` of `"accordion-section"`, `false` otherwise. * @param element The element to be inspected. */ export declare function isAccordionSection(element?: defs.Element): boolean; /** * Returns `true` if the element has a `type` of `"Section"` and a `format` of `"collapsible-section"`, `false` otherwise. * @param element The element to be inspected. */ export declare function isCollapsibleSection(element?: defs.Element): boolean; export declare function isFieldsetSection(element?: defs.Element): boolean; export declare function isMutuallyExclusiveSection(element?: defs.Element): boolean; /** * Returns `true` if the element has a `type` of `"Section"` and a `format` of `"tab-section"`, `false` otherwise. * @param element The element to be inspected. */ export declare function isTabSection(element?: defs.Element): boolean; export declare function isNumber(value: defs.Value | undefined): value is number; /** @product This is intended for internal use only within VertiGIS Studio products. */ export declare function isString(value: defs.Value | undefined): value is string; export declare function isDataRef(value: defs.Value | undefined): value is defs.DataRef; export declare function isDateRangeRef(value: defs.Value | undefined): value is defs.DateRangeRef; export declare function isDateTimeRef(value: defs.Value | undefined): value is defs.DateTimeRef; export declare function isFilesRef(value: defs.Value | undefined): value is defs.FilesRef; export declare function isScanRef(value: defs.Value | undefined): value is defs.ScanRef; export declare function isGeometryRef(value: defs.Value | undefined): value is defs.GeometryRef; export declare function isItemsRef(value: defs.Value | undefined): value is defs.ItemsRef; /** @product This is intended for internal use only within VertiGIS Studio products. */ export declare function isNumberRef(value: defs.Value | undefined): value is defs.NumberRef; /** @product This is intended for internal use only within VertiGIS Studio products. */ export declare function sanitizeGeometryRef(value: defs.Value | undefined): defs.GeometryRef | undefined; /** @product This is intended for internal use only within VertiGIS Studio products. */ export declare function createGeometryRef(format: defs.GeometryFormat): defs.GeometryRef; /** * Creates a debounced function that will invoke the given function * only after the function has not been called for the duration of the delay. * @param func The function to invoke. * @param delay The delay to wait (in milliseconds) before invoking the function. */ export declare function debounce(fn: Function, delay?: number): (this: any, ...args: any[]) => DebounceResult; /** * Creates a throttled function that will invoke the given * function at most once per the given delay. * @param func The function to invoke. * @param delay The delay to wait (in milliseconds) before invoking the function again. */ export declare function throttle(func: Function, delay?: number): (this: any) => void; /** * Determines whether a value is numeric, i.e. a number or a numeric string. * @param value The value to check. */ export declare function isNumeric(value: string | number | undefined): boolean; export declare function getElementProps(component: FormComponent, element: defs.Element): FormElementProps; /** * Gets the id of an item from a Record. * @param item The item to find. * @param items The items to look through. * @returns The key corresponding to the item, or undefined if no match was found. */ export declare function getItemId(item: defs.Item | null | undefined, items: Record): string | undefined; type NumberFormatKeys = keyof defs.NumberFormat; type SizeKeys = keyof defs.Size; /** * Helper function to determine which properties are children of the * appearance element. * @param accessor The property accessor to be checked. */ export declare function isItemAppearanceProperty(accessor: string): accessor is keyof defs.ItemAppearance; /** * Helper function to determine which properties are children of the * format element. * @param accessor The property accessor to be checked. */ export declare function isNumberFormatProperty(accessor: string): accessor is NumberFormatKeys; export declare function isSizeProperty(accessor: string): accessor is SizeKeys; export declare function getBorderStyle(borderStyle?: string): defs.BorderStyle; export declare function getEmphasis(emphasis?: string): "custom" | defs.Emphasis; export declare function getIconPosition(iconPosition?: string): defs.IconPosition; export declare function getItemColors(itemAppearance: defs.ItemAppearance, theme: Theme): { foregroundColor?: undefined; backgroundColor?: undefined; } | { foregroundColor: string; backgroundColor: string; }; export declare function getItemSize(size?: string): defs.ItemSize; export declare function getShowBorder(emphasis: defs.Emphasis | "custom", showBorder: boolean | undefined): boolean; /** * This function checks the elements to decide if they are an older single-column layout, or a newer * layout that supports side-by-side elements. * * Since Workflow 5.25, form element position information has been saved in `rowNumber` and `rowIndex` values, allowing * elements to be placed beside each other on the same row. * Prior to that, the `index` property was used and all elements were stacked in a single column. * * The header and footer are excluded from this check as they never contain any of these properties. * @param elements A set of form elements to be instpected. * @returns True if the elements should be treated as a single-column layout, false if they should allow side-by-sde elements. */ export declare function isSingleColumnLayout(elements: Record): boolean; /** * This function orders elements based on their `index` property, with the `header` always first and the `footer` always last. * @param elementTuple1 The first element to compare. * @param elementTuple2 The second element to compare. * @returns A negative number if `elementTuple1` should be before `elementTuple2`, * a positive number if `elementTuple2` should be before `elementTuple1`, * or zero if their `index` values are the same. */ export declare function compareElementIndex(elementTuple1: ElementTuple, elementTuple2: ElementTuple): number; /** * This function orders elements based on their `rowNumber` and `rowIndex` properties, with the `header` always first and the `footer` always last. * @param elementTuple1 The first element to compare. * @param elementTuple2 The second element to compare. * @returns A negative number if `elementTuple1` should be before `elementTuple2`, * a positive number if `elementTuple2` should be before `elementTuple1`, * or zero if their `rowNumber` and `rowIndex` values are the same. */ export declare function compareRowNumberAndRowIndex(elementTuple1: ElementTuple, elementTuple2: ElementTuple): number;