option-item.mjs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 { optionV2Props, optionV2Emits } 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: optionV2Props,
  10. emits: optionV2Emits,
  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. const contentId = select.contentId;
  17. return {
  18. ns,
  19. contentId,
  20. hoverItem,
  21. selectOptionClick,
  22. getLabel
  23. };
  24. }
  25. });
  26. const _hoisted_1 = ["id", "aria-selected", "aria-disabled"];
  27. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  28. return openBlock(), createElementBlock("li", {
  29. id: `${_ctx.contentId}-${_ctx.index}`,
  30. role: "option",
  31. "aria-selected": _ctx.selected,
  32. "aria-disabled": _ctx.disabled || void 0,
  33. style: normalizeStyle(_ctx.style),
  34. class: normalizeClass([
  35. _ctx.ns.be("dropdown", "item"),
  36. _ctx.ns.is("selected", _ctx.selected),
  37. _ctx.ns.is("disabled", _ctx.disabled),
  38. _ctx.ns.is("created", _ctx.created),
  39. _ctx.ns.is("hovering", _ctx.hovering)
  40. ]),
  41. onMousemove: _cache[0] || (_cache[0] = (...args) => _ctx.hoverItem && _ctx.hoverItem(...args)),
  42. onClick: _cache[1] || (_cache[1] = withModifiers((...args) => _ctx.selectOptionClick && _ctx.selectOptionClick(...args), ["stop"]))
  43. }, [
  44. renderSlot(_ctx.$slots, "default", {
  45. item: _ctx.item,
  46. index: _ctx.index,
  47. disabled: _ctx.disabled
  48. }, () => [
  49. createElementVNode(
  50. "span",
  51. null,
  52. toDisplayString(_ctx.getLabel(_ctx.item)),
  53. 1
  54. )
  55. ])
  56. ], 46, _hoisted_1);
  57. }
  58. var OptionItem = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/select-v2/src/option-item.vue"]]);
  59. export { OptionItem as default };
  60. //# sourceMappingURL=option-item.mjs.map