@api-components/api-forms
Version:
A library containing helper classes to compute API data from the AMF web API model.
63 lines (56 loc) • 2.22 kB
TypeScript
import {AmfFormItem} from '@advanced-rest-client/arc-types/src/forms/FormTypes';
import {Part} from 'lit-html';
/**
* Computes value for `renderEmptyMessage`.
*
* @param allowCustom True if the form allows to add custom values.
* @param model Current model
* @returns `true` when allowCustom is falsy set and model is empty
*/
export declare function canRenderEmptyMessage(allowCustom: boolean, model: object[]): boolean;
/**
* Computes if model item is optional.
* The items is always optional if is not required and when `hasOptional`
* is set to `true`.
*
* @param hasOptional
* @param model Model item.
* @returns `true` if the model item is optional in the form.
*/
export function isOptional(hasOptional: boolean, model: AmfFormItem): boolean;
/**
* Computes if given model item is a custom property (not generated by
* AMF model transformation).
* @param model Model item.
* @returns `true` if `isCustom` property is set on model's schema property.
*/
export function isCustom(model: AmfFormItem): boolean;
/**
* Computes value for `renderOptionalCheckbox` property.
*
* @param render Value of `allowHideOptional` property
* @param has Value of `hasOptional` property.
* @returns True if both values are `true`.
*/
export function renderCheckbox(render: boolean, has: boolean): boolean;
/**
* Computes if any of the parameters are required.
* It iterates over the model to find any first element that has `required`
* property set to `false`.
*
* @param allowHideOptional State of `allowHideOptional` property.
* If `false` this function always returns `false`.
* @param model Current model
* @returns `true` if model has at leas one element that is not required.
*/
export function hasOptionalParameters(allowHideOptional: boolean, model: AmfFormItem[]): boolean;
/**
* Computes class name for each form item depending on the item state.
*
* This method to be overwritten by child classes.
*
* @param item Model item
* @param allowHideOptional
* @param optionalOpened True if optional parameters are rendered.
*/
export function rowClass(item: AmfFormItem, allowHideOptional?: boolean, optionalOpened?: boolean, allowDisableParams?: boolean): (part: Part) => void;