| 1 | import type { ComputedRef } from 'vue' |
| 2 | |
| 3 | export type RawSingleAtValue = null | undefined | boolean | string | number |
| 4 | export type RawRangeAtValue = null | undefined | false | [string | number, string | number] |
| 5 | export type RawAtValue = RawSingleAtValue | RawRangeAtValue |
| 6 | |
| 7 | export type NormalizedSingleClickValue |
| 8 | = | number // since absolute click |
| 9 | | string // since relative click |
| 10 | | null // disabled |
| 11 | export type NormalizedRangeClickValue |
| 12 | = | [number, number] // [absolute start, absolute end] |
| 13 | | [number, string] // [absolute start, absolute end based on start] |
| 14 | | [string, number] // [relative start, absolute end] |
| 15 | | [string, string] // [relative start, relative end] |
| 16 | | [string | number, string | number] // make TypeScript happy |
| 17 | | null // disabled |
| 18 | export type NormalizedAtValue |
| 19 | = | NormalizedSingleClickValue // since |
| 20 | | NormalizedRangeClickValue // range |
| 21 | |
| 22 | export type ClicksElement = Element | string |
| 23 | |
| 24 | export interface ClicksInfo { |
| 25 | /** |
| 26 | * The absolute start click num |
| 27 | */ |
| 28 | start: number |
| 29 | /** |
| 30 | * The absolute end click num |
| 31 | */ |
| 32 | end: number |
| 33 | /** |
| 34 | * The required total click num |
| 35 | */ |
| 36 | max: number |
| 37 | /** |
| 38 | * The delta for relative clicks |
| 39 | */ |
| 40 | delta: number |
| 41 | /** |
| 42 | * currentClicks - start |
| 43 | */ |
| 44 | currentOffset: ComputedRef<number> |
| 45 | /** |
| 46 | * currentOffset === 0 |
| 47 | */ |
| 48 | isCurrent: ComputedRef<boolean> |
| 49 | /** |
| 50 | * Computed ref of whether the click is active |
| 51 | */ |
| 52 | isActive: ComputedRef<boolean> |
| 53 | } |
| 54 | |
| 55 | export interface ClicksContext { |
| 56 | current: number |
| 57 | readonly clicksStart: number |
| 58 | readonly relativeSizeMap: Map<ClicksElement, number> |
| 59 | readonly maxMap: Map<ClicksElement, number> |
| 60 | calculateSince: (at: RawSingleAtValue, size?: number) => ClicksInfo | null |
| 61 | calculateRange: (at: RawRangeAtValue) => ClicksInfo | null |
| 62 | calculate: (at: RawAtValue) => ClicksInfo | null |
| 63 | register: (el: ClicksElement, info: Pick<ClicksInfo, 'delta' | 'max'> | null) => void |
| 64 | unregister: (el: ClicksElement) => void |
| 65 | readonly isMounted: boolean |
| 66 | setup: () => void |
| 67 | readonly currentOffset: number |
| 68 | readonly total: number |
| 69 | } |
| 70 |