Skip to content

Commit

Permalink
refactor(kottiPagination): add prop types, zod schema and add to expo…
Browse files Browse the repository at this point in the history
…rted kotti types
  • Loading branch information
Isokaeder committed Oct 14, 2021
1 parent ec52a7d commit 7364b8a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
22 changes: 7 additions & 15 deletions packages/kotti-ui/source/kotti-pagination/KtPagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,24 @@
import { Yoco } from '@3yourmind/yoco'
import { computed, defineComponent, ref } from '@vue/composition-api'
import { makeProps } from '../make-props'
import PaginationExpanded from './components/PaginationExpanded.vue'
import PaginationFlexible from './components/PaginationFlexible.vue'
import PaginationFractionated from './components/PaginationFractionated.vue'
import { KottiPagination } from './types'
export default defineComponent<{
adjacentAmount: number
fixedWidth: boolean
fractionStyle: boolean
page: number
pageSize: number
pagingStyle: 'default' | 'flex' | 'fraction'
total: number
}>({
export default defineComponent<
KottiPagination.PropsInternal & { fractionStyle: boolean }
>({
name: 'KtPagination',
components: {
PaginationExpanded,
PaginationFlexible,
PaginationFractionated,
},
props: {
adjacentAmount: { type: Number, default: 1 },
fixedWidth: { type: Boolean, default: false },
page: { type: Number, default: 1 },
pageSize: { type: Number, default: 10 },
pagingStyle: { type: String, default: 'expand' },
total: { type: Number, required: true },
...makeProps(KottiPagination.propsSchema),
/**
* @deprecated
Expand Down
6 changes: 5 additions & 1 deletion packages/kotti-ui/source/kotti-pagination/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { MetaDesignType } from '../types/kotti'
import { attachMeta, makeInstallable } from '../utilities'

import KtPaginationVue from './KtPagination.vue'
import { KottiPagination } from './types'

export const KtPagination = attachMeta(makeInstallable(KtPaginationVue), {
addedVersion: '0.0.6',
Expand All @@ -11,5 +12,8 @@ export const KtPagination = attachMeta(makeInstallable(KtPaginationVue), {
url: 'https://www.figma.com/file/0yFVivSWXgFf2ddEF92zkf/Kotti-Design-System?node-id=101%3A1106',
},
slots: {},
typeScript: null,
typeScript: {
namespace: 'KottiPagination',
schema: KottiPagination.propsSchema,
},
})
21 changes: 21 additions & 0 deletions packages/kotti-ui/source/kotti-pagination/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { z } from 'zod'

export namespace KottiPagination {
export enum PagingStyle {
DEFAULT = 'default',
FLEX = 'flex',
FRACTION = 'fraction',
}

export const propsSchema = z.object({
adjacentAmount: z.number().nullable().default(null),
fixedWidth: z.boolean().nullable().default(null),
page: z.number().nullable().default(null),
pageSize: z.number().nullable().default(null),
pagingStyle: z.nativeEnum(PagingStyle).nullable().default(null),
total: z.number(),
})

export type PropsInternal = z.output<typeof propsSchema>
export type Props = z.input<typeof propsSchema>
}
1 change: 1 addition & 0 deletions packages/kotti-ui/source/types/kotti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export { KottiI18n as I18n } from '../kotti-i18n/types'
export { KottiLine as Line } from '../kotti-line/types'
export { KottiModal as Modal } from '../kotti-modal/types'
export { KottiNavbar as Navbar } from '../kotti-navbar/types'
export { KottiPagination as Pagination } from '../kotti-pagination/types'
export { KottiPopover as Popover } from '../kotti-popover/types'
export { KottiRow as Row } from '../kotti-row/types'

Expand Down

0 comments on commit 7364b8a

Please sign in to comment.