UNPKG

@opentiny/vue-renderless

Version:

An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.

106 lines (105 loc) 3.63 kB
import "../../chunk-G2ADBYYC.js"; import { isBoolean } from "../static"; import { initFilter } from "./common"; let columnUniqueId = 0; class FixedDetails { constructor(fixedType) { this.isLeft = fixedType === "left"; this.isLeftLast = false; this.isRight = fixedType === "right"; this.isRightFirst = false; this.left = 0; this.right = 0; } getStyle(rightExtra = 0) { const { isLeft, left, isRight, right } = this; return { left: isLeft ? `${left}px` : void 0, right: isRight ? `${right + rightExtra}px` : void 0 }; } getClass() { const { isLeftLast, isRightFirst } = this; return { "fixed-left-last__column": isLeftLast, "fixed-right-first__column": isRightFirst }; } } class ColumnConfig { constructor(context, { renderHeader, renderCell, renderData } = {}, config = {}) { this.id = `col_${++columnUniqueId}`; this.type = context.type; this.prop = context.prop; this.rules = context.rules; this.required = context.required; this.property = context.field || context.prop; this.title = context.title; this.label = context.label; this.width = context.width; this.minWidth = context.minWidth; this.resizable = context.resizable; this._fixed = context.fixed; this._fixedDetails = context.fixed ? new FixedDetails(context.fixed) : void 0; this.align = context.align; this.headerAlign = context.headerAlign; this.footerAlign = context.footerAlign; this.showOverflow = context.showOverflow; this.showHeaderOverflow = context.showHeaderOverflow; this.showTip = context.showTip; this.showHeaderTip = context.showHeaderTip; this.className = context.class || context.className; this.headerClassName = context.headerClassName; this.footerClassName = context.footerClassName; this.indexMethod = context.indexMethod; this.formatText = context.formatText; this.formatValue = context.formatValue; this.format = context.formatConfig; this.sortable = context.sortable; this.sortBy = context.sortBy; this.sortMethod = context.sortMethod; this.remoteSort = context.remoteSort; this.filterMultiple = isBoolean(context.filterMultiple) ? context.filterMultiple : true; this.filterMethod = context.filterMethod; this.filterRender = context.filterRender; this.filter = context.filter && initFilter(context.filter); this.treeNode = context.treeNode; this.renderer = context.renderer; this.editor = context.editor; this.operationConfig = context.operationConfig; this.equals = context.equals; this.params = context.params; this.visible = true; this.level = 1; this.rowSpan = 1; this.colSpan = 1; this.order = null; this.renderWidth = 0; this.renderHeight = 0; this.resizeWidth = 0; this.renderLeft = 0; this.model = {}; this.renderHeader = renderHeader || context.renderHeader; this.renderCell = renderCell || context.renderCell; this.renderData = renderData; this.showIcon = isBoolean(context.showIcon) ? context.showIcon : true; this.loading = false; this.slots = context.slots; this.own = context; this.asyncPrefix = config.constant.asyncPrefix; } set fixed(val) { this._fixed = val; this._fixedDetails = val ? new FixedDetails(val) : void 0; } get fixed() { return this._fixed; } get fixedDetails() { return this._fixedDetails; } } const getColumnConfig = (context, options, config) => context instanceof ColumnConfig ? context : new ColumnConfig(context, options, config); export { getColumnConfig };