This commit is contained in:
haomingming
2023-03-06 17:57:39 +08:00
parent 3794faceae
commit 1066e37c96
4230 changed files with 193453 additions and 0 deletions
@@ -0,0 +1,34 @@
:: BASE_DOC ::
## API
### Steps Props
name | type | default | description | required
-- | -- | -- | -- | --
current | String / Number | - | \- | N
default-current | String / Number | undefined | uncontrolled property | N
current-status | String | process | optionsdefault/process/finish/error | N
external-classes | Array | - | `['t-class']` | N
layout | String | horizontal | optionshorizontal/vertical | N
readonly | Boolean | false | \- | N
separator | String | line | optionsline/dashed/arrow | N
style | String | - | \- | N
theme | String | default | optionsdefault/dot | N
### Steps Events
name | params | description
-- | -- | --
change | `({current: string \| number, previous: string \| number})` | \-
### StepItem Props
name | type | default | description | required
-- | -- | -- | -- | --
content | String / Slot | '' | \- | N
external-classes | Array | - | `['t-class', 't-class-content', 't-class-title', 't-class-description', 't-class-extra']` | N
icon | String / Slot | - | \- | N
status | String | default | optionsdefault/process/finish/error。Typescript`StepStatus` `type StepStatus = 'default' \| 'process' \| 'finish' \| 'error'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/step-item/type.ts) | N
style | String | - | \- | N
sub-step-items | Array | [] | Typescript`SubStepItem[]` `interface SubStepItem { status: StepStatus, title: string }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/step-item/type.ts) | N
title | String / Slot | '' | \- | N
+88
View File
@@ -0,0 +1,88 @@
---
title: Steps 步骤条
description: 用于任务步骤展示或任务进度展示。
spline: navigation
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-98%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-88%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-96%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-82%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-steps": "tdesign-miniprogram/steps/steps",
"t-step-item": "tdesign-miniprogram/step-item/step-item",
}
```
## 代码演示
步骤条,方向可以横向和纵向,可以自定义步骤条显示内容以及是否可写
### 组件类型
#### 水平步骤条
支持三种类型:序号、图标、简略
{{ horizontal }}
#### 垂直步骤条
支持三种类型:序号、图标、简略
{{ vertical }}
### 组件状态
#### 选项卡状态
共支持 4 种状态:未完成(default)、已完成(finish)、进行中(process)、错误(error
{{ status }}
### 特殊类型
通过已有特性,改造出两种常见类型:
- 垂直自定义(在 Cascader 中使用)
- 纯展示步骤条
可以参考以下代码实现
{{ special }}
## API
### Steps Props
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
current | String / Number | - | 当前步骤,即整个步骤条进度。默认根据步骤下标判断步骤的完成状态,当前步骤为进行中,当前步骤之前的步骤为已完成,当前步骤之后的步骤为未开始。如果每个步骤没有设置 value,current 值为步骤长度则表示所有步骤已完成。如果每个步骤设置了自定义 value,则 current = 'FINISH' 表示所有状态完成 | N
default-current | String / Number | undefined | 当前步骤,即整个步骤条进度。默认根据步骤下标判断步骤的完成状态,当前步骤为进行中,当前步骤之前的步骤为已完成,当前步骤之后的步骤为未开始。如果每个步骤没有设置 value,current 值为步骤长度则表示所有步骤已完成。如果每个步骤设置了自定义 value,则 current = 'FINISH' 表示所有状态完成。非受控属性 | N
current-status | String | process | 用于控制 current 指向的步骤条的状态。可选项:default/process/finish/error | N
external-classes | Array | - | 组件类名,用于设置组件外层元素元素类名。`['t-class']` | N
layout | String | horizontal | 步骤条方向,有两种:横向和纵向。可选项:horizontal/vertical | N
readonly | Boolean | false | 只读状态 | N
separator | String | line | 步骤条分割符。可选项:line/dashed/arrow | N
style | String | - | 自定义组件样式 | N
theme | String | default | 步骤条风格。可选项:default/dot | N
### Steps Events
名称 | 参数 | 描述
-- | -- | --
change | `({current: string \| number, previous: string \| number})` | 当前步骤发生变化时触发
### StepItem Props
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
content | String / Slot | '' | 步骤描述 | N
external-classes | Array | - | 组件类名,用于设置组件外层元素元素类名。`['t-class', 't-class-content', 't-class-title', 't-class-description', 't-class-extra']` | N
icon | String / Slot | - | 图标。传入 slot 代表使用插槽,其他字符串代表使用内置图标 | N
status | String | default | 当前步骤的状态:默认状态(未开始)、进行中状态、完成状态、错误状态。可选项:default/process/finish/error。TS 类型:`StepStatus` `type StepStatus = 'default' \| 'process' \| 'finish' \| 'error'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/step-item/type.ts) | N
style | String | - | 自定义组件样式 | N
sub-step-items | Array | [] | 子步骤条,仅支持 layout = 'vertical' 时。TS 类型:`SubStepItem[]` `interface SubStepItem { status: StepStatus, title: string }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/step-item/type.ts) | N
title | String / Slot | '' | 标题 | N
+3
View File
@@ -0,0 +1,3 @@
import { TdStepsProps } from './type';
declare const props: TdStepsProps;
export default props;
+37
View File
@@ -0,0 +1,37 @@
const props = {
current: {
type: null,
value: null,
},
defaultCurrent: {
type: null,
},
currentStatus: {
type: String,
value: 'process',
},
externalClasses: {
type: Array,
},
layout: {
type: String,
value: 'horizontal',
},
readonly: {
type: Boolean,
value: false,
},
separator: {
type: String,
value: 'line',
},
style: {
type: String,
value: '',
},
theme: {
type: String,
value: 'default',
},
};
export default props;
+22
View File
@@ -0,0 +1,22 @@
import { SuperComponent, RelationsOptions } from '../common/src/index';
export default class Steps extends SuperComponent {
relations: RelationsOptions;
externalClasses: string[];
properties: import("./type").TdStepsProps;
controlledProps: {
key: string;
event: string;
}[];
data: {
prefix: string;
classPrefix: string;
};
observers: {
current(): void;
};
methods: {
updateChildren(): void;
updateLastChid(): void;
handleClick(index: any): void;
};
}
+74
View File
@@ -0,0 +1,74 @@
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { wxComponent, SuperComponent } from '../common/src/index';
import config from '../common/config';
import props from './props';
const { prefix } = config;
const name = `${prefix}-steps`;
let Steps = class Steps extends SuperComponent {
constructor() {
super(...arguments);
this.relations = {
'../step-item/step-item': {
type: 'child',
linked(child) {
this.updateChildren();
const { readonly } = this.data;
child.setData({
readonly,
});
},
unlinked() {
this.updateLastChid();
},
},
};
this.externalClasses = [`${prefix}-class`];
this.properties = props;
this.controlledProps = [
{
key: 'current',
event: 'change',
},
];
this.data = {
prefix,
classPrefix: name,
};
this.observers = {
current() {
this.updateChildren();
},
};
this.methods = {
updateChildren() {
const { current, currentStatus, readonly, theme, layout } = this.data;
const items = this.$children;
items.forEach((item, index) => {
item.updateStatus(current, currentStatus, index, theme, layout, items, readonly);
});
},
updateLastChid() {
const items = this.$children;
items.forEach((child, index) => child.setData({ isLastChild: index === items.length - 1 }));
},
handleClick(index) {
if (!this.data.readonly) {
const preIndex = this.data.current;
this._trigger('change', {
previous: preIndex,
current: index,
});
}
},
};
}
};
Steps = __decorate([
wxComponent()
], Steps);
export default Steps;
+6
View File
@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"t-step": "../step-item/step-item"
}
}
+5
View File
@@ -0,0 +1,5 @@
<wxs src="../common/utils.wxs" module="_" />
<view style="{{customStyle}}" class="{{_.cls(classPrefix, [layout, ['readonly', readonly]])}} {{prefix}}-class">
<slot />
</view>
+40
View File
@@ -0,0 +1,40 @@
.t-float-left {
float: left;
}
.t-float-right {
float: right;
}
@keyframes tdesign-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
.hotspot-expanded.relative {
position: relative;
}
.hotspot-expanded::after {
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
transform: scale(1.5);
}
:host {
display: flex;
}
.t-step--vertical {
padding-right: 32rpx;
}
.t-steps {
display: flex;
width: 100%;
}
.t-steps--vertical {
flex-direction: column;
}
+38
View File
@@ -0,0 +1,38 @@
export interface TdStepsProps {
current?: {
type: null;
value?: string | number;
};
defaultCurrent?: {
type: null;
value?: string | number;
};
currentStatus?: {
type: StringConstructor;
value?: 'default' | 'process' | 'finish' | 'error';
};
externalClasses?: {
type: ArrayConstructor;
value?: ['t-class'];
};
layout?: {
type: StringConstructor;
value?: 'horizontal' | 'vertical';
};
readonly?: {
type: BooleanConstructor;
value?: boolean;
};
separator?: {
type: StringConstructor;
value?: 'line' | 'dashed' | 'arrow';
};
style?: {
type: StringConstructor;
value?: string;
};
theme?: {
type: StringConstructor;
value?: 'default' | 'dot';
};
}
+1
View File
@@ -0,0 +1 @@
export {};