New Huajishe Check ChaoXing

This commit is contained in:
e2hang
2025-10-01 10:01:52 +08:00
parent 240b884eac
commit 80be8ae3cf
1094 changed files with 61709 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
:: BASE_DOC ::
## API
### TabBar Props
name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets)used to set style on virtual component | N
bordered | Boolean | true | \- | N
fixed | Boolean | true | \- | N
safe-area-inset-bottom | Boolean | true | \- | N
shape | String | normal | options: normal/round | N
split | Boolean | true | \- | N
theme | String | normal | options: normal/tag | N
value | String / Number / Array | - | Typescript`string \| number \| Array<string \| number>` | N
default-value | String / Number / Array | undefined | uncontrolled property。Typescript`string \| number \| Array<string \| number>` | N
### TabBar Events
name | params | description
-- | -- | --
change | `(value: string \| number)` | \-
### TabBar External Classes
className | Description
-- | --
t-class | \-
### TabBarItem Props
name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets)used to set style on virtual component | N
badge-props | Object | - | Typescript`BadgeProps`[Badge API Documents](./badge?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/tab-bar-item/type.ts) | N
icon | String / Object / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
sub-tab-bar | Array | - | Typescript`SubTabBarItem[] ` `interface SubTabBarItem { value: string; label: string }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/tab-bar-item/type.ts) | N
value | String / Number | - | \- | N
### CSS Variables
The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
--td-tab-bar-active-bg | @brand-color-light | -
--td-tab-bar-active-color | @brand-color | -
--td-tab-bar-bg-color | @bg-color-container | -
--td-tab-bar-border-color | @border-color | -
--td-tab-bar-color | @font-gray-1 | -
--td-tab-bar-height | 80rpx | -
--td-tab-bar-hover-bg-color | rgba(0, 0, 0, 0.05) | -
--td-tab-bar-spread-border-color | @border-color | -
--td-tab-bar-spread-shadow | @shadow-3 | -
--td-tab-bar-border-color | @border-color | -
--td-tab-bar-round-shadow | @shadow-3 | -

View File

@@ -0,0 +1,115 @@
---
title: TabBar 标签栏
description: 用于在不同功能模块之间进行快速切换,位于页面底部。
spline: navigation
isComponent: true
---
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-93%25-blue" /></span>
## 引入
全局引入,在 miniprogram 根目录下的`app.json`中配置,局部引入,在需要引入的页面或组件的`index.json`中配置。
```json
"usingComponents": {
"t-tab-bar": "tdesign-miniprogram/tab-bar/tab-bar",
"t-tab-bar-item": "tdesign-miniprogram/tab-bar-item/tab-bar-item"
}
```
## 代码演示
<a href="https://developers.weixin.qq.com/s/H0G5SdmU7HSh" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后依次执行npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
</blockquote>
### 组件类型
#### 纯文本标签栏
{{ text-only }}
#### 图标加文字标签栏
{{ base }}
#### 纯图标标签栏
{{ icon-only }}
#### 双层级纯文本标签栏
{{ sub }}
### 组件样式
#### 弱选中标签栏
{{ badge }}
#### 悬浮胶囊标签栏
{{ round }}
#### 自定义主题
{{ custom }}
## API
### TabBar Props
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
bordered | Boolean | true | 是否显示外边框 | N
fixed | Boolean | true | 是否固定在底部 | N
safe-area-inset-bottom | Boolean | true | 是否为 iPhoneX 留出底部安全距离 | N
shape | String | normal | 标签栏的形状。可选项normal/round | N
split | Boolean | true | 是否需要分割线 | N
theme | String | normal | 选项风格。可选项normal/tag | N
value | String / Number / Array | - | 当前选中标签的索引。TS 类型:`string \| number \| Array<string \| number>` | N
default-value | String / Number / Array | undefined | 当前选中标签的索引。非受控属性。TS 类型:`string \| number \| Array<string \| number>` | N
### TabBar Events
名称 | 参数 | 描述
-- | -- | --
change | `(value: string \| number)` | 选中标签切换时触发
### TabBar External Classes
类名 | 描述
-- | --
t-class | 根节点样式类
### TabBarItem Props
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
badge-props | Object | - | 图标右上角提示信息。TS 类型:`BadgeProps`[Badge API Documents](./badge?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/tab-bar-item/type.ts) | N
icon | String / Object / Slot | - | 图标名称。传入对象时透传至 Icon 组件。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
sub-tab-bar | Array | - | 二级菜单。TS 类型:`SubTabBarItem[] ` `interface SubTabBarItem { value: string; label: string }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/tab-bar-item/type.ts) | N
value | String / Number | - | 标识符 | N
### CSS Variables
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-tab-bar-active-bg | @brand-color-light | -
--td-tab-bar-active-color | @brand-color | -
--td-tab-bar-bg-color | @bg-color-container | -
--td-tab-bar-border-color | @border-color | -
--td-tab-bar-color | @font-gray-1 | -
--td-tab-bar-height | 80rpx | -
--td-tab-bar-hover-bg-color | rgba(0, 0, 0, 0.05) | -
--td-tab-bar-spread-border-color | @border-color | -
--td-tab-bar-spread-shadow | @shadow-3 | -
--td-tab-bar-border-color | @border-color | -
--td-tab-bar-round-shadow | @shadow-3 | -

View File

