UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

42 lines (41 loc) 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useFormFieldModel = void 0; const common_1 = require("@workday/canvas-kit-react/common"); exports.useFormFieldModel = (0, common_1.createModelHook)({ defaultConfig: { /** * Optional flag to denote if this field has an error or warning to display. * If value is `error`: `aria-invalid` is added to the `FormField.Input` and the red error ring is added. * If value is `alert`: A visual orange warning ring is added to the `FormField.Input`. */ error: undefined, /** * Optional `id` provided to `FormField`'s subcomponents as HTML attributes: * - `FormField.Input` will set `aria-describedby` to `hint-${id}` * - `FormField.Input` will set `id` to `input-${id}` * - `FormField.Label` will set `htmlFor` to `input-${id}` * - `FormField.Hint` will set `id` to `hint-${id}` * * If a value is not provided, a unique id will be automatically created by `useUniqueId()`. * @default {useUniqueId} */ id: '', /** * Optional flag to denote if this field is required. When true the `FormField.Input` will have * `required` set to true, and an asterisk will be appended to the `FormField.Label`. */ isRequired: false, orientation: 'vertical', }, })(config => { const id = (0, common_1.useUniqueId)(config.id); const state = { ...config, id, }; return { state, events: {}, }; });