Skip to content

Commit

Permalink
chore(button, divider): add withDefault (#2900)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Jan 30, 2024
1 parent 2f641f0 commit 759f9b3
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 114 deletions.
61 changes: 23 additions & 38 deletions src/packages/__VUE/button/button.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</template>

<script setup lang="ts">
import { PropType, CSSProperties, toRefs, computed } from 'vue';
import { CSSProperties, toRefs, computed } from 'vue';
import { Loading } from '@nutui/icons-vue-taro';
import Taro from '@tarojs/taro';
import type { ButtonShape, ButtonType, ButtonSize, ButtonFormType } from './types';
Expand All @@ -26,43 +26,28 @@ defineOptions({
name: 'NutButton'
});
const props = defineProps({
color: {
type: String,
default: ''
},
shape: {
type: String as PropType<ButtonShape>,
default: 'round'
},
plain: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
type: {
type: String as PropType<ButtonType>,
default: 'default'
},
formType: {
type: String as PropType<ButtonFormType>,
default: 'button'
},
size: {
type: String as PropType<ButtonSize>,
default: 'normal'
},
block: {
type: Boolean,
default: false
}
export type ButtonProps = Partial<{
color: string;
shape: ButtonShape;
plain: boolean;
loading: boolean;
disabled: boolean;
type: ButtonType;
size: ButtonSize;
block: boolean;
formType: ButtonFormType;
}>;
const props = withDefaults(defineProps<ButtonProps>(), {
color: '',
shape: 'round',
plain: false,
loading: false,
disabled: false,
type: 'default',
size: 'normal',
block: false,
formType: 'button'
});
const emit = defineEmits(['click']);
Expand Down
55 changes: 21 additions & 34 deletions src/packages/__VUE/button/button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,34 @@
</template>

<script setup lang="ts">
import { PropType, CSSProperties, toRefs, computed } from 'vue';
import { CSSProperties, toRefs, computed } from 'vue';
import type { ButtonShape, ButtonType, ButtonSize } from './types';
import { Loading } from '@nutui/icons-vue';
defineOptions({
name: 'NutButton'
});
const props = defineProps({
color: {
type: String,
default: ''
},
shape: {
type: String as PropType<ButtonShape>,
default: 'round'
},
plain: {
type: Boolean,
default: false
},
loading: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
type: {
type: String as PropType<ButtonType>,
default: 'default'
},
size: {
type: String as PropType<ButtonSize>,
default: 'normal'
},
block: {
type: Boolean,
default: false
}
export type ButtonProps = Partial<{
color: string;
shape: ButtonShape;
plain: boolean;
loading: boolean;
disabled: boolean;
type: ButtonType;
size: ButtonSize;
block: boolean;
}>;
const props = withDefaults(defineProps<ButtonProps>(), {
color: '',
shape: 'round',
plain: false,
loading: false,
disabled: false,
type: 'default',
size: 'normal',
block: false
});
const emit = defineEmits(['click']);
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/button/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ The color of the button can be customized through the color property.
| --- | --- | --- |
| click | Emitted when component is clicked | `event: MouseEvent` |

### Types v4.2.9
### Types v4.3.0

The component exports the following type definitions:

Expand All @@ -102,6 +102,7 @@ import type {
ButtonSize,
ButtonShape,
ButtonFormType,
ButtonProps,
ButtonInstance
} from '@nutui/nutui';
```
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/button/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ app.use(Button);
| --- | --- | --- |
| click | 点击按钮时触发 | `event: MouseEvent` |

### 类型定义 v4.2.9
### 类型定义 v4.3.0

组件导出以下类型定义:

Expand All @@ -102,6 +102,7 @@ import type {
ButtonSize,
ButtonShape,
ButtonFormType,
ButtonProps,
ButtonInstance
} from '@nutui/nutui';
```
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/button/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ app.use(Button);
| --- | --- | --- |
| click | 点击按钮时触发 | `event: MouseEvent` |

### 类型定义 v4.2.9
### 类型定义 v4.3.0

组件导出以下类型定义:

Expand All @@ -103,6 +103,7 @@ import type {
ButtonSize,
ButtonShape,
ButtonFormType,
ButtonProps,
ButtonInstance
} from '@nutui/nutui-taro';
```
Expand Down
2 changes: 2 additions & 0 deletions src/packages/__VUE/button/index.taro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { withInstall } from '@/packages/utils';

withInstall(Button);

export type { ButtonProps } from './button.taro.vue';

export type { ButtonType, ButtonSize, ButtonShape, ButtonFormType } from './types';

export type ButtonInstance = ComponentPublicInstance & InstanceType<typeof Button>;
Expand Down
2 changes: 2 additions & 0 deletions src/packages/__VUE/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { withInstall } from '@/packages/utils';

withInstall(Button);

export type { ButtonProps } from './button.vue';

export type { ButtonType, ButtonSize, ButtonShape, ButtonFormType } from './types';

export type ButtonInstance = ComponentPublicInstance & InstanceType<typeof Button>;
Expand Down
31 changes: 13 additions & 18 deletions src/packages/__VUE/divider/divider.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,25 @@
</view>
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue';
import { computed } from 'vue';
import { DividerDirection, DividerPosition } from './types';
defineOptions({
name: 'NutDivider'
});
const props = defineProps({
contentPosition: {
type: String as PropType<DividerPosition>,
default: 'center'
},
dashed: {
type: Boolean,
default: false
},
hairline: {
type: Boolean,
default: true
},
direction: {
type: String as PropType<DividerDirection>,
default: 'horizontal'
}
export type DividerProps = Partial<{
contentPosition: DividerPosition;
dashed: boolean;
hairline: boolean;
direction: DividerDirection;
}>;
const props = withDefaults(defineProps<DividerProps>(), {
contentPosition: 'center',
dashed: false,
hairline: true,
direction: 'horizontal'
});
const slots = defineSlots();
Expand Down
31 changes: 13 additions & 18 deletions src/packages/__VUE/divider/divider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,25 @@
</view>
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue';
import { computed } from 'vue';
import { DividerDirection, DividerPosition } from './types';
defineOptions({
name: 'NutDivider'
});
const props = defineProps({
contentPosition: {
type: String as PropType<DividerPosition>,
default: 'center'
},
dashed: {
type: Boolean,
default: false
},
hairline: {
type: Boolean,
default: true
},
direction: {
type: String as PropType<DividerDirection>,
default: 'horizontal'
}
export type DividerProps = Partial<{
contentPosition: DividerPosition;
dashed: boolean;
hairline: boolean;
direction: DividerDirection;
}>;
const props = withDefaults(defineProps<DividerProps>(), {
contentPosition: 'center',
dashed: false,
hairline: true,
direction: 'horizontal'
});
const slots = defineSlots();
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/divider/doc.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ User can custom divider style with style attribute.
| --- | --- |
| default | Default slot, when `direction` = `horizontal` |

### Types v4.2.9
### Types v4.3.0

The component exports the following type definitions:

```js
import type {
DividerPosition,
DividerDirection,
DividerProps,
DividerInstance
} from '@nutui/nutui';
```
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/divider/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ app.use(Divider);
| --- | --- |
| default | 内容,仅在 `direction``horizontal` 时生效 |

### 类型定义 v4.2.9
### 类型定义 v4.3.0

组件导出以下类型定义:

```js
import type {
DividerPosition,
DividerDirection,
DividerProps,
DividerInstance
} from '@nutui/nutui';
```
Expand Down
3 changes: 2 additions & 1 deletion src/packages/__VUE/divider/doc.taro.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ app.use(Divider);
| --- | --- |
| default | 内容,仅在 `direction``horizontal` 时生效 |

### 类型定义 v4.2.9
### 类型定义 v4.3.0

组件导出以下类型定义:

```js
import type {
DividerPosition,
DividerDirection,
DividerProps,
DividerInstance
} from '@nutui/nutui-taro';
```
Expand Down
2 changes: 2 additions & 0 deletions src/packages/__VUE/divider/index.taro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { withInstall } from '@/packages/utils';

withInstall(Divider);

export type { DividerProps } from './divider.taro.vue';

export type { DividerPosition, DividerDirection } from './types';

export type DividerInstance = ComponentPublicInstance & InstanceType<typeof Divider>;
Expand Down
2 changes: 2 additions & 0 deletions src/packages/__VUE/divider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { withInstall } from '@/packages/utils';

withInstall(Divider);

export type { DividerProps } from './divider.vue';

export type { DividerPosition, DividerDirection } from './types';

export type DividerInstance = ComponentPublicInstance & InstanceType<typeof Divider>;
Expand Down

0 comments on commit 759f9b3

Please sign in to comment.