UNPKG

@veracity/vui

Version:

Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.

53 lines (51 loc) 2.15 kB
import { inputStateMapping } from "./consts.js"; import vui from "../core/vui.js"; import { HelpText } from "./helpText.js"; import { TextField } from "../textField/textField.js"; import { InputIcon } from "./inputIcon.js"; import { InputInput } from "./inputInput.js"; import { useEffect } from "react"; import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime"; //#region src/input/input.tsx /** * @deprecated Use `TextField` instead. `Input` is a thin wrapper kept for backward compatibility and * will be removed in a future major version. */ const Input = vui((props, ref) => { const { children, iconLeft, iconRight, input, inputProps, inputRef, startIcon, endIcon, state, stateMapping, ...rest } = props; useEffect(() => { console.warn("[Input] is deprecated. Use `TextField` instead."); if (iconLeft !== void 0) console.warn("[Input] `iconLeft` is deprecated. Use `startIcon` instead."); if (iconRight !== void 0) console.warn("[Input] `iconRight` is deprecated. Use `endIcon` instead."); if (state !== void 0) console.warn("[Input] `state` is deprecated. Use `variant`, `errorText` or `loading` on `TextField` instead."); }, [ iconLeft, iconRight, state ]); const states = { ...inputStateMapping, ...stateMapping }; const stateIconProps = state && state !== "loading" ? states[state]?.iconProps : void 0; const resolvedEndIcon = endIcon ?? iconRight; const endIconWithState = resolvedEndIcon && stateIconProps ? /* @__PURE__ */ jsxs(Fragment$1, { children: [resolvedEndIcon, /* @__PURE__ */ jsx(TextField.Icon, { ...stateIconProps })] }) : stateIconProps ? /* @__PURE__ */ jsx(TextField.Icon, { ...stateIconProps }) : resolvedEndIcon; return /* @__PURE__ */ jsx(TextField, { endIcon: endIconWithState, field: children ?? input, fieldProps: inputProps, fieldRef: inputRef, loading: state === "loading", ref, startIcon: startIcon ?? iconLeft, ...rest }); }); Input.Icon = InputIcon; Input.Input = InputInput; Input.HelpText = HelpText; Input.displayName = "Input"; //#endregion export { Input, Input as default }; globalThis.__vuiVersion__ = "5.4.0-alpha" //# sourceMappingURL=input.js.map