File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ export default () => {
3636| -------------- | -------------------- | --------- | ------------------ |
3737| className | string | - | 类名 |
3838| style | React.CSSProperties | - | 样式 |
39+ | disabled | ` boolean ` | ` false ` | 是否禁用 |
3940| keepOpenOnBlur | ` boolean ` | ` false ` | 失去焦点时保持打开 |
4041| hideActions | ` boolean ` | ` false ` | 是否隐藏操作按钮 |
4142| confirmText | ` string ` | ` Confirm ` | 确认文本 |
Original file line number Diff line number Diff line change 11{
22 "name" : " @twp0217/react-inline-edit" ,
3- "version" : " 1.0.6 " ,
3+ "version" : " 1.0.7 " ,
44 "description" : " Inline edit component for React" ,
55 "scripts" : {
66 "start" : " dumi dev" ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const InlineEdit = (props: InlineEditProps) => {
99 const {
1010 className,
1111 style,
12+ disabled,
1213 keepOpenOnBlur,
1314 isEditing : customizeIsEditing ,
1415 readView,
@@ -80,7 +81,7 @@ const InlineEdit = (props: InlineEditProps) => {
8081
8182 return (
8283 < div className = { classNames ( 'inline-edit-container' , className ) } style = { style } >
83- { isEditing ? (
84+ { ! disabled && isEditing ? (
8485 < EditView
8586 { ...props }
8687 onBlur = { handleBlur }
@@ -90,7 +91,7 @@ const InlineEdit = (props: InlineEditProps) => {
9091 onCancel = { handleCancel }
9192 />
9293 ) : (
93- < ReadView readView = { readView } onClick = { handleReadViewClick } />
94+ < ReadView disabled = { disabled } readView = { readView } onClick = { handleReadViewClick } />
9495 ) }
9596 </ div >
9697 ) ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { InlineEditProps } from '../interface' ;
3+ import classNames from 'classnames' ;
34
4- interface ReadViewProps extends Pick < InlineEditProps , 'readView' > {
5+ interface ReadViewProps extends Pick < InlineEditProps , 'disabled' | ' readView'> {
56 onClick : ( ) => void ;
67}
78
89const ReadView = ( props : ReadViewProps ) => {
9- const { readView, onClick } = props ;
10+ const { disabled , readView, onClick } = props ;
1011
1112 return (
12- < div className = " inline-edit-read-view-container" onClick = { onClick } >
13+ < div className = { classNames ( ' inline-edit-read-view-container' , { disabled } ) } onClick = { onClick } >
1314 { readView }
1415 </ div >
1516 ) ;
Original file line number Diff line number Diff line change 3131 border-radius : 2px ;
3232 box-shadow : 0 0 0 0 transparent ;
3333
34- & :hover {
34+ & :not ( .disabled ) : hover {
3535 box-shadow : 0 0 0 1px @border-color ;
3636 }
3737 }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ export type Placement = 'top' | 'bottom';
55export interface InlineEditProps < T = Value > {
66 className ?: string ;
77 style ?: React . CSSProperties ;
8+ disabled ?: boolean ;
89 keepOpenOnBlur ?: boolean ;
910 hideActions ?: boolean ;
1011 confirmText ?: string ;
You can’t perform that action at this time.
0 commit comments