{"version":3,"file":"SelectValue.cjs","sources":["../../src/Select/SelectValue.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { AcceptableValue } from '@/shared/types'\n\nexport interface SelectValueProps extends PrimitiveProps {\n  /** The content that will be rendered inside the `SelectValue` when no `value` or `defaultValue` is set. */\n  placeholder?: string\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, onMounted } from 'vue'\nimport { injectSelectRootContext } from './SelectRoot.vue'\nimport { Primitive } from '@/Primitive'\nimport { useForwardExpose } from '@/shared'\n\nconst props = withDefaults(defineProps<SelectValueProps>(), {\n  as: 'span',\n  placeholder: '',\n})\n\nconst { forwardRef, currentElement } = useForwardExpose()\n\nconst rootContext = injectSelectRootContext()\n\nonMounted(() => {\n  rootContext.valueElement = currentElement\n})\n\nconst selectedLabel = computed(() => {\n  let list: string[] = []\n  const options = Array.from(rootContext.optionsSet.value)\n  const getOption = (value?: AcceptableValue) => options.find(option => option.value === value)\n  if (Array.isArray(rootContext.modelValue.value)) {\n    list = rootContext.modelValue.value.map(value => getOption(value)?.textContent ?? '')\n  }\n  else {\n    list = [getOption(rootContext.modelValue.value)?.textContent ?? '']\n  }\n  return list.filter(Boolean)\n})\n\nconst slotText = computed(() => {\n  return selectedLabel.value.length ? selectedLabel.value.join(', ') : props.placeholder\n})\n</script>\n\n<template>\n  <Primitive\n    :ref=\"forwardRef\"\n    :as=\"as\"\n    :as-child=\"asChild\"\n    :style=\"{ pointerEvents: 'none' }\"\n    :data-placeholder=\"selectedLabel.length ? undefined : props.placeholder\"\n  >\n    <slot\n      :selected-label=\"selectedLabel\"\n      :model-value=\"rootContext.modelValue.value\"\n    >\n      {{ slotText }}\n    </slot>\n  </Primitive>\n</template>\n"],"names":["useForwardExpose","injectSelectRootContext","onMounted","computed"],"mappings":";;;;;;;;;;;;;;;AAgBA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAKd,IAAA,MAAM,EAAE,UAAA,EAAY,cAAe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