You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.3 KiB
29 lines
1.3 KiB
import { ref, inject, computed, unref } from 'vue';
|
|
import '../../tokens/index.mjs';
|
|
import { buildProp, componentSize } from '../../utils/props.mjs';
|
|
import { useProp } from '../use-prop/index.mjs';
|
|
import { useGlobalConfig } from '../use-global-config/index.mjs';
|
|
import { elFormKey, elFormItemKey } from '../../tokens/form.mjs';
|
|
|
|
const useSizeProp = buildProp({
|
|
type: String,
|
|
values: ["", ...componentSize],
|
|
default: ""
|
|
});
|
|
const useSize = (fallback, ignore = {}) => {
|
|
const emptyRef = ref(void 0);
|
|
const size = ignore.prop ? emptyRef : useProp("size");
|
|
const globalConfig = ignore.global ? emptyRef : useGlobalConfig("size");
|
|
const form = ignore.form ? { size: void 0 } : inject(elFormKey, void 0);
|
|
const formItem = ignore.formItem ? { size: void 0 } : inject(elFormItemKey, void 0);
|
|
return computed(() => size.value || unref(fallback) || (formItem == null ? void 0 : formItem.size) || (form == null ? void 0 : form.size) || globalConfig.value || "default");
|
|
};
|
|
const useDisabled = (fallback) => {
|
|
const disabled = useProp("disabled");
|
|
const form = inject(elFormKey, void 0);
|
|
return computed(() => disabled.value || unref(fallback) || (form == null ? void 0 : form.disabled) || false);
|
|
};
|
|
|
|
export { useDisabled, useSize, useSizeProp };
|
|
//# sourceMappingURL=index.mjs.map
|