UNPKG

@cerberus-design/react

Version:

The Cerberus Design React component library.

94 lines (91 loc) 2.45 kB
import { FieldStartIndicator } from "./chunk-EMDNETC7.js"; import { FieldStatusIndicator } from "./chunk-LCURHO24.js"; import { CerberusFieldErrorText } from "./chunk-QTV75ATT.js"; import { createCerberusPrimitive } from "./chunk-YJRAJNYI.js"; import { splitProps } from "./chunk-BL7G3577.js"; // src/components/field/primitives.tsx import { Field } from "@ark-ui/react/field"; import { ark } from "@ark-ui/react"; import { field } from "styled-system/recipes"; import { jsx, jsxs } from "react/jsx-runtime"; var { withSlotRecipe, withNoRecipe } = createCerberusPrimitive(field); var FieldRoot = withSlotRecipe(Field.Root, "root"); function FieldLabelEl(props) { const { children, ...nativeProps } = props; return /* @__PURE__ */ jsxs(Field.Label, { ...nativeProps, children: [ children, /* @__PURE__ */ jsx(Field.RequiredIndicator, { children: "(required)" }) ] }); } var FieldLabel = withSlotRecipe(FieldLabelEl, "label"); function FieldRequiredIndicatorEl(props) { return /* @__PURE__ */ jsx(Field.RequiredIndicator, { ...props, children: "(required)" }); } var FieldRequiredIndicator = withNoRecipe( FieldRequiredIndicatorEl ); var FieldInputRoot = withSlotRecipe( ark.div, "inputRoot" ); var FieldInput = withSlotRecipe(Field.Input, "input"); var FieldHelperText = withSlotRecipe( Field.HelperText, "helperText" ); var FieldErrorText = withSlotRecipe( CerberusFieldErrorText, "errorText" ); var FieldTextarea = withSlotRecipe( Field.Textarea, "textarea" ); var Input = CerberusFieldInput; var Textarea = FieldTextarea; // src/components/field/input.tsx import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime"; function CerberusFieldInput(props) { const [{ startIcon, endIcon }, fieldProps] = splitProps(props, [ "startIcon", "endIcon" ]); const hasStartIcon = Boolean(startIcon); return /* @__PURE__ */ jsxs2(FieldInputRoot, { children: [ /* @__PURE__ */ jsx2(FieldStartIndicator, { children: startIcon }), /* @__PURE__ */ jsx2( FieldInput, { ...fieldProps, ...hasStartIcon && { "data-has": "start-indicator" } } ), /* @__PURE__ */ jsx2(FieldStatusIndicator, { fallback: endIcon }) ] }); } export { CerberusFieldInput, FieldRoot, FieldLabel, FieldRequiredIndicator, FieldInputRoot, FieldInput, FieldHelperText, FieldErrorText, FieldTextarea, Input, Textarea }; //# sourceMappingURL=chunk-5L5PT37R.js.map