1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
| 'use strict';
|
| Object.defineProperty(exports, '__esModule', { value: true });
|
| var vue = require('vue');
| require('../../../hooks/index.js');
| var useOption = require('./useOption.js');
| var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
| var index = require('../../../hooks/use-namespace/index.js');
|
| const _sfc_main = vue.defineComponent({
| name: "ElOption",
| componentName: "ElOption",
| props: {
| value: {
| required: true,
| type: [String, Number, Boolean, Object]
| },
| label: [String, Number],
| created: Boolean,
| disabled: {
| type: Boolean,
| default: false
| }
| },
| setup(props) {
| const ns = index.useNamespace("select");
| const states = vue.reactive({
| index: -1,
| groupDisabled: false,
| visible: true,
| hitState: false,
| hover: false
| });
| const { currentLabel, itemSelected, isDisabled, select, hoverItem } = useOption.useOption(props, states);
| const { visible, hover } = vue.toRefs(states);
| const vm = vue.getCurrentInstance().proxy;
| select.onOptionCreate(vm);
| vue.onBeforeUnmount(() => {
| const key = vm.value;
| const { selected } = select;
| const selectedOptions = select.props.multiple ? selected : [selected];
| const doesSelected = selectedOptions.some((item) => {
| return item.value === vm.value;
| });
| vue.nextTick(() => {
| if (select.cachedOptions.get(key) === vm && !doesSelected) {
| select.cachedOptions.delete(key);
| }
| });
| select.onOptionDestroy(key, vm);
| });
| function selectOptionClick() {
| if (props.disabled !== true && states.groupDisabled !== true) {
| select.handleOptionSelect(vm);
| }
| }
| return {
| ns,
| currentLabel,
| itemSelected,
| isDisabled,
| select,
| hoverItem,
| visible,
| hover,
| selectOptionClick,
| states
| };
| }
| });
| function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
| return vue.withDirectives((vue.openBlock(), vue.createElementBlock("li", {
| class: vue.normalizeClass([
| _ctx.ns.be("dropdown", "item"),
| _ctx.ns.is("disabled", _ctx.isDisabled),
| {
| selected: _ctx.itemSelected,
| hover: _ctx.hover
| }
| ]),
| onMouseenter: _cache[0] || (_cache[0] = (...args) => _ctx.hoverItem && _ctx.hoverItem(...args)),
| onClick: _cache[1] || (_cache[1] = vue.withModifiers((...args) => _ctx.selectOptionClick && _ctx.selectOptionClick(...args), ["stop"]))
| }, [
| vue.renderSlot(_ctx.$slots, "default", {}, () => [
| vue.createElementVNode("span", null, vue.toDisplayString(_ctx.currentLabel), 1)
| ])
| ], 34)), [
| [vue.vShow, _ctx.visible]
| ]);
| }
| var Option = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/element-plus/element-plus/packages/components/select/src/option.vue"]]);
|
| exports["default"] = Option;
| //# sourceMappingURL=option.js.map
|
|