yanzhen-design-vue
Version:
80 lines (79 loc) • 2.52 kB
JavaScript
import { buildProps, definePropType, buildEmits, propsSeparate } from "@yanzhen-libs/utils-vue";
import "../../../hooks/index.mjs";
import { isBoolean, omit } from "lodash-es";
import { contactsProps, contactsEmits } from "./contacts.mjs";
import { useNamespace } from "../../../hooks/use-namespace/index.mjs";
const ns = useNamespace("contacts-select");
const contactsSelectOptions = {
ns,
class: ns.b(),
name: ns.defineVNodeName()
};
const contactsSelectListType = ["avatar", "input"];
function defineContactsSelectProps(info) {
return {
maxCount: (info == null ? void 0 : info.maxCount) ?? 5,
placeholder: (info == null ? void 0 : info.placeholder) ?? void 0,
primaryIcon: (info == null ? void 0 : info.primaryIcon) ?? void 0,
autoClear: isBoolean(info == null ? void 0 : info.autoClear) ? info == null ? void 0 : info.autoClear : true,
multiple: isBoolean(info == null ? void 0 : info.autoClear) ? info == null ? void 0 : info.autoClear : false
};
}
const contactsSelectName = contactsSelectOptions.name;
const contactsModalIgnoreProp = ["open", "onCancel", "onOk"];
const contactsSelectProps = buildProps({
...contactsProps,
// ant modal props
modalProps: {
type: definePropType(Object),
default: () => ({})
},
// ant modal title props
modalTitle: {
type: String,
default: "通讯录"
},
// ant modal open props
modalOpen: Boolean,
// 单选时候,选择后,立即执行
immediate: {
type: Boolean,
default: true
},
listType: {
type: definePropType([String, Boolean]),
default: () => contactsSelectListType[0]
},
autoClear: {
type: Boolean,
default: void 0
},
selectProps: definePropType(Object),
/**
* 点击“确认”按钮时的钩子函数,如果该函数返回值为true,那么会执行confirm,否则会返回
*/
beforeConfirm: definePropType(Function),
onChange: contactsProps["onChange"],
onBlur: definePropType(Function),
// 确认按钮事件
onConfirm: definePropType(Function),
// 取消按钮事件
onCancel: definePropType(Function)
});
const contactsSelectEmits = buildEmits({
...contactsEmits,
...propsSeparate(contactsSelectProps).emits
});
const contactsSelectOmitModalProps = (props) => {
return omit(props, ...contactsModalIgnoreProp);
};
export {
contactsModalIgnoreProp,
contactsSelectEmits,
contactsSelectListType,
contactsSelectName,
contactsSelectOmitModalProps,
contactsSelectOptions,
contactsSelectProps,
defineContactsSelectProps
};