option-item.mjs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { defineComponent, inject, openBlock, createElementBlock, normalizeStyle, normalizeClass, withModifiers, renderSlot, createElementVNode, toDisplayString } from 'vue';
  2. import { useOption } from './useOption.mjs';
  3. import { useProps } from './useProps.mjs';
  4. import { OptionProps, optionEmits } from './defaults.mjs';
  5. import { selectV2InjectionKey } from './token.mjs';
  6. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  7. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  8. const _sfc_main = defineComponent({
  9. props: OptionProps,
  10. emits: optionEmits,
  11. setup(props, { emit }) {
  12. const select = inject(selectV2InjectionKey);
  13. const ns = useNamespace("select");
  14. const { hoverItem, selectOptionClick } = useOption(props, { emit });
  15. const { getLabel } = useProps(select.props);
  16. return {
  17. ns,
  18. hoverItem,
  19. selectOptionClick,
  20. getLabel
  21. };
  22. }
  23. });
  24. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  25. return openBlock(), createElementBlock("li", {
  26. "aria-selected": _ctx.selected,
  27. style: normalizeStyle(_ctx.style),
  28. class: normalizeClass([
  29. _ctx.ns.be("dropdown", "item"),
  30. _ctx.ns.is("selected", _ctx.selected),
  31. _ctx.ns.is("disabled", _ctx.disabled),
  32. _ctx.ns.is("created", _ctx.created),
  33. _ctx.ns.is("hovering", _ctx.hovering)
  34. ]),
  35. onMousemove: _ctx.hoverItem,
  36. onClick: withModifiers(_ctx.selectOptionClick, ["stop"])
  37. }, [
  38. renderSlot(_ctx.$slots, "default", {
  39. item: _ctx.item,
  40. index: _ctx.index,
  41. disabled: _ctx.disabled
  42. }, () => [
  43. createElementVNode("span", null, toDisplayString(_ctx.getLabel(_ctx.item)), 1)
  44. ])
  45. ], 46, ["aria-selected", "onMousemove", "onClick"]);
  46. }
  47. var OptionItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "option-item.vue"]]);
  48. export { OptionItem as default };
  49. //# sourceMappingURL=option-item.mjs.map