reka-ui
Version:
Vue port for Radix UI Primitives.
1 lines • 2.18 kB
Source Map (JSON)
{"version":3,"file":"SliderRange.cjs","sources":["../../src/Slider/SliderRange.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { PrimitiveProps } from '@/Primitive'\nimport { useForwardExpose } from '@/shared'\n\nexport interface SliderRangeProps extends PrimitiveProps {}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { Primitive } from '@/Primitive'\nimport { injectSliderRootContext } from './SliderRoot.vue'\nimport { convertValueToPercentage, injectSliderOrientationContext } from './utils'\n\nwithDefaults(defineProps<SliderRangeProps>(), { as: 'span' })\nconst rootContext = injectSliderRootContext()\nconst orientation = injectSliderOrientationContext()\n\nuseForwardExpose()\nconst percentages = computed(() => rootContext.currentModelValue.value.map(value =>\n convertValueToPercentage(value, rootContext.min.value, rootContext.max.value),\n))\n\nconst offsetStart = computed(() => rootContext.currentModelValue.value.length > 1 ? Math.min(...percentages.value!) : 0)\nconst offsetEnd = computed(() => 100 - Math.max(...percentages.value, 0))\n</script>\n\n<template>\n <Primitive\n :data-disabled=\"rootContext.disabled.value ? '' : undefined\"\n :data-orientation=\"rootContext.orientation.value\"\n :as-child=\"asChild\"\n :as=\"as\"\n :style=\"{\n [orientation!.startEdge]: `${offsetStart}%`,\n [orientation!.endEdge]: `${offsetEnd}%`,\n }\"\n >\n <slot />\n </Primitive>\n</template>\n"],"names":["injectSliderRootContext","injectSliderOrientationContext","useForwardExpose","computed","convertValueToPercentage"],"mappings":";;;;;;;;;;;;;;;AAcA,IAAA,MAAM,cAAcA,yCAAwB,EAAA;AAC5C,IAAA,MAAM,cAAcC,2CAA+B,EAAA;AAEnD,IAAiBC,wCAAA,EAAA;AACjB,IAAA,MAAM,WAAc,GAAAC,YAAA,CAAS,MAAM,WAAA,CAAY,kBAAkB,KAAM,CAAA,GAAA;AAAA,MAAI,CAAA,KAAA,KACzEC,sCAAyB,KAAO,EAAA,WAAA,CAAY,IAAI,KAAO,EAAA,WAAA,CAAY,IAAI,KAAK;AAAA,KAC7E,CAAA;AAED,IAAA,MAAM,WAAc,GAAAD,YAAA,CAAS,MAAM,WAAA,CAAY,kBAAkB,KAAM,CAAA,MAAA,GAAS,CAAI,GAAA,IAAA,CAAK,GAAI,CAAA,GAAG,WAAY,CAAA,KAAM,IAAI,CAAC,CAAA;AACvH,IAAM,MAAA,SAAA,GAAYA,YAAS,CAAA,MAAM,GAAM,GAAA,IAAA,CAAK,IAAI,GAAG,WAAA,CAAY,KAAO,EAAA,CAAC,CAAC,CAAA;;;;;;;;;;;;;;;;;;;;;;;"}