1.0.7 • Published 2 years ago

@twp0217/react-inline-edit v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-inline-edit

Inline edit component for React(基于 React 的内联编辑组件)

安装

npm install @twp0217/react-inline-edit --save

使用

import React from 'react';
import InlineEdit from '@twp0217/react-inline-edit';

export default () => {
  const [editValue, setEditValue] = React.useState<string>('');

  return (
    <InlineEdit
      defaultValue={editValue}
      readView={editValue || '请点击输入值'}
      editView={<input placeholder="请输入值" />}
      onConfirm={setEditValue}
    />
  );
};

API

InlineEditProps

名称类型默认值说明
classNamestring-类名
styleReact.CSSProperties-样式
disabledbooleanfalse是否禁用
keepOpenOnBlurbooleanfalse失去焦点时保持打开
hideActionsbooleanfalse是否隐藏操作按钮
confirmTextstringConfirm确认文本
cancelTextstringCancel取消文本
defaultValuestring-默认值
isEditingboolean-是否正在编辑
loadingboolean-加载中
placementtop | bottom-按钮位置
readViewReact.ReactNode-查看视图
editViewReact.ReactNode-编辑视图
onEdit() => void-编辑事件
onBlur() => void-失去焦点事件
onConfirm(value: T) => void-确认事件
onCancel() => void-取消事件

支持

  • 如果项目对你有帮助,请点颗星星:star:,谢谢。
  • 如果你对项目有想法、问题、BUG,欢迎讨论。