UNPKG

@llamaindex/ui

Version:

A comprehensive UI component library built with React, TypeScript, and Tailwind CSS for LlamaIndex applications

95 lines (89 loc) 3.5 kB
'use strict'; var chunkHK7TFVDA_js = require('./chunk-HK7TFVDA.js'); var chunk4E3IDRQJ_js = require('./chunk-4E3IDRQJ.js'); var React = require('react'); var classVarianceAuthority = require('class-variance-authority'); var lucideReact = require('lucide-react'); var jsxRuntime = require('react/jsx-runtime'); function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var React__namespace = /*#__PURE__*/_interopNamespace(React); var inputVariants = classVarianceAuthority.cva( "flex w-full min-w-0 rounded-md border border-input bg-transparent text-base shadow-xs transition-[color,box-shadow] outline-none ring-offset-background file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40", { variants: { size: { default: "h-10 px-3 py-2 md:text-sm", xs: "h-8 px-2.5 py-1.5 text-xs" } }, defaultVariants: { size: "default" } } ); var Input = React__namespace.forwardRef( (_a, ref) => { var _b = _a, { className, size, type = "text", disabled } = _b, props = chunk4E3IDRQJ_js.__objRest(_b, ["className", "size", "type", "disabled"]); const [showPassword, setShowPassword] = React__namespace.useState(false); const isPassword = type === "password"; React__namespace.useEffect(() => { if (!isPassword && showPassword) { setShowPassword(false); } }, [isPassword, showPassword]); const inputType = isPassword && showPassword ? "text" : type; const inputClasses = chunkHK7TFVDA_js.cn( inputVariants({ size }), isPassword && "pr-10", className, disabled ? "cursor-not-allowed" : "", "focus-visible:border-[#8B5CF6]" ); const inputElement = /* @__PURE__ */ jsxRuntime.jsx( "input", chunk4E3IDRQJ_js.__spreadValues({ ref, type: inputType, "data-slot": "input", className: inputClasses }, props) ); if (!isPassword) { return inputElement; } return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [ inputElement, /* @__PURE__ */ jsxRuntime.jsx( "button", { type: "button", className: "absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground", onClick: () => setShowPassword((prev) => !prev), "aria-label": showPassword ? "Hide password" : "Show password", "aria-pressed": showPassword, disabled, children: showPassword ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eye, { className: "size-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.EyeOff, { className: "size-4", "aria-hidden": "true" }) } ) ] }); } ); Input.displayName = "Input"; exports.Input = Input; exports.inputVariants = inputVariants;