Skip to content

Commit d5b21f0

Browse files
committed
feat: add visible props, visiable mark is deprecated. (#148)
1 parent 677a672 commit d5b21f0

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

core/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,26 @@ export default Demo;
5656

5757
### Available for layout
5858

59-
Setting `visiable={false}` disables the drag bar, which can be used for layout.
59+
Setting `visible={false}` disables the drag bar, which can be used for layout.
6060

6161
```jsx mdx:preview&background=#fff&codeSandbox=true&codePen=true
6262
import React from 'react';
6363
import Split from '@uiw/react-split';
6464

6565
const Demo = () => (
6666
<div>
67-
<Split mode="vertical" visiable={false}>
67+
<Split mode="vertical" visible={false}>
6868
<div style={{ minHeight: 45, background: '#dcdcdc' }}>Header</div>
69-
<Split visiable={false}>
69+
<Split visible={false}>
7070
<div style={{ minWidth: 200, maxWidth: 200, minHeight: 120, background: '#b5b5b5' }}>Sider</div>
7171
<div style={{ width: '100%', background: '#ececec' }}>Content</div>
7272
</Split>
7373
<div style={{ minHeight: 45, background: '#dcdcdc' }}>Footer</div>
7474
</Split>
7575
<div style={{ height: 20 }}></div>
76-
<Split visiable={false}>
76+
<Split visible={false}>
7777
<div style={{ minWidth: 200, maxWidth: 200, minHeight: 85, background: '#a9a9a9' }}>Sider</div>
78-
<Split mode="vertical" visiable={false} style={{ width: '100%' }}>
78+
<Split mode="vertical" visible={false} style={{ width: '100%' }}>
7979
<div style={{ minHeight: 45, background: '#dcdcdc' }}>Header</div>
8080
<div style={{ minHeight: 85, background: '#b5b5b5' }}>Content</div>
8181
<div style={{ minHeight: 45, background: '#dcdcdc' }}>Footer</div>
@@ -319,6 +319,10 @@ export interface SplitProps extends Omit<React.HTMLAttributes<HTMLDivElement>, '
319319
/** Set the drag and drop toolbar as a line style. */
320320
lineBar?: boolean;
321321
/** Set the dragged toolbar, whether it is visible or not */
322+
visible?: boolean | number[];
323+
/**
324+
* @deprecated Use `visible` instead
325+
*/
322326
visiable?: boolean | number[];
323327
/**
324328
* Set the drag and drop toolbar, disable

core/src/index.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export interface SplitProps extends Omit<React.HTMLAttributes<HTMLDivElement>, '
1717
/** Set the drag and drop toolbar as a line style. */
1818
lineBar?: boolean;
1919
/** Set the dragged toolbar, whether it is visible or not */
20+
visible?: boolean | number[];
21+
/**
22+
* @deprecated Use `visible` instead
23+
*/
2024
visiable?: boolean | number[];
2125
/**
2226
* Set the drag and drop toolbar, disable
@@ -149,6 +153,7 @@ export default class Split extends React.Component<SplitProps, SplitState> {
149153
children,
150154
mode,
151155
visiable,
156+
visible = this.props.visible ?? this.props.visiable,
152157
renderBar,
153158
lineBar,
154159
disable,
@@ -169,7 +174,7 @@ export default class Split extends React.Component<SplitProps, SplitState> {
169174
className: [`${prefixCls}-pane`, element.props.className].filter(Boolean).join(' ').trim(),
170175
style: { ...element.props.style },
171176
});
172-
const visiableBar = visiable === true || (visiable && visiable.includes((idx + 1) as never)) || false;
177+
const visibleBar = visible === true || (visible && visible.includes((idx + 1) as never)) || false;
173178
const barProps = {
174179
className: [
175180
`${prefixCls}-bar`,
@@ -184,9 +189,9 @@ export default class Split extends React.Component<SplitProps, SplitState> {
184189
barProps.className = [barProps.className, disable ? 'disable' : null].filter(Boolean).join(' ').trim();
185190
}
186191
let BarCom = null;
187-
if (idx !== 0 && visiableBar && renderBar) {
192+
if (idx !== 0 && visibleBar && renderBar) {
188193
BarCom = renderBar({ ...barProps, onMouseDown: this.onMouseDown.bind(this, idx + 1) });
189-
} else if (idx !== 0 && visiableBar) {
194+
} else if (idx !== 0 && visibleBar) {
190195
BarCom = React.createElement(
191196
'div',
192197
{ ...barProps },

0 commit comments

Comments
 (0)