yanzhen-design-vue
Version:
51 lines (50 loc) • 2.02 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const utilsVue = require("@yanzhen-libs/utils-vue");
const utils = require("@yanzhen-libs/utils");
const lodashEs = require("lodash-es");
const contacts = require("../constants/contacts.cjs");
const user = require("../constants/user.cjs");
function useContactsTitle() {
const title = utilsVue.useProp("title");
return vue.computed(() => {
return utilsVue.unref(title) ?? "";
});
}
const showUserTabKeyPropValues = user.userTypes.map((k) => `${k}-${contacts.Contacts.USER}`);
const showTabKeyPropValues = [...showUserTabKeyPropValues, ...contacts.contactsTypes];
const showTabKeysProps = utilsVue.buildProps({
showTabKeys: {
type: utilsVue.definePropType(Array),
values: showTabKeyPropValues,
default: () => []
}
});
function useContactsShowTabKeys() {
const dynamicProps = utilsVue.useDynamicProps(true);
const _showTabKeys = utilsVue.useProp("showTabKeys");
const propsTabKeys = vue.computed(
() => contacts.contactsModelValueType.filter((key) => {
var _a;
return key !== "value" && ((_a = utilsVue.unref(dynamicProps)) == null ? void 0 : _a.includes(key));
}).map((key) => utils.kebabCase(key).split("-")[0])
);
return vue.computed(() => {
const tabKeys = utilsVue.unref(propsTabKeys);
const showTabKeys = lodashEs.flattenDeep([utilsVue.unref(_showTabKeys)]);
if (showTabKeys.length === 0 && tabKeys.length === 0) {
return [...contacts.contactsTypes];
}
const keys = lodashEs.uniq([...showTabKeys, ...tabKeys]);
if (keys.includes("user") && !keys.includes(contacts.Contacts.USUALLY)) {
keys.push(contacts.Contacts.USUALLY);
}
return keys;
});
}
exports.showTabKeyPropValues = showTabKeyPropValues;
exports.showTabKeysProps = showTabKeysProps;
exports.showUserTabKeyPropValues = showUserTabKeyPropValues;
exports.useContactsShowTabKeys = useContactsShowTabKeys;
exports.useContactsTitle = useContactsTitle;