@@ -0,0 +1,3 @@
import { TdTabBarProps } from './type';
declare const props: TdTabBarProps;
export default props;

View File

@@ -0,0 +1,37 @@
const props = {
bordered: {
type: Boolean,
value: true,
},
externalClasses: {
type: Array,
},
fixed: {
type: Boolean,
value: true,
},
safeAreaInsetBottom: {
type: Boolean,
value: true,
},
shape: {
type: String,
value: 'normal',
},
split: {
type: Boolean,
value: true,
},
theme: {
type: String,
value: 'normal',
},
value: {
type: null,
value: null,
},
defaultValue: {
type: null,
},
};
export default props;

View File

@@ -0,0 +1,28 @@
import { SuperComponent, RelationsOptions } from '../common/src/index';
export default class Tabbar extends SuperComponent {
relations: RelationsOptions;
externalClasses: string[];
backupValue: number;
data: {
prefix: string;
classPrefix: string;
};
properties: import("./type").TdTabBarProps;
controlledProps: {
key: string;
event: string;
}[];
observers: {
value(): void;
};
lifetimes: {
ready(): void;
};
methods: {
showChildren(): void;
updateChildren(): void;
updateValue(value: any): void;
changeOtherSpread(value: any): void;
initName(): any;
};
}

View File

@@ -0,0 +1,78 @@
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 classPrefix = `${prefix}-tab-bar`;
let Tabbar = class Tabbar extends SuperComponent {
constructor() {
super(...arguments);
this.relations = {
'../tab-bar-item/tab-bar-item': {
type: 'descendant',
},
};
this.externalClasses = [`${prefix}-class`];
this.backupValue = -1;
this.data = {
prefix,
classPrefix,
};
this.properties = props;
this.controlledProps = [
{
key: 'value',
event: 'change',
},
];
this.observers = {
value() {
this.updateChildren();
},
};
this.lifetimes = {
ready() {
this.showChildren();
},
};
this.methods = {
showChildren() {
const { value } = this.data;
this.$children.forEach((child) => {
child.setData({ crowded: this.$children.length > 3 });
if (child.properties.value === value) {
child.showSpread();
}
});
},
updateChildren() {
const { value } = this.data;
this.$children.forEach((child) => {
child.checkActive(value);
});
},
updateValue(value) {
this._trigger('change', { value });
},
changeOtherSpread(value) {
this.$children.forEach((child) => {
if (child.properties.value !== value) {
child.closeSpread();
}
});
},
initName() {
return (this.backupValue += 1);
},
};
}
};
Tabbar = __decorate([
wxComponent()
], Tabbar);
export default Tabbar;

View File

@@ -0,0 +1,5 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {}
}

View File

@@ -0,0 +1,9 @@
<wxs src="../common/utils.wxs" module="_" />
<view
style="{{_._style([style, customStyle])}}"
class="{{_.cls(classPrefix, [['border', bordered], ['fixed', fixed], ['safe', safeAreaInsetBottom], shape])}} class {{prefix}}-class"
aria-role="tablist"
>
<slot />
</view>

View File

@@ -0,0 +1,69 @@
.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);
}
.t-tab-bar {
display: flex;
flex-wrap: nowrap;
align-items: center;
position: relative;
font-size: 16px;
background-color: var(--td-tab-bar-bg-color, var(--td-bg-color-container, var(--td-font-white-1, #ffffff)));
box-sizing: border-box;
}
.t-tab-bar--normal.t-tab-bar--border::before {
z-index: 1;
position: absolute;
box-sizing: border-box;
content: ' ';
pointer-events: none;
right: 0;
left: 0;
top: 0;
border-top: 1px solid var(--td-tab-bar-border-color, var(--td-border-level-1-color, var(--td-gray-color-3, #e7e7e7)));
transform: scaleY(0.5);
transform-origin: 0 0;
}
.t-tab-bar--fixed {
position: fixed;
left: 0;
bottom: 0;
right: 0;
}
.t-tab-bar--normal.t-tab-bar--safe {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
.t-tab-bar--round {
margin-left: 32rpx;
margin-right: 32rpx;
border-radius: 999px;
box-shadow: var(--td-tab-bar-round-shadow, var(--td-shadow-3, 0 6px 30px 5px rgba(0, 0, 0, 0.05), 0 16px 24px 2px rgba(0, 0, 0, 0.04), 0 8px 10px -5px rgba(0, 0, 0, 0.08)));
}
.t-tab-bar--fixed.t-tab-bar--round.t-tab-bar--safe {
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
}

View File

@@ -0,0 +1,38 @@
export interface TdTabBarProps {
bordered?: {
type: BooleanConstructor;
value?: boolean;
};
externalClasses?: {
type: ArrayConstructor;
value?: ['t-class'];
};
fixed?: {
type: BooleanConstructor;
value?: boolean;
};
safeAreaInsetBottom?: {
type: BooleanConstructor;
value?: boolean;
};
shape?: {
type: StringConstructor;
value?: 'normal' | 'round';
};
split?: {
type: BooleanConstructor;
value?: boolean;
};
theme?: {
type: StringConstructor;
value?: 'normal' | 'tag';
};
value?: {
type: null;
value?: string | number | Array<string | number>;
};
defaultValue?: {
type: null;
value?: string | number | Array<string | number>;
};
}

View File

@@ -0,0 +1 @@
export {};