@xdp/button
Version:
button el-button vue3
31 lines (28 loc) • 1.06 kB
JavaScript
import { computed } from 'vue';
import { useConfig } from '@xdp/config';
import { defaultButtonConfigMap } from './config.js';
const useButtonConfigMap = () => {
const xdpConfig = useConfig();
const buttonConfigMap = computed(() => {
const result = {};
const defaultKeys = Object.keys(defaultButtonConfigMap);
defaultKeys.forEach((key) => {
var _a;
const defaultButtonConfig = defaultButtonConfigMap[key];
if ((_a = xdpConfig.buttonConfigMap) == null ? void 0 : _a[key]) {
result[key] = Object.assign({}, defaultButtonConfig, xdpConfig.buttonConfigMap[key]);
} else {
result[key] = defaultButtonConfig;
}
});
const globalButtonConfigMapKeys = Object.keys(xdpConfig.buttonConfigMap || {});
if (globalButtonConfigMapKeys.length > 0) {
globalButtonConfigMapKeys.filter((key) => !defaultKeys.includes(key)).forEach((key) => {
result[key] = xdpConfig.buttonConfigMap[key];
});
}
return result;
});
return buttonConfigMap;
};
export { useButtonConfigMap };