reka-ui
Version:
Vue port for Radix UI Primitives.
1 lines • 2.43 kB
Source Map (JSON)
{"version":3,"file":"BaseSeparator.cjs","sources":["../../src/shared/component/BaseSeparator.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { DataOrientation } from '../types'\nimport type { PrimitiveProps } from '@/Primitive'\n\nexport interface BaseSeparatorProps extends PrimitiveProps {\n /**\n * Orientation of the component.\n *\n * Either `vertical` or `horizontal`. Defaults to `horizontal`.\n */\n orientation?: DataOrientation\n /**\n * Whether or not the component is purely decorative. <br>When `true`, accessibility-related attributes\n * are updated so that that the rendered element is removed from the accessibility tree.\n */\n decorative?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed } from 'vue'\nimport { Primitive } from '@/Primitive'\n\nconst props = withDefaults(defineProps<BaseSeparatorProps>(), {\n orientation: 'horizontal',\n})\n\nconst ORIENTATIONS = ['horizontal', 'vertical'] as const\nfunction isValidOrientation(orientation: any): orientation is DataOrientation {\n return ORIENTATIONS.includes(orientation)\n}\n\nconst computedOrientation = computed(() =>\n isValidOrientation(props.orientation) ? props.orientation : 'horizontal',\n)\n// `aria-orientation` defaults to `horizontal` so we only need it if `orientation` is vertical\nconst ariaOrientation = computed(() =>\n computedOrientation.value === 'vertical' ? props.orientation : undefined,\n)\n\nconst semanticProps = computed(() =>\n props.decorative\n ? { role: 'none' }\n : { 'aria-orientation': ariaOrientation.value, 'role': 'separator' },\n)\n</script>\n\n<template>\n <Primitive\n :as=\"as\"\n :as-child=\"asChild\"\n :data-orientation=\"computedOrientation\"\n v-bind=\"semanticProps\"\n >\n <slot />\n </Primitive>\n</template>\n"],"names":["computed"],"mappings":";;;;;;;;;;;;;;AAuBA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAId,IAAM,MAAA,YAAA,GAAe,CAAC,YAAA,EAAc,UAAU,CAAA;AAC9C,IAAA,SAAS,mBAAmB,WAAkD,EAAA;AAC5E,MAAO,OAAA,YAAA,CAAa,SAAS,WAAW,CAAA;AAAA;AAG1C,IAAA,MAAM,mBAAsB,GAAAA,YAAA;AAAA,MAAS,MACnC,kBAAmB,CAAA,KAAA,CAAM,WAAW,CAAA,GAAI,MAAM,WAAc,GAAA;AAAA,KAC9D;AAEA,IAAA,MAAM,eAAkB,GAAAA,YAAA;AAAA,MAAS,MAC/B,mBAAA,CAAoB,KAAU,KAAA,UAAA,GAAa,MAAM,WAAc,GAAA;AAAA,KACjE;AAEA,IAAA,MAAM,aAAgB,GAAAA,YAAA;AAAA,MAAS,MAC7B,KAAA,CAAM,UACF,GAAA,EAAE,IAAM,EAAA,MAAA,EACR,GAAA,EAAE,kBAAoB,EAAA,eAAA,CAAgB,KAAO,EAAA,MAAA,EAAQ,WAAY;AAAA,KACvE;;;;;;;;;;;;;;;;;;"}