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

1 month ago
  1. {"ast":null,"code":"import { ref, watchEffect, watch, unref, computed, onMounted, nextTick } from 'vue';\nimport { useEventListener, useResizeObserver } from '@vueuse/core';\nimport { useFormSize } from '../../../form/src/hooks/use-form-common-props.mjs';\nfunction useStyle(props, layout, store, table) {\n const isHidden = ref(false);\n const renderExpanded = ref(null);\n const resizeProxyVisible = ref(false);\n const setDragVisible = visible => {\n resizeProxyVisible.value = visible;\n };\n const resizeState = ref({\n width: null,\n height: null,\n headerHeight: null\n });\n const isGroup = ref(false);\n const scrollbarViewStyle = {\n display: \"inline-block\",\n verticalAlign: \"middle\"\n };\n const tableWidth = ref();\n const tableScrollHeight = ref(0);\n const bodyScrollHeight = ref(0);\n const headerScrollHeight = ref(0);\n const footerScrollHeight = ref(0);\n const appendScrollHeight = ref(0);\n watchEffect(() => {\n layout.setHeight(props.height);\n });\n watchEffect(() => {\n layout.setMaxHeight(props.maxHeight);\n });\n watch(() => [props.currentRowKey, store.states.rowKey], ([currentRowKey, rowKey]) => {\n if (!unref(rowKey) || !unref(currentRowKey)) return;\n store.setCurrentRowKey(`${currentRowKey}`);\n }, {\n immediate: true\n });\n watch(() => props.data, data => {\n table.store.commit(\"setData\", data);\n }, {\n immediate: true,\n deep: true\n });\n watchEffect(() => {\n if (props.expandRowKeys) {\n store.setExpandRowKeysAdapter(props.expandRowKeys);\n }\n });\n const handleMouseLeave = () => {\n table.store.commit(\"setHoverRow\", null);\n if (table.hoverState) table.hoverState = null;\n };\n const handleHeaderFooterMousewheel = (event, data) => {\n const {\n pixelX,\n pixelY\n } = data;\n if (Math.abs(pixelX) >= Math.abs(pixelY)) {\n table.refs.bodyWrapper.scrollLeft += data.pixelX / 5;\n }\n };\n const shouldUpdateHeight = computed(() => {\n return props.height || props.maxHeight || store.states.fixedColumns.value.length > 0 || store.states.rightFixedColumns.value.length > 0;\n });\n const tableBodyStyles = computed(() => {\n return {\n width: layout.bodyWidth.value ? `${layout.bodyWidth.value}px` : \"\"\n };\n });\n const doLayout = () => {\n if (shouldUpdateHeight.value) {\n layout.updateElsHeight();\n }\n layout.updateColumnsWidth();\n requestAnimationFrame(syncPosition);\n };\n onMounted(async () => {\n await nextTick();\n store.updateColumns();\n bindEvents();\n requestAnimationFrame(doLayout);\n const el = table.vnode.el;\n const tableHeader = table.refs.headerWrapper;\n if (props.flexible && el && el.parentElement) {\n el.parentElement.style.minWidth = \"0\";\n }\n resizeState.value = {\n width: tableWidth.value = el.offsetWidth,\n height: el.offsetHeight,\n headerHeight: props.showHeader && tableHeader ? tableHeader.offsetHeight : null\n };\n store.states.columns.value.forEach(column => {\n if (column.filteredValue && column.filteredValue.length) {\n table.store.commit(\"filterChange\", {\n column,\n values: column.filteredValue,\n silent: true\n });\n }\n });\n table.$ready = true;\n });\n const setScrollClassByEl = (el, className) => {\n if (!el) return;\n const classList = Array.from(el.classList).filter(item => !item.startsWith(\"is-scrolling-\"));\n classList.push(layout.scrollX.value ? className : \"is-scrolling-none\");\n el.className = classList.join(\" \");\n };\n const setScrollClass = className => {\n const {\n tableWrapper\n } = table.refs;\n setScrollClassByEl(tableWrapper, className);\n };\n const hasScrollClass = className => {\n const {\n tableWrapper\n } = table.refs;\n return !!(tableWrapper && tableWrapper.classList.contains(className));\n };\n const syncPosition = function () {\n if (!table.refs.scrollBarRef) return;\n if (!layout.scrollX.value) {\n cons