export default function usePropsForInputElement()

in packages-rc/console-base-rc-input/src/model/hook/use-props-for-input-element.ts [16:66]


export default function usePropsForInputElement(): InputHTMLAttributes<HTMLInputElement> {
  const props = useModelProps();
  const value = useValue();
  const hovered = useHovered();
  const focused = useFocused();
  const handleFocusIn = useHandleFocusIn();
  const handleFocusOut = useHandleFocusOut();
  const handleChange = useHandleChange();
  const handleCompositionStart = useHandleCompositionStart();
  const handleCompositionEnd = useHandleCompositionEnd();
  
  return useMemo(() => {
    const {
      theme,
      block,
      round,
      borderless,
      innerLeft,
      innerRight,
      weakFocusStyle,
      className,
      style,
      hasClear,
      status,
      onMouseEnter,
      onMouseLeave,
      onFocus,
      onBlur,
      onChange,
      onFocusedChange,
      onHoveredChange,
      // 以上属性或是容器扩展,或被接管,剔除
      ...rest
    } = props;
    
    return {
      type: 'text',
      'aria-autocomplete': 'none',
      autocomplete: 'off',
      ...rest,
      value,
      hovered,
      focused,
      onFocus: handleFocusIn,
      onBlur: handleFocusOut,
      onCompositionStart: handleCompositionStart,
      onCompositionEnd: handleCompositionEnd,
      onChange: handleChange
    };
  }, [props, value, hovered, focused, handleFocusIn, handleFocusOut, handleCompositionStart, handleCompositionEnd, handleChange]);
}