first commit

This commit is contained in:
lingxiao865
2026-02-10 08:05:03 +08:00
commit c5af079d8c
1094 changed files with 97530 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
:: BASE_DOC ::
## API
### Collapse Props
name | type | default | description | required
-- | -- | -- | -- | --
custom-style | Object | - | CSS(Cascading Style Sheets) | N
default-expand-all | Boolean | false | \- | N
disabled | Boolean | - | \- | N
expand-icon | Boolean | true | \- | N
expand-mutex | Boolean | false | \- | N
theme | String | default | options: default/card | N
value | Array | - | `v-model:value` is supported。Typescript`CollapseValue` `type CollapseValue = Array<string \| number>`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/packages/uniapp-components/collapse/type.ts) | N
default-value | Array | - | uncontrolled property。Typescript`CollapseValue` `type CollapseValue = Array<string \| number>`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/packages/uniapp-components/collapse/type.ts) | N
### Collapse Events
name | params | description
-- | -- | --
change | `(context: { value: CollapseValue, context: { e: MouseEvent }})` | \-
### Collapse Slots
name | Description
-- | --
\- | \-
### CollapsePanel Props
name | type | default | description | required
-- | -- | -- | -- | --
custom-style | Object | - | CSS(Cascading Style Sheets) | N
content | String | - | \- | N
disabled | Boolean | undefined | \- | N
expand-icon | Boolean | undefined | \- | N
header | String | - | \- | N
header-left-icon | String | - | \- | N
header-right-content | String | - | \- | N
placement | String | bottom | options: bottom/top | N
value | String / Number | - | \- | N
### CollapsePanel Slots
name | Description
-- | --
\- | \-
content | \-
expand-icon | \-
header | \-
header-left-icon | \-
header-right-content | \-
### CollapsePanel External Classes
className | Description
-- | --
t-class | \-
t-class-content | \-
t-class-header | \-
### CSS Variables
The component provides the following CSS variables, which can be used to customize styles.
Name | Default Value | Description
-- | -- | --
--td-collapse-border-color | @border-level-1-color | -
--td-collapse-content-font | @font-body-medium | -
--td-collapse-content-padding | 32rpx | -
--td-collapse-content-text-color | @text-color-primary | -
--td-collapse-disabled-color | @text-color-disabled | -
--td-collapse-extra-font | @font-body-large | -
--td-collapse-header-height | auto | -
--td-collapse-header-text-color | @text-color-primary | -
--td-collapse-header-text-disabled-color | @collapse-disabled-color | -
--td-collapse-horizontal-padding | 32rpx | -
--td-collapse-icon-color | @text-color-placeholder | -
--td-collapse-left-icon-color | @brand-color | -
--td-collapse-panel-bg-color | @bg-color-container | -
--td-collapse-title-font | @font-body-large | -

View File

@@ -0,0 +1,119 @@
---
title: Collapse 折叠面板
description: 用于对复杂区域进行分组和隐藏 常用于订单信息展示等
spline: data
isComponent: true
---
## 引入
可在 `main.ts` 或在需要使用的页面或组件中引入。
```js
import TCollapse from '@tdesign/uniapp/collapse/collapse.vue';
import TCollapsePanel from '@tdesign/uniapp/collapse-panel/collapse-panel.vue';
```
### 类型
基础折叠面板
{{ base }}
带操作说明
{{ action }}
手风琴模式
{{ accordion }}
### 样式
卡片折叠面板
{{ theme }}
## API
### Collapse Props
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
custom-style | Object | - | 自定义样式 | N
default-expand-all | Boolean | false | 默认是否展开全部 | N
disabled | Boolean | - | 是否禁用面板展开/收起操作 | N
expand-icon | Boolean | true | 展开图标 | N
expand-mutex | Boolean | false | 每个面板互斥展开,每次只展开一个面板 | N
theme | String | default | 折叠面板风格。可选项default/card | N
value | Array | - | 展开的面板集合。支持语法糖 `v-model:value`。TS 类型:`CollapseValue` `type CollapseValue = Array<string \| number>`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/packages/uniapp-components/collapse/type.ts) | N
default-value | Array | - | 展开的面板集合。非受控属性。TS 类型:`CollapseValue` `type CollapseValue = Array<string \| number>`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/packages/uniapp-components/collapse/type.ts) | N
### Collapse Events
名称 | 参数 | 描述
-- | -- | --
change | `(context: { value: CollapseValue, context: { e: MouseEvent }})` | 切换面板时触发,返回变化的值
### Collapse Slots
名称 | 描述
-- | --
\- | 默认插槽,自定义内容区域内容
### CollapsePanel Props
名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
custom-style | Object | - | 自定义样式 | N
content | String | - | 折叠面板内容 | N
disabled | Boolean | undefined | 禁止当前面板展开,优先级大于 Collapse 的同名属性 | N
expand-icon | Boolean | undefined | 当前折叠面板展开图标,优先级大于 Collapse 的同名属性 | N
header | String | - | 面板头内容 | N
header-left-icon | String | - | 面板头左侧图标 | N
header-right-content | String | - | 面板头的右侧区域,一般用于呈现面板操作 | N
placement | String | bottom | 选项卡内容的位置。可选项bottom/top | N
value | String / Number | - | 当前面板唯一标识,如果值为空则取当前面下标兜底作为唯一标识 | N
### CollapsePanel Slots
名称 | 描述
-- | --
\- | 默认插槽,作用同 `content` 插槽
content | 自定义 `content` 显示内容
expand-icon | 自定义 `expand-icon` 显示内容
header | 自定义 `header` 显示内容
header-left-icon | 自定义 `header-left-icon` 显示内容
header-right-content | 自定义 `header-right-content` 显示内容
### CollapsePanel External Classes
类名 | 描述
-- | --
t-class | 根节点样式类
t-class-content | 内容样式类
t-class-header | 头部样式类
### CSS Variables
组件提供了下列 CSS 变量,可用于自定义样式。
名称 | 默认值 | 描述
-- | -- | --
--td-collapse-border-color | @border-level-1-color | -
--td-collapse-content-font | @font-body-medium | -
--td-collapse-content-padding | 32rpx | -
--td-collapse-content-text-color | @text-color-primary | -
--td-collapse-disabled-color | @text-color-disabled | -
--td-collapse-extra-font | @font-body-large | -
--td-collapse-header-height | auto | -
--td-collapse-header-text-color | @text-color-primary | -
--td-collapse-header-text-disabled-color | @collapse-disabled-color | -
--td-collapse-horizontal-padding | 32rpx | -
--td-collapse-icon-color | @text-color-placeholder | -
--td-collapse-left-icon-color | @brand-color | -
--td-collapse-panel-bg-color | @bg-color-container | -
--td-collapse-title-font | @font-body-large | -

