@avoraui/av-dual-list-box
Version:
A customizable Angular dual list box component for managing item selections.
108 lines (105 loc) • 5.6 kB
TypeScript
import * as i0 from '@angular/core';
import { OnInit, OnChanges, AfterViewInit, SimpleChanges } from '@angular/core';
import { MatSelectionList } from '@angular/material/list';
import { ControlValueAccessor, FormGroup, FormBuilder } from '@angular/forms';
declare class AvDualListBox<T extends Record<string, any>> implements OnInit, OnChanges, AfterViewInit, ControlValueAccessor {
private formBuilder;
sourceList: T[];
destinationObjectReference: string[];
displayProperty: keyof T | '';
protected destinationList: T[];
private originalSourceList;
private originalDestinationList;
protected form: FormGroup;
SourceList: MatSelectionList;
DestinationList: MatSelectionList;
private onChange;
private onTouched;
private disabled;
constructor(formBuilder: FormBuilder);
ngOnInit(): void;
/**
* Responds to changes in input-bound properties of the component.
* Executes logic whenever the bound properties are updated.
*
* @param {SimpleChanges} changes - An object that contains the changes to the bound properties. Each property corresponds to a component input and contains its current and previous values.
* @return {void} This method does not return a value.
*/
ngOnChanges(changes: SimpleChanges): void;
/**
* Writes the provided value to the destination list, processes and maps the values accordingly,
* and updates the source and destination lists.
*
* @param {T[]} value - The array of values to process and write to the destination list. If the value is null or undefined, the destination list is cleared.
* @return {void} This method does not return any value.
*/
writeValue(value: T[]): void;
/**
* Maps and filters the input array based on the `destinationObjectReference`.
* For each item in the `value` array, it retrieves a nested value determined
* by the keys in the `destinationObjectReference`. Only non-null values are returned.
*
* @param {T[]} value - The array of items to be processed and filtered.
* @return {T[]} - A filtered array containing only the mapped and non-null values.
*/
private getMappedDestinationValues;
private resetAndFilterSourceList;
registerOnChange(fn: (value: T[]) => void): void;
registerOnTouched(fn: () => void): void;
setDisabledState?(isDisabled: boolean): void;
/**
* Moves selected items between the source list and the destination list based on the provided direction.
*
* @param {boolean} isToDestination - A boolean flag to determine the direction of movement. If true, moves items from source list to destination list. If false, moves items from destination list to source list.
* @return {void} No return value.
*/
moveItems(isToDestination: boolean): void;
/**
* Moves all items between source and destination lists based on the specified direction.
*
* @param {boolean} isToDestination - Indicates the direction of the move.
* If true, moves all items from the source list to the destination list.
* If false, moves all items from the destination list back to the source list.
*
* @return {void} This method does not return any value.
*/
moveAllItems(isToDestination: boolean): void;
/**
* Clears the selection from either the source list or the destination list based on the provided parameter.
*
* @param {boolean} isToDestination - A flag indicating whether to clear the destination list (`true`) or source list (`false`).
* @return {void} This method does not return a value.
*/
private clearSelection;
/**
* Filters the original list based on the search value from the specified form control.
*
* @param {string} searchControlName - The name of the form control used to retrieve the search input.
* @param {T[]} originalList - The original unfiltered list of items.
* @param {T[]} targetList - The list to store the filtered results. It will reflect the filtered or full contents of the original list.
* @return {T[]} - The filtered list of items matching the search input, or the original list if no input is entered.
*/
filterList(searchControlName: string, originalList: T[], targetList: T[]): T[];
/**
* Filters the source list based on the provided search criteria and updates the source list.
*
* @return {void} This method does not return a value. It updates the sourceList property with the filtered results.
*/
filterSourceList(): void;
/**
* Filters the destination list based on the search criteria provided and updates the existing list.
*
* @return {void} Updates the `destinationList` property with the filtered results.
*/
filterDestinationList(): void;
/**
* A lifecycle hook that is called after the component's view has been fully initialized.
* This method ensures that all options in the DestinationList are marked as selected.
*
* @return {void} This method does not return a value.
*/
ngAfterViewInit(): void;
static ɵfac: i0.ɵɵFactoryDeclaration<AvDualListBox<any>, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<AvDualListBox<any>, "av-dual-list-box", never, { "sourceList": { "alias": "sourceList"; "required": false; }; "destinationObjectReference": { "alias": "destinationObjectReference"; "required": false; }; "displayProperty": { "alias": "displayProperty"; "required": false; }; }, {}, never, never, true, never>;
}
export { AvDualListBox };