mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
refactor(components): [pagination/prev] switch to script-setup syntax (#7745)
* refactor(components): [pagination/prev] switch to script-setup syntax * fix(components): [pagination/prev] cast props to const * fix(components): [pagination/prev] extract emits to utility file * fix(components): [pagination/prev] remove prop default Co-authored-by: metanas <matanas@pre-history.com>
This commit is contained in:
22
packages/components/pagination/src/components/prev.ts
Normal file
22
packages/components/pagination/src/components/prev.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { buildProps } from '@element-plus/utils'
|
||||
import type { ExtractPropTypes } from 'vue'
|
||||
import type Prev from './prev.vue'
|
||||
|
||||
export const paginationPrevProps = buildProps({
|
||||
disabled: Boolean,
|
||||
currentPage: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
prevText: {
|
||||
type: String,
|
||||
},
|
||||
} as const)
|
||||
|
||||
export const paginationPrevEmits = {
|
||||
click: (evt: MouseEvent) => evt instanceof MouseEvent,
|
||||
}
|
||||
|
||||
export type PaginationPrevProps = ExtractPropTypes<typeof paginationPrevProps>
|
||||
|
||||
export type PrevInstance = InstanceType<typeof Prev>
|
||||
@@ -11,40 +11,20 @@
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { computed, defineComponent } from 'vue'
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue'
|
||||
import { ElIcon } from '@element-plus/components/icon'
|
||||
import { ArrowLeft } from '@element-plus/icons-vue'
|
||||
import { paginationPrevEmits, paginationPrevProps } from './prev'
|
||||
|
||||
const paginationPrevProps = {
|
||||
disabled: Boolean,
|
||||
currentPage: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
prevText: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
} as const
|
||||
|
||||
export default defineComponent({
|
||||
defineOptions({
|
||||
name: 'ElPaginationPrev',
|
||||
|
||||
components: {
|
||||
ElIcon,
|
||||
ArrowLeft,
|
||||
},
|
||||
props: paginationPrevProps,
|
||||
emits: ['click'],
|
||||
|
||||
setup(props) {
|
||||
const internalDisabled = computed(
|
||||
() => props.disabled || props.currentPage <= 1
|
||||
)
|
||||
return {
|
||||
internalDisabled,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const props = defineProps(paginationPrevProps)
|
||||
defineEmits(paginationPrevEmits)
|
||||
|
||||
const internalDisabled = computed(
|
||||
() => props.disabled || props.currentPage <= 1
|
||||
)
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user