View File

@@ -0,0 +1,5 @@
.t-collapse--card {
margin: 0 32rpx;
border-radius: var(--td-radius-large, 18rpx);
overflow: hidden;
}

View File

@@ -0,0 +1,119 @@
<template>
<view
:style="tools._style([customStyle])"
:class="[
tClass,
tools.cls(classPrefix, [['hairline--top-bottom', border], theme])
]"
>
<slot />
</view>
</template>
<script>
import { uniComponent } from '../common/src/index';
import { prefix } from '../common/config';
import { coalesce } from '../common/utils';
import props from './props';
import tools from '../common/utils.wxs';
import { ParentMixin, RELATION_MAP } from '../common/relation';
const name = `${prefix}-collapse`;
export default uniComponent({
name,
controlledProps: [
{
key: 'value',
event: 'change',
},
],
options: {
styleIsolation: 'shared',
},
externalClasses: [`${prefix}-class`],
mixins: [ParentMixin(RELATION_MAP.CollapsePanel)],
props: {
...props,
},
emits: [
'update:value',
],
data() {
return {
prefix,
classPrefix: name,
tools,
border: false,
dataValue: coalesce(this.value, this.defaultValue),
mounted: false,
};
},
watch: {
value: {
handler(value) {
this.dataValue = value;
},
immediate: true,
},
dataValue: {
handler() {
this.waitUntilMounted(this.updateExpanded);
},
immediate: true,
deep: true,
},
expandMutex: {
handler() {
this.waitUntilMounted(this.updateExpanded);
},
immediate: true,
},
},
mounted() {
let interval = 0;
// #ifdef APP-PLUS
interval = 33;
// #endif
setTimeout(() => {
this.mounted = true;
}, interval);
},
methods: {
waitUntilMounted(cb) {
if (this.mounted) {
cb.call(this);
return;
}
setTimeout(() => {
cb.call(this);
}, 33);
},
updateExpanded() {
this.children?.forEach((e) => {
e.updateExpanded(this.dataValue);
});
},
switch(panelValue) {
const { expandMutex, dataValue: activeValues } = this;
let value = [];
const hit = activeValues?.indexOf(panelValue);
if (hit > -1) {
value = activeValues.filter(item => item !== panelValue);
} else {
value = expandMutex ? [panelValue] : activeValues.concat(panelValue);
}
this._trigger('change', { value });
},
},
});
</script>
<style scoped>
@import './collapse.css';
</style>

View File

@@ -0,0 +1,42 @@
/* eslint-disable */
/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */
import type { TdCollapseProps } from './type';
export default {
/** 默认是否展开全部 */
defaultExpandAll: Boolean,
/** 是否禁用面板展开/收起操作 */
disabled: Boolean,
/** 展开图标 */
expandIcon: {
type: Boolean,
default: true,
},
/** 每个面板互斥展开,每次只展开一个面板 */
expandMutex: Boolean,
/** 折叠面板风格 */
theme: {
type: String,
default: 'default' as TdCollapseProps['theme'],
validator(val: TdCollapseProps['theme']): boolean {
if (!val) return true;
return ['default', 'card'].includes(val);
},
},
/** 展开的面板集合 */
value: {
type: Array,
},
/** 展开的面板集合,非受控属性 */
defaultValue: {
type: Array,
},
/** 切换面板时触发,返回变化的值 */
onChange: {
type: Function,
default: () => ({}),
},
};

View File

@@ -0,0 +1,46 @@
/* eslint-disable */
/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */
export interface TdCollapseProps {
/**
* 默认是否展开全部
* @default false
*/
defaultExpandAll?: boolean;
/**
* 是否禁用面板展开/收起操作
*/
disabled?: boolean;
/**
* 展开图标
* @default true
*/
expandIcon?: boolean;
/**
* 每个面板互斥展开,每次只展开一个面板
* @default false
*/
expandMutex?: boolean;
/**
* 折叠面板风格
* @default default
*/
theme?: 'default' | 'card';
/**
* 展开的面板集合
*/
value?: CollapseValue;
/**
* 展开的面板集合,非受控属性
*/
defaultValue?: CollapseValue;
/**
* 切换面板时触发,返回变化的值
*/
onChange?: (context: { value: CollapseValue; context: { e: MouseEvent } }) => void;
}
export type CollapseValue = Array<string | number>;