diff --git a/.github/workflows/pr-compressed-size.yml b/.github/workflows/pr-compressed-size.yml index 544b313886..0f6492de72 100644 --- a/.github/workflows/pr-compressed-size.yml +++ b/.github/workflows/pr-compressed-size.yml @@ -7,11 +7,12 @@ on: jobs: compressed-size: runs-on: ubuntu-latest + if: startsWith(github.head_ref, 'release/') steps: - uses: actions/checkout@v3 with: submodules: recursive - uses: 94dreamer/compressed-size-action@master with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - pattern: "./dist/**/*.{js,css}" \ No newline at end of file + repo-token: '${{ secrets.GITHUB_TOKEN }}' + pattern: './dist/**/*.{js,css}' diff --git a/.github/workflows/tag-push.yml b/.github/workflows/tag-push.yml index 218f37021a..c6bca87165 100644 --- a/.github/workflows/tag-push.yml +++ b/.github/workflows/tag-push.yml @@ -10,4 +10,5 @@ jobs: uses: Tencent/tdesign/.github/workflows/publish.yml@main secrets: TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }} - TDESIGN_NPM_TOKEN: ${{ secrets.TDESIGN_NPM_TOKEN }} \ No newline at end of file + TDESIGN_NPM_TOKEN: ${{ secrets.TDESIGN_NPM_TOKEN }} + PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 139ef7387d..3e7a743621 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,30 @@ toc: false docClass: timeline --- +## 🌈 0.41.5 `2022-05-20` +### 🚀 Features +- `Form`: 支持 `help` 配置的表单项说明内容与错误提示同时展示,未配置 `help` 时不再默认占位 @HQ-Lin ([#884](https://github.com/Tencent/tdesign-vue/pull/884)) +- `Table`: @chaishi (https://github.com/Tencent/tdesign-vue/pull/879)) + - 树形结构,支持默认展开全部,`tree.defaultExpandAll`,[issue#852](https://github.com/Tencent/tdesign-vue/issues/852) + - 树形结构,支持自由控制展开全部,或收起全部 `expandAll()` `foldAll()` + - 树形结构,支持拖拽排序,调整同层级顺序 + - 树形结构,支持在当前节点之前插入新节点 `insertBefore` + - 树形结构,支持在当后节点之后插入新节点 `insertAfter` +- `Tree`: label 支持多行文本展示,[issue# common 444](https://github.com/Tencent/tdesign-common/issues/444) @ccccpj ([#460](https://github.com/Tencent/tdesign-common/pull/460)) +### 🐞 Bug Fixes +- `Table`: 列拖动优化;修复选中行后列拖动距离被重置问题 @LoopZhou ([#870](https://github.com/Tencent/tdesign-vue/pull/870)) +- `Table`: 修复 多级表头 + 列配置 综合示例中,列数量超出一定限制时报错,[issue#713](https://github.com/Tencent/tdesign-vue-next/issues/713) @chaishi ([#875](https://github.com/Tencent/tdesign-vue/pull/875)) +- `Transfer`: 修复列表数量变化时的页码展示问题 @BigLiao ([#893](https://github.com/Tencent/tdesign-vue/pull/893)) +- `Input`: 修复 `clear` 触发后的 `focus`, 修复外部传入`onMouseenter`, `onMouseleave`, `onwheel` 事件导致组件内对应`方法`未执行的问题 @pengYYYYY ([#894](https://github.com/Tencent/tdesign-vue/pull/894)) +- `TreeSelect`: 修复未支持 treeProps.keys.children 字段配置的问题 @LoopZhou ([#890](https://github.com/Tencent/tdesign-vue/pull/890)) +- `Menu`: 修复 `expandType=popup` 时箭头方向展示错误的问题,@fengxianqi ([#806](https://github.com/Tencent/tdesign-vue/pull/806)) +- `Menu`: 修复 width 不支持数组类型的问题,@LeeJim ([#897](https://github.com/Tencent/tdesign-vue/pull/897)) + ## 🌈 0.41.3 `2022-05-13` ### 🚀 Features - `Icon`: 更新图标 新增`file-icon`图标 调整`file-excel`、`file-pdf`、`file-powerpoint`、`file-unknown`、`file-word`和`star-filled`图标的绘制路径 @uyarn ([#854](https://github.com/Tencent/tdesign-vue/pull/854)) - `Dialog`: 支持`preventScrollThrough` API @uyarn ([#861](https://github.com/Tencent/tdesign-vue/pull/861)) -- `Tabl -树形结构图标 `treeExpandAndFoldIcon`,同时支持全局配置此图标,[issue#717](https://github.com/Tencent/tdesign-vue-next/issues/717) @chaishi ([#863](https://github.com/Tencent/tdesign-vue/pull/863)) +- `Table`: 支持自定义树形结构图标 `treeExpandAndFoldIcon`,同时支持全局配置此图标,[issue#717](https://github.com/Tencent/tdesign-vue-next/issues/717) @chaishi ([#863](https://github.com/Tencent/tdesign-vue/pull/863)) - `Table`: 支持隐藏排序文本提示 `hideSortTips`,同时支持全局配置是否隐藏排序文本提示,[issue#736](https://github.com/Tencent/tdesign-vue-next/issues/736) @chaishi ([#863](https://github.com/Tencent/tdesign-vue/pull/863)) - `Steps`: 新增 `separator` 属性,用于控制步骤条分隔符类型 @HQ-Lin ([#863](https://github.com/Tencent/tdesign-vue/pull/868)) ### 🐞 Bug Fixes diff --git a/examples/affix/affix.en-US.md b/examples/affix/affix.en-US.md new file mode 100644 index 0000000000..bbb1e9247c --- /dev/null +++ b/examples/affix/affix.en-US.md @@ -0,0 +1,19 @@ +:: BASE_DOC :: + +## API + +### Affix Props + +name | type | default | description | required +-- | -- | -- | -- | -- +container | String / Function | () => (() => window) | Typescript:`ScrollContainer` | N +offsetBottom | Number | 0 | \- | N +offsetTop | Number | 0 | \- | N +zIndex | Number | - | \- | N +onFixedChange | Function | | TS 类型:`(affixed: boolean, context: { top: number }) => void`
| N + +### Affix Events + +name | params | description +-- | -- | -- +fixed-change | `(affixed: boolean, context: { top: number })` | \- diff --git a/examples/alert/alert.en-US.md b/examples/alert/alert.en-US.md new file mode 100644 index 0000000000..c7ab0bf6cc --- /dev/null +++ b/examples/alert/alert.en-US.md @@ -0,0 +1,25 @@ +:: BASE_DOC :: + +## API + +### Alert Props + +name | type | default | description | required +-- | -- | -- | -- | -- +close | String / Boolean / Slot / Function | false | Typescript:`string | boolean | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +default | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +icon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +maxLine | Number | 0 | \- | N +message | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +operation | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +theme | String | info | options:success/info/warning/error | N +title | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +onClose | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
| N +onClosed | Function | | TS 类型:`(context: { e: TransitionEvent }) => void`
| N + +### Alert Events + +name | params | description +-- | -- | -- +close | `(context: { e: MouseEvent })` | \- +closed | `(context: { e: TransitionEvent })` | \- diff --git a/examples/anchor/anchor.en-US.md b/examples/anchor/anchor.en-US.md new file mode 100644 index 0000000000..127c468d8a --- /dev/null +++ b/examples/anchor/anchor.en-US.md @@ -0,0 +1,38 @@ +:: BASE_DOC :: + +## API + +### Anchor Props + +name | type | default | description | required +-- | -- | -- | -- | -- +affixProps | Object | - | Typescript:`AffixProps`,[Affix API Documents](./affix?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/anchor/type.ts) | N +bounds | Number | 5 | \- | N +container | String / Function | () => (() => window) | Typescript:`ScrollContainer` | N +cursor | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +size | String | medium | options:small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +targetOffset | Number | 0 | \- | N +onChange | Function | | TS 类型:`(currentLink: string, prevLink: string) => void`
| N +onClick | Function | | TS 类型:`(link: { href: string; title: string; e: MouseEvent }) => void`
| N + +### Anchor Events + +name | params | description +-- | -- | -- +change | `(currentLink: string, prevLink: string)` | \- +click | `(link: { href: string; title: string; e: MouseEvent })` | \- + +### AnchorItem Props + +name | type | default | description | required +-- | -- | -- | -- | -- +href | String | - | required | Y +target | String | _self | options:_self/_blank/_parent/_top | N +title | String / Slot / Function | '' | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### AnchorTarget Props + +name | type | default | description | required +-- | -- | -- | -- | -- +id | String | - | required | Y +tag | String | div | \- | N diff --git a/examples/anchor/demos/container.vue b/examples/anchor/demos/container.vue index e6421beaa8..a48842d7c3 100644 --- a/examples/anchor/demos/container.vue +++ b/examples/anchor/demos/container.vue @@ -1,6 +1,6 @@ - diff --git a/examples/avatar/avatar.en-US.md b/examples/avatar/avatar.en-US.md new file mode 100644 index 0000000000..f0f2c27702 --- /dev/null +++ b/examples/avatar/avatar.en-US.md @@ -0,0 +1,32 @@ +:: BASE_DOC :: + +## API + +### Avatar Props + +name | type | default | description | required +-- | -- | -- | -- | -- +alt | String | - | show it when url is not valid | N +hideOnLoadFailed | Boolean | false | hide image when loading image failed | N +icon | Slot / Function | - | use icon to fill。Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +image | String | - | images url | N +shape | String | circle | shape。options:circle/round。Typescript:`ShapeEnum ` `type ShapeEnum = 'circle' | 'round'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/avatar/type.ts) | N +size | String | - | size | N +onError | Function | | TS 类型:`() => void`
trigger on image load failed | N + +### Avatar Events + +name | params | description +-- | -- | -- +error | \- | trigger on image load failed + +### AvatarGroup Props + +name | type | default | description | required +-- | -- | -- | -- | -- +cascading | String | 'right-up' | multiple images cascading。options:left-up/right-up。Typescript:`CascadingValue` `type CascadingValue = 'left-up' | 'right-up'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/avatar/type.ts) | N +collapseAvatar | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +max | Number | - | \- | N +placement | String | - | popup placement。options:left/top/bottom/right。Typescript:`MaxOverPlacement` `type MaxOverPlacement = 'left' | 'top' | 'bottom' | 'right'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/avatar/type.ts) | N +popupProps | Object | - | Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/avatar/type.ts) | N +size | String | medium | size | N diff --git a/examples/badge/badge.en-US.md b/examples/badge/badge.en-US.md new file mode 100644 index 0000000000..d5c0368fb2 --- /dev/null +++ b/examples/badge/badge.en-US.md @@ -0,0 +1,18 @@ +:: BASE_DOC :: + +## API + +### Badge Props + +name | type | default | description | required +-- | -- | -- | -- | -- +color | String | - | \- | N +content | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +count | String / Number / Slot / Function | 0 | Typescript:`string | number | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +default | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +dot | Boolean | false | \- | N +maxCount | Number | 99 | \- | N +offset | Array | - | Typescript:`Array` | N +shape | String | circle | options:circle/round | N +showZero | Boolean | false | \- | N +size | String | medium | options:small/medium | N diff --git a/examples/breadcrumb/breadcrumb.en-US.md b/examples/breadcrumb/breadcrumb.en-US.md new file mode 100644 index 0000000000..7369ff0704 --- /dev/null +++ b/examples/breadcrumb/breadcrumb.en-US.md @@ -0,0 +1,26 @@ +:: BASE_DOC :: + +## API + +### Breadcrumb Props + +name | type | default | description | required +-- | -- | -- | -- | -- +maxItemWidth | String | undefined | \- | N +options | Array | - | Typescript:`Array` | N +separator | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +theme | String | light | options:light | N + +### BreadcrumbItem Props + +name | type | default | description | required +-- | -- | -- | -- | -- +content | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +default | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +disabled | Boolean | - | \- | N +href | String | - | \- | N +maxWidth | String | undefined | \- | N +replace | Boolean | false | \- | N +router | Object | - | Typescript:`any` | N +target | String | _self | options:_blank/_self/_parent/_top | N +to | String / Object | - | Typescript:`Route` `interface Route { path?: string; name?: string; hash?: string; query?: RouteData; params?: RouteData }` `type RouteData = { [key: string]: string | string[] }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/breadcrumb/type.ts) | N diff --git a/examples/button/button_en.md b/examples/button/button.en-US.md similarity index 87% rename from examples/button/button_en.md rename to examples/button/button.en-US.md index 7476ddfb87..e956181cf3 100644 --- a/examples/button/button_en.md +++ b/examples/button/button.en-US.md @@ -14,13 +14,13 @@ icon | Slot / Function | - | use it to set left icon in button。Typescript:`T loading | Boolean | false | set button to be loading state | N shape | String | rectangle | button shape。options:rectangle/square/round/circle | N size | String | medium | a button has three size。options:small/medium/large。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N -theme | String | undefined | button theme。options:default/primary/danger/warning/success | N +theme | String | - | button theme。options:default/primary/danger/warning/success | N type | String | button | type of button element in html。options:submit/reset/button | N variant | String | base | variant of button。options:base/outline/dashed/text | N -onClick | Function | | `(e: MouseEvent) => {}` | N +onClick | Function | | TS 类型:`(e: MouseEvent) => void`
| N ### Button Events name | params | description -- | -- | -- -click | `(e: MouseEvent)` | - +click | `(e: MouseEvent)` | \- diff --git a/examples/calendar/calendar.en-US.md b/examples/calendar/calendar.en-US.md new file mode 100644 index 0000000000..4c8aa1c755 --- /dev/null +++ b/examples/calendar/calendar.en-US.md @@ -0,0 +1,62 @@ +:: BASE_DOC :: + +## API + +### Calendar Props + +name | type | default | description | required +-- | -- | -- | -- | -- +cell | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +cellAppend | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +controllerConfig | Boolean / Object | - | Typescript:`boolean | CalendarController` | N +fillWithZero | Boolean | - | \- | N +firstDayOfWeek | Number | - | options:1/2/3/4/5/6/7 | N +format | String | 'YYYY-MM-DD' | \- | N +head | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +isShowWeekendDefault | Boolean | true | \- | N +mode | String | month | options:month/year | N +month | String / Number | - | \- | N +preventCellContextmenu | Boolean | false | \- | N +range | Array | - | Typescript:`Array` | N +theme | String | full | options:full/card | N +value | String / Date | - | Typescript:`CalendarValue` `type CalendarValue = string | Date`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/calendar/type.ts) | N +week | Array / Slot / Function | - | Typescript:`Array | TNode` `interface CalendarWeek { day: WeekDay }` `type WeekDay = 1 | 2 | 3 | 4 | 5 | 6 | 7`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/calendar/type.ts) | N +year | String / Number | - | \- | N +onCellClick | Function | | TS 类型:`(options: { cell: CalendarCell; e: MouseEvent }) => void`
| N +onCellDoubleClick | Function | | TS 类型:`(options: { cell: CalendarCell; e: MouseEvent }) => void`
| N +onCellRightClick | Function | | TS 类型:`(options: { cell: CalendarCell; e: MouseEvent }) => void`
| N +onControllerChange | Function | | TS 类型:`(options: ControllerOptions) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/calendar/type.ts)。
`interface ControllerOptions { filterDate: Date; formattedFilterDate: string; mode: string; isShowWeekend: boolean }`
| N +onMonthChange | Function | | TS 类型:`(options: { month: string; year: string }) => void`
| N + +### Calendar Events + +name | params | description +-- | -- | -- +cell-click | `(options: { cell: CalendarCell; e: MouseEvent })` | \- +cell-double-click | `(options: { cell: CalendarCell; e: MouseEvent })` | \- +cell-right-click | `(options: { cell: CalendarCell; e: MouseEvent })` | \- +controller-change | `(options: ControllerOptions)` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/calendar/type.ts)。
`interface ControllerOptions { filterDate: Date; formattedFilterDate: string; mode: string; isShowWeekend: boolean }`
+month-change | `(options: { month: string; year: string })` | \- + +### CalendarController + +name | type | default | description | required +-- | -- | -- | -- | -- +current | Object | - | Typescript:`{ visible?: boolean; currentDayButtonProps?: ButtonProps; currentMonthButtonProps?: ButtonProps }` | N +disabled | Boolean | false | \- | N +mode | Object | - | Typescript:`{ visible?: boolean; radioGroupProps?: RadioGroupProps }`,[Radio API Documents](./radio?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/calendar/type.ts) | N +month | Object | - | Typescript:`{ visible?: boolean; selectProps?: SelectProps }` | N +weekend | Object | - | Typescript:`{ visible?: boolean; showWeekendButtonProps?: CheckTagProps; hideWeekendButtonProps?: CheckTagProps }`,[Tag API Documents](./tag?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/calendar/type.ts) | N +year | Object | - | Typescript:`{ visible?: boolean; selectProps?: SelectProps }`,[Select API Documents](./select?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/calendar/type.ts) | N + +### CalendarCell + +name | type | default | description | required +-- | -- | -- | -- | -- +belongTo | Number | - | \- | N +date | Object | - | Typescript:`Date` | N +day | Number | - | \- | N +formattedDate | String | - | \- | N +isCurrent | Boolean | - | \- | N +weekOrder | Number | - | \- | N +`ControllerOptions` | \- | - | \- | N diff --git a/examples/card/card.en-US.md b/examples/card/card.en-US.md new file mode 100644 index 0000000000..5d6c93dd26 --- /dev/null +++ b/examples/card/card.en-US.md @@ -0,0 +1,26 @@ +:: BASE_DOC :: + +## API + +### Card Props + +name | type | default | description | required +-- | -- | -- | -- | -- +actions | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +avatar | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +bordered | Boolean | true | \- | N +content | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +cover | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +default | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +description | String / Slot / Function | - | card description。Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +footer | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +header | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +headerBordered | Boolean | false | \- | N +hoverShadow | Boolean | false | \- | N +loading | Boolean / Slot / Function | false | Typescript:`boolean | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +shadow | Boolean | false | \- | N +size | String | medium | options:medium/small | N +status | String | - | \- | N +subtitle | String / Slot / Function | - | card subtitle。Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +theme | String | normal | options:normal/poster1/poster2 | N +title | String / Slot / Function | - | card title。Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N diff --git a/examples/cascader/cascader.en-US.md b/examples/cascader/cascader.en-US.md new file mode 100644 index 0000000000..f1043eedca --- /dev/null +++ b/examples/cascader/cascader.en-US.md @@ -0,0 +1,51 @@ +:: BASE_DOC :: + +## API + +### Cascader Props + +name | type | default | description | required +-- | -- | -- | -- | -- +checkProps | Object | - | Typescript:`CheckboxProps`,[Checkbox API Documents](./checkbox?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts) | N +checkStrictly | Boolean | false | \- | N +clearable | Boolean | false | \- | N +collapsedItems | Slot / Function | - | Typescript:`TNode<{ value: CascaderOption[]; collapsedSelectedItems: CascaderOption[]; count: number }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +disabled | Boolean | false | \- | N +empty | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +filterable | Boolean | false | \- | N +keys | Object | - | Typescript:`CascaderKeysType` `interface CascaderKeysType { value?: string; label?: string; children?: string | boolean }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts) | N +lazy | Boolean | true | \- | N +load | Function | - | Typescript:`(node: TreeNodeModel) => Promise>` | N +loading | Boolean | false | \- | N +loadingText | String / Slot / Function | '' | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +max | Number | 0 | \- | N +minCollapsedNum | Number | 0 | \- | N +multiple | Boolean | false | \- | N +options | Array | [] | Typescript:`Array` | N +placeholder | String | undefined | \- | N +popupProps | Object | - | Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts) | N +popupVisible | Boolean | undefined | \- | N +readonly | Boolean | false | \- | N +selectInputProps | Object | - | Typescript:`SelectInputProps`,[SelectInput API Documents](./select-input?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts) | N +showAllLevels | Boolean | true | \- | N +size | String | medium | options:large/medium/small。Typescript:`SizeEnum`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +trigger | String | click | options:click/hover | N +value | String / Number / Array | [] | `v-model` is supported。Typescript:`CascaderValue` `type CascaderValue = string | number | T | Array>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts) | N +defaultValue | String / Number / Array | [] | uncontrolled property。Typescript:`CascaderValue` `type CascaderValue = string | number | T | Array>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts) | N +valueMode | String | onlyLeaf | options:onlyLeaf/parentFirst/all | N +valueType | String | single | options:single/full | N +onBlur | Function | | TS 类型:`(context: { value: CascaderValue; e: FocusEvent }) => void`
| N +onChange | Function | | TS 类型:`(value: CascaderValue, context: CascaderChangeContext) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts)。
`interface CascaderChangeContext { node?: TreeNodeModel; source: CascaderChangeSource }`

`import { TreeNodeModel } from '@Tree'`

`type CascaderChangeSource = 'invalid-value' | 'check' | 'clear' | 'uncheck'`
| N +onFocus | Function | | TS 类型:`(context: { value: CascaderValue; e: FocusEvent }) => void`
| N +onPopupVisibleChange | Function | | TS 类型:`(visible: boolean, context: PopupVisibleChangeContext) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts)。
`import { PopupVisibleChangeContext } from '@Popup'`
| N +onRemove | Function | | TS 类型:`(context: RemoveContext) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts)。
`interface RemoveContext { value: CascaderValue; node: TreeNodeModel }`
| N + +### Cascader Events + +name | params | description +-- | -- | -- +blur | `(context: { value: CascaderValue; e: FocusEvent })` | \- +change | `(value: CascaderValue, context: CascaderChangeContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts)。
`interface CascaderChangeContext { node?: TreeNodeModel; source: CascaderChangeSource }`

