@v-c/mentions 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/DropdownMenu.cjs +124 -0
- package/dist/DropdownMenu.d.ts +12 -0
- package/dist/DropdownMenu.js +117 -0
- package/dist/KeywordTrigger.cjs +130 -0
- package/dist/KeywordTrigger.d.ts +16 -0
- package/dist/KeywordTrigger.js +123 -0
- package/dist/Mentions.cjs +802 -0
- package/dist/Mentions.d.ts +58 -0
- package/dist/Mentions.js +795 -0
- package/dist/MentionsContext.cjs +19 -0
- package/dist/MentionsContext.d.ts +18 -0
- package/dist/MentionsContext.js +16 -0
- package/dist/Option.cjs +7 -0
- package/dist/Option.d.ts +10 -0
- package/dist/Option.js +3 -0
- package/dist/_virtual/rolldown_runtime.cjs +21 -0
- package/dist/context.cjs +12 -0
- package/dist/context.d.ts +7 -0
- package/dist/context.js +9 -0
- package/dist/hooks/useEffectState.cjs +23 -0
- package/dist/hooks/useEffectState.d.ts +5 -0
- package/dist/hooks/useEffectState.js +18 -0
- package/dist/index.cjs +12 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/util.cjs +65 -0
- package/dist/util.d.ts +37 -0
- package/dist/util.js +59 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 antdv-community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
6
|
+
const require_MentionsContext = require("./MentionsContext.cjs");
|
|
7
|
+
let vue = require("vue");
|
|
8
|
+
let _v_c_menu = require("@v-c/menu");
|
|
9
|
+
_v_c_menu = require_rolldown_runtime.__toESM(_v_c_menu);
|
|
10
|
+
let _v_c_util_dist_Dom_findDOMNode = require("@v-c/util/dist/Dom/findDOMNode");
|
|
11
|
+
function _isSlot(s) {
|
|
12
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
|
|
13
|
+
}
|
|
14
|
+
var DropdownMenu = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
15
|
+
const mentionsContext = require_MentionsContext.useMentionsContext();
|
|
16
|
+
const menuRef = (0, vue.shallowRef)();
|
|
17
|
+
const activeIndex = (0, vue.computed)(() => mentionsContext.value.activeIndex);
|
|
18
|
+
const activeOption = (0, vue.computed)(() => props.options[activeIndex.value] || {});
|
|
19
|
+
const activeOptionKey = (0, vue.computed)(() => activeOption.value?.key);
|
|
20
|
+
let removeListListeners;
|
|
21
|
+
const bindListEvents = (list) => {
|
|
22
|
+
if (removeListListeners) {
|
|
23
|
+
removeListListeners();
|
|
24
|
+
removeListListeners = void 0;
|
|
25
|
+
}
|
|
26
|
+
if (!list) return;
|
|
27
|
+
const handleFocus = (event) => {
|
|
28
|
+
mentionsContext.value.onFocus?.(event);
|
|
29
|
+
};
|
|
30
|
+
const handleBlur = (event) => {
|
|
31
|
+
mentionsContext.value.onBlur?.(event);
|
|
32
|
+
};
|
|
33
|
+
const handleScroll = (event) => {
|
|
34
|
+
mentionsContext.value.onScroll?.(event);
|
|
35
|
+
};
|
|
36
|
+
list.addEventListener("focusin", handleFocus);
|
|
37
|
+
list.addEventListener("focusout", handleBlur);
|
|
38
|
+
list.addEventListener("scroll", handleScroll);
|
|
39
|
+
removeListListeners = () => {
|
|
40
|
+
list.removeEventListener("focusin", handleFocus);
|
|
41
|
+
list.removeEventListener("focusout", handleBlur);
|
|
42
|
+
list.removeEventListener("scroll", handleScroll);
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
(0, vue.watch)(() => menuRef.value?.list, (list, _, onCleanup) => {
|
|
46
|
+
if (list) list = (0, _v_c_util_dist_Dom_findDOMNode.getDOM)(list);
|
|
47
|
+
bindListEvents(list || null);
|
|
48
|
+
onCleanup(() => {
|
|
49
|
+
removeListListeners?.();
|
|
50
|
+
removeListListeners = void 0;
|
|
51
|
+
});
|
|
52
|
+
}, {
|
|
53
|
+
immediate: true,
|
|
54
|
+
flush: "post"
|
|
55
|
+
});
|
|
56
|
+
(0, vue.watch)([
|
|
57
|
+
activeIndex,
|
|
58
|
+
activeOptionKey,
|
|
59
|
+
() => props.opened
|
|
60
|
+
], () => {
|
|
61
|
+
if (!props.opened || activeIndex.value === -1) return;
|
|
62
|
+
(0, vue.nextTick)(() => {
|
|
63
|
+
const key = activeOptionKey.value;
|
|
64
|
+
if (!key) return;
|
|
65
|
+
(menuRef.value?.findItem?.({ key }))?.scrollIntoView({
|
|
66
|
+
block: "nearest",
|
|
67
|
+
inline: "nearest"
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
(0, vue.onBeforeUnmount)(() => {
|
|
72
|
+
removeListListeners?.();
|
|
73
|
+
removeListListeners = void 0;
|
|
74
|
+
});
|
|
75
|
+
return () => {
|
|
76
|
+
const { notFoundContent, setActiveIndex, selectOption } = mentionsContext.value;
|
|
77
|
+
const { prefixCls, options } = props;
|
|
78
|
+
const activeKey = activeOptionKey.value;
|
|
79
|
+
return (0, vue.createVNode)(_v_c_menu.default, {
|
|
80
|
+
"ref": menuRef,
|
|
81
|
+
"prefixCls": `${prefixCls}-menu`,
|
|
82
|
+
"activeKey": activeKey,
|
|
83
|
+
"onSelect": ({ key }) => {
|
|
84
|
+
const option = options.find(({ key: optionKey }) => optionKey === key);
|
|
85
|
+
if (option) selectOption(option);
|
|
86
|
+
}
|
|
87
|
+
}, { default: () => [options.map((option, index) => {
|
|
88
|
+
const { key, disabled, class: className, style, label } = option;
|
|
89
|
+
return (0, vue.createVNode)(_v_c_menu.Item, (0, vue.mergeProps)({
|
|
90
|
+
"key": key,
|
|
91
|
+
"disabled": disabled,
|
|
92
|
+
"class": className,
|
|
93
|
+
"style": style
|
|
94
|
+
}, { onMouseenter: () => {
|
|
95
|
+
setActiveIndex(index);
|
|
96
|
+
} }), _isSlot(label) ? label : { default: () => [label] });
|
|
97
|
+
}), !options.length && (0, vue.createVNode)(_v_c_menu.Item, {
|
|
98
|
+
"disabled": true,
|
|
99
|
+
"key": "notFound"
|
|
100
|
+
}, _isSlot(notFoundContent) ? notFoundContent : { default: () => [notFoundContent] })] });
|
|
101
|
+
};
|
|
102
|
+
}, {
|
|
103
|
+
props: {
|
|
104
|
+
prefixCls: {
|
|
105
|
+
type: String,
|
|
106
|
+
required: false,
|
|
107
|
+
default: void 0
|
|
108
|
+
},
|
|
109
|
+
options: {
|
|
110
|
+
type: Array,
|
|
111
|
+
required: true,
|
|
112
|
+
default: void 0
|
|
113
|
+
},
|
|
114
|
+
opened: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
required: true,
|
|
117
|
+
default: void 0
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
name: "DropdownMenu",
|
|
121
|
+
inheritAttrs: false
|
|
122
|
+
});
|
|
123
|
+
var DropdownMenu_default = DropdownMenu;
|
|
124
|
+
exports.default = DropdownMenu_default;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DataDrivenOptionProps } from './Mentions';
|
|
2
|
+
export interface DropdownMenuProps {
|
|
3
|
+
prefixCls?: string;
|
|
4
|
+
options: DataDrivenOptionProps[];
|
|
5
|
+
opened: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* We only use Menu to display the candidate.
|
|
9
|
+
* The focus is controlled by textarea to make accessibility easy.
|
|
10
|
+
*/
|
|
11
|
+
declare const DropdownMenu: import('vue').DefineSetupFnComponent<DropdownMenuProps, {}, {}, DropdownMenuProps & {}, import('vue').PublicProps>;
|
|
12
|
+
export default DropdownMenu;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { useMentionsContext } from "./MentionsContext.js";
|
|
2
|
+
import { computed, createVNode, defineComponent, isVNode, mergeProps, nextTick, onBeforeUnmount, shallowRef, watch } from "vue";
|
|
3
|
+
import Menu, { Item } from "@v-c/menu";
|
|
4
|
+
import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
|
|
5
|
+
function _isSlot(s) {
|
|
6
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
7
|
+
}
|
|
8
|
+
var DropdownMenu_default = /* @__PURE__ */ defineComponent((props) => {
|
|
9
|
+
const mentionsContext = useMentionsContext();
|
|
10
|
+
const menuRef = shallowRef();
|
|
11
|
+
const activeIndex = computed(() => mentionsContext.value.activeIndex);
|
|
12
|
+
const activeOption = computed(() => props.options[activeIndex.value] || {});
|
|
13
|
+
const activeOptionKey = computed(() => activeOption.value?.key);
|
|
14
|
+
let removeListListeners;
|
|
15
|
+
const bindListEvents = (list) => {
|
|
16
|
+
if (removeListListeners) {
|
|
17
|
+
removeListListeners();
|
|
18
|
+
removeListListeners = void 0;
|
|
19
|
+
}
|
|
20
|
+
if (!list) return;
|
|
21
|
+
const handleFocus = (event) => {
|
|
22
|
+
mentionsContext.value.onFocus?.(event);
|
|
23
|
+
};
|
|
24
|
+
const handleBlur = (event) => {
|
|
25
|
+
mentionsContext.value.onBlur?.(event);
|
|
26
|
+
};
|
|
27
|
+
const handleScroll = (event) => {
|
|
28
|
+
mentionsContext.value.onScroll?.(event);
|
|
29
|
+
};
|
|
30
|
+
list.addEventListener("focusin", handleFocus);
|
|
31
|
+
list.addEventListener("focusout", handleBlur);
|
|
32
|
+
list.addEventListener("scroll", handleScroll);
|
|
33
|
+
removeListListeners = () => {
|
|
34
|
+
list.removeEventListener("focusin", handleFocus);
|
|
35
|
+
list.removeEventListener("focusout", handleBlur);
|
|
36
|
+
list.removeEventListener("scroll", handleScroll);
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
watch(() => menuRef.value?.list, (list, _, onCleanup) => {
|
|
40
|
+
if (list) list = getDOM(list);
|
|
41
|
+
bindListEvents(list || null);
|
|
42
|
+
onCleanup(() => {
|
|
43
|
+
removeListListeners?.();
|
|
44
|
+
removeListListeners = void 0;
|
|
45
|
+
});
|
|
46
|
+
}, {
|
|
47
|
+
immediate: true,
|
|
48
|
+
flush: "post"
|
|
49
|
+
});
|
|
50
|
+
watch([
|
|
51
|
+
activeIndex,
|
|
52
|
+
activeOptionKey,
|
|
53
|
+
() => props.opened
|
|
54
|
+
], () => {
|
|
55
|
+
if (!props.opened || activeIndex.value === -1) return;
|
|
56
|
+
nextTick(() => {
|
|
57
|
+
const key = activeOptionKey.value;
|
|
58
|
+
if (!key) return;
|
|
59
|
+
(menuRef.value?.findItem?.({ key }))?.scrollIntoView({
|
|
60
|
+
block: "nearest",
|
|
61
|
+
inline: "nearest"
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
onBeforeUnmount(() => {
|
|
66
|
+
removeListListeners?.();
|
|
67
|
+
removeListListeners = void 0;
|
|
68
|
+
});
|
|
69
|
+
return () => {
|
|
70
|
+
const { notFoundContent, setActiveIndex, selectOption } = mentionsContext.value;
|
|
71
|
+
const { prefixCls, options } = props;
|
|
72
|
+
const activeKey = activeOptionKey.value;
|
|
73
|
+
return createVNode(Menu, {
|
|
74
|
+
"ref": menuRef,
|
|
75
|
+
"prefixCls": `${prefixCls}-menu`,
|
|
76
|
+
"activeKey": activeKey,
|
|
77
|
+
"onSelect": ({ key }) => {
|
|
78
|
+
const option = options.find(({ key: optionKey }) => optionKey === key);
|
|
79
|
+
if (option) selectOption(option);
|
|
80
|
+
}
|
|
81
|
+
}, { default: () => [options.map((option, index) => {
|
|
82
|
+
const { key, disabled, class: className, style, label } = option;
|
|
83
|
+
return createVNode(Item, mergeProps({
|
|
84
|
+
"key": key,
|
|
85
|
+
"disabled": disabled,
|
|
86
|
+
"class": className,
|
|
87
|
+
"style": style
|
|
88
|
+
}, { onMouseenter: () => {
|
|
89
|
+
setActiveIndex(index);
|
|
90
|
+
} }), _isSlot(label) ? label : { default: () => [label] });
|
|
91
|
+
}), !options.length && createVNode(Item, {
|
|
92
|
+
"disabled": true,
|
|
93
|
+
"key": "notFound"
|
|
94
|
+
}, _isSlot(notFoundContent) ? notFoundContent : { default: () => [notFoundContent] })] });
|
|
95
|
+
};
|
|
96
|
+
}, {
|
|
97
|
+
props: {
|
|
98
|
+
prefixCls: {
|
|
99
|
+
type: String,
|
|
100
|
+
required: false,
|
|
101
|
+
default: void 0
|
|
102
|
+
},
|
|
103
|
+
options: {
|
|
104
|
+
type: Array,
|
|
105
|
+
required: true,
|
|
106
|
+
default: void 0
|
|
107
|
+
},
|
|
108
|
+
opened: {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
required: true,
|
|
111
|
+
default: void 0
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
name: "DropdownMenu",
|
|
115
|
+
inheritAttrs: false
|
|
116
|
+
});
|
|
117
|
+
export { DropdownMenu_default as default };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
+
});
|
|
5
|
+
const require_rolldown_runtime = require("./_virtual/rolldown_runtime.cjs");
|
|
6
|
+
const require_DropdownMenu = require("./DropdownMenu.cjs");
|
|
7
|
+
let vue = require("vue");
|
|
8
|
+
let _v_c_trigger = require("@v-c/trigger");
|
|
9
|
+
_v_c_trigger = require_rolldown_runtime.__toESM(_v_c_trigger);
|
|
10
|
+
var BUILT_IN_PLACEMENTS = {
|
|
11
|
+
bottomRight: {
|
|
12
|
+
points: ["tl", "br"],
|
|
13
|
+
offset: [0, 4],
|
|
14
|
+
overflow: {
|
|
15
|
+
adjustX: 1,
|
|
16
|
+
adjustY: 1
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
bottomLeft: {
|
|
20
|
+
points: ["tr", "bl"],
|
|
21
|
+
offset: [0, 4],
|
|
22
|
+
overflow: {
|
|
23
|
+
adjustX: 1,
|
|
24
|
+
adjustY: 1
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
topRight: {
|
|
28
|
+
points: ["bl", "tr"],
|
|
29
|
+
offset: [0, -4],
|
|
30
|
+
overflow: {
|
|
31
|
+
adjustX: 1,
|
|
32
|
+
adjustY: 1
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
topLeft: {
|
|
36
|
+
points: ["br", "tl"],
|
|
37
|
+
offset: [0, -4],
|
|
38
|
+
overflow: {
|
|
39
|
+
adjustX: 1,
|
|
40
|
+
adjustY: 1
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var KeywordTrigger = /* @__PURE__ */ (0, vue.defineComponent)((props, { slots }) => {
|
|
45
|
+
const opened = (0, vue.shallowRef)(false);
|
|
46
|
+
const dropdownPlacement = (0, vue.computed)(() => {
|
|
47
|
+
if (props.direction === "rtl") return props.placement === "top" ? "topLeft" : "bottomLeft";
|
|
48
|
+
return props.placement === "top" ? "topRight" : "bottomRight";
|
|
49
|
+
});
|
|
50
|
+
return () => {
|
|
51
|
+
const { prefixCls, options, visible, transitionName, getPopupContainer, popupClassName, popupStyle } = props;
|
|
52
|
+
const dropdownPrefix = `${prefixCls}-dropdown`;
|
|
53
|
+
const dropdownElement = (0, vue.createVNode)(require_DropdownMenu.default, {
|
|
54
|
+
"prefixCls": dropdownPrefix,
|
|
55
|
+
"options": options,
|
|
56
|
+
"opened": opened.value
|
|
57
|
+
}, null);
|
|
58
|
+
return (0, vue.createVNode)(_v_c_trigger.default, {
|
|
59
|
+
"prefixCls": dropdownPrefix,
|
|
60
|
+
"popupVisible": visible,
|
|
61
|
+
"popup": dropdownElement,
|
|
62
|
+
"popupPlacement": dropdownPlacement.value,
|
|
63
|
+
"popupMotion": { name: transitionName },
|
|
64
|
+
"builtinPlacements": BUILT_IN_PLACEMENTS,
|
|
65
|
+
"getPopupContainer": getPopupContainer,
|
|
66
|
+
"popupClassName": popupClassName,
|
|
67
|
+
"popupStyle": popupStyle,
|
|
68
|
+
"afterOpenChange": (nextOpen) => {
|
|
69
|
+
opened.value = nextOpen;
|
|
70
|
+
}
|
|
71
|
+
}, { default: () => [slots?.default?.()] });
|
|
72
|
+
};
|
|
73
|
+
}, {
|
|
74
|
+
props: {
|
|
75
|
+
loading: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
required: false,
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
options: {
|
|
81
|
+
type: Array,
|
|
82
|
+
required: true,
|
|
83
|
+
default: void 0
|
|
84
|
+
},
|
|
85
|
+
prefixCls: {
|
|
86
|
+
type: String,
|
|
87
|
+
required: false,
|
|
88
|
+
default: void 0
|
|
89
|
+
},
|
|
90
|
+
placement: {
|
|
91
|
+
type: String,
|
|
92
|
+
required: false,
|
|
93
|
+
default: void 0
|
|
94
|
+
},
|
|
95
|
+
direction: {
|
|
96
|
+
type: String,
|
|
97
|
+
required: false,
|
|
98
|
+
default: void 0
|
|
99
|
+
},
|
|
100
|
+
visible: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
required: false,
|
|
103
|
+
default: void 0
|
|
104
|
+
},
|
|
105
|
+
transitionName: {
|
|
106
|
+
type: String,
|
|
107
|
+
required: false,
|
|
108
|
+
default: void 0
|
|
109
|
+
},
|
|
110
|
+
getPopupContainer: {
|
|
111
|
+
type: Function,
|
|
112
|
+
required: false,
|
|
113
|
+
default: void 0
|
|
114
|
+
},
|
|
115
|
+
popupClassName: {
|
|
116
|
+
type: String,
|
|
117
|
+
required: false,
|
|
118
|
+
default: void 0
|
|
119
|
+
},
|
|
120
|
+
popupStyle: {
|
|
121
|
+
type: Object,
|
|
122
|
+
required: false,
|
|
123
|
+
default: void 0
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
name: "KeywordTrigger",
|
|
127
|
+
inheritAttrs: false
|
|
128
|
+
});
|
|
129
|
+
var KeywordTrigger_default = KeywordTrigger;
|
|
130
|
+
exports.default = KeywordTrigger_default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSProperties } from 'vue';
|
|
2
|
+
import { DataDrivenOptionProps, Direction, Placement } from './Mentions';
|
|
3
|
+
interface KeywordTriggerProps {
|
|
4
|
+
loading?: boolean;
|
|
5
|
+
options: DataDrivenOptionProps[];
|
|
6
|
+
prefixCls?: string;
|
|
7
|
+
placement?: Placement;
|
|
8
|
+
direction?: Direction;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
transitionName?: string;
|
|
11
|
+
getPopupContainer?: () => HTMLElement;
|
|
12
|
+
popupClassName?: string;
|
|
13
|
+
popupStyle?: CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
declare const KeywordTrigger: import('vue').DefineSetupFnComponent<KeywordTriggerProps, {}, {}, KeywordTriggerProps & {}, import('vue').PublicProps>;
|
|
16
|
+
export default KeywordTrigger;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import DropdownMenu_default from "./DropdownMenu.js";
|
|
2
|
+
import { computed, createVNode, defineComponent, shallowRef } from "vue";
|
|
3
|
+
import Trigger from "@v-c/trigger";
|
|
4
|
+
var BUILT_IN_PLACEMENTS = {
|
|
5
|
+
bottomRight: {
|
|
6
|
+
points: ["tl", "br"],
|
|
7
|
+
offset: [0, 4],
|
|
8
|
+
overflow: {
|
|
9
|
+
adjustX: 1,
|
|
10
|
+
adjustY: 1
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
bottomLeft: {
|
|
14
|
+
points: ["tr", "bl"],
|
|
15
|
+
offset: [0, 4],
|
|
16
|
+
overflow: {
|
|
17
|
+
adjustX: 1,
|
|
18
|
+
adjustY: 1
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
topRight: {
|
|
22
|
+
points: ["bl", "tr"],
|
|
23
|
+
offset: [0, -4],
|
|
24
|
+
overflow: {
|
|
25
|
+
adjustX: 1,
|
|
26
|
+
adjustY: 1
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
topLeft: {
|
|
30
|
+
points: ["br", "tl"],
|
|
31
|
+
offset: [0, -4],
|
|
32
|
+
overflow: {
|
|
33
|
+
adjustX: 1,
|
|
34
|
+
adjustY: 1
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var KeywordTrigger_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
|
|
39
|
+
const opened = shallowRef(false);
|
|
40
|
+
const dropdownPlacement = computed(() => {
|
|
41
|
+
if (props.direction === "rtl") return props.placement === "top" ? "topLeft" : "bottomLeft";
|
|
42
|
+
return props.placement === "top" ? "topRight" : "bottomRight";
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
const { prefixCls, options, visible, transitionName, getPopupContainer, popupClassName, popupStyle } = props;
|
|
46
|
+
const dropdownPrefix = `${prefixCls}-dropdown`;
|
|
47
|
+
const dropdownElement = createVNode(DropdownMenu_default, {
|
|
48
|
+
"prefixCls": dropdownPrefix,
|
|
49
|
+
"options": options,
|
|
50
|
+
"opened": opened.value
|
|
51
|
+
}, null);
|
|
52
|
+
return createVNode(Trigger, {
|
|
53
|
+
"prefixCls": dropdownPrefix,
|
|
54
|
+
"popupVisible": visible,
|
|
55
|
+
"popup": dropdownElement,
|
|
56
|
+
"popupPlacement": dropdownPlacement.value,
|
|
57
|
+
"popupMotion": { name: transitionName },
|
|
58
|
+
"builtinPlacements": BUILT_IN_PLACEMENTS,
|
|
59
|
+
"getPopupContainer": getPopupContainer,
|
|
60
|
+
"popupClassName": popupClassName,
|
|
61
|
+
"popupStyle": popupStyle,
|
|
62
|
+
"afterOpenChange": (nextOpen) => {
|
|
63
|
+
opened.value = nextOpen;
|
|
64
|
+
}
|
|
65
|
+
}, { default: () => [slots?.default?.()] });
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
68
|
+
props: {
|
|
69
|
+
loading: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
required: false,
|
|
72
|
+
default: void 0
|
|
73
|
+
},
|
|
74
|
+
options: {
|
|
75
|
+
type: Array,
|
|
76
|
+
required: true,
|
|
77
|
+
default: void 0
|
|
78
|
+
},
|
|
79
|
+
prefixCls: {
|
|
80
|
+
type: String,
|
|
81
|
+
required: false,
|
|
82
|
+
default: void 0
|
|
83
|
+
},
|
|
84
|
+
placement: {
|
|
85
|
+
type: String,
|
|
86
|
+
required: false,
|
|
87
|
+
default: void 0
|
|
88
|
+
},
|
|
89
|
+
direction: {
|
|
90
|
+
type: String,
|
|
91
|
+
required: false,
|
|
92
|
+
default: void 0
|
|
93
|
+
},
|
|
94
|
+
visible: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
required: false,
|
|
97
|
+
default: void 0
|
|
98
|
+
},
|
|
99
|
+
transitionName: {
|
|
100
|
+
type: String,
|
|
101
|
+
required: false,
|
|
102
|
+
default: void 0
|
|
103
|
+
},
|
|
104
|
+
getPopupContainer: {
|
|
105
|
+
type: Function,
|
|
106
|
+
required: false,
|
|
107
|
+
default: void 0
|
|
108
|
+
},
|
|
109
|
+
popupClassName: {
|
|
110
|
+
type: String,
|
|
111
|
+
required: false,
|
|
112
|
+
default: void 0
|
|
113
|
+
},
|
|
114
|
+
popupStyle: {
|
|
115
|
+
type: Object,
|
|
116
|
+
required: false,
|
|
117
|
+
default: void 0
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
name: "KeywordTrigger",
|
|
121
|
+
inheritAttrs: false
|
|
122
|
+
});
|
|
123
|
+
export { KeywordTrigger_default as default };
|