import {ComponentType} from 'react'
import type {ConfigContext} from 'sanity'
import {FieldDefinitionBase} from 'sanity'
import {ListItem} from 'sanity/structure'
import {MenuItem} from 'sanity/structure'
import {SortOrdering} from 'sanity'
import {StringDefinition} from 'sanity'
import {StructureBuilder} from 'sanity/structure'
import {WidenInitialValue} from 'sanity'
import {WidenValidation} from 'sanity'

declare type NewItemPosition = 'after' | 'before'

export declare function orderableDocumentListDeskItem(config: OrderableListConfig): ListItem

export declare interface OrderableListConfig {
  type: string
  id?: string
  title?: string
  icon?: ComponentType
  params?: Record<string, unknown>
  filter?: string
  menuItems?: MenuItem[]
  createIntent?: boolean
  context: ConfigContext
  S: StructureBuilder
}

export declare const orderRankField: (config: RankFieldConfig) => {
  type: 'string'
  name: 'orderRank'
} & Omit<StringDefinition, 'preview'> &
  FieldDefinitionBase &
  WidenValidation &
  WidenInitialValue

export declare const orderRankOrdering: SortOrdering

export declare interface RankFieldConfig {
  type: string
  newItemPosition?: NewItemPosition
}

export {}
