/** * Adds a Binder to the end of the registry. * It will be processed after all other binders. * To have the Binder be processed earlier use unshift(binder) * If the Binder is already in the registry it will be moved to the end * @param {Array} binder */ export function add(...binder: Array): void; /** * Use to insert binders at the start. * Use this to have a binder be evaluated first before other binders * If the Binder is already in the registry it will be moved to the start * @param {Array} binder */ export function unshift(...binder: Array): void; /** * NOTE even if a binder is removed, it will still be used for controls that have already initialized * @param {Array} binder to remove */ export function remove(...binder: Array): void; /** * Looks for a matching binder for a given control. If a binder is found it is initialized with the control to create a binding. * @param {ControlElement} controlCandidate to find a binding for * @param {OnValueChangeCallback} onChange that will be called when the control value changes * @param {OnTouchCallback} onTouch that will be called when the control is touched * @returns {ControlBinding} if a binding is found then an initialized binding is returned. If no binding was found for the control then null is returned. */ export function initialize(controlCandidate: ControlElement, onChange: OnValueChangeCallback, onTouch: OnTouchCallback): ControlBinding; export type ControlElement = Element; export type ValidationResult = import("./validation-result").ValidationResult; export type OnValueChangeCallbackOptions = { /** * optional JSON Pointer that will be appended to the controllers JSON Pointer. This is useful if the control is responsible for many properties in the schema, like a grid. */ ref?: string; }; export type OnValueChangeCallback = (newValue: any, options?: OnValueChangeCallbackOptions) => void; export type OnTouchCallback = () => void; export type Binder = { /** * css selector associated with this value accessor */ controlSelector: string; /** * should be used to bind component value change events to onChange. e.g. (control, binder) => control.addEventListener('input', () => binder.onChange()) */ initializeEvents: (arg0: TElement, arg1: OnValueChangeCallback, arg2: OnTouchCallback) => void; /** * responsible for writing a value to the control e.g. (control, value) => control.value = value */ writeValue: (arg0: TElement, arg1: undefined | TValue) => void; /** * optional function to report validation results to the control e.g. (control, validationResult) => control.setCustomValidity(...) */ reportValidity?: (arg0: TElement, arg1: import("./validation-result").ValidationResult[]) => void; }; import { ControlBinding } from "./control-binding.js";