@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.
49 lines (48 loc) • 1.3 kB
JavaScript
import {
__spreadValues
} from "../../chunk-G2ADBYYC.js";
import { set, isObject, merge } from "../deps/utils";
const isArr = Array.isArray;
var extend_default = ({ options, extend }) => {
if (!extend) {
return;
}
Object.keys(extend).forEach((key) => {
const value = extend[key];
if (~key.indexOf(".")) {
set(options, key, value);
} else if (typeof value === "function") {
options[key] = value(options[key]);
} else if (isArr(options[key]) && isArr(value)) {
const attrList = [
"series",
"yAxis",
"xAxis",
"color",
"dataZoom",
"legend",
"toolbox",
"grid",
"graphic",
"timeline",
"visualMap",
"brush"
];
if (~attrList.indexOf(key)) {
options[key] = merge(options[key], value);
}
} else {
if (isArr(options[key]) && isObject(options[key][0])) {
options[key].forEach((option, i) => options[key][i] = __spreadValues(__spreadValues({}, option), value));
} else if (isObject(options[key])) {
let optionBase = options[key];
options[key] = __spreadValues(__spreadValues({}, optionBase), value);
} else {
options[key] = value;
}
}
});
};
export {
extend_default as default
};