UNPKG

reka-ui

Version:

Vue port for Radix UI Primitives.

1 lines 2.13 kB
{"version":3,"file":"TagsInputItemDelete.cjs","sources":["../../src/TagsInput/TagsInputItemDelete.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { PrimitiveProps } from '@/Primitive'\nimport { injectTagsInputItemContext } from './TagsInputItem.vue'\nimport { injectTagsInputRootContext } from './TagsInputRoot.vue'\nimport { computed } from 'vue'\nimport { useForwardExpose } from '@/shared'\nimport { isEqual } from 'ohash'\n\nexport interface TagsInputItemDeleteProps extends PrimitiveProps {}\n</script>\n\n<script setup lang=\"ts\">\nimport { Primitive } from '@/Primitive'\n\nconst props = withDefaults(defineProps<TagsInputItemDeleteProps>(), {\n as: 'button',\n})\n\nuseForwardExpose()\nconst context = injectTagsInputRootContext()\nconst itemContext = injectTagsInputItemContext()\n\nconst disabled = computed(() => itemContext.disabled?.value || context.disabled.value)\n\nfunction handleDelete() {\n if (disabled.value)\n return\n const index = context.modelValue.value.findIndex(i => isEqual(i, itemContext.value.value))\n context.onRemoveValue(index)\n}\n</script>\n\n<template>\n <Primitive\n tabindex=\"-1\"\n v-bind=\"props\"\n :aria-labelledby=\"itemContext.textId\"\n :aria-current=\"itemContext.isSelected.value\"\n :data-state=\"itemContext.isSelected.value ? 'active' : 'inactive'\"\n :data-disabled=\"disabled ? '' : undefined\"\n :type=\"as === 'button' ? 'button' : undefined\"\n @click=\"handleDelete\"\n >\n <slot />\n </Primitive>\n</template>\n"],"names":["useForwardExpose","injectTagsInputRootContext","injectTagsInputItemContext","computed","isEqual"],"mappings":";;;;;;;;;;;;;;;;AAcA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAId,IAAiBA,wCAAA,EAAA;AACjB,IAAA,MAAM,UAAUC,kDAA2B,EAAA;AAC3C,IAAA,MAAM,cAAcC,kDAA2B,EAAA;AAE/C,IAAM,MAAA,QAAA,GAAWC,aAAS,MAAM,WAAA,CAAY,UAAU,KAAS,IAAA,OAAA,CAAQ,SAAS,KAAK,CAAA;AAErF,IAAA,SAAS,YAAe,GAAA;AACtB,MAAA,IAAI,QAAS,CAAA,KAAA;AACX,QAAA;AACF,MAAM,MAAA,KAAA,GAAQ,OAAQ,CAAA,UAAA,CAAW,KAAM,CAAA,SAAA,CAAU,CAAK,CAAA,KAAAC,aAAA,CAAQ,CAAG,EAAA,WAAA,CAAY,KAAM,CAAA,KAAK,CAAC,CAAA;AACzF,MAAA,OAAA,CAAQ,cAAc,KAAK,CAAA;AAAA;;;;;;;;;;;;;;;;;;;;;"}