UNPKG

@extclp/vexip-ui

Version:

A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good

1 lines 5.28 kB
{"version":3,"file":"table-body.vue2.mjs","sources":["../../../components/table/table-body.vue"],"sourcesContent":["<script setup lang=\"ts\">\r\nimport { computed, inject, toRef } from 'vue'\r\n\r\nimport TableCell from './table-cell.vue'\r\nimport TableRow from './table-row.vue'\r\nimport { useNameHelper } from '@vexip-ui/config'\r\nimport { getLast } from '@vexip-ui/utils'\r\nimport { TABLE_STORE } from './symbol'\r\n\r\nimport type { PropType } from 'vue'\r\n\r\ndefineOptions({ name: 'TableBody' })\r\n\r\nconst props = defineProps({\r\n fixed: {\r\n type: String as PropType<'left' | 'right' | undefined>,\r\n default: null,\r\n },\r\n})\r\n\r\nconst { state, getters } = inject(TABLE_STORE)!\r\n\r\nconst nh = useNameHelper('table')\r\nconst locale = toRef(state, 'locale')\r\n\r\nconst columns = computed(() => {\r\n return props.fixed === 'left'\r\n ? state.leftFixedColumns\r\n : props.fixed === 'right'\r\n ? state.rightFixedColumns\r\n : state.normalColumns\r\n})\r\nconst data = computed(() => (state.virtual ? state.virtualData : getters.processedData))\r\nconst style = computed(() => {\r\n const width =\r\n props.fixed === 'left'\r\n ? getLast(getters.leftFixedWidths)\r\n : props.fixed === 'right'\r\n ? getLast(getters.rightFixedWidths)\r\n : getLast(getters.normalWidths)\r\n const padLeft = columns.value[0]?.fixed === 'left' ? state.sidePadding[0] || 0 : 0\r\n const padRight = getLast(columns.value)?.fixed === 'right' ? state.sidePadding[1] || 0 : 0\r\n\r\n return {\r\n [nh.cv('expanded-fix-width')]:\r\n props.fixed === 'right' && width ? `${width + padLeft + padRight}px` : '0px',\r\n minWidth: width && `${width + padLeft + padRight}px`,\r\n minHeight: `${state.totalHeight}px`,\r\n }\r\n})\r\nconst emptyStyle = computed(() => {\r\n const { rowHeight, rowMinHeight } = state\r\n\r\n return {\r\n minHeight: `${rowHeight || rowMinHeight}px`,\r\n }\r\n})\r\n</script>\r\n\r\n<template>\r\n <div :class=\"nh.be('body')\" role=\"rowgroup\" :style=\"style\">\r\n <template v-if=\"data.length\">\r\n <TableRow\r\n v-for=\"(row, index) in data\"\r\n :key=\"index\"\r\n :row=\"row\"\r\n :index=\"row.listIndex\"\r\n :fixed=\"fixed\"\r\n :aria-rowindex=\"row.index\"\r\n >\r\n <TableCell\r\n v-for=\"(column, colIndex) in columns\"\r\n :key=\"colIndex\"\r\n :row=\"row\"\r\n :row-index=\"row.listIndex\"\r\n :column=\"column\"\r\n :col-index=\"colIndex\"\r\n :fixed=\"fixed\"\r\n :aria-colindex=\"colIndex\"\r\n ></TableCell>\r\n </TableRow>\r\n </template>\r\n <div v-else :class=\"nh.be('empty')\" :style=\"emptyStyle\">\r\n <slot name=\"empty\" :is-fixed=\"!!fixed\">\r\n <template v-if=\"!fixed\">\r\n {{ locale.empty }}\r\n </template>\r\n </slot>\r\n </div>\r\n </div>\r\n</template>\r\n"],"names":["props","__props","state","getters","inject","TABLE_STORE","nh","useNameHelper","locale","toRef","columns","computed","data","style","width","getLast","padLeft","_a","padRight","_b","emptyStyle","rowHeight","rowMinHeight","_createElementBlock","_normalizeClass","_unref","_openBlock","_Fragment","_renderList","row","index","_createBlock","TableRow","column","colIndex","TableCell","_renderSlot","_ctx","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,UAAMA,IAAQC,GAOR,EAAE,OAAAC,GAAO,SAAAC,MAAYC,EAAOC,CAAW,GAEvCC,IAAKC,EAAc,OAAO,GAC1BC,IAASC,EAAMP,GAAO,QAAQ,GAE9BQ,IAAUC,EAAS,MAChBX,EAAM,UAAU,SACnBE,EAAM,mBACNF,EAAM,UAAU,UACdE,EAAM,oBACNA,EAAM,aACb,GACKU,IAAOD,EAAS,MAAOT,EAAM,UAAUA,EAAM,cAAcC,EAAQ,aAAc,GACjFU,IAAQF,EAAS,MAAM;;AAC3B,YAAMG,IACJd,EAAM,UAAU,SACZe,EAAQZ,EAAQ,eAAe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