@nestledjs/forms
Version:
A flexible React form library supporting both declarative and imperative usage patterns with TypeScript support
45 lines (44 loc) • 1.68 kB
TypeScript
import { FormField, FormFieldProps, FormFieldType } from '../form-types';
/**
* Generic utility function to transform multi-select values from display format to submission format.
* Converts from SearchSelectOption[] (display format) to string[] (API format).
*
* This transformation is automatically applied to Apollo multi-search components, but can also be
* used manually for custom form handling or non-Apollo multi-select fields.
*
* @example
* ```tsx
* // Automatic usage (no need to configure)
* const field = {
* key: 'variants',
* type: FormFieldType.SearchSelectMultiApollo,
* options: {
* label: 'Select Variants',
* document: SEARCH_VARIANTS_QUERY,
* dataType: 'variants',
* // submitTransform is applied automatically!
* }
* }
*
* // Manual usage for custom handling
* const transformedValues = multiSelectSubmitTransform(formValues.selectedItems)
* ```
*/
export declare function multiSelectSubmitTransform(value: any): string[];
/**
* @deprecated Use multiSelectSubmitTransform instead. This alias is kept for backward compatibility.
*/
export declare const apolloMultiSelectSubmitTransform: typeof multiSelectSubmitTransform;
type RequiredItemShape = {
id: string;
name?: string;
firstName?: string;
lastName?: string;
};
export declare function SelectFieldMultiSearchApollo<TDataItem extends RequiredItemShape>({ form, field, hasError, formReadOnly, formReadOnlyStyle, }: FormFieldProps<Extract<FormField, {
type: FormFieldType.SearchSelectMultiApollo;
}>> & {
formReadOnly?: boolean;
formReadOnlyStyle?: 'value' | 'disabled';
}): import("react/jsx-runtime").JSX.Element;
export {};