`import { TreeNodeModel } from '@Tree'`

`type CascaderChangeSource = 'invalid-value' | 'check' | 'clear' | 'uncheck'`
+focus | `(context: { value: CascaderValue; e: FocusEvent })` | \- +popup-visible-change | `(visible: boolean, context: PopupVisibleChangeContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts)。
`import { PopupVisibleChangeContext } from '@Popup'`
+remove | `(context: RemoveContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/cascader/type.ts)。
`interface RemoveContext { value: CascaderValue; node: TreeNodeModel }`
diff --git a/examples/checkbox/checkbox.en-US.md b/examples/checkbox/checkbox.en-US.md new file mode 100644 index 0000000000..57ca465f8b --- /dev/null +++ b/examples/checkbox/checkbox.en-US.md @@ -0,0 +1,43 @@ +:: BASE_DOC :: + +## API + +### Checkbox Props + +name | type | default | description | required +-- | -- | -- | -- | -- +checkAll | Boolean | false | \- | N +checked | Boolean | false | `v-model` is supported | N +defaultChecked | Boolean | false | uncontrolled property | N +default | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +disabled | Boolean | undefined | \- | N +indeterminate | Boolean | false | \- | N +label | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +name | String | - | \- | N +readonly | Boolean | false | \- | N +value | String / Number | - | Typescript:`string | number` | N +onChange | Function | | TS 类型:`(checked: boolean, context: { e: Event }) => void`
| N + +### Checkbox Events + +name | params | description +-- | -- | -- +change | `(checked: boolean, context: { e: Event })` | \- + +### CheckboxGroup Props + +name | type | default | description | required +-- | -- | -- | -- | -- +disabled | Boolean | false | \- | N +max | Number | undefined | \- | N +name | String | - | \- | N +options | Array | [] | Typescript:`Array` `type CheckboxOption = string | number | CheckboxOptionObj` `interface CheckboxOptionObj { label?: string | TNode; value?: string | number; disabled?: boolean; name?: string; checkAll?: true }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/checkbox/type.ts) | N +value | Array | [] | `v-model` is supported。Typescript:`CheckboxGroupValue` `type CheckboxGroupValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/checkbox/type.ts) | N +defaultValue | Array | [] | uncontrolled property。Typescript:`CheckboxGroupValue` `type CheckboxGroupValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/checkbox/type.ts) | N +onChange | Function | | TS 类型:`(value: CheckboxGroupValue, context: CheckboxGroupChangeContext) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/checkbox/type.ts)。
`interface CheckboxGroupChangeContext { e: Event; current: string | number; option: CheckboxOption | TdCheckboxProps; type: 'check' | 'uncheck' }`
| N + +### CheckboxGroup Events + +name | params | description +-- | -- | -- +change | `(value: CheckboxGroupValue, context: CheckboxGroupChangeContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/checkbox/type.ts)。
`interface CheckboxGroupChangeContext { e: Event; current: string | number; option: CheckboxOption | TdCheckboxProps; type: 'check' | 'uncheck' }`
diff --git a/examples/collapse/collapse.en-US.md b/examples/collapse/collapse.en-US.md new file mode 100644 index 0000000000..54c53a6633 --- /dev/null +++ b/examples/collapse/collapse.en-US.md @@ -0,0 +1,37 @@ +:: BASE_DOC :: + +## API + +### Collapse Props + +name | type | default | description | required +-- | -- | -- | -- | -- +borderless | Boolean | false | \- | N +defaultExpandAll | Boolean | false | \- | N +disabled | Boolean | - | \- | N +expandIcon | Boolean / Slot / Function | true | Typescript:`boolean | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +expandIconPlacement | String | left | options:left/right | N +expandMutex | Boolean | false | \- | N +expandOnRowClick | Boolean | true | \- | N +value | Array | - | `v-model` is supported。Typescript:`CollapseValue` `type CollapseValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/collapse/type.ts) | N +defaultValue | Array | - | uncontrolled property。Typescript:`CollapseValue` `type CollapseValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/collapse/type.ts) | N +onChange | Function | | TS 类型:`(value: CollapseValue) => void`
| N + +### Collapse Events + +name | params | description +-- | -- | -- +change | `(value: CollapseValue)` | \- + +### CollapsePanel Props + +name | type | default | description | required +-- | -- | -- | -- | -- +content | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +default | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +destroyOnCollapse | Boolean | false | \- | N +disabled | Boolean | undefined | \- | N +expandIcon | Boolean / Slot / Function | undefined | Typescript:`boolean | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +header | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +headerRightContent | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +value | String / Number | - | \- | N diff --git a/examples/color-picker/color-picker.en-US.md b/examples/color-picker/color-picker.en-US.md new file mode 100644 index 0000000000..87604a221f --- /dev/null +++ b/examples/color-picker/color-picker.en-US.md @@ -0,0 +1,33 @@ +:: BASE_DOC :: + +## API + +### ColorPicker Props + +name | type | default | description | required +-- | -- | -- | -- | -- +closeBtn | String / Boolean / Slot / Function | true | Typescript:`string | boolean | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +colorModes | Array | ()=> ['monochrome', 'linear-gradient'] | Typescript:`Array<'monochrome' | 'linear-gradient'>` | N +disabled | Boolean | false | \- | N +enableAlpha | Boolean | false | \- | N +format | String | RGB | options:RGB/RGBA/HSL/HSLA/HSB/HSV/HSVA/HEX/CMYK/CSS | N +inputProps | Object | - | Typescript:`InputProps`,[Input API Documents](./input?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/color-picker/type.ts) | N +multiple | Boolean | false | \- | N +popupProps | Object | - | Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/color-picker/type.ts) | N +recentColors | Array | [] | used color recently。`.sync` is supported。Typescript:`boolean | Array` | N +defaultRecentColors | Array | [] | used color recently。uncontrolled property。Typescript:`boolean | Array` | N +selectInputProps | Object | - | Typescript:`SelectInputProps`,[SelectInput API Documents](./select-input?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/color-picker/type.ts) | N +swatchColors | Array | - | swatch colors。Typescript:`Array` | N +value | String | - | color value。`v-model` is supported | N +defaultValue | String | - | color value。uncontrolled property | N +onChange | Function | | TS 类型:`(value: string, context: { color: ColorObject; trigger: ColorPickerChangeTrigger }) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/color-picker/type.ts)。
`type ColorPickerChangeTrigger = 'palette-saturation-brightness' | 'palette-saturation' | 'palette-brightness' | 'palette-hue-bar' | 'palette-alpha-bar' | 'input'`
| N +onPaletteBarChange | Function | | TS 类型:`(context: { color: ColorObject }) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/color-picker/type.ts)。
`interface ColorObject { alpha: number; css: string; hex: string; hex8: string; hsl: string; hsla: string; hsv: string; hsva: string; rgb: string; rgba: string; saturation: number; value: number; isGradient: boolean; linearGradient?: string; }`
| N +onRecentColorsChange | Function | | TS 类型:`(value: Array) => void`
| N + +### ColorPicker Events + +name | params | description +-- | -- | -- +change | `(value: string, context: { color: ColorObject; trigger: ColorPickerChangeTrigger })` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/color-picker/type.ts)。
`type ColorPickerChangeTrigger = 'palette-saturation-brightness' | 'palette-saturation' | 'palette-brightness' | 'palette-hue-bar' | 'palette-alpha-bar' | 'input'`
+palette-bar-change | `(context: { color: ColorObject })` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/color-picker/type.ts)。
`interface ColorObject { alpha: number; css: string; hex: string; hex8: string; hsl: string; hsla: string; hsv: string; hsva: string; rgb: string; rgba: string; saturation: number; value: number; isGradient: boolean; linearGradient?: string; }`
+recent-colors-change | `(value: Array)` | \- diff --git a/examples/comment/comment.en-US.md b/examples/comment/comment.en-US.md new file mode 100644 index 0000000000..e19e78569e --- /dev/null +++ b/examples/comment/comment.en-US.md @@ -0,0 +1,15 @@ +:: BASE_DOC :: + +## API + +### Comment Props + +name | type | default | description | required +-- | -- | -- | -- | -- +actions | Array | - | Typescript:`Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +author | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +avatar | String / Object / Slot / Function | - | Typescript:`string | AvatarProps | TNode`,[Avatar API Documents](./avatar?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/comment/type.ts) | N +content | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +datetime | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +quote | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +reply | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N diff --git a/examples/config-provider/config-provider.en-US.md b/examples/config-provider/config-provider.en-US.md new file mode 100644 index 0000000000..42d19a4573 --- /dev/null +++ b/examples/config-provider/config-provider.en-US.md @@ -0,0 +1,276 @@ +:: BASE_DOC :: + +## API + +### GlobalConfigProvider + +name | type | default | description | required +-- | -- | -- | -- | -- +alert | Object | - | Alert global configs。Typescript:`AlertConfig` | N +anchor | Object | - | Anchor global configs。Typescript:`AnchorConfig` | N +animation | Object | - | Typescript:`Partial>>` `type AnimationType = 'ripple' | 'expand' | 'fade'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N +calendar | Object | - | Calendar global configs。Typescript:`CalendarConfig` | N +cascader | Object | - | Cascader global configs。Typescript:`CascaderConfig` | N +classPrefix | String | t | \- | N +colorPicker | Object | - | ColorPicker global configs。Typescript:`ColorPickerConfig` | N +datePicker | Object | - | DatePicker global configs。Typescript:`DatePickerConfig` | N +dialog | Object | - | Dialog global configs。Typescript:`DialogConfig` | N +drawer | Object | - | Drawer global configs。Typescript:`DrawerConfig` | N +form | Object | - | Form global configs。Typescript:`FormConfig` | N +input | Object | - | Input global configs。Typescript:`InputConfig` | N +list | Object | - | List global configs。Typescript:`ListConfig` | N +pagination | Object | - | Pagination global configs。Typescript:`PaginationConfig` | N +popconfirm | Object | - | Popconfirm global configs。Typescript:`PopconfirmConfig` | N +select | Object | - | Select global configs。Typescript:`SelectConfig` | N +steps | Object | - | Steps global configs。Typescript:`StepsConfig` | N +table | Object | - | Table global configs。Typescript:`TableConfig` | N +tag | Object | - | Tag global configs。Typescript:`TagConfig` | N +timePicker | Object | - | TimePicker global configs。Typescript:`TimePickerConfig` | N +transfer | Object | - | Transfer global configs。Typescript:`TransferConfig` | N +tree | Object | - | Tree global configs。Typescript:`TreeConfig` | N +treeSelect | Object | - | TreeSelect global configs。Typescript:`TreeSelectConfig` | N +upload | Object | - | Upload global configs。Typescript:`UploadConfig` | N + +### InputConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +placeholder | String | - | \- | N + +### PaginationConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +itemsPerPage | String | - | \- | N +jumpTo | String | - | \- | N +page | String | - | \- | N +total | String | - | \- | N + +### CalendarConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +cellMonth | String | - | \- | N +controllerConfig | Object | - | Typescript:`CalendarController`,[Calendar API Documents](./calendar?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N +fillWithZero | Boolean | true | \- | N +firstDayOfWeek | Number | 1 | options:1/2/3/4/5/6/7 | N +hideWeekend | String | - | \- | N +monthRadio | String | - | \- | N +monthSelection | String | - | \- | N +showWeekend | String | - | \- | N +thisMonth | String | - | \- | N +today | String | - | \- | N +week | String | - | \- | N +yearRadio | String | - | \- | N +yearSelection | String | - | \- | N + +### CascaderConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +empty | String | - | \- | N +loadingText | String | - | \- | N +placeholder | String | - | select placeholder text | N + +### ColorPickerConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +clearConfirmText | String | - | \- | N +recentColorTitle | String | - | \- | N +swatchColorTitle | String | - | \- | N + +### TransferConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +empty | String | - | \- | N +placeholder | String | - | \- | N +title | String | - | \- | N + +### TimePickerConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +anteMeridiem | String | - | \- | N +confirm | String | - | \- | N +now | String | - | \- | N +placeholder | String | - | placeholder text | N +postMeridiem | String | - | \- | N + +### DatePickerConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +confirm | String | - | confirm text | N +dayAriaLabel | String | - | date text | N +direction | String | 'ltr' | range separator text | N +firstDayOfWeek | Number | 7 | options:1/2/3/4/5/6/7 | N +format | String | 'YYYY-MM-DD' | date format rules | N +monthAriaLabel | String | - | month text | N +months | Array | - | Typescript:`string[]` | N +nextDecade | String | - | next decade text | N +nextMonth | String | - | next month text | N +nextYear | String | - | next year text | N +now | String | - | now text | N +placeholder | Object | - | Typescript:`{ date?: string; month?: string; year?: string }` | N +preDecade | String | - | pre decade text | N +preMonth | String | - | pre month text | N +presets | Object | - | Typescript:`ConfigPresetDate` `interface ConfigPresetDate { [name: string]: DateConfigValue | (() => DateConfigValue) }` `type DateConfigValue = string | Date | Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N +preYear | String | - | pre year text | N +rangeSeparator | String | - | range separator text | N +selectDate | String | - | select date text | N +selectTime | String | - | select time text | N +weekAbbreviation | String | - | week text | N +weekdays | Object | - | Typescript:`string[]` | N +yearAriaLabel | String | - | year text | N + +### DialogConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +cancel | Object | - | Typescript:`string | ButtonProps`,[Button API Documents](./button?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N +confirm | Object | - | Typescript:`string | ButtonProps` | N +confirmBtnTheme | Object | - | Typescript:`{ default: string; info: string; warning: string; danger: string; success: string; }` | N + +### DrawerConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +cancel | String | - | Typescript:`string | ButtonProps` | N +confirm | String | - | Typescript:`string | ButtonProps` | N + +### PopconfirmConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +cancel | String / Object | - | Typescript:`string | ButtonProps`,[Button API Documents](./button?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N +confirm | String / Object | - | Typescript:`string | ButtonProps` | N +confirmBtnTheme | Object | - | Typescript:`{ default: string; warning: string; danger: string; }` | N + +### TableConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +cancelText | String | - | \- | N +clearFilterResultButtonText | String | - | \- | N +columnConfigButtonText | String | - | \- | N +columnConfigDescriptionText | String | - | \- | N +columnConfigTitleText | String | - | \- | N +confirmText | String | - | \- | N +empty | String / Slot / Function | - | Typescript:`string | TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +expandIcon | Slot / Function | undefined | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +filterIcon | Slot / Function | undefined | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +hideSortTips | Boolean | false | hide sort tips | N +loadingMoreText | String | - | \- | N +loadingText | String | - | \- | N +resetText | String | - | \- | N +searchResultText | String | - | \- | N +selectAllText | String | - | \- | N +sortAscendingOperationText | String | - | \- | N +sortCancelOperationText | String | - | \- | N +sortDescendingOperationText | String | - | \- | N +sortIcon | Slot / Function | undefined | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +treeExpandAndFoldIcon | Function | undefined | Typescript:`TNode<{ type: 'expand' | 'fold' }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### SelectConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +clearIcon | Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +empty | String | - | \- | N +loadingText | String | - | \- | N +placeholder | String | - | placeholder text | N + +### TreeConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +empty | String | - | \- | N +folderIcon | Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### TreeSelectConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +empty | String | - | \- | N +loadingText | String | - | \- | N +placeholder | String | - | placeholder text | N + +### ListConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +loadingMoreText | String | - | \- | N +loadingText | String | - | \- | N + +### UploadConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +cancelUploadText | String | - | \- | N +dragger | Object | - | Typescript:`UploadConfigDragger` | N +file | Object | - | Typescript:`UploadConfigFileList` | N +progress | Object | - | Typescript:`UploadConfigProgress` | N +sizeLimitMessage | String | - | \- | N +triggerUploadText | Object | - | Typescript:`UploadTriggerUploadText` `interface UploadTriggerUploadText { image?: string, normal?: string, fileInput?: string, reupload?: string, continueUpload: string, delete?: string }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N + +### UploadConfigProgress + +name | type | default | description | required +-- | -- | -- | -- | -- +failText | String | - | \- | N +successText | String | - | \- | N +uploadingText | String | - | \- | N +waitingText | String | - | \- | N + +### UploadConfigDragger + +name | type | default | description | required +-- | -- | -- | -- | -- +clickAndDragText | String | - | \- | N +dragDropText | String | - | \- | N +draggingText | String | - | \- | N + +### UploadConfigFileList + +name | type | default | description | required +-- | -- | -- | -- | -- +fileNameText | String | - | \- | N +fileOperationDateText | String | - | \- | N +fileOperationText | String | - | \- | N +fileSizeText | String | - | \- | N +fileStatusText | String | - | \- | N + +### FormConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +errorMessage | Object | - | Typescript:`FormErrorMessage`,[Form API Documents](./form?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/config-provider/type.ts) | N +requiredMark | Boolean | true | \- | N + +### TagConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +closeIcon | Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### StepsConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +errorIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### AlertConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +collapseText | String | - | \- | N +expandText | String | - | \- | N + +### AnchorConfig + +name | type | default | description | required +-- | -- | -- | -- | -- +copySuccessText | String | - | \- | N +copyText | String | - | \- | N diff --git a/examples/date-picker/date-picker.en-US.md b/examples/date-picker/date-picker.en-US.md new file mode 100644 index 0000000000..f9222151b0 --- /dev/null +++ b/examples/date-picker/date-picker.en-US.md @@ -0,0 +1,84 @@ +:: BASE_DOC :: + +## API + +### DatePicker Props + +name | type | default | description | required +-- | -- | -- | -- | -- +allowInput | Boolean | false | \- | N +clearable | Boolean | false | \- | N +disabled | Boolean | false | \- | N +disableDate | Object / Array / Function | - | Typescript:`DisableDate` `type DisableDate = Array | DisableDateObj | ((date: DateValue) => boolean)` `interface DisableDateObj { from?: string; to?: string; before?: string; after?: string }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +enableTimePicker | Boolean | false | \- | N +firstDayOfWeek | Number | - | options:1/2/3/4/5/6/7 | N +format | String | undefined | \- | N +inputProps | Object | - | Typescript:`InputProps`,[Input API Documents](./input?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +mode | String | date | options:year/month/date | N +placeholder | String / Array | undefined | Typescript:`string` | N +popupProps | Object | - | Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +prefixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +presets | Object | - | Typescript:`PresetDate` `interface PresetDate { [name: string]: DateValue | (() => DateValue) }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +presetsPlacement | String | bottom | options:left/top/right/bottom | N +range | Boolean | false | \- | N +suffixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +timePickerProps | Object | - | Typescript:`TimePickerProps`,[TimePicker API Documents](./time-picker?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +value | String / Number / Array / Date | - | `v-model` is supported。Typescript:`DateValue` `type DateValue = string | number | Date`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +defaultValue | String / Number / Array / Date | - | uncontrolled property。Typescript:`DateValue` `type DateValue = string | number | Date`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +valueType | String | YYYY-MM-DD | \- | N +onBlur | Function | | TS 类型:`(context: { value: DateValue; e: FocusEvent }) => void`
| N +onChange | Function | | TS 类型:`(value: DateValue, context: { dayjsValue?: Dayjs, trigger?: DatePickerTriggerSource }) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts)。
`import { Dayjs } from 'dayjs'`

`type DatePickerTriggerSource = 'confirm' | 'pick' | 'enter' | 'preset' | 'clear'`
| N +onFocus | Function | | TS 类型:`(context: { value: DateValue; e: FocusEvent }) => void`
| N +onInput | Function | | TS 类型:`(context: { input: string; value: DateValue; e: InputEvent }) => void`
| N +onPick | Function | | TS 类型:`(value: DateValue) => void`
| N + +### DatePicker Events + +name | params | description +-- | -- | -- +blur | `(context: { value: DateValue; e: FocusEvent })` | \- +change | `(value: DateValue, context: { dayjsValue?: Dayjs, trigger?: DatePickerTriggerSource })` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts)。
`import { Dayjs } from 'dayjs'`

`type DatePickerTriggerSource = 'confirm' | 'pick' | 'enter' | 'preset' | 'clear'`
+focus | `(context: { value: DateValue; e: FocusEvent })` | \- +input | `(context: { input: string; value: DateValue; e: InputEvent })` | \- +pick | `(value: DateValue)` | \- + +### DateRangePicker Props + +name | type | default | description | required +-- | -- | -- | -- | -- +allowInput | Boolean | false | \- | N +clearable | Boolean | false | \- | N +disabled | Boolean / Array | false | Typescript:`boolean | Array` | N +disableDate | Object / Array / Function | - | Typescript:`DisableRangeDate` `type DisableRangeDate = Array | DisableDateObj | ((context: { date: DateRangeValue; partial: DateRangePickerPartial }) => boolean)` `interface DisableDateObj { from?: string; to?: string; before?: string; after?: string }` `type DateRangePickerPartial = 'start' | 'end'`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +enableTimePicker | Boolean | false | \- | N +firstDayOfWeek | Number | - | options:1/2/3/4/5/6/7 | N +format | String | 'YYYY-MM-DD' | \- | N +mode | String | date | options:year/month/date | N +placeholder | String / Array | - | Typescript:`string | Array` | N +popupProps | Object | - | Typescript:`PopupProps`,[Popup API Documents](./popup?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +prefixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +presets | Object | - | Typescript:`PresetRange` `interface PresetRange { [range: string]: DateRange | (() => DateRange)}` `type DateRange = [DateValue, DateValue]`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +presetsPlacement | String | bottom | options:left/top/right/bottom | N +rangeInputProps | Object | - | Typescript:`RangeInputProps`,[RangeInput API Documents](./range-input?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +separator | String | - | \- | N +size | String | medium | options:small/medium/large | N +suffixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +timePickerProps | Object | - | Typescript:`TimePickerProps`,[TimePicker API Documents](./time-picker?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +value | Array | - | `v-model` is supported。Typescript:`DateRangeValue` `type DateRangeValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +defaultValue | Array | - | uncontrolled property。Typescript:`DateRangeValue` `type DateRangeValue = Array`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts) | N +valueType | String | YYYY-MM-DD | \- | N +onBlur | Function | | TS 类型:`(context: { value: DateRangeValue; partial: DateRangePickerPartial; e: FocusEvent }) => void`
| N +onChange | Function | | TS 类型:`(value: DateRangeValue, context: { dayjsValue?: Dayjs[], trigger?: DatePickerTriggerSource }) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts)。
`import { Dayjs } from 'dayjs'`
| N +onFocus | Function | | TS 类型:`(context: { value: DateRangeValue; partial: DateRangePickerPartial; e: FocusEvent }) => void`
| N +onInput | Function | | TS 类型:`(context: { input: string; value: DateRangeValue; partial: DateRangePickerPartial; e: InputEvent }) => void`
| N +onPick | Function | | TS 类型:`(value: DateValue, context: PickContext) => void`
[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts)。
`interface PickContext { e: MouseEvent; partial: DateRangePickerPartial }`
| N + +### DateRangePicker Events + +name | params | description +-- | -- | -- +blur | `(context: { value: DateRangeValue; partial: DateRangePickerPartial; e: FocusEvent })` | \- +change | `(value: DateRangeValue, context: { dayjsValue?: Dayjs[], trigger?: DatePickerTriggerSource })` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts)。
`import { Dayjs } from 'dayjs'`
+focus | `(context: { value: DateRangeValue; partial: DateRangePickerPartial; e: FocusEvent })` | \- +input | `(context: { input: string; value: DateRangeValue; partial: DateRangePickerPartial; e: InputEvent })` | \- +pick | `(value: DateValue, context: PickContext)` | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/date-picker/type.ts)。
`interface PickContext { e: MouseEvent; partial: DateRangePickerPartial }`
diff --git a/examples/dialog/demos/attach.vue b/examples/dialog/demos/attach.vue index e76cb754dc..3fa1ab6772 100644 --- a/examples/dialog/demos/attach.vue +++ b/examples/dialog/demos/attach.vue @@ -78,7 +78,7 @@ export default Vue.extend({ }, }); - diff --git a/site/src/routes.js b/site/src/routes.js index 38debbebc4..d98eca5c3f 100644 --- a/site/src/routes.js +++ b/site/src/routes.js @@ -1,7 +1,7 @@ import config from '../site.config'; import TdesignComponents from './components/page.vue'; -const { docs } = config; +const { docs, enDocs } = config; function getDocsRoutes(docs, type) { let docsRoutes = []; @@ -9,16 +9,8 @@ function getDocsRoutes(docs, type) { docs.forEach((item) => { const docType = item.type || type; + let { children } = item; - if (item.type === 'component') { - children = item.children.sort((a, b) => { - const nameA = a.name.toUpperCase(); - const nameB = b.name.toUpperCase(); - if (nameA < nameB) return -1; - if (nameA > nameB) return 1; - return 0; - }); - } if (children) { docsRoutes = docsRoutes.concat(getDocsRoutes(children, docType)); } else { @@ -34,7 +26,7 @@ const routes = [ path: '/vue', redirect: '/vue/overview', component: TdesignComponents, - children: getDocsRoutes(docs), + children: [...getDocsRoutes(docs), ...getDocsRoutes(enDocs)], }, { path: '*', diff --git a/src/_common b/src/_common index 2729728c5a..8afb185642 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 2729728c5a2af622f0ea1140d8bf2ed241007ce7 +Subproject commit 8afb185642e84c60900a3541c467c25c6538c5f1 diff --git a/src/color-picker/props.ts b/src/color-picker/props.ts new file mode 100644 index 0000000000..876407388b --- /dev/null +++ b/src/color-picker/props.ts @@ -0,0 +1,78 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdColorPickerProps } from './type'; +import { PropType } from 'vue'; + +export default { + /** 关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 或 `undefined` 则不显示关闭按钮;值类型为函数,则表示自定义关闭按钮 */ + closeBtn: { + type: [String, Boolean, Function] as PropType, + default: true, + }, + /** 颜色模式选择。同时支持单色和渐变两种模式,可仅使用单色或者渐变其中一种模式,也可以同时使用。`monochrome` 表示单色,`linear-gradient` 表示渐变色 */ + colorModes: { + type: Array as PropType, + default: () => ['monochrome', 'linear-gradient'], + }, + /** 是否禁用组件 */ + disabled: Boolean, + /** 是否开启透明通道 */ + enableAlpha: Boolean, + /** 格式化色值。`enableAlpha` 为真时,`RGBA/HSLA/HSVA` 等值有效 */ + format: { + type: String as PropType, + default: 'RGB' as TdColorPickerProps['format'], + validator(val: TdColorPickerProps['format']): boolean { + if (!val) return true; + return ['RGB', 'RGBA', 'HSL', 'HSLA', 'HSB', 'HSV', 'HSVA', 'HEX', 'CMYK', 'CSS'].includes(val); + }, + }, + /** 透传 Input 输入框组件全部属性 */ + inputProps: { + type: Object as PropType, + }, + /** 【开发中】是否允许选中多个颜色 */ + multiple: Boolean, + /** 透传 Popup 组件全部属性,如 `placement` `overlayStyle` `overlayClassName` `trigger`等 */ + popupProps: { + type: Object as PropType, + }, + /** 最近使用的颜色。值为 [] 表示以组件内部的“最近使用颜色”为准,值长度大于 0 则以该值为准显示“最近使用颜色”。值为 null 则完全不显示“最近使用颜色” */ + recentColors: { + type: Array as PropType, + default: (): TdColorPickerProps['recentColors'] => [], + }, + /** 最近使用的颜色。值为 [] 表示以组件内部的“最近使用颜色”为准,值长度大于 0 则以该值为准显示“最近使用颜色”。值为 null 则完全不显示“最近使用颜色”,非受控属性 */ + defaultRecentColors: { + type: Array as PropType, + default: (): TdColorPickerProps['defaultRecentColors'] => [], + }, + /** 透传 SelectInputProps 筛选器输入框组件全部属性 */ + selectInputProps: { + type: Object as PropType, + }, + /** 系统预设的颜色样例,值为 `null` 或 `[]` 则不显示系统色,值为 `undefined` 会显示组件内置的系统默认色 */ + swatchColors: { + type: Array as PropType, + }, + /** 色值 */ + value: { + type: String, + default: '', + }, + /** 色值,非受控属性 */ + defaultValue: { + type: String, + default: '', + }, + /** 选中的色值发生变化时触发,第一个参数 `value` 表示新色值,`context.color` 表示当前调色板控制器的色值,`context.trigger` 表示触发颜色变化的来源 */ + onChange: Function as PropType, + /** 调色板控制器的值变化时触发,`context.color` 指调色板控制器的值 */ + onPaletteBarChange: Function as PropType, + /** 最近使用颜色发生变化时触发 */ + onRecentColorsChange: Function as PropType, +}; diff --git a/src/color-picker/type.ts b/src/color-picker/type.ts new file mode 100644 index 0000000000..ae9f0d53c8 --- /dev/null +++ b/src/color-picker/type.ts @@ -0,0 +1,116 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { InputProps } from '../input'; +import { PopupProps } from '../popup'; +import { SelectInputProps } from '../select-input'; +import { TNode } from '../common'; + +export interface TdColorPickerProps { + /** + * 关闭按钮,值为 `true` 显示默认关闭按钮;值为 `false` 或 `undefined` 则不显示关闭按钮;值类型为函数,则表示自定义关闭按钮 + * @default true + */ + closeBtn?: string | boolean | TNode; + /** + * 颜色模式选择。同时支持单色和渐变两种模式,可仅使用单色或者渐变其中一种模式,也可以同时使用。`monochrome` 表示单色,`linear-gradient` 表示渐变色 + * @default ()=> ['monochrome', 'linear-gradient'] + */ + colorModes?: Array<'monochrome' | 'linear-gradient'>; + /** + * 是否禁用组件 + * @default false + */ + disabled?: boolean; + /** + * 是否开启透明通道 + * @default false + */ + enableAlpha?: boolean; + /** + * 格式化色值。`enableAlpha` 为真时,`RGBA/HSLA/HSVA` 等值有效 + * @default RGB + */ + format?: 'RGB' | 'RGBA' | 'HSL' | 'HSLA' | 'HSB' | 'HSV' | 'HSVA' | 'HEX' | 'CMYK' | 'CSS'; + /** + * 透传 Input 输入框组件全部属性 + */ + inputProps?: InputProps; + /** + * 【开发中】是否允许选中多个颜色 + * @default false + */ + multiple?: boolean; + /** + * 透传 Popup 组件全部属性,如 `placement` `overlayStyle` `overlayClassName` `trigger`等 + */ + popupProps?: PopupProps; + /** + * 最近使用的颜色。值为 [] 表示以组件内部的“最近使用颜色”为准,值长度大于 0 则以该值为准显示“最近使用颜色”。值为 null 则完全不显示“最近使用颜色” + * @default [] + */ + recentColors?: boolean | Array; + /** + * 最近使用的颜色。值为 [] 表示以组件内部的“最近使用颜色”为准,值长度大于 0 则以该值为准显示“最近使用颜色”。值为 null 则完全不显示“最近使用颜色”,非受控属性 + * @default [] + */ + defaultRecentColors?: boolean | Array; + /** + * 透传 SelectInputProps 筛选器输入框组件全部属性 + */ + selectInputProps?: SelectInputProps; + /** + * 系统预设的颜色样例,值为 `null` 或 `[]` 则不显示系统色,值为 `undefined` 会显示组件内置的系统默认色 + */ + swatchColors?: Array; + /** + * 色值 + * @default '' + */ + value?: string; + /** + * 色值,非受控属性 + * @default '' + */ + defaultValue?: string; + /** + * 选中的色值发生变化时触发,第一个参数 `value` 表示新色值,`context.color` 表示当前调色板控制器的色值,`context.trigger` 表示触发颜色变化的来源 + */ + onChange?: (value: string, context: { color: ColorObject; trigger: ColorPickerChangeTrigger }) => void; + /** + * 调色板控制器的值变化时触发,`context.color` 指调色板控制器的值 + */ + onPaletteBarChange?: (context: { color: ColorObject }) => void; + /** + * 最近使用颜色发生变化时触发 + */ + onRecentColorsChange?: (value: Array) => void; +} + +export type ColorPickerChangeTrigger = + | 'palette-saturation-brightness' + | 'palette-saturation' + | 'palette-brightness' + | 'palette-hue-bar' + | 'palette-alpha-bar' + | 'input'; + +export interface ColorObject { + alpha: number; + css: string; + hex: string; + hex8: string; + hsl: string; + hsla: string; + hsv: string; + hsva: string; + rgb: string; + rgba: string; + saturation: number; + value: number; + isGradient: boolean; + linearGradient?: string; +} diff --git a/src/common.ts b/src/common.ts index 4635583eca..0bdd212aff 100644 --- a/src/common.ts +++ b/src/common.ts @@ -1,4 +1,4 @@ -/** Vue2 特有全局变量 */ +/** Vue2 特有全局类型 */ export type TNodeReturnValue = import('vue/types/vnode').ScopedSlotReturnValue; export type TNode = T extends undefined @@ -10,7 +10,7 @@ export type JsxNode = TNodeReturnValue; export type AttachNodeReturnValue = HTMLElement | Element | Document; export type AttachNode = CSSSelector | ((triggerNode?: HTMLElement) => AttachNodeReturnValue); -// 与滚动相关的容器类型,因为 document 上没有 scroll 相关属性, 因此排除document +// 与滚动相关的容器类型,因为 document 上没有 scroll 相关属性, 因此排除 document export type ScrollContainerElement = Window | HTMLElement; export type ScrollContainer = (() => ScrollContainerElement) | CSSSelector; @@ -21,7 +21,7 @@ export type FormSubmitEvent = Event; export interface Styles { [css: string]: string | number; } -/** 通用全局变量 */ +/** 通用全局类型 */ export type OptionData = { label?: string; diff --git a/src/form/form-item.tsx b/src/form/form-item.tsx index c1ed84566f..72453e8543 100644 --- a/src/form/form-item.tsx +++ b/src/form/form-item.tsx @@ -79,11 +79,28 @@ export default mixins(getConfigReceiverMixins(' CLASS_NAMES.formItem, FORM_ITEM_CLASS_PREFIX + this.name, { - [CLASS_NAMES.formItemWithHelp]: this.help, - [CLASS_NAMES.formItemWithExtra]: this.renderTipsInfo(), + [CLASS_NAMES.formItemWithHelp]: this.helpNode, + [CLASS_NAMES.formItemWithExtra]: this.extraNode, }, ]; }, + helpNode() { + let helpVNode: VNode = null; + if (this.help) { + helpVNode =
{this.help}
; + } + return helpVNode; + }, + extraNode() { + const list = this.errorList; + if (this.needErrorMessage && list && list[0] && list[0].message) { + return
{list[0].message}
; + } + if (this.successList.length) { + return
{this.successList[0].message}
; + } + return null; + }, labelClasses(): ClassName { const parent = this.form; const labelAlign = isNil(this.labelAlign) ? parent?.labelAlign : this.labelAlign; @@ -288,20 +305,6 @@ export default mixins(getConfigReceiverMixins(' ); }, - renderTipsInfo(): VNode { - let helpVNode: VNode =
; - if (this.help) { - helpVNode =
{this.help}
; - } - const list = this.errorList; - if (this.needErrorMessage && list && list[0] && list[0].message) { - return
{list[0].message}
; - } - if (this.successList.length) { - return
{this.successList[0].message}
; - } - return helpVNode; - }, getDefaultIcon(): TNodeReturnValue { const resultIcon = (Icon: IconConstructor) => ( @@ -403,7 +406,8 @@ export default mixins(getConfigReceiverMixins(' {this.$slots.default} {this.getSuffixIcon()} - {this.renderTipsInfo()} + {this.helpNode} + {this.extraNode} ); diff --git a/src/input/input.tsx b/src/input/input.tsx index 4e2f089b52..d89a43a4d7 100644 --- a/src/input/input.tsx +++ b/src/input/input.tsx @@ -53,7 +53,8 @@ export default mixins(getConfigReceiverMixins('input }, showClear(): boolean { return ( - (this.value && !this.disabled && this.clearable && this.isHover && !this.readonly) || this.showClearIconOnEmpty + ((this.value && !this.disabled && this.clearable && !this.readonly) || this.showClearIconOnEmpty) + && this.isHover ); }, inputAttrs(): Record { @@ -200,8 +201,6 @@ export default mixins(getConfigReceiverMixins('input emitClear(e: MouseEvent) { emitEvent>(this, 'clear', { e }); emitEvent>(this, 'change', '', { e }); - this.focus(); - this.emitFocus(e); }, emitFocus(e: FocusEvent) { this.inputValue = this.value; @@ -302,10 +301,10 @@ export default mixins(getConfigReceiverMixins('input
{prefixIcon ? {prefixIcon} : null} {labelContent} diff --git a/src/menu/menu.tsx b/src/menu/menu.tsx index c019daeef5..fc5aae9b53 100644 --- a/src/menu/menu.tsx +++ b/src/menu/menu.tsx @@ -31,14 +31,17 @@ export default defineComponent({ { [`${prefix}-menu--scroll`]: mode.value !== 'popup' }, 'narrow-scrollbar', ]); - const styles = computed(() => { + const expandWidth = computed(() => { const { width } = props; - const expandWidth = typeof width === 'number' ? `${width}px` : width; - return { - height: '100%', - width: props.collapsed ? '64px' : expandWidth, - }; + const format = (val: string | number) => (typeof val === 'number' ? `${val}px` : val); + if (Array.isArray(width)) return width.map((item) => format(item)); + + return [format(width), '64px']; }); + const styles = computed(() => ({ + height: '100%', + width: props.collapsed ? expandWidth.value[1] : expandWidth.value[0], + })); const activeValue = ref(props.defaultValue || props.value); const activeValues = ref([]); const expandValues = ref(props.expanded || []); diff --git a/src/menu/submenu.tsx b/src/menu/submenu.tsx index 8f170f79fe..1c52b448a5 100644 --- a/src/menu/submenu.tsx +++ b/src/menu/submenu.tsx @@ -168,7 +168,7 @@ export default defineComponent({ paddingLeft += 16; } - const needRotate = this.mode === 'popup' && this.isNested; + const needRotate = this.mode === 'popup'; const rippleVal = (this.keepAnimation as Record).ripple ? this.rippleColor : false; const normalSubmenu = [ diff --git a/src/select-input/useSingle.tsx b/src/select-input/useSingle.tsx index 2f8cba0477..1fa9610e6f 100644 --- a/src/select-input/useSingle.tsx +++ b/src/select-input/useSingle.tsx @@ -24,10 +24,6 @@ const COMMON_PROPERTIES = [ 'readonly', 'suffix', 'suffixIcon', - 'onPaste', - 'onEnter', - 'onMouseenter', - 'onMouseleave', ]; const DEFAULT_KEYS = { @@ -86,7 +82,7 @@ export default function useSingle(props: TdSelectInputProps, context: SetupConte readonly: !props.allowInput, placeholder: singleValueDisplay ? '' : props.placeholder, suffixIcon: !props.disabled && props.loading ? () => : props.suffixIcon, - showClearIconOnEmpty: Boolean(props.clearable && inputValue.value), + showClearIconOnEmpty: Boolean(props.clearable && (inputValue.value || displayedValue)), inputClass: { [`${classPrefix.value}-input--focused`]: popupVisible, }, @@ -112,6 +108,18 @@ export default function useSingle(props: TdSelectInputProps, context: SetupConte instance.emit('focus', value.value, { ...context, tagInputValue: val }); !popupVisible && setInputValue(getInputValue(value.value, keys.value), { ...context, trigger: 'input' }); // 聚焦时拿到value }} + onPaste={(context: { e: ClipboardEvent; pasteValue: string }) => { + props.onPaste?.(context); + instance.emit('paste', context); + }} + onMouseenter={(context: { e: MouseEvent }) => { + props.onMouseenter?.(context); + instance.emit('mouseenter', context); + }} + onMouseleave={(context: { e: MouseEvent }) => { + props.onMouseleave?.(context); + instance.emit('mouseenter', context); + }} /> ); }; diff --git a/src/swiper/style/index.js b/src/swiper/style/index.js index cadf1b5724..de356833ab 100644 --- a/src/swiper/style/index.js +++ b/src/swiper/style/index.js @@ -1 +1 @@ -import '../../_common/style/web/components/swiper-new/_index.less'; +import '../../_common/style/web/components/swiper/_index.less'; diff --git a/src/table/base-table-props.ts b/src/table/base-table-props.ts index db4d937f31..286df9132b 100644 --- a/src/table/base-table-props.ts +++ b/src/table/base-table-props.ts @@ -96,7 +96,7 @@ export default { /** 使用 rowKey 唯一标识一行数据 */ rowKey: { type: String, - default: '', + default: 'id', required: true, }, /** 用于自定义合并单元格,泛型 T 指表格数据类型。示例:`({ row, col, rowIndex, colIndex }) => { rowspan: 2, colspan: 3 }` */ diff --git a/src/table/enhanced-table-props.ts b/src/table/enhanced-table-props.ts index 34d0ed2200..f66a477122 100644 --- a/src/table/enhanced-table-props.ts +++ b/src/table/enhanced-table-props.ts @@ -8,7 +8,11 @@ import { TdEnhancedTableProps } from '../table/type'; import { PropType } from 'vue'; export default { - /** 树形结构相关配置。`tree.indent` 表示树结点缩进距离,单位:px,默认为 24px。`tree.treeNodeColumnIndex` 表示树结点在第几列渲染,默认为 0 ,第一列。`tree.childrenKey` 表示树形结构子节点字段,默认为 children。`tree.checkStrictly` 表示树形结构的行选中(多选),父子行选中是否独立,默认独立,值为 true */ + /** 树形结构中,拖拽排序前控制,返回值为 `true` 则继续排序;返回值为 `false` 则中止排序还原数据 */ + beforeDragSort: { + type: Function as PropType, + }, + /** 树形结构相关配置。具体属性文档查看 `TableTreeConfig` 相关描述 */ tree: { type: Object as PropType, }, @@ -16,6 +20,8 @@ export default { treeExpandAndFoldIcon: { type: Function as PropType, }, + /** 异常拖拽排序时触发,如:树形结构中,非同层级之间的交换。`context.code` 指交换异常错误码,固定值;`context.reason` 指交换异常的原因 */ + onAbnormalDragSort: Function as PropType, /** 树形结构,用户操作引起节点展开或收起时触发,代码操作不会触发 */ onTreeExpandChange: Function as PropType, }; diff --git a/src/table/enhanced-table.tsx b/src/table/enhanced-table.tsx index 7717f79d9e..683b136568 100644 --- a/src/table/enhanced-table.tsx +++ b/src/table/enhanced-table.tsx @@ -5,7 +5,9 @@ import baseTableProps from './base-table-props'; import primaryTableProps from './primary-table-props'; import enhancedTableProps from './enhanced-table-props'; import PrimaryTable, { BASE_TABLE_ALL_EVENTS } from './primary-table'; -import { TdEnhancedTableProps, PrimaryTableCol, TableRowData } from './type'; +import { + TdEnhancedTableProps, PrimaryTableCol, TableRowData, DragSortContext, +} from './type'; import useTreeData from './hooks/useTreeData'; import useTreeSelect from './hooks/useTreeSelect'; import { TableListeners } from './base-table'; @@ -17,7 +19,6 @@ const PRIMARY_B_EVENTS = [ 'filter-change', 'sort-change', 'data-change', - 'drag-sort', 'async-loading-click', ]; @@ -34,7 +35,7 @@ export default defineComponent({ setup(props: TdEnhancedTableProps, context: SetupContext) { const { - store, dataSource, formatTreeColumn, ...treeInstanceFunctions + store, dataSource, formatTreeColumn, swapData, ...treeInstanceFunctions } = useTreeData(props, context); const treeDataMap = ref(store.value.treeDataMap); @@ -64,10 +65,22 @@ export default defineComponent({ return isTreeData ? props.columns : getColumns(props.columns); }); + const onDragSortChange = (context: DragSortContext) => { + if (props.beforeDragSort && !props.beforeDragSort(context)) return; + swapData({ + current: context.current, + target: context.target, + currentIndex: context.currentIndex, + targetIndex: context.targetIndex, + }); + props.onDragSort?.(context); + }; + return { store, dataSource, tColumns, + onDragSortChange, onInnerSelectChange, ...treeInstanceFunctions, }; @@ -98,6 +111,7 @@ export default defineComponent({ const on: TableListeners = { ...this.getListener(), 'select-change': this.onInnerSelectChange, + 'drag-sort': this.onDragSortChange, }; // replace `scopedSlots={this.$scopedSlots}` of `v-slots={this.$slots}` in Vue3 return ; diff --git a/src/table/hooks/tree-store.ts b/src/table/hooks/tree-store.ts index 00f0fca9ea..54b8f8fc11 100644 --- a/src/table/hooks/tree-store.ts +++ b/src/table/hooks/tree-store.ts @@ -1,3 +1,5 @@ +/* eslint-disable class-methods-use-this */ +/* eslint-disable no-param-reassign */ import get from 'lodash/get'; import { isRowSelectedDisabled } from '../utils'; import { @@ -5,7 +7,7 @@ import { } from '../type'; import log from '../../_common/js/log'; -export type TableTreeDataMap = Map>; +export type TableTreeDataMap = Map; export interface TableRowModel extends TableRowState { setData?: (key: string | number, data: T) => void; @@ -16,6 +18,18 @@ export interface KeysType { childrenKey: string; } +export interface SwapParams { + current: T; + target: T; + currentIndex: number; + targetIndex: number; +} + +export const TABLE_TREE_ERROR_CODE_NOT_SAME_LEVEL = { + code: 1001, + reason: 'The same level of rows can not be swapped.', +}; + /** * 表格树形结构处理器 * Vue 和 React 可以通用 @@ -28,7 +42,9 @@ export interface KeysType { */ class TableTreeStore { /** 树形结构 Map 存储 */ - treeDataMap: TableTreeDataMap = new Map(); + treeDataMap: TableTreeDataMap = new Map(); + + expandAllRowIndex: 0; constructor() { this.treeDataMap = new Map(); @@ -42,7 +58,7 @@ class TableTreeStore { */ initialTreeStore(dataSource: T[], columns: PrimaryTableCol[], keys: KeysType) { this.treeDataMap?.clear(); - initialTreeDataMap(this.treeDataMap, dataSource, columns[0], keys); + this.initialTreeDataMap(this.treeDataMap, dataSource, columns[0], keys); } toggleExpandData(p: { rowIndex: number; row: T }, dataSource: T[], keys: KeysType) { @@ -55,18 +71,14 @@ class TableTreeStore { log.error('EnhancedTable', '`rowKey` could be wrong, can not get rowValue from `data` by `rowKey`.'); return []; } - const r = this.treeDataMap.get(rowValue) || { - row: p.row, - rowIndex: p.rowIndex, - expanded: false, - }; + const r = this.treeDataMap.get(rowValue); r.rowIndex = p.rowIndex; r.expanded = !r.expanded; this.treeDataMap.set(rowValue, r); return this.updateExpandRow(r, dataSource, keys); } - updateExpandRow(changeRow: TableRowState, dataSource: T[], keys: KeysType) { + updateExpandRow(changeRow: TableRowState, dataSource: T[], keys: KeysType) { const { row, rowIndex, expanded } = changeRow; const { treeDataMap } = this; const childrenNodes = get(row, keys.childrenKey); @@ -94,22 +106,22 @@ class TableTreeStore { * @param key 行唯一标识 * @returns {TableRowState} 当前行数据 */ - getData(key: TableRowValue): TableRowState { + getData(key: TableRowValue): TableRowState { return this.treeDataMap.get(key); } /** * 更新当前行数据,并返回当前行下标 - * @param key 当前行唯一标识值 + * @param rowValue 当前行唯一标识值 * @param newRowData 新行数据 * @returns {number} rowIndex 设置的行下标 */ - updateData(key: TableRowValue, newRowData: T, dataSource: T[], keys: KeysType): number { - const newKey = get(newRowData, keys.rowKey); - const rowState = this.treeDataMap.get(key); + updateData(rowValue: TableRowValue, newRowData: T, dataSource: T[], keys: KeysType): number { + const newRowValue = get(newRowData, keys.rowKey); + const rowState = this.treeDataMap.get(rowValue); // Map 没有查询到,或者查询到的 rowIndex 值为 -1,均表示当前数据不在 dataSource 列表中,未显示在页面中 if (!rowState || rowState.rowIndex === -1) { - updateRowData(dataSource, key, newRowData, { + updateRowData(dataSource, rowValue, newRowData, { rowKey: keys.rowKey, childrenKey: keys.childrenKey, }); @@ -117,18 +129,20 @@ class TableTreeStore { } const currentRowIndex = rowState.rowIndex; rowState.row = newRowData; - this.treeDataMap.set(key, rowState); + rowState.id = newRowValue; + + // 更新父元素中存储的当前元素值 if (rowState.parent) { + // 更新直接子元素数组 const siblings = get(rowState.parent.row, keys.childrenKey); - const index = siblings.findIndex((item: T) => get(item, keys.rowKey) === key); + const index = siblings.findIndex((item: T) => get(item, keys.rowKey) === rowValue); siblings[index] = newRowData; } - // key 也发生了变化 - if (key !== newKey) { - this.treeDataMap.set(newKey, rowState); - this.treeDataMap.delete(key); - } else { - this.treeDataMap.set(key, rowState); + + this.treeDataMap.set(newRowValue, rowState); + // rowValue 也发生了变化,需移除 旧 rowValue 数据 + if (rowValue !== newRowValue) { + this.treeDataMap.delete(rowValue); } return currentRowIndex; } @@ -143,23 +157,23 @@ class TableTreeStore { // 移除当前节点时,展开的节点的子节点需同步移除 const removeNumber = (r.expandChildrenLength || 0) + 1; dataSource.splice(r.rowIndex, removeNumber); + if (r.parent) { const siblings = get(r.parent.row, keys.childrenKey); const index = siblings.findIndex((item: TableRowData) => get(item, keys.rowKey) === key); siblings.splice(index, 1); - updateRowExpandLength(this.treeDataMap, r.parent.row, -1 * removeNumber, 'delete', { - rowKey: keys.rowKey, - childrenKey: keys.childrenKey, - }); + updateRowExpandLength(this.treeDataMap, r.parent.row, -1 * removeNumber, 'delete', keys); } + this.treeDataMap.delete(key); + // 更新 rowIndex 之后的下标 updateRowIndex(this.treeDataMap, dataSource, { minRowIndex: r.rowIndex, rowKey: keys.rowKey, + type: 'remove', }); } else { - // TODO, remove from dataSource console.warn('TDesign Table Warn: Do not remove this node, which is not appeared.'); } return dataSource; @@ -167,37 +181,34 @@ class TableTreeStore { /** * 为当前节点添加子节点,默认添加到最后一个节点 - * @param key 当前节点唯一标识 + * @param rowValue 当前节点唯一标识 * @param newData 待添加的新节点 */ - appendTo(key: string | number, newData: T, dataSource: T[], keys: KeysType): T[] { - const state = this.treeDataMap.get(key); - if (!state) { - console.warn(`TDesign Table Warn: ${key} is not exist.`); - return; - } + appendTo(rowValue: string | number, newData: T, dataSource: T[], keys: KeysType): T[] { + const state = this.treeDataMap.get(rowValue); + if (!this.validateDataExist(state, rowValue)) return dataSource; const newRowValue = get(newData, keys.rowKey); - if (this.treeDataMap.get(newRowValue)) { - console.warn(`TDesign Table Warn: Duplicated Key. ${newRowValue} is already exists.`); - return; - } + const mapState = this.treeDataMap.get(newRowValue); + if (!this.validateDataDoubleExist(mapState, newRowValue)) return dataSource; const children: T[] = get(state.row, keys.childrenKey); // 子节点不存在,则表示为叶子节点 const isShowNewNode = state.expanded || !children?.length; + const rowIndex = isShowNewNode ? state.rowIndex + (state.expandChildrenLength || 0) + 1 : -1; const newState = { + id: newRowValue, row: newData, + rowIndex, level: state.level + 1, - parent: state, - path: [...state.path], expanded: false, expandChildrenLength: 0, - rowIndex: isShowNewNode ? state.rowIndex + (state.expandChildrenLength || 0) + 1 : -1, + disabled: false, + path: [...state.path], + parent: state, }; newState.path = newState.path.concat(newState); if (children?.length) { state.row[keys.childrenKey].push(newData); } else { - // @ts-ignore state.row[keys.childrenKey] = [newData]; state.expanded = true; } @@ -205,7 +216,7 @@ class TableTreeStore { // 如果当前节点为展开状态,则需要继续处理 if (isShowNewNode) { dataSource.splice(newState.rowIndex, 0, newData); - // 更新展开子节点数量 + // 更新父元素及祖先元素展开子节点的数量 updateRowExpandLength(this.treeDataMap, state.row, 1, 'insert', { rowKey: keys.rowKey, childrenKey: keys.childrenKey, @@ -214,44 +225,296 @@ class TableTreeStore { updateRowIndex(this.treeDataMap, dataSource, { minRowIndex: newState.rowIndex, rowKey: keys.rowKey, + type: 'add', }); } + return dataSource; } -} -export default TableTreeStore; + /** + * 在当前节点后,插入一个兄弟节点 + * @param rowValue 当前节点唯一标识 + * @param newData 待添加的新节点 + */ + insertAfter(rowValue: string | number, newData: T, dataSource: T[], keys: KeysType): T[] { + return this.insert(rowValue, newData, dataSource, keys, 'after'); + } -export function initialTreeDataMap( - treeDataMap: TableTreeDataMap, - dataSource: T[], - column: PrimaryTableCol, - keys: KeysType, -) { - for (let i = 0, len = dataSource.length; i < len; i++) { - const item = dataSource[i]; - const rowValue = get(item, keys.rowKey); - if (rowValue === undefined) { - log.error('EnhancedTable', '`rowKey` could be wrong, can not get rowValue from `data` by `rowKey`.'); - return; - } - const state: TableRowState = { - row: item, - rowIndex: i, + /** + * 在当前节点前,插入一个兄弟节点 + * @param rowValue 当前节点唯一标识 + * @param newData 待添加的新节点 + */ + insertBefore(rowValue: string | number, newData: T, dataSource: T[], keys: KeysType): T[] { + return this.insert(rowValue, newData, dataSource, keys, 'before'); + } + + insert(rowValue: string | number, newData: T, dataSource: T[], keys: KeysType, type: 'before' | 'after') { + const state = this.treeDataMap.get(rowValue); + if (!this.validateDataExist(state, rowValue)) return dataSource; + const newRowValue = get(newData, keys.rowKey); + const mapState = this.treeDataMap.get(newRowValue); + if (!this.validateDataDoubleExist(mapState, newRowValue)) return dataSource; + const rowIndex = type === 'after' ? state.rowIndex + 1 : state.rowIndex; + const newState = { + id: newRowValue, + row: newData, + rowIndex, + level: state.level, expanded: false, - level: 0, expandChildrenLength: 0, - disabled: isRowSelectedDisabled(column, item, i), + disabled: false, + path: state.path.slice(0, -1), + parent: state.parent, }; - state.path = [state]; - treeDataMap.set(rowValue, state); - const children = get(item, keys.childrenKey); - if (children?.length) { - initialTreeDataMap(treeDataMap, children, column, keys); + newState.path = newState.path.concat(newState); + const dataIndex = type === 'after' ? state.rowIndex + (state.expandChildrenLength + 1) : state.rowIndex; + dataSource.splice(dataIndex, 0, newData); + const distance = type === 'after' ? 1 : 0; + if (state.parent) { + const childrenIndex = state.parent.row[keys.childrenKey].findIndex( + (t: TableRowData) => rowValue === get(t, keys.rowKey), + ); + state.parent.row[keys.childrenKey].splice(childrenIndex + distance, 0, newData); + updateRowExpandLength(this.treeDataMap, state.parent.row, 1, 'insert', keys); + } + this.treeDataMap.set(newRowValue, newState); + + // 更新 rowIndex 之后的下标 + updateRowIndex(this.treeDataMap, dataSource, { + rowKey: keys.rowKey, + minRowIndex: state.rowIndex + 1, + type: 'add', + }); + + return dataSource; + } + + /** + * 交换数据行 + * @returns 交换失败返回 false + */ + swapData( + dataSource: T[], + params: SwapParams, + keys: KeysType, + ): { dataSource: T[]; result: boolean; code?: number; reason?: string } { + const startIndex = params.currentIndex; + const endIndex = params.targetIndex; + if (startIndex === endIndex) return { dataSource, result: true }; + const startRowValue = get(params.current, keys.rowKey); + const endRowValue = get(params.target, keys.rowKey); + const startState = this.treeDataMap.get(startRowValue); + const endState = this.treeDataMap.get(endRowValue); + if (startState.level !== endState.level) { + return { + dataSource, + result: false, + code: TABLE_TREE_ERROR_CODE_NOT_SAME_LEVEL.code, + reason: TABLE_TREE_ERROR_CODE_NOT_SAME_LEVEL.reason, + }; + } + const startLastIndex = startIndex + startState.expandChildrenLength + 1; + const endLastIndex = endIndex + endState.expandChildrenLength + 1; + const startRowList = dataSource.slice(startIndex, startLastIndex); + const endRowList = dataSource.slice(endIndex, endLastIndex); + if (startIndex > endIndex) { + const middleRowList = dataSource.slice(endLastIndex, startIndex); + const allSwapList = startRowList.concat(endRowList, middleRowList); + dataSource.splice(endIndex, allSwapList.length); + dataSource.splice(endIndex, 0, ...allSwapList); + updateRowIndex(this.treeDataMap, dataSource, { + rowKey: keys.rowKey, + minRowIndex: endIndex, + maxRowIndex: startLastIndex, + }); + } else { + const middleRowList = dataSource.slice(startLastIndex, endIndex); + const allSwapList = middleRowList.concat(endRowList, startRowList); + dataSource.splice(startIndex, allSwapList.length); + dataSource.splice(startIndex, 0, ...allSwapList); + updateRowIndex(this.treeDataMap, dataSource, { + rowKey: keys.rowKey, + minRowIndex: startIndex, + maxRowIndex: endLastIndex, + }); + } + + // 交换父元素中的两个元素位置 + if (startState.parent) { + const children = startState.parent.row[keys.childrenKey]; + let count = 0; + for (let i = 0, len = children.length; i < len; i++) { + if (get(children[i], keys.rowKey) === startRowValue) { + children[i] = params.target; + count += 1; + } + if (get(children[i], keys.rowKey) === endRowValue) { + children[i] = params.current; + count += 1; + } + if (count >= 2) break; + } + } + + return { dataSource, result: true }; + } + + /** + * 展开所有节点 + */ + expandAll(dataSource: T[], keys: KeysType) { + this.expandAllRowIndex = 0; + const expandLoop = ( + dataSource: T[], + keys: KeysType, + newData: T[] = [], + parentExpanded = false, + parent: TableRowState = null, + ) => { + for (let i = 0, len = dataSource.length; i < len; i++) { + const item = dataSource[i]; + const rowValue = get(item, keys.rowKey); + const state = this.treeDataMap.get(rowValue); + const children = get(item, keys.childrenKey); + const originalExpanded = state.expanded; + state.rowIndex = this.expandAllRowIndex; + state.expanded = true; + state.expandChildrenLength = children?.length || 0; + this.expandAllRowIndex += 1; + if (!parentExpanded) { + newData.push(item); + } + this.treeDataMap.set(rowValue, state); + if (children?.length && !originalExpanded) { + // 同步更新父元素的展开数量 + let tmpParent = parent; + while (tmpParent?.row) { + tmpParent.expandChildrenLength += children.length; + this.treeDataMap.set(tmpParent.id, tmpParent); + tmpParent = tmpParent.parent; + } + // 继续子元素 + expandLoop(children, keys, newData, originalExpanded, state); + } + } + return newData; + }; + return expandLoop(dataSource, keys); + } + + /** + * 收起所有节点 + */ + foldAll(dataSource: T[], keys: KeysType) { + const newData: T[] = []; + for (let i = 0, len = dataSource.length; i < len; i++) { + const item = dataSource[i]; + const rowValue = get(item, keys.rowKey); + const state = this.treeDataMap.get(rowValue); + state.rowIndex = state.level === 0 ? i : -1; + state.expanded = false; + state.expandChildrenLength = 0; + if (state.level === 0) { + newData.push(item); + } + const children = get(item, keys.childrenKey); + if (children?.length) { + this.foldAll(children, keys); + } } + return newData; + } + + /** + * 初始化树形结构 Map + * @param treeDataMap 树形结构 Map + * @param dataSource 数据源 + * @param column 树形结构列 + * @param keys 字段映射关系 + * @param level 层级 + * @param parent 父元素 + * @returns void + */ + initialTreeDataMap( + treeDataMap: TableTreeDataMap, + dataSource: T[], + column: PrimaryTableCol, + keys: KeysType, + level = 0, + parent: TableRowState = null, + ) { + for (let i = 0, len = dataSource.length; i < len; i++) { + const item = dataSource[i]; + const rowValue = get(item, keys.rowKey); + if (rowValue === undefined) { + log.error('EnhancedTable', '`rowKey` could be wrong, can not get rowValue from `data` by `rowKey`.'); + return; + } + const children = get(item, keys.childrenKey); + const state: TableRowState = { + id: rowValue, + row: item, + rowIndex: level === 0 ? i : -1, + level, + expanded: false, + expandChildrenLength: 0, + disabled: isRowSelectedDisabled(column, item, i), + parent, + }; + state.path = parent ? parent.path.concat(state) : [state]; + treeDataMap.set(rowValue, state); + if (children?.length) { + this.initialTreeDataMap(treeDataMap, children, column, keys, level + 1, state); + } + } + } + + // column.checkProps 和 column.disabled 会影响行的禁用状态,因此当列发生变化时,需要重置禁用状态 + updateDisabledState(dataSource: T[], column: PrimaryTableCol, keys: KeysType) { + for (let i = 0, len = dataSource.length; i < len; i++) { + const item = dataSource[i]; + const rowValue = get(item, keys.rowKey); + if (rowValue === undefined) { + log.error('EnhancedTable', '`rowKey` could be wrong, can not get rowValue from `data` by `rowKey`.'); + return; + } + const state = this.treeDataMap.get(rowValue); + state.disabled = isRowSelectedDisabled(column, item, i); + this.treeDataMap.set(rowValue, state); + const children = get(item, keys.childrenKey); + if (children?.length) { + this.updateDisabledState(children, column, keys); + } + } + } + + /** + * 校验数据合法性 + */ + validateDataExist(state: TableRowState, rowValue: string | number) { + if (!state) { + console.warn(`TDesign Table Warn: ${rowValue} does not exist.`); + return false; + } + return true; + } + + /** + * 校验数据是否已存在 + */ + validateDataDoubleExist(state: TableRowState, rowValue: string | number) { + if (state) { + console.warn(`TDesign Table Warn: Duplicated Key. ${rowValue} already exists.`); + return false; + } + return true; } } +export default TableTreeStore; + /** * 更新展开的子节点数量 * @param rowSate 行数据和状态 @@ -298,26 +561,23 @@ export function clearRowExpandLength(treeDataMap: TableTreeDataMap, row: T, k */ export function updateChildrenRowState( treeDataMap: TableTreeDataMap, - rowState: TableRowState, + rowState: TableRowState, expanded: boolean, keys: KeysType, ) { - const { row, level = 0, rowIndex } = rowState; + const { row, rowIndex } = rowState; const childrenNodes = get(row, keys.childrenKey); childrenNodes.forEach((item: T, kidRowIndex: number) => { const rowValue = get(item, keys.rowKey); const index = expanded ? rowIndex + 1 + kidRowIndex : -1; const curState = treeDataMap.get(rowValue); - const newState: TableRowState = { + const newState: TableRowState = { ...curState, row: item, rowIndex: index, expanded: false, parent: rowState, - level: level + 1, - path: [], }; - newState.path = newState.path.concat(newState); treeDataMap.set(rowValue, newState); // 父节点展开,子节点不一定展开;父节点收起,则所有子节点收起 if (!expanded) { @@ -361,7 +621,12 @@ export function updateRowData( export function updateRowIndex( treeDataMap: TableTreeDataMap, dataSource: T[], - extra: { rowKey: string; minRowIndex?: number; maxRowIndex?: number }, + extra: { + rowKey: string; + minRowIndex?: number; + maxRowIndex?: number; + type?: 'add' | 'remove'; + }, ) { const start = extra.minRowIndex || 0; const end = extra.maxRowIndex || dataSource.length; diff --git a/src/table/hooks/useDragSort.ts b/src/table/hooks/useDragSort.ts index a3dd5ca350..4099217f94 100644 --- a/src/table/hooks/useDragSort.ts +++ b/src/table/hooks/useDragSort.ts @@ -83,9 +83,9 @@ export default function useDragSort(props: TdPrimaryTableProps, context: SetupCo const { oldIndex: currentIndex, newIndex: targetIndex } = evt; const params: DragSortContext = { currentIndex, - current: data[currentIndex], + current: props.data[currentIndex], targetIndex, - target: data[targetIndex], + target: props.data[targetIndex], currentData: swapDragArrayElement(props.data, currentIndex, targetIndex), e: evt, sort: 'row', diff --git a/src/table/hooks/useTreeData.tsx b/src/table/hooks/useTreeData.tsx index 580c0e4013..e4e6084650 100644 --- a/src/table/hooks/useTreeData.tsx +++ b/src/table/hooks/useTreeData.tsx @@ -5,7 +5,7 @@ import { AddRectangleIcon, MinusRectangleIcon } from 'tdesign-icons-vue'; import cloneDeep from 'lodash/cloneDeep'; import get from 'lodash/get'; import { CreateElement } from 'vue'; -import TableTreeStore from './tree-store'; +import TableTreeStore, { SwapParams } from './tree-store'; import { TdEnhancedTableProps, PrimaryTableCol, TableRowData, TableRowValue, TableRowState, } from '../type'; @@ -28,6 +28,13 @@ export default function useTreeData(props: TdEnhancedTableProps, context: SetupC childrenKey: props.tree?.childrenKey || 'children', })); + const checkedColumn = computed(() => columns.value.find((col) => col.colKey === 'row-select')); + + watch(checkedColumn, (column) => { + if (!store.value) return; + store.value.updateDisabledState(dataSource.value, column, rowDataKeys.value); + }); + function getFoldIcon(h: CreateElement) { const params = { type: 'fold' }; const defaultFoldIcon = t(global.value.treeExpandAndFoldIcon, h, params) || ; @@ -52,15 +59,15 @@ export default function useTreeData(props: TdEnhancedTableProps, context: SetupC if (!data) return []; // 如果没有树形解构,则不需要相关逻辑 if (!props.tree || !Object.keys(props.tree).length) { - // @ts-ignore dataSource.value = data; return; } - const newVal = cloneDeep(data); - // @ts-ignore - dataSource.value = newVal; - // @ts-ignore + let newVal = cloneDeep(data); store.value.initialTreeStore(newVal, props.columns, rowDataKeys.value); + if (props.tree?.defaultExpandAll) { + newVal = store.value.expandAll(newVal, rowDataKeys.value); + } + dataSource.value = newVal; }, { immediate: true }, ); @@ -95,23 +102,19 @@ export default function useTreeData(props: TdEnhancedTableProps, context: SetupC * 组件实例方法,展开或收起某一行 * @param p 行数据 */ - function toggleExpandData(p: { row: TableRowData; rowIndex: number; trigger?: 'inner' }) { - if (!props.tree) { - console.error('toggleExpandData can only be used in tree data.'); - return; - } + function toggleExpandData(p: { row: TableRowData; rowIndex: number }, trigger?: 'expand-fold-icon') { dataSource.value = store.value.toggleExpandData(p, dataSource.value, rowDataKeys.value); - if (p.trigger === 'inner') { - const rowValue = get(p.row, rowDataKeys.value.rowKey); - const params = { - row: p.row, - rowIndex: p.rowIndex, - rowState: store.value?.treeDataMap?.get(rowValue), - }; - props.onTreeExpandChange?.(params); - // Vue3 ignore next line - context.emit('tree-expand-change', params); - } + const rowValue = get(p.row, rowDataKeys.value.rowKey); + const rowState = store.value?.treeDataMap?.get(rowValue); + const params = { + row: p.row, + rowIndex: p.rowIndex, + rowState, + trigger, + }; + props.onTreeExpandChange?.(params); + // Vue3 ignore next line + context.emit('tree-expand-change', params); } function getTreeNodeColumnCol() { @@ -143,7 +146,7 @@ export default function useTreeData(props: TdEnhancedTableProps, context: SetupC return (
{!!childrenNodes.length && ( - toggleExpandData({ ...p, trigger: 'inner' })}> + toggleExpandData(p, 'expand-fold-icon')}> {iconNode} )} @@ -191,7 +194,7 @@ export default function useTreeData(props: TdEnhancedTableProps, context: SetupC */ function remove(key: TableRowValue) { // 引用传值,可自动更新 dataSource。(dataSource 本是内部变量,可以在任何地方进行任何改变) - dataSource.value = store.value.remove(key, dataSource.value, rowDataKeys.value); + dataSource.value = [...store.value.remove(key, dataSource.value, rowDataKeys.value)]; } /** @@ -201,26 +204,69 @@ export default function useTreeData(props: TdEnhancedTableProps, context: SetupC */ function appendTo(key: TableRowValue, newData: T) { // 引用传值,可自动更新 dataSource。(dataSource 本是内部变量,可以在任何地方进行任何改变) - dataSource.value = store.value.appendTo(key, newData, dataSource.value, rowDataKeys.value); + dataSource.value = [...store.value.appendTo(key, newData, dataSource.value, rowDataKeys.value)]; + } + + /** + * 当前节点之后,插入节点 + */ + function insertAfter(rowValue: TableRowValue, newData: T) { + dataSource.value = [...store.value.insertAfter(rowValue, newData, dataSource.value, rowDataKeys.value)]; } /** - * 设置展开行层级 + * 当前节点之后,插入节点 */ - // function setExpandedLevel(level: 1 | 2 | 3 | 4 | 5) { - // dataSource.value = store.value.setExpandedLevel(level, dataSource.value, rowDataKeys.value); - // } + function insertBefore(rowValue: TableRowValue, newData: T) { + dataSource.value = [...store.value.insertBefore(rowValue, newData, dataSource.value, rowDataKeys.value)]; + } + + /** + * 展开所有节点 + */ + function expandAll() { + dataSource.value = [...store.value.expandAll(dataSource.value, rowDataKeys.value)]; + } + + /** + * 收起所有节点 + */ + function foldAll() { + dataSource.value = [...store.value.foldAll(dataSource.value, rowDataKeys.value)]; + } + + /** + * 交换行数据 + */ + function swapData(params: SwapParams) { + const r = store.value.swapData(dataSource.value, params, rowDataKeys.value); + if (r.result) { + dataSource.value = [...r.dataSource]; + } else { + const params = { + code: r.code, + reason: r.reason, + }; + props.onAbnormalDragSort?.(params); + // Vue3 do not need next line + context.emit('abnormal-drag-sort', params); + } + } return { store, rowDataKeys, dataSource, + swapData, setData, getData, remove, appendTo, + insertAfter, + insertBefore, formatTreeColumn, toggleExpandData, - // setExpandedLevel, + expandAll, + foldAll, }; } diff --git a/src/table/type.ts b/src/table/type.ts index 29e6c554a2..6475bdaace 100644 --- a/src/table/type.ts +++ b/src/table/type.ts @@ -123,7 +123,7 @@ export interface TdBaseTableProps { rowClassName?: ClassName | ((params: RowClassNameParams) => ClassName); /** * 使用 rowKey 唯一标识一行数据 - * @default '' + * @default 'id' */ rowKey: string; /** @@ -491,13 +491,21 @@ export interface PrimaryTableCol export interface TdEnhancedTableProps extends TdPrimaryTableProps { /** - * 树形结构相关配置。`tree.indent` 表示树结点缩进距离,单位:px,默认为 24px。`tree.treeNodeColumnIndex` 表示树结点在第几列渲染,默认为 0 ,第一列。`tree.childrenKey` 表示树形结构子节点字段,默认为 children。`tree.checkStrictly` 表示树形结构的行选中(多选),父子行选中是否独立,默认独立,值为 true + * 树形结构中,拖拽排序前控制,返回值为 `true` 则继续排序;返回值为 `false` 则中止排序还原数据 + */ + beforeDragSort?: (context: DragSortContext) => boolean; + /** + * 树形结构相关配置。具体属性文档查看 `TableTreeConfig` 相关描述 */ tree?: TableTreeConfig; /** * 自定义树形结构展开图标,支持全局配置 `GlobalConfigProvider` */ treeExpandAndFoldIcon?: TNode<{ type: 'expand' | 'fold' }>; + /** + * 异常拖拽排序时触发,如:树形结构中,非同层级之间的交换。`context.code` 指交换异常错误码,固定值;`context.reason` 指交换异常的原因 + */ + onAbnormalDragSort?: (context: TableAbnormalDragSortContext) => void; /** * 树形结构,用户操作引起节点展开或收起时触发,代码操作不会触发 */ @@ -506,6 +514,14 @@ export interface TdEnhancedTableProps ext /** 组件实例方法 */ export interface EnhancedTableInstanceFunctions { + /** + * 展开全部行 + */ + expandAll: () => void; + /** + * 折叠全部行 + */ + foldAll: () => void; /** * 树形结构中,用于获取行数据所有信息。泛型 `T` 表示行数据类型 */ @@ -539,6 +555,10 @@ export interface TableRowState { * @default false */ expanded: boolean; + /** + * 唯一标识 + */ + id: string | number; /** * 当前节点层级 */ @@ -556,7 +576,7 @@ export interface TableRowState { */ row: T; /** - * 表格行下标 + * 表格行下标,值为 `-1` 标识当前行未展开显示 */ rowIndex: number; } @@ -650,6 +670,34 @@ export interface TableColumnController { placement?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; } +export interface TableTreeConfig { + /** + * 表示树形结构的行选中(多选),父子行选中是否独立 + * @default true + */ + checkStrictly?: boolean; + /** + * 树形结构子节点字段,示例:`childrenKey='list'`。一般应用在数据 `data` 的子节点字段不是 `children` 的场景 + * @default children + */ + childrenKey?: string; + /** + * 是否默认展开全部,仅默认情况有效。如果希望自由控制树形结构的展开或收起,可使用实例方法 `expandAll` 和 `foldAll` + * @default false + */ + defaultExpandAll?: boolean; + /** + * 树结点缩进距离,单位:px + * @default 24 + */ + indent?: number; + /** + * 树结点在第几列渲染,默认为第一列 + * @default 0 + */ + treeNodeColumnIndex?: number; +} + export type TableRowAttributes = | HTMLElementAttributes | ((params: { row: T; rowIndex: number; type: 'body' | 'foot' }) => HTMLElementAttributes) @@ -809,17 +857,16 @@ export type SorterFun = (a: T, b: T) => number; export type SortType = 'desc' | 'asc' | 'all'; -export interface TableTreeConfig { - indent?: number; - treeNodeColumnIndex?: number; - childrenKey?: 'children'; - checkStrictly?: boolean; +export interface TableAbnormalDragSortContext { + code: number; + reason: string; } export interface TableTreeExpandChangeContext { row: T; rowIndex: number; rowState: TableRowState; + trigger?: 'expand-fold-icon'; } export type TableRowValue = string | number; diff --git a/src/transfer/components/transfer-list.tsx b/src/transfer/components/transfer-list.tsx index 0c5fa7221b..6bd22fca4b 100644 --- a/src/transfer/components/transfer-list.tsx +++ b/src/transfer/components/transfer-list.tsx @@ -145,6 +145,14 @@ export default mixins(keepAnimationMixins).extend({ return getLeafCount(this.dataSource); }, }, + watch: { + totalCount(val) { + if (val <= (this.currentPage - 1) * this.pageSize) { + const lastPage = Math.ceil(val / this.pageSize); + this.defaultCurrent = lastPage; + } + }, + }, methods: { handlePaginationChange(pageInfo: PageInfo): void { this.$emit('pageChange', pageInfo); diff --git a/src/tree-select/tree-select.tsx b/src/tree-select/tree-select.tsx index b366711123..ff04741680 100644 --- a/src/tree-select/tree-select.tsx +++ b/src/tree-select/tree-select.tsx @@ -214,6 +214,10 @@ export default mixins(getConfigReceiverMixins('treeSelect } return 'value'; }, + realChildren(): string { + const { treeProps } = this; + return treeProps?.keys?.children || 'children'; + }, tagList(): Array { if (this.nodeInfo && isArray(this.nodeInfo)) { return this.nodeInfo.map((node) => node.label); @@ -381,7 +385,7 @@ export default mixins(getConfigReceiverMixins('treeSelect if (data[i][this.realValue] === targetValue) { return { label: data[i][this.realLabel], value: data[i][this.realValue] }; } - const childrenData = data[i]?.children; + const childrenData = data[i][this.realChildren]; if (childrenData) { const data = Array.isArray(childrenData) ? childrenData : this.getTreeData(); const result = this.getTreeNode(data, targetValue); diff --git a/src/watermark/props.ts b/src/watermark/props.ts new file mode 100644 index 0000000000..c73c18af93 --- /dev/null +++ b/src/watermark/props.ts @@ -0,0 +1,79 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdWatermarkProps } from './type'; +import { PropType } from 'vue'; + +export default { + /** 水印整体透明度,取值范围 [0-1] */ + alpha: { + type: Number, + default: 1, + }, + /** 水印所覆盖的内容节点 */ + content: { + type: [String, Function] as PropType, + }, + /** 水印所覆盖的内容节点,同 `content` */ + default: { + type: [String, Function] as PropType, + }, + /** 水印高度 */ + height: { + type: Number, + }, + /** 水印是否重复出现 */ + isRepeat: { + type: Boolean, + default: true, + }, + /** 行间距,只作用在多行(`content` 配置为数组)情况下 */ + lineSpace: { + type: Number, + default: 16, + }, + /** 水印是否可移动 */ + movable: Boolean, + /** 水印发生运动位移的间隙,单位:毫秒 */ + moveInterval: { + type: Number, + default: 3000, + }, + /** 水印在画布上绘制的水平和垂直偏移量,正常情况下水印绘制在中间位置,即 `offset = [gapX / 2, gapY / 2]` */ + offset: { + type: Array as PropType, + }, + /** 水印是否可被删除,默认会开启水印节点防删 */ + removable: { + type: Boolean, + default: true, + }, + /** 水印旋转的角度,单位 ° */ + rotate: { + type: Number, + default: -22, + }, + /** 水印内容,需要显示多行情况下可配置为数组 */ + watermarkContent: { + type: [Object, Array] as PropType, + }, + /** 水印宽度 */ + width: { + type: Number, + }, + /** 水印之间的水平间距 */ + x: { + type: Number, + }, + /** 水印之间的垂直间距 */ + y: { + type: Number, + }, + /** 水印元素的 `z-index`,默认值写在 CSS 中 */ + zIndex: { + type: Number, + }, +}; diff --git a/src/watermark/type.ts b/src/watermark/type.ts new file mode 100644 index 0000000000..abfefdf711 --- /dev/null +++ b/src/watermark/type.ts @@ -0,0 +1,117 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TNode } from '../common'; + +export interface TdWatermarkProps { + /** + * 水印整体透明度,取值范围 [0-1] + * @default 1 + */ + alpha?: number; + /** + * 水印所覆盖的内容节点 + */ + content?: string | TNode; + /** + * 水印所覆盖的内容节点,同 `content` + */ + default?: string | TNode; + /** + * 水印高度 + */ + height?: number; + /** + * 水印是否重复出现 + * @default true + */ + isRepeat?: boolean; + /** + * 行间距,只作用在多行(`content` 配置为数组)情况下 + * @default 16 + */ + lineSpace?: number; + /** + * 水印是否可移动 + * @default false + */ + movable?: boolean; + /** + * 水印发生运动位移的间隙,单位:毫秒 + * @default 3000 + */ + moveInterval?: number; + /** + * 水印在画布上绘制的水平和垂直偏移量,正常情况下水印绘制在中间位置,即 `offset = [gapX / 2, gapY / 2]` + */ + offset?: Array; + /** + * 水印是否可被删除,默认会开启水印节点防删 + * @default true + */ + removable?: boolean; + /** + * 水印旋转的角度,单位 ° + * @default -22 + */ + rotate?: number; + /** + * 水印内容,需要显示多行情况下可配置为数组 + */ + watermarkContent?: WatermarkText | WatermarkImage | Array; + /** + * 水印宽度 + */ + width?: number; + /** + * 水印之间的水平间距 + */ + x?: number; + /** + * 水印之间的垂直间距 + */ + y?: number; + /** + * 水印元素的 `z-index`,默认值写在 CSS 中 + */ + zIndex?: number; +} + +export interface WatermarkText { + /** + * 水印文本文字颜色 + * @default rgba(0,0,0,0.1) + */ + fontColor?: string; + /** + * 水印文本文字大小 + * @default 16 + */ + fontSize?: number; + /** + * 水印文本文字粗细 + * @default normal + */ + fontWeight?: 'normal' | 'lighter' | 'bold' | 'bolder'; + /** + * 水印文本内容 + * @default '' + */ + text?: string; +} + +export interface WatermarkImage { + /** + * 水印图片是否需要灰阶显示 + * @default false + */ + isGrayscale?: boolean; + /** + * 水印图片源地址,为了显示清楚,建议导出 2 倍或 3 倍图 + * @default '' + */ + url?: string; +} diff --git a/test/ssr/__snapshots__/ssr.test.js.snap b/test/ssr/__snapshots__/ssr.test.js.snap index 7a97d4bfad..3b75dace36 100644 --- a/test/ssr/__snapshots__/ssr.test.js.snap +++ b/test/ssr/__snapshots__/ssr.test.js.snap @@ -2223,7 +2223,7 @@ exports[`ssr snapshot test renders ./examples/calendar/demos/slot-props-api.vue exports[`ssr snapshot test renders ./examples/calendar/demos/value.vue correctly 1`] = `
-
+
@@ -2231,10 +2231,9 @@ exports[`ssr snapshot test renders ./examples/calendar/demos/value.vue correctly
-
-
+
@@ -2242,7 +2241,6 @@ exports[`ssr snapshot test renders ./examples/calendar/demos/value.vue correctly
-
@@ -3420,7 +3418,7 @@ exports[`ssr snapshot test renders ./examples/config-provider/demos/global.vue c exports[`ssr snapshot test renders ./examples/config-provider/demos/others.vue correctly 1`] = `
-
+
@@ -3428,10 +3426,9 @@ exports[`ssr snapshot test renders ./examples/config-provider/demos/others.vue c
-
-
+
@@ -3439,7 +3436,6 @@ exports[`ssr snapshot test renders ./examples/config-provider/demos/others.vue c
-


@@ -4395,7 +4391,7 @@ exports[`ssr snapshot test renders ./examples/form/demos/align.vue correctly 1`]
-
+
@@ -4403,10 +4399,9 @@ exports[`ssr snapshot test renders ./examples/form/demos/align.vue correctly 1`]
-
-
+
@@ -4414,7 +4409,6 @@ exports[`ssr snapshot test renders ./examples/form/demos/align.vue correctly 1`]
-
@@ -4424,7 +4418,7 @@ exports[`ssr snapshot test renders ./examples/form/demos/align.vue correctly 1`] exports[`ssr snapshot test renders ./examples/form/demos/base.vue correctly 1`] = `
-
+
@@ -4432,10 +4426,9 @@ exports[`ssr snapshot test renders ./examples/form/demos/base.vue correctly 1`]
-
-
+
@@ -4443,10 +4436,9 @@ exports[`ssr snapshot test renders ./examples/form/demos/base.vue correctly 1`]
-
-
+
@@ -4454,32 +4446,28 @@ exports[`ssr snapshot test renders ./examples/form/demos/base.vue correctly 1`]
-
-
+
-
-
+
-
-
+
-
@@ -4489,7 +4477,7 @@ exports[`ssr snapshot test renders ./examples/form/demos/base.vue correctly 1`] exports[`ssr snapshot test renders ./examples/form/demos/clear-validate.vue correctly 1`] = `
-