UNPKG

@workday/canvas-kit-react

Version:

The parent module that contains all Workday Canvas Kit React components

28 lines (27 loc) 1.27 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FormFieldGroupInput = exports.useFormFieldGroupInput = void 0; const common_1 = require("@workday/canvas-kit-react/common"); const canvas_kit_styling_1 = require("@workday/canvas-kit-styling"); const react_1 = __importDefault(require("react")); const hooks_1 = require("./hooks"); /** * Adds the necessary props to an `Input` component for grouped inputs. */ exports.useFormFieldGroupInput = (0, common_1.createElemPropsHook)(hooks_1.useFormFieldModel)(({ state }) => { return { 'aria-invalid': state.error === 'error' ? true : undefined, 'aria-describedby': state.id ? `hint-${state.id}` : undefined, 'aria-required': state.isRequired ? true : undefined, }; }); exports.FormFieldGroupInput = (0, common_1.createSubcomponent)('input')({ displayName: 'FormField.Input', modelHook: hooks_1.useFormFieldModel, elemPropsHook: exports.useFormFieldGroupInput, })((elemProps, Element) => { return react_1.default.createElement(Element, { ...(0, canvas_kit_styling_1.handleCsProp)(elemProps) }); });