// @ts-nocheck import { buildProp, buildProps, definePropType, mutable, } from '@element-plus/utils' import { VERTICAL } from './defaults' import type { ExtractPropTypes, StyleValue } from 'vue' import type { GridItemKeyGetter, ItemSize } from './types' const itemSize = buildProp({ type: definePropType([Number, Function]), required: true, } as const) const estimatedItemSize = buildProp({ type: Number, } as const) const cache = buildProp({ type: Number, default: 2, } as const) const direction = buildProp({ type: String, values: ['ltr', 'rtl'], default: 'ltr', } as const) const initScrollOffset = buildProp({ type: Number, default: 0, } as const) const total = buildProp({ type: Number, required: true, } as const) const layout = buildProp({ type: String, values: ['horizontal', 'vertical'], default: VERTICAL, } as const) export const virtualizedProps = buildProps({ className: { type: String, default: '', }, containerElement: { type: definePropType([String, Object]), default: 'div', }, data: { type: definePropType(Array), default: () => mutable([] as const), }, /** * @description controls the horizontal direction. */ direction, height: { type: [String, Number], required: true, }, innerElement: { type: [String, Object], default: 'div', }, style: { type: definePropType([Object, String, Array]), }, useIsScrolling: { type: Boolean, default: false, }, width: { type: [Number, String], required: false, }, perfMode: { type: Boolean, default: true, }, scrollbarAlwaysOn: { type: Boolean, default: false, }, } as const) export const virtualizedListProps = buildProps({ /** * @description describes how many items should be pre rendered to the head * and the tail of the window */ cache, estimatedItemSize, /** * @description controls the list's orientation */ layout, initScrollOffset, /** * @description describes the total number of the list. */ total, itemSize, ...virtualizedProps, } as const) const scrollbarSize = { type: Number, default: 6, } as const const startGap = { type: Number, default: 0 } as const const endGap = { type: Number, default: 2 } as const export const virtualizedGridProps = buildProps({ columnCache: cache, columnWidth: itemSize, estimatedColumnWidth: estimatedItemSize, estimatedRowHeight: estimatedItemSize, initScrollLeft: initScrollOffset, initScrollTop: initScrollOffset, itemKey: { type: definePropType(Function), default: ({ columnIndex, rowIndex }) => `${rowIndex}:${columnIndex}`, }, rowCache: cache, rowHeight: itemSize, totalColumn: total, totalRow: total, hScrollbarSize: scrollbarSize, vScrollbarSize: scrollbarSize, scrollbarStartGap: startGap, scrollbarEndGap: endGap, ...virtualizedProps, } as const) export const virtualizedScrollbarProps = buildProps({ alwaysOn: Boolean, class: String, layout, total, ratio: { type: Number, required: true, }, clientSize: { type: Number, required: true, }, scrollFrom: { type: Number, required: true, }, scrollbarSize, startGap, endGap, visible: Boolean, } as const) export type VirtualizedProps = ExtractPropTypes export type VirtualizedListProps = ExtractPropTypes export type VirtualizedGridProps = ExtractPropTypes export type VirtualizedScrollbarProps = ExtractPropTypes< typeof virtualizedScrollbarProps >