71e24a1b13ae761dc660a6c919025f0a06588df94447ef640bf683fbcefb8a814551396d1a7819586520ab350f25a0c5acdf5977d8a9cd4d60b1fc31260b11 1.2 KB

1234567891011121314151617181920212223
  1. import { computed, unref, ref, inject } from 'vue';
  2. import { useGlobalSize } from '../../../../hooks/use-size/index.mjs';
  3. import { useProp } from '../../../../hooks/use-prop/index.mjs';
  4. import { formContextKey, formItemContextKey } from '../constants.mjs';
  5. const useFormSize = (fallback, ignore = {}) => {
  6. const emptyRef = ref(void 0);
  7. const size = ignore.prop ? emptyRef : useProp("size");
  8. const globalConfig = ignore.global ? emptyRef : useGlobalSize();
  9. const form = ignore.form ? { size: void 0 } : inject(formContextKey, void 0);
  10. const formItem = ignore.formItem ? { size: void 0 } : inject(formItemContextKey, void 0);
  11. return computed(() => size.value || unref(fallback) || (formItem == null ? void 0 : formItem.size) || (form == null ? void 0 : form.size) || globalConfig.value || "");
  12. };
  13. const useFormDisabled = (fallback) => {
  14. const disabled = useProp("disabled");
  15. const form = inject(formContextKey, void 0);
  16. return computed(() => disabled.value || unref(fallback) || (form == null ? void 0 : form.disabled) || false);
  17. };
  18. const useSize = useFormSize;
  19. const useDisabled = useFormDisabled;
  20. export { useDisabled, useFormDisabled, useFormSize, useSize };
  21. //# sourceMappingURL=use-form-common-props.mjs.map