@siren-js/client
Version:
Siren API client library
37 lines (36 loc) • 1.23 kB
TypeScript
import { SirenElementVisitor } from '../visitor';
import { SirenElement } from './siren-element';
/**
* Represents an input control inside an `Action`. Serialization of a `Field` depends on its `type` and its
* corresponding `Action`'s `type`.
* @typeParam T Type of the `value` property.
*/
export declare class Field<T = unknown> implements SirenElement {
/**
* List of strings describing the nature of the `Field` based on the current representation. Possible values are
* implementation-dependent and should be documented.
*/
class: string[];
/**
* Name describing the control. Must be unique within an `Action`.
*/
name: string;
/**
* Textual annotation of a field. Clients may use this as a label.
*/
title?: string;
/**
* Input type of the field. May include any of the [input types from HTML](https://html.spec.whatwg.org/multipage/input.html#attr-input-type).
* When missing, the default is assumed to be `text`.
*/
type: string;
/**
* Value assigned to the `Field`.
*/
value?: T;
[extension: string]: unknown;
/**
* Visits this field.
*/
accept(visitor: SirenElementVisitor): Promise<void>;
}