数通智联化工云平台
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.

1 line
12 KiB

2 years ago
{"version":3,"file":"config.mjs","sources":["../../../../../../packages/components/table/src/config.ts"],"sourcesContent":["// @ts-nocheck\nimport { h } from 'vue'\nimport ElCheckbox from '@element-plus/components/checkbox'\nimport { ElIcon } from '@element-plus/components/icon'\nimport { ArrowRight, Loading } from '@element-plus/icons-vue'\nimport { getProp } from '@element-plus/utils'\n\nimport type { VNode } from 'vue'\nimport type { TableColumnCtx } from './table-column/defaults'\nimport type { Store } from './store'\nimport type { TreeNode } from './table/defaults'\n\nconst defaultClassNames = {\n selection: 'table-column--selection',\n expand: 'table__expand-column',\n}\n\nexport const cellStarts = {\n default: {\n order: '',\n },\n selection: {\n width: 48,\n minWidth: 48,\n realWidth: 48,\n order: '',\n },\n expand: {\n width: 48,\n minWidth: 48,\n realWidth: 48,\n order: '',\n },\n index: {\n width: 48,\n minWidth: 48,\n realWidth: 48,\n order: '',\n },\n}\n\nexport const getDefaultClassName = (type) => {\n return defaultClassNames[type] || ''\n}\n\n// 这些选项不应该被覆盖\nexport const cellForced = {\n selection: {\n renderHeader<T>({ store, column }: { store: Store<T> }) {\n function isDisabled() {\n return store.states.data.value && store.states.data.value.length === 0\n }\n return h(ElCheckbox, {\n disabled: isDisabled(),\n size: store.states.tableSize.value,\n indeterminate:\n store.states.selection.value.length > 0 &&\n !store.states.isAllSelected.value,\n 'onUpdate:modelValue': store.toggleAllSelection,\n modelValue: store.states.isAllSelected.value,\n ariaLabel: column.label,\n })\n },\n renderCell<T>({\n row,\n column,\n store,\n $index,\n }: {\n row: T\n column: TableColumnCtx<T>\n store: Store<T>\n $index: string\n }) {\n return h(ElCheckbox, {\n disabled: column.selectable\n ? !column.selectable.call(null, row, $index)\n : false,\n size: store.states.tableSize.value,\n onChange: () => {\n store.commit('rowSelectedChanged', row)\n },\n onClick: (event: Event) => event.stopPropagation(),\n modelValue: store.isSelected(row),\n ariaLabel: column.label,\n })\n },\n sortable: false,\n resizable: false,\n },\n index: {\n renderHeader<T>({ column }: { column: TableColumnCtx<T> }) {\n return column.label || '#'\n },\n renderCell<T>({\n column,\n $index,\n }: {\n column: TableColumnCtx<T>\n $index: number\n }) {\n let i = $index + 1\n const index = column.index\n\n if (typeof index === 'number') {\n i = $index + index\n } else if (typeof index === 'function') {\n i = index($index)\n }\n return h('div', {}, [i])\n },\n sortable: false,\n },\n expand: {\n renderHeader<T>({ column }: { column: TableColumnCtx<T> }) {\n return column.label || ''\n },\n renderCell<T>({\n row,\n store,\n expanded,\n }: {\n row: T\n store: Store<T>\n expanded: boolean\n }) {\n const { ns } = store\n const classes = [ns.e('expand-icon')]\n if (expanded) {\n classes.push(ns.em('expand-icon', 'expanded'))\n }\n const callback = function (e: Event) {\n e.stopPropagation()\n store.toggleRowExpansion(row)\n }\n return h(\n 'div',\n {\n class: classes,\n onClick: callback,\n },\n {\n default: () => {\n return [\n h(ElIcon, null, {\n default: () => {\n return [h(ArrowRight)]\n },\n }),\n ]\n },\n }\n )\n },\n sortable: false,\n resizable: false,\n },\n}\n\nexport function defaultRenderCell<T>({\n row,\n column,\n $index,\n}: {\n row: T\n column: TableColumnCtx<T>\n $ind