MDK Logo

Types

TypeScript types for type-safe development

Types

The @mdk/core package exports TypeScript types for type-safe development.

Import

import type {
  ComponentSize,
  ButtonVariant,
  ColorVariant,
  Status,
  ApiResponse,
} from '@mdk/core'

Common types

Component size

The ComponentSize type defines standard size variants used across multiple components.

type ComponentSize = 'sm' | 'md' | 'lg'

Used by: Button, Badge, Checkbox, Switch, Radio, Spinner, Indicator, EmptyState, Pagination

Button size

The ButtonSize type extends component size with an icon-only variant.

type ButtonSize = ComponentSize | 'icon'

Border radius

The BorderRadius type defines border radius variants for form components.

type BorderRadius = 'none' | 'small' | 'medium' | 'large' | 'full'

Used by: Checkbox, Switch, Radio

Color variant

The ColorVariant type provides comprehensive color variants for components.

type ColorVariant =
  | 'default'
  | 'primary'
  | 'secondary'
  | 'success'
  | 'warning'
  | 'error'
  | 'info'

Status variant

The StatusVariant type defines status variants for state indication.

type StatusVariant = 'success' | 'processing' | 'error' | 'warning' | 'default' | 'idle'

Used by: badges, notifications, status indicators

Component color

The ComponentColor type defines color options for form components.

type ComponentColor = 'default' | 'primary' | 'success' | 'warning' | 'error'

Used by: Checkbox, Switch, Radio, Typography

Position

Position/side options for UI elements.

type Position = 'top' | 'right' | 'bottom' | 'left'

Used by: Tooltip, Popover, chart legends

Text align

The TextAlign type defines text alignment options.

type TextAlign = 'left' | 'center' | 'right' | 'justify'

Flex align

The FlexAlign type defines flex/grid alignment options.

type FlexAlign = 'start' | 'center' | 'end'

Component types

Button variant

The ButtonVariant type defines button visual variants.

type ButtonVariant =
  | 'primary'
  | 'secondary'
  | 'danger'
  | 'tertiary'
  | 'link'
  | 'icon'
  | 'outline'
  | 'ghost'

Button icon position

The ButtonIconPosition type defines where icons appear in buttons.

type ButtonIconPosition = 'left' | 'right'

Notification variant

The NotificationVariant type defines toast/notification variants.

type NotificationVariant = 'success' | 'error' | 'warning' | 'info'

Badge status

The BadgeStatus type defines badge status options.

type BadgeStatus = 'success' | 'processing' | 'error' | 'warning' | 'default'

Typography color

The TypographyColor type defines typography color options including muted.

type TypographyColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'muted'

Utility types

Unknown record

The UnknownRecord type is a generic type for objects with unknown structure.

type UnknownRecord = Record<string, unknown>

Nullable / Optional / Maybe

Null/undefined wrapper types.

type Nullable<T> = T | null
type Optional<T> = T | undefined
type Maybe<T> = T | null | undefined

Status

Async operation status.

type Status = 'idle' | 'loading' | 'success' | 'error'

API types

Pagination params

The PaginationParams type defines pagination request parameters.

type PaginationParams = {
  limit?: number
  offset?: number
  page?: number
}

Paginated response

The PaginatedResponse type is a paginated response wrapper.

type PaginatedResponse<T> = {
  data: T[]
  page: number
  total: number
  totalPages: number
}

API response

The ApiResponse type is an API response wrapper.

type ApiResponse<T> = {
  data: T
  message?: string
  status: number
}

API error

The ApiError type defines API error response structure.

type ApiError = {
  error: string
  message: string
  status: number
  data?: {
    message?: string
  }
}

Data table types

Re-exported from TanStack Table for convenience.

import type {
  DataTableColumnDef,
  DataTableExpandedState,
  DataTablePaginationState,
  DataTableRow,
  DataTableRowSelectionState,
  DataTableSortingState,
} from '@mdk/core'

Value types

Value unit

The ValueUnit type represents a value with unit for display formatting.

type ValueUnit = {
  value: number | string | null
  unit: string
  realValue: number
}

Hashrate unit / Currency unit

The HashrateUnit and CurrencyUnit types are specialized value-unit types.

type HashrateUnit = ValueUnit
type CurrencyUnit = ValueUnit

Unit label

The UnitLabel type defines SI-prefix unit labels.

type UnitLabel = 'decimal' | 'k' | 'M' | 'G' | 'T' | 'P'

Time types

Time range formatted

The TimeRangeFormatted type represents a formatted time range.

type TimeRangeFormatted = {
  start: string
  end: string
  formatted: string
}

Time interval

The TimeInterval type represents a time interval with start/end timestamps.

type TimeInterval = {
  start: number
  end: number
}

Chart types

Chart legend position

The ChartLegendPosition type defines chart legend position options.

type ChartLegendPosition = 'top' | 'bottom' | 'left' | 'right' | 'center' | 'chartArea'

Weighted average result

The WeightedAverageResult type represents the result from weighted average calculation.

type WeightedAverageResult = {
  avg: number
  totalWeight: number
  weightedValue: number
}

Error with timestamp

The ErrorWithTimestamp type represents an error with optional timestamp.

type ErrorWithTimestamp = {
  msg?: string
  message?: string
  timestamp?: number | string
}

On this page