diff --git a/packages/components/table/src/table.ts b/packages/components/table/src/table.ts index 12274792..e773f799 100644 --- a/packages/components/table/src/table.ts +++ b/packages/components/table/src/table.ts @@ -2,12 +2,34 @@ import { buildProps } from '@puik/utils' import type { ExtractPropTypes, PropType } from 'vue' import type Table from './table.vue' +export enum PuikTableSortOrder { + Asc = 'ASC', + Desc = 'DESC', +} + +export enum PuikTableSortIcon { + Default = 'unfold_more', + Asc = 'expand_more', + Desc = 'expand_less', +} + +export enum PuikTableScrollBarPosistion { + Left = 'left', + Right = 'right', + IsScrolling = 'isScrolling', +} + +export type sortOption = { + sortBy?: string + sortOrder?: PuikTableSortOrder +} export interface PuikTableHeader { value: string text?: string size?: 'sm' | 'md' | 'lg' align?: 'left' | 'center' | 'right' width?: string + sortable?: boolean } export const tableProps = buildProps({ @@ -35,6 +57,11 @@ export const tableProps = buildProps({ required: false, default: () => [], }, + sortFromServer: { + type: Boolean, + required: false, + default: false, + }, fullWidth: { type: Boolean, required: false, diff --git a/packages/components/table/src/table.vue b/packages/components/table/src/table.vue index 396bf713..6f1ba93d 100644 --- a/packages/components/table/src/table.vue +++ b/packages/components/table/src/table.vue @@ -11,8 +11,9 @@ { 'puik-table__head__row__item--sticky-scroll': stickyFirstCol && - (ScrollBarPosition === 'isScrolling' || - ScrollBarPosition === 'right'), + (ScrollBarPosition === + PuikTableScrollBarPosistion.IsScrolling || + ScrollBarPosition === PuikTableScrollBarPosistion.Right), }, { 'puik-table__head__row__item--selection': selectable }, { 'puik-table__head__row__item--expandable': expandable }, @@ -40,34 +41,55 @@ [`puik-table__head__row__item--${header.size}`]: header?.size && !header?.width, }, + { + 'puik-table__head__row__item--sortable': header?.sortable, + }, { 'puik-table__head__row__item--sticky': isSticky(index) }, { 'puik-table__head__row__item--sticky-scroll': - isSticky(index) && ScrollBarPosition === 'isScrolling', + isSticky(index) && + ScrollBarPosition === PuikTableScrollBarPosistion.IsScrolling, }, { 'puik-table__head__row__item--sticky-left': - isSticky(index) && ScrollBarPosition === 'left', + isSticky(index) && + ScrollBarPosition === PuikTableScrollBarPosistion.Left, }, { 'puik-table__head__row__item--sticky-right': - isSticky(index) && ScrollBarPosition === 'right', + isSticky(index) && + ScrollBarPosition === PuikTableScrollBarPosistion.Right, }, ]" :style="{ minWidth: header.width, width: header.width }" > - - {{ header.text }} - +
+
+ + + {{ header?.text || header?.value }} + + + +
+
-