UNPKG

yanzhen-design-vue

Version:

63 lines (62 loc) 2.09 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const utilsVue = require("@yanzhen-libs/utils-vue"); const constants = require("../constants.cjs"); function useVxeTableConfig(key, defaultValue) { const config = vue.inject(constants.VxeTableConfigContextKey, constants.defaultVxeTableConfig()); if (key) { return vue.computed(() => { var _a; const ref = (_a = vue.unref(config)) == null ? void 0 : _a[key]; return vue.unref(ref) ?? vue.unref(defaultValue); }); } return config; } function provideVxeTableConfig(props) { const config = Object.entries(constants.defaultVxeTableConfig()).reduce((prev, [key, defaultValue]) => { const oldValue = useVxeTableConfig(key, defaultValue); prev[key] = vue.computed( () => { var _a; return vue.unref((_a = vue.unref(props)) == null ? void 0 : _a[key]) ?? vue.unref(oldValue); } ); return prev; }, {}); vue.provide(constants.VxeTableConfigContextKey, config); } function useVxeTableTagConfig(props) { const tagRef = utilsVue.useProp("tag"); const tag = useVxeTableConfig("tag"); const isATableTag = vue.computed(() => { const tagKey = "a-table"; switch (true) { case vue.unref(props == null ? void 0 : props.tag) === tagKey: case vue.unref(tagRef) === tagKey: case vue.unref(tag) === tagKey: return true; } return false; }); const isElTableTag = vue.computed(() => { const tagKey = "el-table"; switch (true) { case vue.unref(props == null ? void 0 : props.tag) === tagKey: case vue.unref(tagRef) === tagKey: case vue.unref(tag) === tagKey: return true; } return false; }); const isVxeTable = vue.computed(() => ![vue.unref(isElTableTag), vue.unref(isElTableTag)].includes(true)); return { isATableTag, isElTableTag, isVxeTable }; } exports.provideVxeTableConfig = provideVxeTableConfig; exports.useVxeTableConfig = useVxeTableConfig; exports.useVxeTableTagConfig = useVxeTableTagConfig;