UNPKG

@cerberus-design/react

Version:

The Cerberus Design React component library.

37 lines (32 loc) 1.58 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const jsxRuntime = require('react/jsx-runtime'); const jsx = require('styled-system/jsx'); const index = require('../../utils/index.cjs'); const show = require('../show/show.cjs'); const primitives = require('./primitives.cjs'); const helperText = require('./helper-text.cjs'); function Field(props) { const [statusProps, fieldProps, rootProps] = index.splitProps( props, ["disabled", "required", "readOnly", "invalid"], [ "label", "helperText", "secondaryHelperText", "errorText", "hideLabel", "children" ] ); return /* @__PURE__ */ jsxRuntime.jsxs(primitives.FieldRoot, { ...statusProps, ...rootProps, children: [ /* @__PURE__ */ jsxRuntime.jsx(show.Show, { when: fieldProps.label, children: /* @__PURE__ */ jsxRuntime.jsx(primitives.FieldLabel, { hideLabel: fieldProps.hideLabel, children: fieldProps.label }) }), fieldProps.children, /* @__PURE__ */ jsxRuntime.jsxs(jsx.HStack, { justifyContent: "space-between", w: "full", children: [ /* @__PURE__ */ jsxRuntime.jsx(helperText.HelperText, { invalid: statusProps.invalid, children: fieldProps.helperText }), /* @__PURE__ */ jsxRuntime.jsx(primitives.FieldErrorText, { children: fieldProps.errorText }), /* @__PURE__ */ jsxRuntime.jsx(show.Show, { when: fieldProps.secondaryHelperText, children: /* @__PURE__ */ jsxRuntime.jsx(primitives.FieldHelperText, { children: fieldProps.secondaryHelperText }) }) ] }) ] }); } exports.Field = Field;