UNPKG

element-plus

Version:

A Component Library for Vue 3

1 lines 1.35 kB
{"version":3,"file":"index.mjs","sources":["../../../../../packages/hooks/use-size/index.ts"],"sourcesContent":["import { computed, inject, unref } from 'vue'\nimport { buildProp } from '@element-plus/utils'\nimport { componentSizes } from '@element-plus/constants'\n\nimport type { InjectionKey, Ref } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\n\nexport const useSizeProp = buildProp({\n type: String,\n values: componentSizes,\n required: false,\n} as const)\n\nexport const useSizeProps = {\n size: useSizeProp,\n}\n\nexport interface SizeContext {\n size: Ref<ComponentSize>\n}\n\nexport const SIZE_INJECTION_KEY: InjectionKey<SizeContext> = Symbol('size')\n\nexport const useGlobalSize = () => {\n const injectedSize = inject(SIZE_INJECTION_KEY, {} as SizeContext)\n\n return computed<ComponentSize>(() => {\n return unref(injectedSize.size) || ''\n })\n}\n"],"names":[],"mappings":";;;;AAOO,MAAM,cAAc,SAAU,CAAA;AAAA,EACnC,IAAM,EAAA,MAAA;AAAA,EACN,MAAQ,EAAA,cAAA;AAAA,EACR,QAAU,EAAA,KAAA;AACZ,CAAU,EAAA;AAEH,MAAM,YAAe,GAAA;AAAA,EAC1B,IAAM,EAAA,WAAA;AACR,EAAA;AAMa,MAAA,kBAAA,GAAgD,OAAO,MAAM,EAAA;AAEnE,MAAM,gBAAgB,MAAM;AACjC,EAAA,MAAM,YAAe,GAAA,MAAA,CAAO,kBAAoB,EAAA,EAAiB,CAAA,CAAA;AAEjE,EAAA,OAAO,SAAwB,MAAM;AACnC,IAAO,OAAA,KAAA,CAAM,YAAa,CAAA,IAAI,CAAK,IAAA,EAAA,CAAA;AAAA,GACpC,CAAA,CAAA;AACH;;;;"}