UNPKG

@extclp/vexip-ui

Version:

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

1 lines 4.02 kB
{"version":3,"file":"table-body.vue2.mjs","sources":["../../../components/table/table-body.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { computed, inject, toRef } from 'vue'\n\nimport TableCell from './table-cell.vue'\nimport TableRow from './table-row.vue'\nimport { useNameHelper } from '@vexip-ui/config'\nimport { getLast } from '@vexip-ui/utils'\nimport { TABLE_STORE } from './symbol'\n\nimport type { PropType } from 'vue'\n\ndefineOptions({ name: 'TableBody' })\n\nconst props = defineProps({\n fixed: {\n type: String as PropType<'left' | 'right' | undefined>,\n default: null\n }\n})\n\nconst { state, getters } = inject(TABLE_STORE)!\n\nconst nh = useNameHelper('table')\nconst locale = toRef(state, 'locale')\n\nconst columns = computed(() => {\n return props.fixed === 'left'\n ? state.leftFixedColumns\n : props.fixed === 'right'\n ? state.rightFixedColumns\n : state.normalColumns\n})\nconst data = computed(() => (state.virtual ? state.virtualData : getters.processedData))\nconst style = computed(() => {\n const width =\n props.fixed === 'left'\n ? getLast(getters.leftFixedWidths)\n : props.fixed === 'right'\n ? getLast(getters.rightFixedWidths)\n : getLast(getters.normalWidths)\n const padLeft = columns.value[0]?.fixed === 'left' ? state.sidePadding[0] || 0 : 0\n const padRight = getLast(columns.value)?.fixed === 'right' ? state.sidePadding[1] || 0 : 0\n\n return {\n [nh.cv('expanded-fix-width')]:\n props.fixed === 'right' && width ? `${width + padLeft + padRight}px` : '0px',\n minWidth: width && `${width + padLeft + padRight}px`,\n minHeight: `${state.totalHeight}px`\n }\n})\nconst emptyStyle = computed(() => {\n const { rowHeight, rowMinHeight } = state\n\n return {\n minHeight: `${rowHeight || rowMinHeight}px`\n }\n})\n</script>\n\n<template>\n <div :class=\"nh.be('body')\" role=\"rowgroup\" :style=\"style\">\n <template v-if=\"data.length\">\n <TableRow\n v-for=\"(row, index) in data\"\n :key=\"index\"\n :row=\"row\"\n :index=\"row.listIndex\"\n :fixed=\"fixed\"\n :aria-rowindex=\"row.index\"\n >\n <TableCell\n v-for=\"(column, colIndex) in columns\"\n :key=\"colIndex\"\n :row=\"row\"\n :row-index=\"row.listIndex\"\n :column=\"column\"\n :col-index=\"colIndex\"\n :fixed=\"fixed\"\n :aria-colindex=\"colIndex\"\n ></TableCell>\n </TableRow>\n </template>\n <div v-else :class=\"nh.be('empty')\" :style=\"emptyStyle\">\n <slot name=\"empty\" :is-fixed=\"!!fixed\">\n <template v-if=\"!fixed\">\n {{ locale.empty }}\n </template>\n </slot>\n </div>\n </div>\n</template>\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"],"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,IAC/BH,EAAM,UAAU,UACde,EAAQZ,EAAQ,gBAAgB,IAChCY,EAAQZ,EAAQ,YAAY,GAC9Ba,MAAUC,IAAAP,EAAQ,MAAM,CAAC,MAAf,gBAAAO,EAAkB,WAAU,UAASf,EAAM,YAAY,CAAC,KAAK,GACvEgB,MAAWC,IAAAJ,EAAQL,EAAQ,KAAK,MAArB,gBAAAS,EAAwB,WAAU,WAAUjB,EAAM,YAAY,CAAC,KAAK;AAE9E,aAAA;AAAA,QACL,CAACI,EAAG,GAAG,oBAAo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