{"version":3,"file":"index.mjs","sources":["../../../../../packages/hooks/use-common-props/index.ts"],"sourcesContent":["import { ref, unref, inject, computed } from 'vue'\r\nimport { FormItemContextKey, FormContextKey } from '@sgui-plus/components/form/src/constants'\r\nimport { useProp } from '../use-prop'\r\nimport { useGlobalSize } from '../use-size'\r\nimport type { ComponentSize } from '@sgui-plus/utils/size'\r\nimport type { MaybeRef } from '@vueuse/core'\r\n\r\nexport const useSize = (\r\n  fallback?: MaybeRef<ComponentSize | undefined>,\r\n  ignore: Partial<Record<'prop' | 'form' | 'formItem' | 'global', boolean>> = {}\r\n) => {\r\n  const emptyRef = ref(undefined)\r\n\r\n  const size = ignore.prop ? emptyRef : useProp<ComponentSize>('size')\r\n  const globalConfig = ignore.global ? emptyRef : useGlobalSize()\r\n  const form = ignore.form ? { size: undefined } : inject(FormContextKey, undefined)\r\n  const formItem = ignore.formItem\r\n    ? { size: undefined }\r\n    : inject(FormItemContextKey, undefined)\r\n\r\n  return computed(\r\n    (): ComponentSize =>\r\n      size.value ||\r\n      unref(fallback) ||\r\n      formItem?.size ||\r\n      form?.size ||\r\n      globalConfig.value ||\r\n      'default'\r\n  )\r\n}\r\n\r\nexport const useDisabled = (fallback?: MaybeRef<boolean | undefined>) => {\r\n  const disabled = useProp<boolean>('disabled')\r\n  const form = inject(FormContextKey, undefined)\r\n  return computed(\r\n    () => disabled.value || unref(fallback) || form?.disabled || false\r\n  )\r\n}\r\n"],"names":[],"mappings":";;;;;AAIY,MAAC,OAAO,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,EAAE,KAAK;AAClD,EAAE,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/B,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AACxD,EAAE,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,GAAG,QAAQ,GAAG,aAAa,EAAE,CAAC;AAClE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