Skip to content

Commit 5431262

Browse files
authored
Merge pull request #1749 from DevCloudFE/dev
feat(button&pagniation): 按钮增加nativeType参数&&pagniation增加最大分页数参数 (#1748)
2 parents fcdb1fa + fdf3c6d commit 5431262

File tree

7 files changed

+33
-11
lines changed

7 files changed

+33
-11
lines changed

Diff for: packages/devui-vue/devui/button/src/button-types.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import type { ComputedRef, ExtractPropTypes, PropType ,InjectionKey, Ref } from 'vue';
1+
import type { ComputedRef, ExtractPropTypes, PropType, InjectionKey, Ref } from 'vue';
22

33
export type IButtonVariant = 'solid' | 'outline' | 'text';
44
export type IButtonColor = 'secondary' | 'primary' | 'danger';
55
export type IButtonSize = 'lg' | 'md' | 'sm';
66
export type IButtonShape = 'round' | 'circle';
7+
export type IButtonType = 'button' | 'submit' | 'reset';
78

89
export const buttonProps = {
910
variant: {
@@ -31,14 +32,18 @@ export const buttonProps = {
3132
},
3233
shape: {
3334
type: String as PropType<IButtonShape>,
34-
}
35+
},
36+
nativeType: {
37+
type: String as PropType<IButtonType>,
38+
default: 'button',
39+
},
3540
} as const;
3641

3742
export const buttonGroupProps = {
3843
size: {
3944
type: String as PropType<IButtonSize>,
4045
default: 'md',
41-
}
46+
},
4247
} as const;
4348

4449
export type ButtonProps = ExtractPropTypes<typeof buttonProps>;
@@ -55,6 +60,4 @@ interface ButtonGroupInjection {
5560
size: Ref<IButtonSize>;
5661
}
5762

58-
export const buttonGroupInjectionKey: InjectionKey<ButtonGroupInjection> =
59-
Symbol('d-button-group');
60-
63+
export const buttonGroupInjectionKey: InjectionKey<ButtonGroupInjection> = Symbol('d-button-group');

Diff for: packages/devui-vue/devui/button/src/button.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineComponent({
1414
props: buttonProps,
1515
emits: ['click'],
1616
setup(props: ButtonProps, ctx: SetupContext) {
17-
const { icon, disabled, loading } = toRefs(props);
17+
const { icon, disabled, loading, nativeType } = toRefs(props);
1818
const { classes, iconClass } = useButton(props, ctx);
1919

2020
const onClick = (e: MouseEvent) => {
@@ -26,7 +26,7 @@ export default defineComponent({
2626

2727
return () => {
2828
return (
29-
<button class={classes.value} disabled={disabled.value} onClick={onClick}>
29+
<button class={classes.value} disabled={disabled.value} onClick={onClick} type={nativeType.value}>
3030
{icon.value && <Icon name={icon.value} size="var(--devui-font-size, 12px)" color="" class={iconClass.value} />}
3131
<div class="loading-icon__container" v-show={loading.value}>
3232
<d-icon name="icon-loading" class="button-icon-loading" color="#BBDEFB"></d-icon>

Diff for: packages/devui-vue/devui/pagination/src/pagination-types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ export const paginationProps = {
9999
onPageSizeChange: {
100100
type: Function as PropType<(v: number) => void>,
101101
},
102+
maxPage: {
103+
type: Number,
104+
default: 0,
105+
},
102106
} as const;
103107

104108
// 组件props

Diff for: packages/devui-vue/devui/pagination/src/pagination.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ export default defineComponent({
4343
pageIndex,
4444
showJumpButton,
4545
haveConfigMenu,
46+
maxPage,
4647
} = toRefs(props);
4748
const ns = useNamespace('pagination');
4849

4950
// 总页数
50-
const totalPages = computed(() => Math.ceil(props.total / props.pageSize));
51+
const totalPages = computed(() => {
52+
if (maxPage.value) {
53+
return Math.min(Math.ceil(props.total / props.pageSize), maxPage.value);
54+
}
55+
return Math.ceil(props.total / props.pageSize);
56+
});
5157

5258
// 极简模式下,可选的下拉选择页码
5359
const litePageOptions = computed(() => liteSelectOptions(totalPages.value));

Diff for: packages/devui-vue/docs/components/button/index.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ button/buttonGroup
7575
| shape | [IButtonShape](#ibuttonshape) | -- | 可选,按钮形状(圆形/圆角) | [图标按钮](#图标按钮) |
7676
| disabled | `boolean` | false | 可选,是否禁用 button | [禁用状态](#禁用状态) |
7777
| loading | `boolean` | false | 可选,设置加载中状态 | [加载中状态](#加载中状态) |
78+
| native-type | [IButtonType](#ibuttontype) | 'button' | 可选,按钮原生type属性 | |
7879

7980
### Button 类型定义
8081

@@ -102,11 +103,17 @@ type IButtonColor = 'primary' | 'secondary' | 'danger';
102103
type IButtonShape = 'circle' | 'round';
103104
```
104105

106+
#### IButtonType
107+
108+
```ts
109+
type IButtonType = 'button' | 'submit' | 'reset';
110+
```
111+
105112
### ButtonGroup 参数
106113

107114
| 参数名 | 类型 | 默认 | 说明 | 跳转 Demo |
108115
| :----- | :------------------------------- | :--- | :--------------- | :---------------- |
109-
| size | [IButtonSize](#iButtonGroupSize) | 'md' | 可选,按钮组尺寸 | [按钮组](#按钮组) |
116+
| size | [IButtonSize](#ibuttongroupsize) | 'md' | 可选,按钮组尺寸 | [按钮组](#按钮组) |
110117

111118
### ButtonGroup 类型定义
112119

Diff for: packages/devui-vue/docs/components/pagination/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
go-to-text="Jump to"
5959
:pre-link="preLink"
6060
:next-link="nextLink"
61+
:max-page="20"
6162
/>
6263
</template>
6364
<script>
@@ -442,6 +443,7 @@ export default defineComponent({
442443
| have-config-menu | `boolean` | false | 可选,`极简模式`下是否显示配置 | [极简模式](#极简模式) |
443444
| auto-fix-page-index | `boolean` | true | 可选,改变 pageSize 时是否自动修正页码,<br>若`pageSizeChange`事件中会对<br>`pageIndex`做处理,则推荐设置为`false` | [极简模式](#极简模式) |
444445
| auto-hide | `boolean` | false | 可选,是否自动隐藏,<br>当 auto-hide 为 true,<br>并且 pageSizeOptions 最小值大于 total,<br>则不展示分页 | [极简模式](#极简模式) |
446+
| max-page | `number` | -- | 可选,可展示的分页最大页数 | [基本用法](#基本用法) |
445447

446448
### Pagination 事件
447449

Diff for: packages/devui-vue/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-devui",
3-
"version": "1.5.15-hotfix.3",
3+
"version": "1.5.15-hotfix.4",
44
"license": "MIT",
55
"description": "DevUI components based on Vite and Vue3",
66
"keywords": [

0 commit comments

Comments
 (0)