Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP feat(module:splitter): add splitter component #8987

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ components/pagination/** @vthinkxie
components/radio/** @vthinkxie
components/select/** @vthinkxie
components/spin/** @vthinkxie
components/splitter/** @laffery
components/switch/** @vthinkxie
components/table/** @vthinkxie
components/tree/** @simplejason
Expand Down
1 change: 1 addition & 0 deletions .github/nz-boot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ issue:
Transfer: Ricbet
Pipes: chensimeng
Image: stygian-desolator
Splitter: laffery
1 change: 1 addition & 0 deletions components/components.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
@import './skeleton/style/entry.less';
@import './slider/style/entry.less';
@import './spin/style/entry.less';
@import './splitter/style/entry.less';
@import './statistic/style/entry.less';
@import './steps/style/entry.less';
@import './switch/style/entry.less';
Expand Down
14 changes: 14 additions & 0 deletions components/splitter/demo/basic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 0
title:
zh-CN: 基本用法
en-US: Basic
---

## zh-CN

初始化面板大小,面板大小限制。

## en-US

Initialize panel size, panel size limit.
10 changes: 10 additions & 0 deletions components/splitter/demo/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { NzSplitterModule } from 'ng-zorro-antd/splitter';

@Component({
selector: 'nz-demo-splitter-basic',
imports: [NzSplitterModule],
template: ``
})
export class NzDemoSplitterBasicComponent {}
14 changes: 14 additions & 0 deletions components/splitter/demo/collapsible.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 3
title:
zh-CN: 可折叠
en-US: Collapsible
---

## zh-CN

配置 `nzCollapsible` 提供快捷收缩能力。可以通过 `nzMin` 限制收缩后不能通过拖拽展开。

## en-US

Set `nzCollapsible` to enable collapse. Can through `nzMin` to limit dragging to expand when collapsed.
10 changes: 10 additions & 0 deletions components/splitter/demo/collapsible.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { NzSplitterModule } from 'ng-zorro-antd/splitter';

@Component({
selector: 'nz-demo-splitter-collapsible',
imports: [NzSplitterModule],
template: ``
})
export class NzDemoSplitterCollapsibleComponent {}
14 changes: 14 additions & 0 deletions components/splitter/demo/complex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 5
title:
zh-CN: 复杂组合
en-US: Complex combination
---

## zh-CN

复杂组合面板,快捷折叠,禁止改变大小。

## en-US

Complex combination panel, quick folding, prohibited from changing size.
10 changes: 10 additions & 0 deletions components/splitter/demo/complex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { NzSplitterModule } from 'ng-zorro-antd/splitter';

@Component({
selector: 'nz-demo-splitter-complex',
imports: [NzSplitterModule],
template: ``
})
export class NzDemoSplitterComplexComponent {}
14 changes: 14 additions & 0 deletions components/splitter/demo/control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 1
title:
zh-CN: 受控模式
en-US: Control Mode
---

## zh-CN

受控调整尺寸。当 Panel 之间任意一方禁用 `nzResizable`,则其拖拽将被禁用。

## en-US

Control the size of the splitter. When one of the panels disables `nzResizable`, dragging will be disabled.
10 changes: 10 additions & 0 deletions components/splitter/demo/control.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { NzSplitterModule } from 'ng-zorro-antd/splitter';

@Component({
selector: 'nz-demo-splitter-control',
imports: [NzSplitterModule],
template: ``
})
export class NzDemoSplitterControlComponent {}
14 changes: 14 additions & 0 deletions components/splitter/demo/lazy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 6
title:
zh-CN: 延迟渲染模式
en-US: Lazy
---

## zh-CN

延迟渲染模式,拖拽时不会立即更新大小,而是等到松手时才更新。

## en-US

Lazy mode, dragging does not update the size immediately, but updates when released.
10 changes: 10 additions & 0 deletions components/splitter/demo/lazy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { NzSplitterModule } from 'ng-zorro-antd/splitter';

@Component({
selector: 'nz-demo-splitter-lazy',
imports: [NzSplitterModule],
template: ``
})
export class NzDemoSplitterLazyComponent {}
14 changes: 14 additions & 0 deletions components/splitter/demo/multiple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 4
title:
zh-CN: 多面板
en-US: Multiple Panels
---

## zh-CN

多面板。

## en-US

Multiple panels.
10 changes: 10 additions & 0 deletions components/splitter/demo/multiple.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { NzSplitterModule } from 'ng-zorro-antd/splitter';

@Component({
selector: 'nz-demo-splitter-multiple',
imports: [NzSplitterModule],
template: ``
})
export class NzDemoSplitterMultipleComponent {}
14 changes: 14 additions & 0 deletions components/splitter/demo/vertical.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
order: 2
title:
zh-CN: 垂直方向
en-US: Control Mode
---

## zh-CN

使用垂直布局。

## en-US

Use vertical layout.
10 changes: 10 additions & 0 deletions components/splitter/demo/vertical.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

import { NzSplitterModule } from 'ng-zorro-antd/splitter';

@Component({
selector: 'nz-demo-splitter-vertical',
imports: [NzSplitterModule],
template: ``
})
export class NzDemoSplitterVerticalComponent {}
41 changes: 41 additions & 0 deletions components/splitter/doc/index.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
category: Components
type: Layout
title: Splitter
tag: 19.1.0
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*f0SISaETY0wAAAAAAAAAAAAADrJ8AQ/original
---

Split panels to isolate.

## When To Use

Can be used to separate areas horizontally or vertically. When you need to freely drag and adjust the size of each area.
When you need to specify the maximum and minimum width and height of an area.

```ts
import { NzSplitterModule } from 'ng-zorro-antd/splitter';
```

## API

### nz-splitter

| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
|-----------------|---------------------------------|------------------------------|----------------|------|
| `[nzLayout]` | Layout direction | `'horizontal' \| 'vertical'` | `'horizontal'` | |
| `[nzLazy]` | Lazy Mode | `boolean` | `false` | |
| `(resizeStart)` | Callback before dragging starts | `EventEmitter<number[]>` | - | |
| `(resize)` | Panel size change callback | `EventEmitter<number[]>` | - | |
| `(resizeEnd)` | Drag end callback | `EventEmitter<number[]>` | - | |

### nz-splitter-panel

| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
|-------------------|-----------------------------------------------------------------|-----------|---------|------|
| `[nzDefaultSize]` | Initial panel size support number for px or 'percent%' usage | `number | string` | - | |
| `[nzMin]` | Minimum threshold support number for px or 'percent%' usage | `number | string` | - | |
| `[nzMax]` | Maximum threshold support number for px or 'percent%' usage | ``number | string` | - | |
| `[nzSize]` | Controlled panel size support number for px or 'percent%' usage | `number | string` | - | |
| `[nzCollapsible]` | Quick folding | `boolean` | `false` | |
| `[nzResizable]` | Whether to enable drag and drop | `boolean` | `true` | |
43 changes: 43 additions & 0 deletions components/splitter/doc/index.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
category: Components
type: 布局
title: Splitter
subtitle: 分隔面板
tag: 19.1.0
cover: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*f0SISaETY0wAAAAAAAAAAAAADrJ8AQ/original
---

自由切分指定区域。

## 何时使用

- 可以水平或垂直地分隔区域。
- 当需要自由拖拽调整各区域大小。
- 当需要指定区域的最大最小宽高时。

```ts
import { NzSplitterModule } from 'ng-zorro-antd/splitter';
```

## API

### nz-splitter

| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
|-----------------|-----------|------------------------------|----------------|------|
| `[nzLayout]` | 布局方向 | `'horizontal' \| 'vertical'` | `'horizontal'` | |
| `[nzLazy]` | 延迟渲染模式 | `boolean` | `false` | |
| `(resizeStart)` | 开始拖拽之前回调 | `EventEmitter<number[]>` | - | |
| `(resize)` | 面板大小变化回调 | `EventEmitter<number[]>` | - | |
| `(resizeEnd)` | 拖拽结束回调 | `EventEmitter<number[]>` | - | |

### nz-splitter-panel

| 参数 | 说明 | 类型 | 默认值 | 全局配置 |
|-------------------|-------------------------------|-----------|---------|------|
| `[nzDefaultSize]` | 初始面板大小,支持数字 px 或者文字 '百分比%' 类型 | `number | string` | - | |
| `[nzMin]` | 最小阈值,支持数字 px 或者文字 '百分比%' 类型 | `number | string` | - | |
| `[nzMax]` | 最大阈值,支持数字 px 或者文字 '百分比%' 类型 | ``number | string` | - | |
| `[nzSize]` | 受控面板大小,支持数字 px 或者文字 '百分比%' 类型 | `number | string` | - | |
| `[nzCollapsible]` | 快速折叠 | `boolean` | `false` | |
| `[nzResizable]` | 是否开启拖拽伸缩 | `boolean` | `true` | |
6 changes: 6 additions & 0 deletions components/splitter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export * from './public-api';
5 changes: 5 additions & 0 deletions components/splitter/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lib": {
"entryFile": "public-api.ts"
}
}
7 changes: 7 additions & 0 deletions components/splitter/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

export * from './splitter.component';
export * from './splitter.module';
Empty file.
16 changes: 16 additions & 0 deletions components/splitter/splitter.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { Component, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'nz-spin',
exportAs: 'nzSpin',
preserveWhitespaces: false,
encapsulation: ViewEncapsulation.None,
template: ``,
imports: []
})
export class NzSplitterComponent {}
14 changes: 14 additions & 0 deletions components/splitter/splitter.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/

import { NgModule } from '@angular/core';

import { NzSplitterComponent } from './splitter.component';

@NgModule({
imports: [NzSplitterComponent],
exports: [NzSplitterComponent]
})
export class NzSplitterModule {}
2 changes: 2 additions & 0 deletions components/splitter/style/entry.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import './index.less';
@import './patch.less';
34 changes: 34 additions & 0 deletions components/splitter/style/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@import '../../style/themes/index';
@import '../../style/mixins/index';

@splitter-prefix-cls: ~'@{ant-prefix}-splitter';

.@{splitter-prefix-cls} {
.reset-component();
display: flex;
align-items: stretch;

box-sizing: border-box;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
color: @text-color;
font-size: @font-size-base;
font-family: @font-family;
line-height: @line-height-base;
list-style: none;

&-horizontal {
flex-direction: row;
}

&-panel {
box-sizing: border-box;
padding: 0 1px;
overflow: auto;
scrollbar-width: thin;
}
}

@import './rtl';
3 changes: 3 additions & 0 deletions components/splitter/style/patch.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nz-splitter {
display: block;
}
Loading