(
- ({ prependIconName, appendIconName, className, hasError, ...props }, ref) => {
- className = `h-28 ${className}`;
- if (prependIconName) {
- className += ' pl-28';
- }
- if (appendIconName) {
- className += ' pr-28';
- }
+ (
+ {
+ prependIconName,
+ prependIconDescription,
+ appendIconName,
+ appendIconDescription,
+ prependElement,
+ appendElement,
+ className,
+ hasError,
+ ...props
+ },
+ ref
+ ) => {
+ const hasPrepended = !!(prependIconName || prependElement);
+ const hasAppended = !!(appendIconName || appendElement);
+
+ const inputClassName = classNames('h-28', className, {
+ 'pl-28': hasPrepended ?? hasAppended,
+ });
const input = (
);
- const iconName = prependIconName || appendIconName;
- if (iconName !== undefined) {
- const iconClassName = classNames(
- ['fill-black-60 dark:fill-white-60', 'absolute', 'z-10'],
- {
- 'left-8': prependIconName,
- 'right-8': appendIconName,
- }
- );
- const icon = ;
+
+ const element = getAffixElement({
+ prependIconName,
+ prependIconDescription,
+ appendIconName,
+ appendIconDescription,
+ prependElement,
+ appendElement,
+ });
+
+ if (element) {
return (
- {prependIconName && icon}
+ {hasPrepended && element}
{input}
- {appendIconName && icon}
+ {hasAppended && element}
);
}
+
return input;
}
);