Files
NapCatQQ/.pnpm-store/v3/files/42/375fbd49c147ca63b9ab3daa313a4877f3c98cd0382f7f8a7660593e3b585b06a9870d92d2477ec4115ed67bd42e3b18785df775339f342177dda8509a0fc1
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

106 lines
3.1 KiB
Plaintext

"use client";
import {
useInput
} from "./chunk-MSLIMGMJ.mjs";
// src/input.tsx
import { CloseFilledIcon } from "@heroui/shared-icons";
import { useMemo } from "react";
import { forwardRef } from "@heroui/system";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
var Input = forwardRef((props, ref) => {
const {
Component,
label,
description,
isClearable,
startContent,
endContent,
labelPlacement,
hasHelper,
isOutsideLeft,
shouldLabelBeOutside,
errorMessage,
isInvalid,
getBaseProps,
getLabelProps,
getInputProps,
getInnerWrapperProps,
getInputWrapperProps,
getMainWrapperProps,
getHelperWrapperProps,
getDescriptionProps,
getErrorMessageProps,
getClearButtonProps
} = useInput({ ...props, ref });
const labelContent = label ? /* @__PURE__ */ jsx("label", { ...getLabelProps(), children: label }) : null;
const end = useMemo(() => {
if (isClearable) {
return /* @__PURE__ */ jsx("button", { ...getClearButtonProps(), children: endContent || /* @__PURE__ */ jsx(CloseFilledIcon, {}) });
}
return endContent;
}, [isClearable, getClearButtonProps]);
const helperWrapper = useMemo(() => {
const shouldShowError = isInvalid && errorMessage;
const hasContent = shouldShowError || description;
if (!hasHelper || !hasContent)
return null;
return /* @__PURE__ */ jsx("div", { ...getHelperWrapperProps(), children: shouldShowError ? /* @__PURE__ */ jsx("div", { ...getErrorMessageProps(), children: errorMessage }) : /* @__PURE__ */ jsx("div", { ...getDescriptionProps(), children: description }) });
}, [
hasHelper,
isInvalid,
errorMessage,
description,
getHelperWrapperProps,
getErrorMessageProps,
getDescriptionProps
]);
const innerWrapper = useMemo(() => {
return /* @__PURE__ */ jsxs("div", { ...getInnerWrapperProps(), children: [
startContent,
/* @__PURE__ */ jsx("input", { ...getInputProps() }),
end
] });
}, [startContent, end, getInputProps, getInnerWrapperProps]);
const mainWrapper = useMemo(() => {
if (shouldLabelBeOutside) {
return /* @__PURE__ */ jsxs("div", { ...getMainWrapperProps(), children: [
/* @__PURE__ */ jsxs("div", { ...getInputWrapperProps(), children: [
!isOutsideLeft ? labelContent : null,
innerWrapper
] }),
helperWrapper
] });
}
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsxs("div", { ...getInputWrapperProps(), children: [
labelContent,
innerWrapper
] }),
helperWrapper
] });
}, [
labelPlacement,
helperWrapper,
shouldLabelBeOutside,
labelContent,
innerWrapper,
errorMessage,
description,
getMainWrapperProps,
getInputWrapperProps,
getErrorMessageProps,
getDescriptionProps
]);
return /* @__PURE__ */ jsxs(Component, { ...getBaseProps(), children: [
isOutsideLeft ? labelContent : null,
mainWrapper
] });
});
Input.displayName = "HeroUI.Input";
var input_default = Input;
export {
input_default
};