hongluan-ui
Version:
Hongluan Component Library for Vue 3
36 lines (33 loc) • 1.35 kB
JavaScript
import { getCurrentInstance, inject, computed } from 'vue';
import '../../tokens/index.mjs';
import { useGlobalConfig } from '../use-global-config/index.mjs';
import { formItemContextKey, formContextKey } from '../../tokens/form.mjs';
function useConsistentProp() {
const { proxy } = getCurrentInstance();
const $props = proxy.$props;
const $parentProps = proxy.$parent.$props;
const $parentOpts = proxy.$parent.$options;
const formItem = inject(formItemContextKey, {});
const form = inject(formContextKey, {});
const size = computed(() => {
const configProviderSize = useGlobalConfig("size");
return $props.size || $parentOpts.name === "Group" && $parentProps.size || (formItem == null ? void 0 : formItem.size) || configProviderSize.value;
});
const disabled = computed(() => {
return $props.disabled || $parentOpts.name === "Group" && $parentProps.disabled || (form == null ? void 0 : form.disabled) || false;
});
const type = computed(() => {
return $props.type || $parentOpts.name === "Group" && $parentProps.type;
});
const fill = computed(() => {
return $props.fill || (form == null ? void 0 : form.fill) || $parentOpts.name === "Group" && $parentProps.fill || false;
});
return {
size,
disabled,
type,
fill
};
}
export { useConsistentProp };
//# sourceMappingURL=index.mjs.map