gatsby-drupal-webform
Version:
React component for Drupal webforms
31 lines (30 loc) • 1.24 kB
TypeScript
import { WebformSettings, WebformElement } from './Webform';
import { formToJSON } from './formToJSON';
/** Webform attribute names that map to object that can be spread to <input> elements. */
export declare const HTML_ATTRIBUTE_WHITELIST: readonly ["required", "defaultValue", "disabled", "readonly", "placeholder", "multiple"];
declare type InputProps = Partial<{
[name in typeof HTML_ATTRIBUTE_WHITELIST[number]]: any;
}>;
export { formToJSON };
/**
* Transform WebformElement
*
* @param element webform element
* @param options custom properties
*/
export declare function useWebformElement<T extends {}>(element: WebformElement, options?: T): [InputProps & T, WebformSettings];
export declare function getOptionId(name: string, value: string): string;
/**
* Generate id for form element
*
* @param name element name
*/
export declare function getElementId(name: string): string;
/**
* Get and return attribute from array of WebformAttributes.
*
* @param attributeName name of the attribute to find.
* @param attributes list of attributes to search.
* @returns value of attribute if found or undefined.
*/
export declare function getAttributeValue(attributeName: string, element: WebformElement): string | undefined;