JewelryMall/admin/node_modules/element-plus/es/components/select-v2/src/useProps.mjs
2026-02-14 19:29:15 +08:00

38 lines
967 B
JavaScript

import { ref, watch } from 'vue';
import { isEqual, get } from 'lodash-unified';
const defaultProps = {
label: "label",
value: "value",
disabled: "disabled",
options: "options"
};
function useProps(props) {
const aliasProps = ref({ ...defaultProps, ...props.props });
let cache = { ...props.props };
watch(
() => props.props,
(val) => {
if (!isEqual(val, cache)) {
aliasProps.value = { ...defaultProps, ...val };
cache = { ...val };
}
},
{ deep: true }
);
const getLabel = (option) => get(option, aliasProps.value.label);
const getValue = (option) => get(option, aliasProps.value.value);
const getDisabled = (option) => get(option, aliasProps.value.disabled);
const getOptions = (option) => get(option, aliasProps.value.options);
return {
aliasProps,
getLabel,
getValue,
getDisabled,
getOptions
};
}
export { defaultProps, useProps };
//# sourceMappingURL=useProps.mjs.map