element-plus
Version:
A Component Library for Vue 3
1 lines • 10 kB
Source Map (JSON)
{"version":3,"file":"defaults.mjs","sources":["../../../../../../../packages/components/table/src/table-column/defaults.ts"],"sourcesContent":["import type { ComponentInternalInstance, PropType, Ref, VNode } from 'vue'\nimport type { DefaultRow, Table, TableSortOrder } from '../table/defaults'\nimport type {\n TableOverflowTooltipFormatter,\n TableOverflowTooltipOptions,\n} from '../util'\nimport type { Store } from '../store'\n\ntype CI<T extends DefaultRow> = {\n column: TableColumnCtx<T>\n $index: number\n store: Store<T>\n _self: any\n}\n\ntype Filters = {\n text: string\n value: string\n}[]\n\ntype FilterMethods<T extends DefaultRow> = (\n value: string,\n row: T,\n column: TableColumnCtx<T>\n) => void\n\ntype ValueOf<T> = T[keyof T]\n\ntype TableColumnCtx<T extends DefaultRow = DefaultRow> = {\n id: string\n realWidth: number | null\n type: string\n label: string\n className: string\n labelClassName: string\n property: string\n prop: string\n width?: string | number\n minWidth: string | number\n renderHeader: (data: CI<T>) => VNode\n sortable: boolean | string\n sortMethod: (a: T, b: T) => number\n sortBy: string | ((row: T, index: number, array?: T[]) => string) | string[]\n resizable: boolean\n columnKey: string\n rawColumnKey: string\n align: string\n headerAlign: string\n showOverflowTooltip?: boolean | TableOverflowTooltipOptions\n tooltipFormatter?: TableOverflowTooltipFormatter<T>\n fixed: boolean | string\n formatter: (\n row: T,\n column: TableColumnCtx<T>,\n cellValue: any,\n index: number\n ) => VNode | string\n selectable: (row: T, index: number) => boolean\n reserveSelection: boolean\n filterMethod: FilterMethods<T>\n filteredValue: string[]\n filters: Filters\n filterPlacement: string\n filterMultiple: boolean\n filterClassName: string\n index: number | ((index: number) => number)\n sortOrders: (TableSortOrder | null)[]\n renderCell: (data: any) => VNode | VNode[]\n colSpan: number\n rowSpan: number\n children?: TableColumnCtx<T>[]\n level: number\n filterable: boolean | FilterMethods<T> | Filters\n order: TableSortOrder | null\n isColumnGroup: boolean\n isSubColumn: boolean\n columns: TableColumnCtx<T>[]\n getColumnIndex: () => number\n no: number\n filterOpened?: boolean\n renderFilterIcon?: (scope: any) => VNode\n renderExpand?: (scope: any) => VNode\n}\n\ninterface TableColumn<T extends DefaultRow> extends ComponentInternalInstance {\n vnode: {\n vParent: TableColumn<T> | Table<T>\n } & VNode\n vParent: TableColumn<T> | Table<T>\n columnId: string\n columnConfig: Ref<Partial<TableColumnCtx<T>>>\n}\n\nexport type { Filters, FilterMethods, TableColumnCtx, TableColumn, ValueOf }\n\nexport default {\n /**\n * @description type of the column. If set to `selection`, the column will display checkbox. If set to `index`, the column will display index of the row (staring from 1). If set to `expand`, the column will display expand icon\n */\n type: {\n type: String,\n default: 'default',\n },\n /**\n * @description column label\n */\n label: String,\n /**\n * @description class name of cells in the column\n */\n className: String,\n /**\n * @description class name of the label of this column\n */\n labelClassName: String,\n /**\n * @description\n */\n property: String,\n /**\n * @description field name. You can also use its alias: `property`\n */\n prop: String,\n /**\n * @description column width\n */\n width: {\n type: [String, Number],\n default: '',\n },\n /**\n * @description column minimum width. Columns with `width` has a fixed width, while columns with `min-width` has a width that is distributed in proportion\n */\n minWidth: {\n type: [String, Number],\n default: '',\n },\n /**\n * @description render function for table header of this column\n */\n renderHeader: Function as PropType<TableColumnCtx<any>['renderHeader']>,\n /**\n * @description whether column can be sorted. Remote sorting can be done by setting this attribute to 'custom' and listening to the `sort-change` event of Table\n */\n sortable: {\n type: [Boolean, String],\n default: false,\n },\n /**\n * @description sorting method, works when `sortable` is `true`. Should return a number, just like Array.sort\n */\n sortMethod: Function as PropType<TableColumnCtx<any>['sortMethod']>,\n /**\n * @description specify which property to sort by, works when `sortable` is `true` and `sort-method` is `undefined`. If set to an Array, the column will sequentially sort by the next property if the previous one is equal\n */\n sortBy: [String, Function, Array] as PropType<TableColumnCtx<any>['sortBy']>,\n /**\n * @description whether column width can be resized, works when `border` of `el-table` is `true`\n */\n resizable: {\n type: Boolean,\n default: true,\n },\n /**\n * @description column's key. If you need to use the filter-change event, you need this attribute to identify which column is being filtered\n */\n columnKey: String,\n /**\n * @description alignment, the value should be 'left' \\/ 'center' \\/ 'right'\n */\n align: String,\n /**\n * @description alignment of the table header. If omitted, the value of the above `align` attribute will be applied, the value should be 'left' \\/ 'center' \\/ 'right'\n */\n headerAlign: String,\n /**\n * @description whether to hide extra content and show them in a tooltip when hovering on the cell\n */\n showOverflowTooltip: {\n type: [Boolean, Object] as PropType<\n TableColumnCtx<any>['showOverflowTooltip']\n >,\n default: undefined,\n },\n /**\n * @description function that formats cell tooltip content, works when `show-overflow-tooltip` is `true`\n */\n tooltipFormatter: Function as PropType<\n TableColumnCtx<any>['tooltipFormatter']\n >,\n /**\n * @description whether column is fixed at left / right. Will be fixed at left if `true`\n */\n fixed: [Boolean, String],\n /**\n * @description function that formats cell content\n */\n formatter: Function as PropType<TableColumnCtx<any>['formatter']>,\n /**\n * @description function that determines if a certain row can be selected, works when `type` is 'selection'\n */\n selectable: Function as PropType<TableColumnCtx<any>['selectable']>,\n /**\n * @description whether to reserve selection after data refreshing, works when `type` is 'selection'. Note that `row-key` is required for this to work\n */\n reserveSelection: Boolean,\n /**\n * @description data filtering method. If `filter-multiple` is on, this method will be called multiple times for each row, and a row will display if one of the calls returns `true`\n */\n filterMethod: Function as PropType<TableColumnCtx<any>['filterMethod']>,\n /**\n * @description filter value for selected data, might be useful when table header is rendered with `render-header`\n */\n filteredValue: Array as PropType<TableColumnCtx<any>['filteredValue']>,\n /**\n * @description an array of data filtering options. For each element in this array, `text` and `value` are required\n */\n filters: Array as PropType<TableColumnCtx<any>['filters']>,\n /**\n * @description placement for the filter dropdown\n */\n filterPlacement: String,\n /**\n * @description whether data filtering supports multiple options\n */\n filterMultiple: {\n type: Boolean,\n default: true,\n },\n /**\n * @description className for the filter dropdown\n */\n filterClassName: String,\n /**\n * @description customize indices for each row, works on columns with `type=index`\n */\n index: [Number, Function] as PropType<TableColumnCtx<any>['index']>,\n /**\n * @description the order of the sorting strategies used when sorting the data, works when `sortable` is `true`. Accepts an array, as the user clicks on the header, the column is sorted in order of the elements in the array\n */\n sortOrders: {\n type: Array as PropType<TableColumnCtx<any>['sortOrders']>,\n default: () => {\n return ['ascending', 'descending', null]\n },\n validator: (val: TableColumnCtx<any>['sortOrders']) => {\n return val.every((order: TableSortOrder | null) =>\n ['ascending', 'descending', null].includes(order)\n )\n },\n },\n}\n"],"names":[],"mappings":"AA+FA,mBAAe;AAAA,EAIb,IAAM,EAAA;AAAA,IACJ,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA,SAAA;AAAA,GACX;AAAA,EAIA,KAAO,EAAA,MAAA;AAAA,EAIP,SAAW,EAAA,MAAA;AAAA,EAIX,cAAgB,EAAA,MAAA;AAAA,EAIhB,QAAU,EAAA,MAAA;AAAA,EAIV,IAAM,EAAA,MAAA;AAAA,EAIN,KAAO,EAAA;AAAA,IACL,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,QAAU,EAAA;AAAA,IACR,IAAA,EAAM,CAAC,MAAA,EAAQ,MAAM,CAAA;AAAA,IACrB,OAAS,EAAA,EAAA;AAAA,GACX;AAAA,EAIA,YAAc,EAAA,QAAA;AAAA,EAId,QAAU,EAAA;AAAA,IACR,IAAA,EAAM,CAAC,OAAA,EAAS,MAAM,CAAA;AAAA,IACtB,OAAS,EAAA,KAAA;AAAA,GACX;AAAA,EAIA,UAAY,EAAA,QAAA;AAAA,EAIZ,MAAQ,EAAA,CAAC,MAAQ,EAAA,QAAA,EAAU,KAAK,CAAA;AAAA,EAIhC,SAAW,EAAA;AAAA,IACT,IAAM,EAAA,OAAA;AAAA,IACN,OAAS,EAAA,IAAA;AAAA,GACX;AAAA,EAIA,SAAW,EAAA,MAAA;AAAA,EAIX,KAAO,EAAA,MAAA;AAAA,EAIP,WAAa,EAAA,MAAA;AAAA,EAIb,mBAAqB,EAAA;AAAA,IACnB,IAAA,EAAM,CAAC,OAAA,EAAS,MAAM,CAAA;AAAA,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