vxe-table
Version:
A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.
1,665 lines • 59.6 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var import_vue = require("vue");
var import_xe_utils = __toESM(require("xe-utils"));
var import_core = require("@vxe-ui/core");
var import_util = require("../../table/src/util");
var import_utils = require("../../ui/src/utils");
var import_vn = require("../../ui/src/vn");
var import_log = require("../../ui/src/log");
const { errLog } = (0, import_log.createComponentLog)("table");
const { getConfig, renderer, getI18n, getComponent } = import_core.VxeUI;
const componentDefaultModelProp = "modelValue";
const defaultCompProps = {};
function handleDefaultValue(value, defaultVal, initVal) {
return import_xe_utils.default.eqNull(value) ? import_xe_utils.default.eqNull(defaultVal) ? initVal : defaultVal : value;
}
function parseDate(value, props) {
return value && props.valueFormat ? import_xe_utils.default.toStringDate(value, props.valueFormat) : value;
}
function getFormatDate(value, props, defaultFormat) {
const { dateConfig = {} } = props;
return import_xe_utils.default.toDateString(parseDate(value, props), dateConfig.labelFormat || defaultFormat);
}
function getLabelFormatDate(value, props) {
return getFormatDate(value, props, getI18n(`vxe.input.date.labelFormat.${props.type || "date"}`));
}
function getOldComponentName(name) {
return `vxe-${name.replace("$", "")}`;
}
function getDefaultComponent({ name }) {
return getComponent(name);
}
function getOldComponent({ name }) {
return (0, import_vue.resolveComponent)(getOldComponentName(name));
}
function updateFilterChangeOption(params, checked, option) {
const { $table } = params;
$table.updateFilterOptionStatus(option, checked);
}
function saveFilterEvent(params) {
const { $table, column } = params;
$table.saveFilterByEvent(new Event("change"), column);
}
function getNativeAttrs(renderOpts) {
let { name, attrs } = renderOpts;
if (name === "input") {
attrs = Object.assign({ type: "text" }, attrs);
}
return attrs;
}
function getInputImmediateModel(renderOpts) {
const { name, immediate, props } = renderOpts;
if (!immediate) {
if (name === "VxeInput" || name === "$input") {
const { type } = props || {};
return !(!type || type === "text" || type === "number" || type === "integer" || type === "float");
}
if (name === "input" || name === "textarea" || name === "$textarea") {
return false;
}
return true;
}
return immediate;
}
function getCellEditProps(renderOpts, params, value, defaultProps) {
return import_xe_utils.default.assign({ immediate: getInputImmediateModel(renderOpts) }, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value });
}
function getCellEditFilterProps(renderOpts, params, value, defaultProps) {
return import_xe_utils.default.assign({}, defaultCompProps, defaultProps, renderOpts.props, { [componentDefaultModelProp]: value });
}
function isImmediateCell(renderOpts, params) {
return params.$type === "cell" || getInputImmediateModel(renderOpts);
}
function getCellLabelVNs(renderOpts, params, cellLabel, opts) {
const { placeholder } = renderOpts;
return [
(0, import_vue.h)(
"span",
{
key: 1,
class: ["vxe-cell--label", opts ? opts.class : ""]
},
placeholder && (0, import_utils.isEmptyValue)(cellLabel) ? [
(0, import_vue.h)(
"span",
{
class: "vxe-cell--placeholder"
},
(0, import_utils.formatText)((0, import_utils.getFuncText)(placeholder), 1)
)
] : (0, import_utils.formatText)(cellLabel, 1)
)
];
}
function getNativeElementOns(renderOpts, params, eFns) {
const { events } = renderOpts;
const modelEvent = (0, import_vn.getModelEvent)(renderOpts);
const changeEvent = (0, import_vn.getChangeEvent)(renderOpts);
const { model: modelFunc, change: changeFunc, blur: blurFunc } = eFns || {};
const isSameEvent = changeEvent === modelEvent;
const ons = {};
if (events) {
import_xe_utils.default.objectEach(events, (func, key) => {
ons[(0, import_vn.getOnName)(key)] = function(...args) {
func(params, ...args);
};
});
}
if (modelFunc) {
ons[(0, import_vn.getOnName)(modelEvent)] = function(targetEvnt) {
modelFunc(targetEvnt);
if (isSameEvent && changeFunc) {
changeFunc(targetEvnt);
}
if (events && events[modelEvent]) {
events[modelEvent](params, targetEvnt);
}
};
}
if (!isSameEvent && changeFunc) {
ons[(0, import_vn.getOnName)(changeEvent)] = function(evnt) {
changeFunc(evnt);
if (events && events[changeEvent]) {
events[changeEvent](params, evnt);
}
};
}
if (blurFunc) {
ons[(0, import_vn.getOnName)(blurEvent)] = function(evnt) {
blurFunc(evnt);
if (events && events[blurEvent]) {
events[blurEvent](params, evnt);
}
};
}
return ons;
}
const blurEvent = "blur";
const clearEvent = "clear";
function getComponentOns(renderOpts, params, eFns, eventOns) {
const { events } = renderOpts;
const modelEvent = (0, import_vn.getModelEvent)(renderOpts);
const changeEvent = (0, import_vn.getChangeEvent)(renderOpts);
const { model: modelFunc, change: changeFunc, blur: blurFunc, clear: clearFunc } = eFns || {};
const ons = {};
import_xe_utils.default.objectEach(events, (func, key) => {
ons[(0, import_vn.getOnName)(key)] = function(...args) {
if (!import_xe_utils.default.isFunction(func)) {
errLog("vxe.error.errFunc", [func]);
}
func(params, ...args);
};
});
if (modelFunc) {
ons[(0, import_vn.getOnName)(modelEvent)] = function(targetEvnt) {
modelFunc(targetEvnt);
if (events && events[modelEvent]) {
events[modelEvent](params, targetEvnt);
}
};
}
if (changeFunc) {
ons[(0, import_vn.getOnName)(changeEvent)] = function(...args) {
changeFunc(...args);
if (events && events[changeEvent]) {
events[changeEvent](params, ...args);
}
};
}
if (blurFunc) {
ons[(0, import_vn.getOnName)(blurEvent)] = function(...args) {
blurFunc(...args);
if (events && events[blurEvent]) {
events[blurEvent](params, ...args);
}
};
}
if (clearFunc) {
ons[(0, import_vn.getOnName)(clearEvent)] = function(...args) {
clearFunc(...args);
if (events && events[clearEvent]) {
events[clearEvent](params, ...args);
}
};
}
return eventOns ? Object.assign(ons, eventOns) : ons;
}
function getEditOns(renderOpts, params) {
const { $table, row, column } = params;
const { name } = renderOpts;
const { model } = column;
const isImmediate = isImmediateCell(renderOpts, params);
return getComponentOns(renderOpts, params, {
model(cellValue) {
model.update = true;
model.value = cellValue;
if (isImmediate) {
(0, import_util.setCellValue)(row, column, cellValue);
}
},
change(eventParams) {
if (!isImmediate && name && ["VxeInput", "VxeNumberInput", "VxeTextarea", "$input", "$textarea"].includes(name)) {
const cellValue = eventParams.value;
model.update = true;
model.value = cellValue;
$table.updateStatus(params, cellValue);
} else {
$table.updateStatus(params);
}
},
blur() {
if (isImmediate) {
$table.handleCellRuleUpdateStatus("blur", params);
} else {
$table.handleCellRuleUpdateStatus("blur", params, model.value);
}
}
});
}
function getFilterOns(renderOpts, params, option) {
return getComponentOns(renderOpts, params, {
model(value) {
option.data = value;
},
change() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
},
blur() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
}
});
}
function getFloatingFilterOns(renderOpts, params, option) {
const { $table, column } = params;
if ((0, import_vn.hasInputType)(renderOpts)) {
return getComponentOns(
renderOpts,
params,
{
model(value) {
option.data = value;
},
change() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
},
clear() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
saveFilterEvent(params);
},
blur() {
$table.saveFilterByEvent(new Event("change"), column);
}
},
renderOpts.name === "VxeNumberInput" ? {
[(0, import_vn.getOnName)("plus-number")]() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
saveFilterEvent(params);
},
[(0, import_vn.getOnName)("minus-number")]() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
saveFilterEvent(params);
}
} : {}
);
}
return getComponentOns(renderOpts, params, {
model(value) {
option.data = value;
},
clear() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
$table.saveFilterByEvent(new Event("change"), column);
},
change() {
updateFilterChangeOption(params, !(0, import_utils.isEmptyValue)(option.data), option);
$table.saveFilterByEvent(new Event("change"), column);
}
});
}
function getNativeEditOns(renderOpts, params) {
const { $table, row, column } = params;
const { model } = column;
return getNativeElementOns(renderOpts, params, {
model(evnt) {
const targetEl = evnt.target;
if (targetEl) {
const cellValue = targetEl.value;
if (isImmediateCell(renderOpts, params)) {
(0, import_util.setCellValue)(row, column, cellValue);
} else {
model.update = true;
model.value = cellValue;
}
}
},
change(evnt) {
const targetEl = evnt.target;
if (targetEl) {
const cellValue = targetEl.value;
$table.updateStatus(params, cellValue);
}
},
blur(evnt) {
const targetEl = evnt.target;
if (targetEl) {
const cellValue = targetEl.value;
$table.updateStatus(params, cellValue);
}
}
});
}
function getNativeFilterOns(renderOpts, params, option) {
return getNativeElementOns(renderOpts, params, {
model(evnt) {
const targetEl = evnt.target;
if (targetEl) {
option.data = targetEl.value;
}
},
change() {
updateFilterChangeOption(params, !import_xe_utils.default.eqNull(option.data), option);
},
blur() {
updateFilterChangeOption(params, !import_xe_utils.default.eqNull(option.data), option);
}
});
}
function nativeInputCellRender(renderOpts, renderParams) {
const { row, column } = renderParams;
const cellValue = import_xe_utils.default.get(row, column.field);
const cellVNs = [
(0, import_vue.h)(
"span",
{
key: 1
},
cellValue
)
];
return getNativeInputRenderCellVNs(cellValue, cellVNs, renderOpts, renderParams);
}
function nativeInputEditRender(renderOpts, renderParams) {
const { row, column } = renderParams;
const { name } = renderOpts;
const cellValue = isImmediateCell(renderOpts, renderParams) ? (0, import_util.getCellValue)(row, column) : column.model.value;
return [
(0, import_vue.h)("" + name, {
key: 2,
class: `vxe-default-${name}`,
...getNativeAttrs(renderOpts),
value: cellValue,
...getNativeEditOns(renderOpts, renderParams)
})
];
}
function buttonCellRender(renderOpts, params) {
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, null),
...getComponentOns(renderOpts, params)
})
];
}
function defaultInputEditRender(renderOpts, params) {
const { row, column } = params;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
key: 2,
...getCellEditProps(renderOpts, params, cellValue),
...getEditOns(renderOpts, params)
})
];
}
function defaultEditRender(renderOpts, params) {
const { row, column } = params;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue),
...getEditOns(renderOpts, params)
})
];
}
function checkboxEditRender(renderOpts, params) {
const { row, column } = params;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue),
...getEditOns(renderOpts, params)
})
];
}
function radioAndCheckboxGroupEditRender(renderOpts, params) {
const { options } = renderOpts;
const { row, column } = params;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
options,
...getCellEditProps(renderOpts, params, cellValue),
...getEditOns(renderOpts, params)
})
];
}
function oldEditRender(renderOpts, params) {
const { row, column } = params;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getOldComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue),
...getEditOns(renderOpts, params)
})
];
}
function oldButtonEditRender(renderOpts, params) {
return [
(0, import_vue.h)(getComponent("vxe-button"), {
...getCellEditProps(renderOpts, params, null),
...getComponentOns(renderOpts, params)
})
];
}
function oldButtonsEditRender(renderOpts, params) {
const { children } = renderOpts;
return children ? children.map((childRenderOpts) => oldButtonEditRender(childRenderOpts, params)[0]) : [];
}
function renderNativeOptgroups(renderOpts, params, renderOptionsMethods) {
const { optionGroups, optionGroupProps = {} } = renderOpts;
const groupOptions = optionGroupProps.options || "options";
const groupLabel = optionGroupProps.label || "label";
if (optionGroups) {
return optionGroups.map((group, gIndex) => {
return (0, import_vue.h)(
"optgroup",
{
key: gIndex,
label: group[groupLabel]
},
renderOptionsMethods(group[groupOptions], renderOpts, params)
);
});
}
return [];
}
function renderNativeOptions(options, renderOpts, params) {
const { optionProps = {} } = renderOpts;
const { row, column } = params;
const labelProp = optionProps.label || "label";
const valueProp = optionProps.value || "value";
const disabledProp = optionProps.disabled || "disabled";
const cellValue = isImmediateCell(renderOpts, params) ? (0, import_util.getCellValue)(row, column) : column.model.value;
if (options) {
return options.map((option, oIndex) => {
return (0, import_vue.h)(
"option",
{
key: oIndex,
value: option[valueProp],
disabled: option[disabledProp],
/* eslint-disable eqeqeq */
selected: option[valueProp] == cellValue
},
option[labelProp]
);
});
}
return [];
}
function nativeFilterRender(renderOpts, params) {
const { column } = params;
const { name } = renderOpts;
const attrs = getNativeAttrs(renderOpts);
return column.filters.map((option, oIndex) => {
return (0, import_vue.h)(`${name}`, {
key: oIndex,
class: `vxe-default-${name}`,
...attrs,
value: option.data,
...getNativeFilterOns(renderOpts, params, option)
});
});
}
function defaultFilterRender(renderOpts, params) {
const { column } = params;
return column.filters.map((option, oIndex) => {
const optionValue = option.data;
return (0, import_vue.h)(getDefaultComponent(renderOpts), {
key: oIndex,
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
...getFilterOns(renderOpts, params, option)
});
});
}
function defaultFloatingFilterRender(renderOpts, params) {
const { option } = params;
const optionValue = option.data;
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
...getFloatingFilterOns(renderOpts, params, option)
})
];
}
function defaultFilterOptions() {
return [{ data: null }];
}
function oldFilterRender(renderOpts, params) {
const { column } = params;
return column.filters.map((option, oIndex) => {
const optionValue = option.data;
return (0, import_vue.h)(getOldComponent(renderOpts), {
key: oIndex,
...getCellEditFilterProps(renderOpts, renderOpts, optionValue),
...getFilterOns(renderOpts, params, option)
});
});
}
function handleFilterMethod({ option, row, column }) {
const { data } = option;
const cellValue = import_xe_utils.default.get(row, column.field);
return cellValue == data;
}
function handleInputFilterMethod({ option, row, column }) {
const { data } = option;
const cellValue = import_xe_utils.default.get(row, column.field);
return import_xe_utils.default.toValueString(cellValue).indexOf(data) > -1;
}
function nativeSelectEditRender(renderOpts, params) {
return [
(0, import_vue.h)(
"select",
{
class: "vxe-default-select",
...getNativeAttrs(renderOpts),
...getNativeEditOns(renderOpts, params)
},
renderOpts.optionGroups ? renderNativeOptgroups(renderOpts, params, renderNativeOptions) : renderNativeOptions(renderOpts.options, renderOpts, params)
)
];
}
function defaultSelectEditRender(renderOpts, params) {
const { row, column } = params;
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
...getEditOns(renderOpts, params)
})
];
}
function defaultTableOrTreeSelectEditRender(renderOpts, params) {
const { row, column } = params;
const { options, optionProps } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps }),
...getEditOns(renderOpts, params)
})
];
}
function oldSelectEditRender(renderOpts, params) {
const { row, column } = params;
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getOldComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue, { options, optionProps, optionGroups, optionGroupProps }),
...getEditOns(renderOpts, params)
})
];
}
function handleSelectCellValue(cellValue, renderOpts) {
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props = {} } = renderOpts;
let selectItem;
const labelProp = optionProps.label || "label";
const valueProp = optionProps.value || "value";
if (!(cellValue === null || cellValue === void 0)) {
let vals = [];
if (import_xe_utils.default.isArray(cellValue)) {
vals = cellValue;
} else {
if (props.multiple && `${cellValue}`.indexOf(",") > -1) {
vals = `${cellValue}`.split(",");
} else {
vals = [cellValue];
}
}
return import_xe_utils.default.map(
vals,
optionGroups ? (value) => {
const groupOptions = optionGroupProps.options || "options";
for (let index = 0; index < optionGroups.length; index++) {
selectItem = import_xe_utils.default.find(optionGroups[index][groupOptions], (item) => item[valueProp] == value);
if (selectItem) {
break;
}
}
return selectItem ? selectItem[labelProp] : value;
} : (value) => {
selectItem = import_xe_utils.default.find(options, (item) => item[valueProp] == value);
return selectItem ? selectItem[labelProp] : value;
}
).join(", ");
}
return "";
}
function getSelectCellValue(renderOpts, { row, column }) {
const cellValue = import_xe_utils.default.get(row, column.field);
return handleSelectCellValue(cellValue, renderOpts);
}
function handleExportSelectMethod(params) {
const { row, column, options } = params;
return options.original ? (0, import_util.getCellValue)(row, column) : getSelectCellValue(column.editRender || column.cellRender, params);
}
function handleTreeSelectCellValue(cellValue, renderOpts) {
const { options, optionProps = {} } = renderOpts;
const labelProp = optionProps.label || "label";
const valueProp = optionProps.value || "value";
const childrenProp = optionProps.children || "children";
if (!(cellValue === null || cellValue === void 0)) {
const keyMaps = {};
import_xe_utils.default.eachTree(
options,
(item) => {
keyMaps[import_xe_utils.default.get(item, valueProp)] = item;
},
{ children: childrenProp }
);
return import_xe_utils.default.map(import_xe_utils.default.isArray(cellValue) ? cellValue : [cellValue], (value) => {
const item = keyMaps[value];
return item ? import_xe_utils.default.get(item, labelProp) : item;
}).join(", ");
}
return "";
}
function getTreeSelectCellValue(renderOpts, { row, column }) {
const cellValue = import_xe_utils.default.get(row, column.field);
return handleTreeSelectCellValue(cellValue, renderOpts);
}
function handleExportTreeSelectMethod(params) {
const { row, column, options } = params;
return options.original ? (0, import_util.getCellValue)(row, column) : getTreeSelectCellValue(column.editRender || column.cellRender, params);
}
function handleNumberCell(cellValue, renderOpts, params) {
const { props = {}, showNegativeStatus } = renderOpts;
const { type } = props;
let isNegative = false;
if (!(0, import_utils.isEmptyValue)(cellValue)) {
const numberInputConfig = getConfig().numberInput || {};
if (type === "float") {
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1);
cellValue = import_xe_utils.default.toFixed(import_xe_utils.default.floor(cellValue, digits), digits);
if (!autoFill) {
cellValue = import_xe_utils.default.toNumber(cellValue);
}
if (showNegativeStatus) {
if (cellValue < 0) {
isNegative = true;
}
}
} else if (type === "amount") {
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2);
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false);
cellValue = import_xe_utils.default.toNumber(cellValue);
if (showNegativeStatus) {
if (cellValue < 0) {
isNegative = true;
}
}
cellValue = import_xe_utils.default.commafy(cellValue, { digits });
if (!autoFill) {
const [iStr, dStr] = cellValue.split(".");
if (dStr) {
const dRest = dStr.replace(/0+$/, "");
cellValue = dRest ? [iStr, ".", dRest].join("") : iStr;
}
}
if (showCurrency) {
cellValue = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n("vxe.numberInput.currencySymbol") || ""}${cellValue}`;
}
} else {
if (type === "integer") {
cellValue = import_xe_utils.default.toInteger(cellValue);
}
if (showNegativeStatus) {
if (import_xe_utils.default.toNumber(cellValue) < 0) {
isNegative = true;
}
}
}
}
return getCellLabelVNs(
renderOpts,
params,
cellValue,
isNegative ? {
class: "is--negative"
} : {}
);
}
function handleFormatDatePicker(renderOpts, renderParams) {
const { props = {} } = renderOpts;
const { cellValue } = renderParams;
if (cellValue) {
if (props.type !== "time") {
return getLabelFormatDate(cellValue, props);
}
}
return cellValue;
}
function handleFormatSelect(renderOpts, renderParams) {
const { cellValue } = renderParams;
return handleSelectCellValue(cellValue, renderOpts);
}
function handleSetSelectValue(renderOpts, renderParams) {
const { row, column, cellValue } = renderParams;
const { field } = column;
if (field) {
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props } = renderOpts;
if ((0, import_utils.isEmptyValue)(cellValue)) {
import_xe_utils.default.set(row, field, props && props.multiple ? [] : null);
return;
}
const isMultiVal = import_xe_utils.default.indexOf(`${cellValue}`, ",") > -1;
const labelProp = optionProps.label || "label";
const valueProp = optionProps.value || "value";
const labelMpas = {};
if (optionGroups && optionGroups.length) {
const groupOptions = optionGroupProps.options || "options";
for (let i = 0; i < optionGroups.length; i++) {
const opts = optionGroups[i][groupOptions] || {};
for (let j = 0; j < opts.length; j++) {
const item = opts[j];
if (isMultiVal) {
labelMpas[item[labelProp]] = item;
} else if (item[labelProp] == cellValue) {
import_xe_utils.default.set(row, field, item[valueProp]);
return;
}
}
}
} else {
if (options) {
for (let i = 0; i < options.length; i++) {
const item = options[i];
if (isMultiVal) {
labelMpas[item[labelProp]] = item;
} else if (item[labelProp] == cellValue) {
import_xe_utils.default.set(row, field, item[valueProp]);
return;
}
}
}
}
if (isMultiVal) {
import_xe_utils.default.set(
row,
field,
(isMultiVal ? cellValue.split(",") : [cellValue]).map((label) => {
const item = labelMpas[label];
return item ? item[valueProp] : label;
})
);
} else {
import_xe_utils.default.set(row, field, cellValue);
}
}
}
function handleFormatTreeSelect(renderOpts, params) {
const { cellValue } = params;
return handleTreeSelectCellValue(cellValue, renderOpts);
}
function handleSetTreeSelectValue(renderOpts, params) {
const { row, column, cellValue } = params;
const { field } = column;
if (field) {
const { options, optionProps = {} } = renderOpts;
const labelProp = optionProps.label || "label";
const valueProp = optionProps.value || "value";
const childrenProp = optionProps.children || "children";
const matchRest = import_xe_utils.default.findTree(options || [], (item) => import_xe_utils.default.get(item, labelProp) === cellValue, { children: childrenProp });
if (matchRest) {
const selectItem = matchRest.item;
if (selectItem) {
import_xe_utils.default.set(row, field, selectItem[valueProp]);
return;
}
}
import_xe_utils.default.set(row, field, cellValue);
}
}
function getNativeInputRenderCellVNs(cellValue, labelVNs, renderOpts, renderParams) {
const { $table, row, column } = renderParams;
const { name } = renderOpts;
const tableProps = $table.props;
const { editConfig, mouseConfig } = tableProps;
const { computeMouseOpts } = $table.getComputeMaps();
const mouseOpts = computeMouseOpts.value;
let isColSelected = false;
let isActiveCellArea = false;
if (editConfig && (0, import_utils.hasEnableConf)(mouseConfig, mouseOpts)) {
const tableReactData = $table.reactData;
const { editStore } = tableReactData;
const { selected } = editStore;
isColSelected = row === selected.row && column === selected.column;
if ($table.getActiveCellArea) {
const activeCellArea = $table.getActiveCellArea();
if (activeCellArea) {
isActiveCellArea = row === activeCellArea.row && column === activeCellArea.column;
}
}
}
const cellVNs = labelVNs;
if (isActiveCellArea || isColSelected) {
cellVNs.push(
(0, import_vue.h)("" + name, {
key: 2,
class: `vxe-default-${name} vxe-reusekeep-control`,
value: cellValue,
...getNativeAttrs(renderOpts),
...getNativeEditOns(renderOpts, renderParams)
})
);
}
return cellVNs;
}
function getInputRenderCellVNs(cellValue, labelVNs, renderOpts, renderParams) {
const { $table, row, column } = renderParams;
const tableProps = $table.props;
const { editConfig, mouseConfig } = tableProps;
const { computeEditOpts, computeMouseOpts } = $table.getComputeMaps();
const mouseOpts = computeMouseOpts.value;
let isColSelected = false;
let isActiveCellArea = false;
if (editConfig && (0, import_utils.hasEnableConf)(mouseConfig, mouseOpts)) {
const tableReactData = $table.reactData;
const { editStore } = tableReactData;
const editOpts = computeEditOpts.value;
if (editOpts.isReuseKeep) {
const { selected } = editStore;
isColSelected = row === selected.row && column === selected.column;
if ($table.getActiveCellArea) {
const activeCellArea = $table.getActiveCellArea();
if (activeCellArea) {
isActiveCellArea = row === activeCellArea.row && column === activeCellArea.column;
}
}
}
}
const cellVNs = labelVNs;
if (isActiveCellArea || isColSelected) {
const compProps = getCellEditProps(renderOpts, renderParams, cellValue);
const { className, inputClassName } = compProps;
cellVNs.push(
(0, import_vue.h)(getDefaultComponent(renderOpts), {
key: 2,
...compProps,
className: "vxe-reusekeep-control" + (className ? " " + className : ""),
inputClassName: "vxe-reusekeep-control" + (inputClassName ? " " + inputClassName : ""),
...getEditOns(renderOpts, renderParams)
})
);
}
return cellVNs;
}
renderer.mixin({
input: {
tableAutoFocus: true,
renderTableEdit: nativeInputEditRender,
renderTableCell: nativeInputCellRender,
renderTableDefault: nativeInputEditRender,
createTableFilterOptions: defaultFilterOptions,
renderTableFilter: nativeFilterRender,
tableFilterDefaultMethod: handleInputFilterMethod
},
textarea: {
tableAutoFocus: true,
renderTableEdit: nativeInputEditRender,
renderTableCell: nativeInputCellRender,
renderTableDefault: nativeInputEditRender
},
select: {
renderTableEdit: nativeSelectEditRender,
renderTableDefault: nativeSelectEditRender,
renderTableCell(renderOpts, params) {
const { options, optionGroups } = renderOpts;
const { $table, row, column } = params;
const opSize = options ? options.length : null;
const ogSize = optionGroups ? optionGroups.length : null;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
isChanged({ oldValue, cellValue }) {
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize;
},
setValue({ cellValue }) {
return [cellValue, opSize, ogSize];
},
getResult({ cellValue }) {
return handleSelectCellValue(cellValue, renderOpts);
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
createTableFilterOptions: defaultFilterOptions,
renderTableFilter(renderOpts, params) {
const { column } = params;
return column.filters.map((option, oIndex) => {
return (0, import_vue.h)(
"select",
{
key: oIndex,
class: "vxe-default-select",
...getNativeAttrs(renderOpts),
...getNativeFilterOns(renderOpts, params, option)
},
renderOpts.optionGroups ? renderNativeOptgroups(renderOpts, params, renderNativeOptions) : renderNativeOptions(renderOpts.options, renderOpts, params)
);
});
},
tableCellFormatter: handleFormatSelect,
tableCellCopyMethod: handleFormatSelect,
tableCellPasteMethod: handleSetSelectValue,
tableFilterDefaultMethod: handleFilterMethod,
tableExportMethod: handleExportSelectMethod
},
VxeInput: {
tableAutoFocus: true,
renderTableEdit: defaultInputEditRender,
renderTableCell(renderOpts, renderParams) {
const { props = {} } = renderOpts;
const { row, column } = renderParams;
const inputConfig = getConfig().input || {};
const digits = props.digits || inputConfig.digits || 2;
let cellValue = import_xe_utils.default.get(row, column.field);
if (cellValue) {
switch (props.type) {
case "date":
case "week":
case "month":
case "quarter":
case "year":
cellValue = getLabelFormatDate(cellValue, props);
break;
case "float":
cellValue = import_xe_utils.default.toFixed(import_xe_utils.default.floor(cellValue, digits), digits);
break;
}
}
const cellVNs = getCellLabelVNs(renderOpts, renderParams, cellValue);
return getInputRenderCellVNs(cellValue, cellVNs, renderOpts, renderParams);
},
renderTableDefault: defaultInputEditRender,
createTableFilterOptions: defaultFilterOptions,
renderTableFilter: defaultFilterRender,
renderTableFloatingFilter: defaultFloatingFilterRender,
tableFilterDefaultMethod: handleInputFilterMethod
},
FormatNumberInput: {
renderTableDefault(renderOpts, renderParams) {
const { row, column } = renderParams;
const cellValue = import_xe_utils.default.get(row, column.field);
return handleNumberCell(cellValue, renderOpts, renderParams);
},
tableFilterDefaultMethod({ option, row, column }) {
const { data } = option;
const cellValue = import_xe_utils.default.get(row, column.field);
return cellValue == data;
},
tableExportMethod(params) {
const { row, column } = params;
const cellValue = import_xe_utils.default.get(row, column.field);
return cellValue;
}
},
VxeNumberInput: {
tableAutoFocus: true,
renderTableEdit: defaultInputEditRender,
renderTableCell(renderOpts, renderParams) {
const { row, column } = renderParams;
const cellValue = import_xe_utils.default.get(row, column.field);
const cellVNs = handleNumberCell(cellValue, renderOpts, renderParams);
return getInputRenderCellVNs(cellValue, cellVNs, renderOpts, renderParams);
},
renderTableFooter(renderOpts, params) {
const { props = {} } = renderOpts;
const { row, column, _columnIndex } = params;
const { type } = props;
const itemValue = import_xe_utils.default.isArray(row) ? row[_columnIndex] : import_xe_utils.default.get(row, column.field);
if (import_xe_utils.default.isNumber(itemValue)) {
const numberInputConfig = getConfig().numberInput || {};
if (type === "float") {
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 1);
let amountLabel = import_xe_utils.default.toFixed(import_xe_utils.default.floor(itemValue, digits), digits);
if (!autoFill) {
amountLabel = "" + import_xe_utils.default.toNumber(amountLabel);
}
return amountLabel;
} else if (type === "amount") {
const autoFill = handleDefaultValue(props.autoFill, numberInputConfig.autoFill, true);
const digits = handleDefaultValue(props.digits, numberInputConfig.digits, 2);
const showCurrency = handleDefaultValue(props.showCurrency, numberInputConfig.showCurrency, false);
let amountLabel = import_xe_utils.default.commafy(import_xe_utils.default.toNumber(itemValue), { digits });
if (!autoFill) {
const [iStr, dStr] = amountLabel.split(".");
if (dStr) {
const dRest = dStr.replace(/0+$/, "");
amountLabel = dRest ? [iStr, ".", dRest].join("") : iStr;
}
}
if (showCurrency) {
amountLabel = `${props.currencySymbol || numberInputConfig.currencySymbol || getI18n("vxe.numberInput.currencySymbol") || ""}${amountLabel}`;
}
return amountLabel;
}
}
return (0, import_utils.getFuncText)(itemValue, 1);
},
renderTableDefault: defaultInputEditRender,
createTableFilterOptions: defaultFilterOptions,
renderTableFilter: defaultFilterRender,
renderTableFloatingFilter: defaultFloatingFilterRender,
tableFilterDefaultMethod({ option, row, column }) {
const { data } = option;
const cellValue = import_xe_utils.default.get(row, column.field);
return cellValue == data;
},
tableExportMethod(params) {
const { row, column } = params;
const cellValue = import_xe_utils.default.get(row, column.field);
return cellValue;
}
},
VxeDatePicker: {
tableAutoFocus: true,
renderTableEdit: defaultEditRender,
renderTableCell(renderOpts, params) {
const props = renderOpts.props || {};
const { $table, row, column } = params;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
getResult({ cellValue }) {
if (cellValue) {
if (props.type !== "time") {
return getLabelFormatDate(cellValue, props);
}
}
return cellValue;
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
tableCellFormatter: handleFormatDatePicker,
renderTableDefault: defaultEditRender,
createTableFilterOptions: defaultFilterOptions,
renderTableFilter: defaultFilterRender,
renderTableFloatingFilter: defaultFloatingFilterRender,
tableFilterDefaultMethod: handleFilterMethod
},
VxeDateRangePicker: {
tableAutoFocus: true,
renderTableEdit(renderOpts, params) {
const { startField, endField } = renderOpts;
const { $table, row, column } = params;
const { model } = column;
const cellValue = (0, import_util.getCellValue)(row, column);
const seProps = {};
const seOs = {};
if (startField && endField) {
seProps.startValue = import_xe_utils.default.get(row, startField);
seProps.endValue = import_xe_utils.default.get(row, endField);
seOs["onUpdate:startValue"] = (value) => {
if (startField) {
import_xe_utils.default.set(row, startField, value);
}
};
seOs["onUpdate:endValue"] = (value) => {
if (endField) {
import_xe_utils.default.set(row, endField, value);
}
};
}
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue, seProps),
...getComponentOns(
renderOpts,
params,
{
model(cellValue2) {
model.update = true;
model.value = cellValue2;
(0, import_util.setCellValue)(row, column, cellValue2);
},
change() {
$table.updateStatus(params);
},
blur() {
$table.handleCellRuleUpdateStatus("blur", params);
}
},
seOs
)
})
];
},
renderTableDefault(renderOpts, params) {
const { startField, endField } = renderOpts;
const { row, column } = params;
const { model } = column;
const cellValue = (0, import_util.getCellValue)(row, column);
const seProps = {};
const seOs = {};
if (startField && endField) {
seProps.startValue = import_xe_utils.default.get(row, startField);
seProps.endValue = import_xe_utils.default.get(row, endField);
seOs["onUpdate:startValue"] = (value) => {
if (startField) {
import_xe_utils.default.set(row, startField, value);
}
};
seOs["onUpdate:endValue"] = (value) => {
if (endField) {
import_xe_utils.default.set(row, endField, value);
}
};
}
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue, seProps),
...getComponentOns(
renderOpts,
params,
{
model(cellValue2) {
model.update = true;
model.value = cellValue2;
(0, import_util.setCellValue)(row, column, cellValue2);
}
},
seOs
)
})
];
},
renderTableCell(renderOpts, params) {
const { startField, endField } = renderOpts;
const { row, column } = params;
let startValue = "";
let endValue = "";
if (startField && endField) {
startValue = import_xe_utils.default.get(row, startField);
endValue = import_xe_utils.default.get(row, endField);
} else {
const cellValue = import_xe_utils.default.get(row, column.field);
if (cellValue) {
if (import_xe_utils.default.isArray(cellValue)) {
startValue = cellValue[0];
endValue = cellValue[1];
} else {
const strs = `${cellValue}`.split(",");
startValue = strs[0];
endValue = strs[1];
}
}
}
let cellLabel = "";
if (startValue && endValue) {
cellLabel = `${startValue} ~ ${endValue}`;
}
return getCellLabelVNs(renderOpts, params, cellLabel);
}
},
VxeTextarea: {
tableAutoFocus: true,
renderTableDefault: defaultInputEditRender,
renderTableCell(renderOpts, renderParams) {
const { row, column } = renderParams;
const cellValue = import_xe_utils.default.get(row, column.field);
const cellVNs = getCellLabelVNs(renderOpts, renderParams, cellValue);
return getInputRenderCellVNs(cellValue, cellVNs, renderOpts, renderParams);
},
renderTableEdit: defaultInputEditRender
},
VxeButton: {
renderTableDefault: buttonCellRender
},
VxeButtonGroup: {
renderTableDefault(renderOpts, params) {
const { options } = renderOpts;
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
options,
...getCellEditProps(renderOpts, params, null),
...getComponentOns(renderOpts, params)
})
];
}
},
VxeSelect: {
tableAutoFocus: true,
renderTableEdit: defaultSelectEditRender,
renderTableDefault: defaultSelectEditRender,
renderTableCell(renderOpts, params) {
const { options, optionGroups } = renderOpts;
const { $table, row, column } = params;
const opSize = options ? options.length : null;
const ogSize = optionGroups ? optionGroups.length : null;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
isChanged({ oldValue, cellValue }) {
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize;
},
setValue({ cellValue }) {
return [cellValue, opSize, ogSize];
},
getResult({ cellValue }) {
return handleSelectCellValue(cellValue, renderOpts);
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
createTableFilterOptions: defaultFilterOptions,
renderTableFilter(renderOpts, params) {
const { column } = params;
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
return column.filters.map((option, oIndex) => {
const optionValue = option.data;
return (0, import_vue.h)(getDefaultComponent(renderOpts), {
key: oIndex,
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
...getFilterOns(renderOpts, params, option)
});
});
},
renderTableFloatingFilter(renderOpts, params) {
const { option } = params;
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
const optionValue = option.data;
return (0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
...getFloatingFilterOns(renderOpts, params, option)
});
},
tableCellFormatter: handleFormatSelect,
tableCellCopyMethod: handleFormatSelect,
tableCellPasteMethod: handleSetSelectValue,
tableFilterDefaultMethod: handleFilterMethod,
tableExportMethod: handleExportSelectMethod
},
VxeText: {
renderTableDefault(renderOpts, params) {
const { $table, row, column } = params;
const { props } = renderOpts;
const cellLabel = $table.getCellLabel(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...props || {},
content: cellLabel,
...getComponentOns(renderOpts, params)
})
];
}
},
VxeLink: {
renderTableDefault(renderOpts, params) {
const { $table, row, column } = params;
const { props } = renderOpts;
const { href } = props || {};
const cellLabel = $table.getCellLabel(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...props || {},
content: cellLabel,
href: import_xe_utils.default.toFormatString(href, params),
...getComponentOns(renderOpts, params)
})
];
}
},
/**
* 已废弃,被 FormatSelect 替换
* @deprecated
*/
formatOption: {
renderTableDefault(renderOpts, params) {
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params));
}
},
FormatSelect: {
renderTableDefault(renderOpts, params) {
const { options, optionGroups } = renderOpts;
const { $table, row, column } = params;
const opSize = options ? options.length : null;
const ogSize = optionGroups ? optionGroups.length : null;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
isChanged({ oldValue, cellValue }) {
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize;
},
setValue({ cellValue }) {
return [cellValue, opSize, ogSize];
},
getResult({ cellValue }) {
return handleSelectCellValue(cellValue, renderOpts);
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
tableCellFormatter: handleFormatSelect,
tableCellCopyMethod: handleFormatSelect,
tableCellPasteMethod: handleSetSelectValue,
tableFilterDefaultMethod: handleFilterMethod,
tableExportMethod: handleExportSelectMethod
},
VxeTreeSelect: {
tableAutoFocus: true,
renderTableEdit: defaultTableOrTreeSelectEditRender,
renderTableCell(renderOpts, params) {
const { options, optionGroups } = renderOpts;
const { $table, row, column } = params;
const opSize = options ? options.length : null;
const ogSize = optionGroups ? optionGroups.length : null;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
isChanged({ oldValue, cellValue }) {
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize;
},
setValue({ cellValue }) {
return [cellValue, opSize, ogSize];
},
getResult({ cellValue }) {
return handleTreeSelectCellValue(cellValue, renderOpts);
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
tableCellFormatter: handleFormatTreeSelect,
tableCellCopyMethod: handleFormatTreeSelect,
tableCellPasteMethod: handleSetTreeSelectValue,
tableExportMethod: handleExportTreeSelectMethod
},
/**
* 已废弃,被 FormatTreeSelect 替换
* @deprecated
*/
formatTree: {
renderTableDefault(renderOpts, params) {
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params));
}
},
FormatTreeSelect: {
renderTableDefault(renderOpts, params) {
const { options, optionGroups } = renderOpts;
const { $table, row, column } = params;
const opSize = options ? options.length : null;
const ogSize = optionGroups ? optionGroups.length : null;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
isChanged({ oldValue, cellValue }) {
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize;
},
setValue({ cellValue }) {
return [cellValue, opSize, ogSize];
},
getResult({ cellValue }) {
return handleTreeSelectCellValue(cellValue, renderOpts);
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
tableCellFormatter: handleFormatTreeSelect,
tableCellCopyMethod: handleFormatTreeSelect,
tableCellPasteMethod: handleSetTreeSelectValue,
tableExportMethod: handleExportTreeSelectMethod
},
VxeCascader: {
tableAutoFocus: true,
renderTableEdit: defaultTableOrTreeSelectEditRender,
renderTableCell(renderOpts, params) {
const { options, optionGroups } = renderOpts;
const { $table, row, column } = params;
const opSize = options ? options.length : null;
const ogSize = optionGroups ? optionGroups.length : null;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
isChanged({ oldValue, cellValue }) {
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize;
},
setValue({ cellValue }) {
return [cellValue, opSize, ogSize];
},
getResult({ cellValue }) {
return handleTreeSelectCellValue(cellValue, renderOpts);
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
tableCellFormatter: handleFormatTreeSelect,
tableCellCopyMethod: handleFormatTreeSelect,
tableCellPasteMethod: handleSetTreeSelectValue,
tableExportMethod: handleExportTreeSelectMethod
},
VxeTableSelect: {
tableAutoFocus: true,
renderTableEdit: defaultTableOrTreeSelectEditRender,
renderTableCell(renderOpts, params) {
const { options, optionGroups } = renderOpts;
const { $table, row, column } = params;
const opSize = options ? options.length : null;
const ogSize = optionGroups ? optionGroups.length : null;
const { cellResult } = $table.effectCellData(row, column, {
key: "render_table_cell",
isChanged({ oldValue, cellValue }) {
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize;
},
setValue({ cellValue }) {
return [cellValue, opSize, ogSize];
},
getResult({ cellValue }) {
return handleTreeSelectCellValue(cellValue, renderOpts);
}
});
return getCellLabelVNs(renderOpts, params, cellResult);
},
tableCellFormatter: handleFormatTreeSelect,
tableCellCopyMethod: handleFormatTreeSelect,
tableCellPasteMethod: handleSetTreeSelectValue,
tableExportMethod: handleExportTreeSelectMethod
},
VxeColorPicker: {
tableAutoFocus: true,
renderTableEdit(renderOpts, params) {
const { row, column } = params;
const { options } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue, { colors: options }),
...getEditOns(renderOpts, params)
})
];
},
renderTableCell(renderOpts, params) {
const { $table, row, column } = params;
const { props } = renderOpts;
const { computeSize } = $table.getComputeMaps();
const customSize = props ? props.size : null;
const vSize = customSize || computeSize.value;
const cellValue = import_xe_utils.default.get(row, column.field);
return (0, import_vue.h)(
"span",
{
class: [
"vxe-color-picker--readonly",
{
[`size--${vSize}`]: vSize
}
]
},
[
(0, import_vue.h)("div", {
class: [
"vxe-color-picker--readonly-color",
{
"is--empty": !cellValue
}
],
style: cellValue ? {
backgroundColor: cellValue
} : void 0
})
]
);
}
},
VxeIconPicker: {
tableAutoFocus: true,
renderTableEdit(renderOpts, params) {
const { row, column } = params;
const { options } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...getCellEditProps(renderOpts, params, cellValue, { icons: options }),
...getEditOns(renderOpts, params)
})
];
},
renderTableCell(renderOpts, params) {
const { row, column } = params;
const cellValue = import_xe_utils.default.get(row, column.field);
return (0, import_vue.h)("i", {
class: cellValue
});
}
},
VxeRadioGroup: {
renderTableDefault: radioAndCheckboxGroupEditRender
},
VxeCheckbox: {
renderTableDefault: checkboxEditRender
},
VxeCheckboxGroup: {
renderTableDefault: radioAndCheckboxGroupEditRender
},
VxeSwitch: {
tableAutoFocus: "button",
renderTableEdit: defaultEditRender,
renderTableDefault: defaultEditRender
},
VxeUpload: {
renderTableEdit: defaultEditRender,
renderTableCell: defaultEditRender,
renderTableDefault: defaultEditRender
},
VxeImage: {
renderTableDefault(renderOpts, params) {
const { row, column } = params;
const { props } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...props,
src: cellValue,
...getEditOns(renderOpts, params)
})
];
}
},
VxeImageGroup: {
renderTableDefault(renderOpts, params) {
const { row, column } = params;
const { props } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...props,
urlList: cellValue,
...getEditOns(renderOpts, params)
})
];
}
},
VxeTextEllipsis: {
renderTableDefault(renderOpts, params) {
const { row, column } = params;
const { props } = renderOpts;
const cellValue = (0, import_util.getCellValue)(row, column);
return [
(0, import_vue.h)(getDefaultComponent(renderOpts), {
...props,
content: cellValue,
...getEditOns(renderOpts, params)
})
];
}
},
VxeRate: {
renderTableDefault: defaultEditRender
},
VxeSlider: {
renderTableDefault: defaultEditRender
},
// 以下已废弃
$input: {
tableAutoFocus: "input",
renderTableEdit: oldEditRender,
renderTableCell(renderOpts, params) {
var _a;
const { props = {} } = renderOpts;
const { row, column } = params;
const digits = props.digits || ((_a = getConfig().input) == null ? void 0 : _a.digits) || 2;
let cellValue = import_xe_utils.default.get(row, column.field);
if (cellValue) {
switch (props.type) {
case "date":
case "week":
case "month":
case "year":
cellValue = getLabelFormatDate(cellValue, props);
break;
case "float":
cellValue = import_xe_utils.default.toFixed(import_xe_utils.default.floor(cellValue, digits), digits);
break;
}
}
return getCellLabelVNs(renderOpts, params, cellValue);
},
renderTableDefault: oldEditRender,
renderTableFilter: oldFilterRender,
tableFilterDefaultMethod: handleInputFilterMethod
},
$textarea: {
tableAutoFocus: "textarea"
},
$button: {
renderTableDefault: oldButtonEditRender
},
$buttons: {
renderTableDefault: oldButtonsEditRender
},
$select: {
tableAutoFocus: "input",
renderTableEdit: oldSelectEditRender,
renderTableDefault: oldSelectEditRender,
renderTableCell(renderOpts, params) {
return getCellLabelVNs(renderOpts, params, getSelectCellValue(renderOpts, params));
},
renderTableFilter(renderOpts, params) {
const { column } = params;
const { options, optionProps, optionGroups, optionGroupProps } = renderOpts;
return column.filters.map((option, oIndex) => {
const optionValue = option.data;
return (0, import_vue.h)(getOldComponent(renderOpts), {
key: oIndex,
...getCellEditFilterProps(renderOpts, params, optionValue, { options, optionProps, optionGroups, optionGroupProps }),
...getFilterOns(renderOpts, params, option)
});
});
},
tableFilterDefaultMethod: handleFilterMethod,
tableExportMethod: handleExportSelectMethod
},
$radio: {
tableAutoFocus: "input"
},
$checkbox: {
tableAutoFocus: "input"
},
$switch: {
tableAutoFocus: "button",
renderTableEdit: oldEditRender,
renderTableDefault: oldEditRender
}
// 以上已废弃
});