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
56 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, getCurrentInstance, ref, computed, unref, onMounted, nextTick, resolveDynamicComponent, h, Fragment } from 'vue';\nimport { useEventListener, isClient } from '@vueuse/core';\nimport ScrollBar from '../components/scrollbar.mjs';\nimport { useGridWheel } from '../hooks/use-grid-wheel.mjs';\nimport { useCache } from '../hooks/use-cache.mjs';\nimport { virtualizedGridProps } from '../props.mjs';\nimport { getScrollDir, getRTLOffsetType, isRTL } from '../utils.mjs';\nimport { ITEM_RENDER_EVT, SCROLL_EVT, FORWARD, BACKWARD, AUTO_ALIGNMENT, RTL, RTL_OFFSET_POS_ASC, RTL_OFFSET_NAG, RTL_OFFSET_POS_DESC } from '../defaults.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nimport { isNumber } from '../../../../utils/types.mjs';\nimport { getScrollBarWidth } from '../../../../utils/dom/scroll.mjs';\nimport { isString, hasOwn } from '@vue/shared';\nconst createGrid = ({\n name,\n clearCache,\n getColumnPosition,\n getColumnStartIndexForOffset,\n getColumnStopIndexForStartIndex,\n getEstimatedTotalHeight,\n getEstimatedTotalWidth,\n getColumnOffset,\n getRowOffset,\n getRowPosition,\n getRowStartIndexForOffset,\n getRowStopIndexForStartIndex,\n initCache,\n injectToInstance,\n validateProps\n}) => {\n return defineComponent({\n name: name != null ? name : \"ElVirtualList\",\n props: virtualizedGridProps,\n emits: [ITEM_RENDER_EVT, SCROLL_EVT],\n setup(props, {\n emit,\n expose,\n slots\n }) {\n const ns = useNamespace(\"vl\");\n validateProps(props);\n const instance = getCurrentInstance();\n const cache = ref(initCache(props, instance));\n injectToInstance == null ? void 0 : injectToInstance(instance, cache);\n const windowRef = ref();\n const hScrollbar = ref();\n const vScrollbar = ref();\n const innerRef = ref(null);\n const states = ref({\n isScrolling: false,\n scrollLeft: isNumber(props.initScrollLeft) ? props.initScrollLeft : 0,\n scrollTop: isNumber(props.initScrollTop) ? props.initScrollTop : 0,\n updateRequested: false,\n xAxisScrollDir: FORWARD,\n yAxisScrollDir: FORWARD\n });\n const getItemStyleCache = useCache();\n const parsedHeight = computed(() => Number.parseInt(`${props.height}`, 10));\n const parsedWidth = computed(() => Number.parseInt(`${props.width}`, 10));\n const columnsToRender = computed(() => {\n const {\n totalColumn,\n totalRow,\n columnCache\n } = props;\n const {\n isScrolling,\n xAxisScrollDir,\n scrollLeft\n } = unref(states);\n if (totalColumn === 0 || totalRow === 0) {\n return [0, 0, 0, 0];\n }\n const startIndex = getColumnStartIndexForOffset(props, scrollLeft, unref(cache));\n const stopIndex = getColumnStopIndexForStartIndex(props, startIndex, scrollLeft, unref(cache));\n const cacheBackward = !isScrolling || xAxisScrollDir === BACKWARD ? Math.max(1, columnCache) : 1;\n const cacheForward = !isScrolling || xAxisScrollDir === FORWARD ? Math.max(1, columnCache) : 1;\n return [Math.max(0, startIndex - cacheBackward), Math.max(0, Math.min(totalColumn - 1, stopIndex + cacheForward)), startIndex, stopIndex];\n });\n const rowsToRender = computed(() => {\n const {\n totalColumn,\n totalRow,\n rowCache\n } = props;\n const {\n isScrolling,\n yAxisScrollDir,\n scrollTop\n } = unref(states);\n if (totalColumn === 0 || totalRow === 0) {\n return [0, 0, 0, 0];\n }\n const startIndex = getRowStartIndexForOffset(props, scrollTop, unref(cache));\n const stopIndex = getRowStopIndexForStartIndex(props, startIndex, scrollTop, unref(cache));\n const cacheBackward = !isScrolling || yAxisScrollDir === BACKWARD ? Math.max(1, rowCache) : 1;\n const cacheForward = !isScrolling || yAxisScrollDir === FORW