You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
42 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, getCurrentInstance, ref, computed, unref, onMounted, onUpdated, onActivated, resolveDynamicComponent, h, Fragment, nextTick } from 'vue';\nimport { useEventListener, isClient } from '@vueuse/core';\nimport { useCache } from '../hooks/use-cache.mjs';\nimport useWheel from '../hooks/use-wheel.mjs';\nimport ScrollBar from '../components/scrollbar.mjs';\nimport { isHorizontal, getRTLOffsetType, getScrollDir } from '../utils.mjs';\nimport { virtualizedListProps } from '../props.mjs';\nimport { ITEM_RENDER_EVT, SCROLL_EVT, HORIZONTAL, RTL, RTL_OFFSET_POS_ASC, RTL_OFFSET_NAG, BACKWARD, FORWARD, AUTO_ALIGNMENT, RTL_OFFSET_POS_DESC } from '../defaults.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nimport { isNumber } from '../../../../utils/types.mjs';\nimport { isString, hasOwn } from '@vue/shared';\nconst createList = ({\n name,\n getOffset,\n getItemSize,\n getItemOffset,\n getEstimatedTotalSize,\n getStartIndexForOffset,\n getStopIndexForStartIndex,\n initCache,\n clearCache,\n validateProps\n}) => {\n return defineComponent({\n name: name != null ? name : \"ElVirtualList\",\n props: virtualizedListProps,\n emits: [ITEM_RENDER_EVT, SCROLL_EVT],\n setup(props, {\n emit,\n expose\n }) {\n validateProps(props);\n const instance = getCurrentInstance();\n const ns = useNamespace(\"vl\");\n const dynamicSizeCache = ref(initCache(props, instance));\n const getItemStyleCache = useCache();\n const windowRef = ref();\n const innerRef = ref();\n const scrollbarRef = ref();\n const states = ref({\n isScrolling: false,\n scrollDir: \"forward\",\n scrollOffset: isNumber(props.initScrollOffset) ? props.initScrollOffset : 0,\n updateRequested: false,\n isScrollbarDragging: false,\n scrollbarAlwaysOn: props.scrollbarAlwaysOn\n });\n const itemsToRender = computed(() => {\n const {\n total,\n cache\n } = props;\n const {\n isScrolling,\n scrollDir,\n scrollOffset\n } = unref(states);\n if (total === 0) {\n return [0, 0, 0, 0];\n }\n const startIndex = getStartIndexForOffset(props, scrollOffset, unref(dynamicSizeCache));\n const stopIndex = getStopIndexForStartIndex(props, startIndex, scrollOffset, unref(dynamicSizeCache));\n const cacheBackward = !isScrolling || scrollDir === BACKWARD ? Math.max(1, cache) : 1;\n const cacheForward = !isScrolling || scrollDir === FORWARD ? Math.max(1, cache) : 1;\n return [Math.max(0, startIndex - cacheBackward), Math.max(0, Math.min(total - 1, stopIndex + cacheForward)), startIndex, stopIndex];\n });\n const estimatedTotalSize = computed(() => getEstimatedTotalSize(props, unref(dynamicSizeCache)));\n const _isHorizontal = computed(() => isHorizontal(props.layout));\n const windowStyle = computed(() => [{\n position: \"relative\",\n [`overflow-${_isHorizontal.value ? \"x\" : \"y\"}`]: \"scroll\",\n WebkitOverflowScrolling: \"touch\",\n willChange: \"transform\"\n }, {\n direction: props.direction,\n height: isNumber(props.height) ? `${props.height}px` : props.height,\n width: isNumber(props.width) ? `${props.width}px` : props.width\n }, props.style]);\n const innerStyle = computed(() => {\n const size = unref(estimatedTotalSize);\n const horizontal = unref(_isHorizontal);\n return {\n height: horizontal ? \"100%\" : `${size}px`,\n pointerEvents: unref(states).isScrolling ? \"none\" : void 0,\n width: horizontal ? `${size}px` : \"100%\"\n };\n });\n const clientSize = computed(() => _isHorizontal.value ? props.width : props.height);\n const {\n onWheel\n } = useWheel({\n atStartEdge: computed(() => states.value.scrollOffset <= 0),\n atEndEdge: computed(() => states.value.scrollOffset >= estimated