UNPKG

vuestic-ui

Version:
1 lines 1.08 kB
{"version":3,"file":"useStringValue.mjs","sources":["../../../../../../src/components/va-select/hooks/useStringValue.ts"],"sourcesContent":["import { computed, type Ref, type ExtractPropTypes } from 'vue'\n\nimport type { SelectOption } from '../types'\n\nexport const useStringValueProps = {\n separator: { type: String, default: ', ' },\n}\n\ntype UseStringValueProps = ExtractPropTypes<typeof useStringValueProps>\n\nexport const useStringValue = (\n props: UseStringValueProps,\n visibleSelectedOptions: Ref<SelectOption[]>,\n getText: (option: SelectOption) => string,\n) => {\n return computed<string>(() => {\n if (!visibleSelectedOptions.value?.length) {\n return ''\n }\n\n return visibleSelectedOptions.value.map(getText).join(props.separator) ?? ''\n })\n}\n"],"names":[],"mappings":";AAIO,MAAM,sBAAsB;AAAA,EACjC,WAAW,EAAE,MAAM,QAAQ,SAAS,KAAK;AAC3C;AAIO,MAAM,iBAAiB,CAC5B,OACA,wBACA,YACG;AACH,SAAO,SAAiB,MAAM;;AACxB,QAAA,GAAC,4BAAuB,UAAvB,mBAA8B,SAAQ;AAClC,aAAA;AAAA,IACT;AAEO,WAAA,uBAAuB,MAAM,IAAI,OAAO,EAAE,KAAK,MAAM,SAAS,KAAK;AAAA,EAAA,CAC3E;AACH;"}