@opentinyvue/vue-dropdown 2.21.0
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 +22 -0
- package/index.d.ts +13 -0
- package/lib/index.js +120 -0
- package/lib/mobile-first.js +216 -0
- package/lib/pc.js +241 -0
- package/package.json +24 -0
- package/src/index.d.ts +80 -0
- package/src/mobile-first.vue.d.ts +2 -0
- package/src/pc.vue.d.ts +2 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 - present TinyVue Authors.
|
|
4
|
+
Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 - present TinyVue Authors.
|
|
3
|
+
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license.
|
|
6
|
+
*
|
|
7
|
+
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
|
|
8
|
+
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
|
|
9
|
+
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
import Dropdown from './src/index';
|
|
13
|
+
export default Dropdown;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
function _extends() {
|
|
2
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
3
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
4
|
+
var t = arguments[e];
|
|
5
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
6
|
+
}
|
|
7
|
+
return n;
|
|
8
|
+
}, _extends.apply(null, arguments);
|
|
9
|
+
}
|
|
10
|
+
import { defineComponent, $prefix, $setup, $props } from "@opentinyvue/vue-common";
|
|
11
|
+
import PcTemplate from "./pc.js";
|
|
12
|
+
import MobileFirstTemplate from "./mobile-first.js";
|
|
13
|
+
import "@opentinyvue/vue-theme/dropdown/index.css";
|
|
14
|
+
var template = function template2(mode) {
|
|
15
|
+
var _process$env;
|
|
16
|
+
var tinyMode = typeof process === "object" ? (_process$env = process.env) == null ? void 0 : _process$env.TINY_MODE : null;
|
|
17
|
+
if ("pc" === (tinyMode || mode)) {
|
|
18
|
+
return PcTemplate;
|
|
19
|
+
}
|
|
20
|
+
if ("mobile-first" === (tinyMode || mode)) {
|
|
21
|
+
return MobileFirstTemplate;
|
|
22
|
+
}
|
|
23
|
+
return PcTemplate;
|
|
24
|
+
};
|
|
25
|
+
var dropdownProps = _extends({}, $props, {
|
|
26
|
+
modelValue: [String, Number],
|
|
27
|
+
type: String,
|
|
28
|
+
trigger: String,
|
|
29
|
+
// 默认主题为 'hover'
|
|
30
|
+
size: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: ""
|
|
33
|
+
},
|
|
34
|
+
disabled: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false
|
|
37
|
+
},
|
|
38
|
+
splitButton: Boolean,
|
|
39
|
+
singleButton: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false
|
|
42
|
+
},
|
|
43
|
+
showTimeout: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 250
|
|
46
|
+
},
|
|
47
|
+
hideTimeout: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: 150
|
|
50
|
+
},
|
|
51
|
+
hideOnClick: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: true
|
|
54
|
+
},
|
|
55
|
+
tabindex: {
|
|
56
|
+
type: Number,
|
|
57
|
+
default: 0
|
|
58
|
+
},
|
|
59
|
+
border: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: false
|
|
62
|
+
},
|
|
63
|
+
round: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: false
|
|
66
|
+
},
|
|
67
|
+
showIcon: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: true
|
|
70
|
+
},
|
|
71
|
+
showSelfIcon: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
// tiny新增
|
|
76
|
+
menuOptions: {
|
|
77
|
+
type: Object,
|
|
78
|
+
default: function _default() {
|
|
79
|
+
return {
|
|
80
|
+
options: [],
|
|
81
|
+
textField: "label",
|
|
82
|
+
popperClass: "",
|
|
83
|
+
placement: "bottom-end"
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
title: {
|
|
88
|
+
type: String,
|
|
89
|
+
default: "下拉菜单"
|
|
90
|
+
},
|
|
91
|
+
inheritWidth: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
suffixIcon: Object,
|
|
96
|
+
lazyShowPopper: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
var Dropdown = defineComponent({
|
|
102
|
+
name: $prefix + "Dropdown",
|
|
103
|
+
componentName: "TinyDropdown",
|
|
104
|
+
props: dropdownProps,
|
|
105
|
+
setup: function setup(props, context) {
|
|
106
|
+
return $setup({
|
|
107
|
+
props,
|
|
108
|
+
context,
|
|
109
|
+
template
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
var version = "2.21.0";
|
|
114
|
+
Dropdown.install = function(Vue) {
|
|
115
|
+
Vue.component(Dropdown.name, Dropdown);
|
|
116
|
+
};
|
|
117
|
+
Dropdown.version = version;
|
|
118
|
+
export {
|
|
119
|
+
Dropdown as default
|
|
120
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { renderless, api } from '@opentinyvue/vue-renderless/dropdown/vue';
|
|
2
|
+
import { defineComponent, $prefix, directive, setup, h, $props } from '@opentinyvue/vue-common';
|
|
3
|
+
import Button from '@opentinyvue/vue-button';
|
|
4
|
+
import ButtonGroup from '@opentinyvue/vue-button-group';
|
|
5
|
+
import Clickoutside from '@opentinyvue/vue-renderless/common/deps/clickoutside';
|
|
6
|
+
import { IconChevronDown, IconChevronUp, IconArrowBottom } from '@opentinyvue/vue-icon';
|
|
7
|
+
|
|
8
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
9
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
10
|
+
if (render) {
|
|
11
|
+
options.render = render;
|
|
12
|
+
options.staticRenderFns = staticRenderFns;
|
|
13
|
+
options._compiled = true;
|
|
14
|
+
}
|
|
15
|
+
var hook;
|
|
16
|
+
if (injectStyles) {
|
|
17
|
+
hook = injectStyles;
|
|
18
|
+
}
|
|
19
|
+
if (hook) {
|
|
20
|
+
if (options.functional) {
|
|
21
|
+
options._injectStyles = hook;
|
|
22
|
+
var originalRender = options.render;
|
|
23
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
24
|
+
hook.call(context);
|
|
25
|
+
return originalRender(h, context);
|
|
26
|
+
};
|
|
27
|
+
} else {
|
|
28
|
+
var existing = options.beforeCreate;
|
|
29
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
exports: scriptExports,
|
|
34
|
+
options
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _extends() {
|
|
39
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
40
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
41
|
+
var t = arguments[e];
|
|
42
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
43
|
+
}
|
|
44
|
+
return n;
|
|
45
|
+
}, _extends.apply(null, arguments);
|
|
46
|
+
}
|
|
47
|
+
var __vue2_script = defineComponent({
|
|
48
|
+
name: $prefix + "Dropdown",
|
|
49
|
+
componentName: "TinyDropdown",
|
|
50
|
+
components: {
|
|
51
|
+
TinyButton: Button,
|
|
52
|
+
TinyButtonGroup: ButtonGroup,
|
|
53
|
+
IconChevronDown: IconChevronDown(),
|
|
54
|
+
IconChevronUp: IconChevronUp(),
|
|
55
|
+
IconArrowBottom: IconArrowBottom()
|
|
56
|
+
},
|
|
57
|
+
directives: directive({
|
|
58
|
+
Clickoutside
|
|
59
|
+
}),
|
|
60
|
+
props: _extends({}, $props, {
|
|
61
|
+
type: String,
|
|
62
|
+
trigger: String,
|
|
63
|
+
size: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: ""
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
singleButton: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: false
|
|
74
|
+
},
|
|
75
|
+
showTimeout: {
|
|
76
|
+
type: Number,
|
|
77
|
+
default: 250
|
|
78
|
+
},
|
|
79
|
+
hideTimeout: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 150
|
|
82
|
+
},
|
|
83
|
+
hideOnClick: {
|
|
84
|
+
type: Boolean,
|
|
85
|
+
default: true
|
|
86
|
+
},
|
|
87
|
+
tabindex: {
|
|
88
|
+
type: Number,
|
|
89
|
+
default: 0
|
|
90
|
+
},
|
|
91
|
+
border: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: false
|
|
94
|
+
},
|
|
95
|
+
round: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: false
|
|
98
|
+
},
|
|
99
|
+
showIcon: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: true
|
|
102
|
+
},
|
|
103
|
+
modelValue: [String, Number],
|
|
104
|
+
showSelfIcon: {
|
|
105
|
+
type: Boolean,
|
|
106
|
+
default: false
|
|
107
|
+
},
|
|
108
|
+
lazyShowPopper: {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: false
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
emits: ["visible-change", "item-click", "button-click", "current-item-click", "menu-item-click", "is-disabled", "selected-index"],
|
|
114
|
+
setup: function setup$1(props, context) {
|
|
115
|
+
return setup({
|
|
116
|
+
props,
|
|
117
|
+
context,
|
|
118
|
+
renderless,
|
|
119
|
+
api,
|
|
120
|
+
mono: true,
|
|
121
|
+
h
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
render: function render() {
|
|
125
|
+
var h2 = arguments[0];
|
|
126
|
+
var type = this.type, disabled = this.disabled, handleMainButtonClick = this.handleMainButtonClick, slots = this.slots, size = this.size, state = this.state, border = this.border, round = this.round, m = this.m, clickOutside = this.clickOutside, singleButton = this.singleButton;
|
|
127
|
+
var params = {
|
|
128
|
+
visible: state.visible
|
|
129
|
+
};
|
|
130
|
+
var triggerElm = null;
|
|
131
|
+
if (singleButton) {
|
|
132
|
+
triggerElm = h2("tiny-button", {
|
|
133
|
+
"ref": "trigger",
|
|
134
|
+
"attrs": {
|
|
135
|
+
"type": type === "primary" ? type : "",
|
|
136
|
+
"size": size,
|
|
137
|
+
"customClass": m(["rounded active:rounded flex items-center justify-center", state.visible && type !== "primary" && "active:border-color-border-focus text-color-text-primary active:text-color-brand-focus focus:border-color-border-focus focus:text-color-brand-focus"]),
|
|
138
|
+
"disabled": disabled,
|
|
139
|
+
"reset-time": 0
|
|
140
|
+
},
|
|
141
|
+
"on": {
|
|
142
|
+
"click": handleMainButtonClick
|
|
143
|
+
}
|
|
144
|
+
}, [h2("div", {
|
|
145
|
+
"class": "overflow-hidden overflow-ellipsis whitespace-nowrap w-full"
|
|
146
|
+
}, [slots.default && slots.default(params)])]);
|
|
147
|
+
} else {
|
|
148
|
+
var defaultSlot = slots.default && slots.default(params);
|
|
149
|
+
var suffixSlot = slots["suffix-icon"] && slots["suffix-icon"]();
|
|
150
|
+
var vnodeData = (defaultSlot == null ? void 0 : defaultSlot[0].data) || {};
|
|
151
|
+
var _vnodeData$attrs = vnodeData.attrs, attrs = _vnodeData$attrs === void 0 ? {} : _vnodeData$attrs;
|
|
152
|
+
if (disabled && !attrs.disabled) {
|
|
153
|
+
attrs.disabled = true;
|
|
154
|
+
vnodeData.attrs = attrs;
|
|
155
|
+
}
|
|
156
|
+
var defaultIcon = h2("span", {
|
|
157
|
+
"class": "block text-[0]"
|
|
158
|
+
}, [h2("icon-chevron-down", {
|
|
159
|
+
"class": "sm:block hidden will-change-transform"
|
|
160
|
+
}), h2("icon-arrow-bottom", {
|
|
161
|
+
"class": "sm:hidden block will-change-transform"
|
|
162
|
+
})]);
|
|
163
|
+
var suffixInner = state.showIcon && h2("span", {
|
|
164
|
+
"attrs": {
|
|
165
|
+
"data-tag": "tiny-dropdown-showicon"
|
|
166
|
+
},
|
|
167
|
+
"class": ["ml-1 sm:ml-2 [&_svg:nth-of-type(1)]:align-top w-4 h-4 inline-block [&_svg]:transition-transform [&_svg]:duration-300", {
|
|
168
|
+
"fill-color-brand-focus [&_svg:nth-of-type(1)]:hover:fill-color-brand-hover [&_svg:nth-of-type(1)]:active:fill-color-brand-focus leading-4": !disabled && !border
|
|
169
|
+
}, border && (state.visible ? "[&_svg]:rotate-180" : "[&_svg]:rotate-0"), border && type !== "primary" && state.visible && "[&_svg]:fill-color-border-focus visited:[&_svg]:fill-color-border-focus active:[&_svg]:fill-color-border-focus"]
|
|
170
|
+
}, [suffixSlot || defaultIcon]);
|
|
171
|
+
triggerElm = border ? h2("tiny-button", {
|
|
172
|
+
"ref": "trigger",
|
|
173
|
+
"attrs": {
|
|
174
|
+
"round": round,
|
|
175
|
+
"size": size,
|
|
176
|
+
"type": type === "primary" ? type : "",
|
|
177
|
+
"disabled": disabled,
|
|
178
|
+
"reset-time": 0
|
|
179
|
+
},
|
|
180
|
+
"class": ["rounded inline-flex items-center justify-center", type === "primary" ? "[&_svg]:fill-color-bg-1" : state.visible ? "active:border-color-border-focus text-color-text-primary active:text-color-brand-focus focus:border-color-border-focus focus:text-color-brand-focus" : "[&_svg]:fill-color-icon-placeholder"]
|
|
181
|
+
}, [defaultSlot, suffixInner]) : h2("span", {
|
|
182
|
+
"ref": "trigger",
|
|
183
|
+
"class": [state.visible && !state.showSelfIcon ? "[&_svg]:rotate-180" : "[&_svg]:rotate-0", disabled && "cursor-not-allowed [&_svg]:fill-color-text-disabled", "inline-flex [&_svg]:transition-transform [&_svg]:duration-300"]
|
|
184
|
+
}, [h2("span", {
|
|
185
|
+
"class": ["inline-flex h-4 leading-4", disabled ? "text-color-text-disabled" : "hover:text-color-brand-hover active:text-color-brand-focus"]
|
|
186
|
+
}, [defaultSlot]), h2("span", {
|
|
187
|
+
"class": "align-bottom leading-4 h-4"
|
|
188
|
+
}, [suffixInner])]);
|
|
189
|
+
}
|
|
190
|
+
var menuElm = disabled ? null : slots.dropdown && slots.dropdown();
|
|
191
|
+
return h2("div", {
|
|
192
|
+
"class": ["relative inline-block [&>span:nth-of-type(1)]:text-color-brand-focus [&>span:nth-of-type(1)]:text-sm sm:[&>span:nth-of-type(1)]:text-xs", disabled && "[&>span:nth-of-type(1)]:text-color-brand-focus", state.showSelfIcon && "leading-4 h-4 [&_svg]:align-top [&_svg]:rotate-0"],
|
|
193
|
+
"directives": [{
|
|
194
|
+
name: "clickoutside",
|
|
195
|
+
value: clickOutside
|
|
196
|
+
}],
|
|
197
|
+
"attrs": {
|
|
198
|
+
"aria-disabled": disabled,
|
|
199
|
+
"data-tag": "tiny-dropdown"
|
|
200
|
+
}
|
|
201
|
+
}, [triggerElm, menuElm]);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
var __vue2_render, __vue2_staticRenderFns;
|
|
205
|
+
var __cssModules = {};
|
|
206
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
|
|
207
|
+
function __vue2_injectStyles(context) {
|
|
208
|
+
for (var o in __cssModules) {
|
|
209
|
+
this[o] = __cssModules[o];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
var mobileFirst = /* @__PURE__ */ function() {
|
|
213
|
+
return __component__.exports;
|
|
214
|
+
}();
|
|
215
|
+
|
|
216
|
+
export { mobileFirst as default };
|
package/lib/pc.js
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { renderless, api } from '@opentinyvue/vue-renderless/dropdown/vue';
|
|
2
|
+
import { defineComponent, $prefix, directive, setup, h, $props } from '@opentinyvue/vue-common';
|
|
3
|
+
import Button from '@opentinyvue/vue-button';
|
|
4
|
+
import ButtonGroup from '@opentinyvue/vue-button-group';
|
|
5
|
+
import Clickoutside from '@opentinyvue/vue-renderless/common/deps/clickoutside';
|
|
6
|
+
import DropdownMenu from '@opentinyvue/vue-dropdown-menu';
|
|
7
|
+
import { iconDownWard } from '@opentinyvue/vue-icon';
|
|
8
|
+
|
|
9
|
+
function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
|
|
10
|
+
var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
|
|
11
|
+
if (render) {
|
|
12
|
+
options.render = render;
|
|
13
|
+
options.staticRenderFns = staticRenderFns;
|
|
14
|
+
options._compiled = true;
|
|
15
|
+
}
|
|
16
|
+
var hook;
|
|
17
|
+
if (injectStyles) {
|
|
18
|
+
hook = injectStyles;
|
|
19
|
+
}
|
|
20
|
+
if (hook) {
|
|
21
|
+
if (options.functional) {
|
|
22
|
+
options._injectStyles = hook;
|
|
23
|
+
var originalRender = options.render;
|
|
24
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
25
|
+
hook.call(context);
|
|
26
|
+
return originalRender(h, context);
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
var existing = options.beforeCreate;
|
|
30
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
exports: scriptExports,
|
|
35
|
+
options
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function _extends() {
|
|
40
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
41
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
42
|
+
var t = arguments[e];
|
|
43
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
44
|
+
}
|
|
45
|
+
return n;
|
|
46
|
+
}, _extends.apply(null, arguments);
|
|
47
|
+
}
|
|
48
|
+
var __vue2_script = defineComponent({
|
|
49
|
+
name: $prefix + "Dropdown",
|
|
50
|
+
componentName: "TinyDropdown",
|
|
51
|
+
components: {
|
|
52
|
+
TinyButton: Button,
|
|
53
|
+
TinyButtonGroup: ButtonGroup,
|
|
54
|
+
TinyDropdownMenu: DropdownMenu,
|
|
55
|
+
IconDownWard: iconDownWard()
|
|
56
|
+
},
|
|
57
|
+
directives: directive({
|
|
58
|
+
Clickoutside
|
|
59
|
+
}),
|
|
60
|
+
props: _extends({}, $props, {
|
|
61
|
+
type: String,
|
|
62
|
+
trigger: String,
|
|
63
|
+
size: {
|
|
64
|
+
type: String,
|
|
65
|
+
default: ""
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
splitButton: Boolean,
|
|
72
|
+
showTimeout: {
|
|
73
|
+
type: Number,
|
|
74
|
+
default: 250
|
|
75
|
+
},
|
|
76
|
+
hideTimeout: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: 150
|
|
79
|
+
},
|
|
80
|
+
hideOnClick: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true
|
|
83
|
+
},
|
|
84
|
+
tabindex: {
|
|
85
|
+
type: Number,
|
|
86
|
+
default: 0
|
|
87
|
+
},
|
|
88
|
+
border: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: false
|
|
91
|
+
},
|
|
92
|
+
round: {
|
|
93
|
+
type: Boolean,
|
|
94
|
+
default: false
|
|
95
|
+
},
|
|
96
|
+
showIcon: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: true
|
|
99
|
+
},
|
|
100
|
+
menuOptions: {
|
|
101
|
+
type: Object,
|
|
102
|
+
default: function _default() {
|
|
103
|
+
return {
|
|
104
|
+
options: [],
|
|
105
|
+
textField: "label",
|
|
106
|
+
popperClass: "",
|
|
107
|
+
placement: "bottom-end"
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
title: {
|
|
112
|
+
type: String,
|
|
113
|
+
default: "下拉菜单"
|
|
114
|
+
// TINY-TODO: 国际化
|
|
115
|
+
},
|
|
116
|
+
inheritWidth: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: false
|
|
119
|
+
},
|
|
120
|
+
suffixIcon: Object,
|
|
121
|
+
prefixIcon: Object,
|
|
122
|
+
lazyShowPopper: {
|
|
123
|
+
type: Boolean,
|
|
124
|
+
default: false
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
emits: ["visible-change", "item-click", "button-click", "menu-item-click", "handle-click", "is-disabled", "selected-index"],
|
|
128
|
+
setup: function setup$1(props, context) {
|
|
129
|
+
return setup({
|
|
130
|
+
props,
|
|
131
|
+
context,
|
|
132
|
+
renderless,
|
|
133
|
+
api,
|
|
134
|
+
h
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
render: function render() {
|
|
138
|
+
var _state$designConfig, _state$designConfig$i, _state$designConfig2, _state$designConfig2$;
|
|
139
|
+
var h2 = arguments[0];
|
|
140
|
+
var splitButton = this.splitButton, type = this.type, disabled = this.disabled, handleMainButtonClick = this.handleMainButtonClick, menuOptions = this.menuOptions, title = this.title, suffixIcon = this.suffixIcon, prefixIcon = this.prefixIcon;
|
|
141
|
+
var slots = this.slots, size = this.size, state = this.state, border = this.border, showIcon = this.showIcon, round = this.round, clickOutside = this.clickOutside;
|
|
142
|
+
var params = {
|
|
143
|
+
visible: state.visible
|
|
144
|
+
};
|
|
145
|
+
var triggerElm = null;
|
|
146
|
+
var triggerClass = "tiny-dropdown__trigger tiny-dropdown-trigger";
|
|
147
|
+
var visibleClass = state.visible ? "tiny-dropdown--visible tiny-dropdown-visible" : "";
|
|
148
|
+
var IconDown = suffixIcon || ((_state$designConfig = state.designConfig) == null ? void 0 : (_state$designConfig$i = _state$designConfig.icons) == null ? void 0 : _state$designConfig$i.dropdownIcon) || iconDownWard();
|
|
149
|
+
var IconPre = prefixIcon;
|
|
150
|
+
var ButtonIconDown = ((_state$designConfig2 = state.designConfig) == null ? void 0 : (_state$designConfig2$ = _state$designConfig2.icons) == null ? void 0 : _state$designConfig2$.dropdownIcon) || iconDownWard();
|
|
151
|
+
var defaultSlot = slots.default && slots.default(params);
|
|
152
|
+
if (splitButton) {
|
|
153
|
+
triggerElm = h2("tiny-button-group", [h2("tiny-button", {
|
|
154
|
+
"attrs": {
|
|
155
|
+
"type": type,
|
|
156
|
+
"size": size,
|
|
157
|
+
"disabled": disabled
|
|
158
|
+
},
|
|
159
|
+
"on": {
|
|
160
|
+
"click": handleMainButtonClick
|
|
161
|
+
},
|
|
162
|
+
"class": "tiny-dropdown__title-button"
|
|
163
|
+
}, [defaultSlot || h2("span", [title])]), h2("tiny-button", {
|
|
164
|
+
"ref": "trigger",
|
|
165
|
+
"attrs": {
|
|
166
|
+
"type": type,
|
|
167
|
+
"size": size,
|
|
168
|
+
"disabled": disabled,
|
|
169
|
+
"reset-time": 0
|
|
170
|
+
},
|
|
171
|
+
"class": "tiny-dropdown__caret-button " + triggerClass
|
|
172
|
+
}, [h2(ButtonIconDown, {
|
|
173
|
+
"class": visibleClass
|
|
174
|
+
})])]);
|
|
175
|
+
} else {
|
|
176
|
+
var _defaultSlot$;
|
|
177
|
+
var suffixSlot = slots["suffix-icon"] && slots["suffix-icon"]();
|
|
178
|
+
var prefixSlot = slots["prefix-icon"] && slots["prefix-icon"]();
|
|
179
|
+
var vnodeData = defaultSlot && ((_defaultSlot$ = defaultSlot[0]) == null ? void 0 : _defaultSlot$.data) || {};
|
|
180
|
+
var _vnodeData$attrs = vnodeData.attrs, attrs = _vnodeData$attrs === void 0 ? {} : _vnodeData$attrs;
|
|
181
|
+
if (disabled && !attrs.disabled) {
|
|
182
|
+
attrs.disabled = true;
|
|
183
|
+
vnodeData.attrs = attrs;
|
|
184
|
+
}
|
|
185
|
+
var suffixInner = showIcon ? h2("span", {
|
|
186
|
+
"class": "tiny-dropdown__suffix-inner " + visibleClass
|
|
187
|
+
}, [suffixSlot || h2(IconDown)]) : "";
|
|
188
|
+
var prefixInner = prefixIcon || prefixSlot ? h2("span", {
|
|
189
|
+
"class": "tiny-dropdown__prefix-inner " + visibleClass
|
|
190
|
+
}, [prefixSlot || h2(IconPre)]) : "";
|
|
191
|
+
var defaultTriggerElm = defaultSlot || title ? h2("span", {
|
|
192
|
+
"class": "tiny-dropdown__title"
|
|
193
|
+
}, [defaultSlot || title]) : null;
|
|
194
|
+
triggerElm = border ? h2("tiny-button", {
|
|
195
|
+
"ref": "trigger",
|
|
196
|
+
"attrs": {
|
|
197
|
+
"round": round,
|
|
198
|
+
"disabled": disabled,
|
|
199
|
+
"type": type,
|
|
200
|
+
"reset-time": 0
|
|
201
|
+
},
|
|
202
|
+
"class": "tiny-dropdown__border " + (state.visible ? "is-expand" : "") + (showIcon ? " is-show-icon " : "") + " " + triggerClass
|
|
203
|
+
}, [prefixInner, defaultTriggerElm, suffixInner]) : h2("span", {
|
|
204
|
+
"ref": "trigger",
|
|
205
|
+
"class": "is-text" + (state.visible ? " is-expand" : " is-hide") + (disabled ? " is-disabled" : "") + " " + triggerClass
|
|
206
|
+
}, [prefixInner, defaultTriggerElm, suffixInner]);
|
|
207
|
+
}
|
|
208
|
+
var defaulMenuElm = h2("tiny-dropdown-menu", {
|
|
209
|
+
"attrs": {
|
|
210
|
+
"options": menuOptions.options,
|
|
211
|
+
"text-field": menuOptions.textField || menuOptions["text-field"],
|
|
212
|
+
"popper-class": menuOptions.popperClass || menuOptions["popper-class"],
|
|
213
|
+
"placement": menuOptions.placement
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
var menuElm = disabled ? null : slots.dropdown && slots.dropdown() || defaulMenuElm;
|
|
217
|
+
return h2("div", {
|
|
218
|
+
"class": "tiny-dropdown",
|
|
219
|
+
"directives": [{
|
|
220
|
+
name: "clickoutside",
|
|
221
|
+
value: clickOutside
|
|
222
|
+
}],
|
|
223
|
+
"attrs": {
|
|
224
|
+
"aria-disabled": disabled
|
|
225
|
+
}
|
|
226
|
+
}, [triggerElm, menuElm]);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
var __vue2_render, __vue2_staticRenderFns;
|
|
230
|
+
var __cssModules = {};
|
|
231
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
|
|
232
|
+
function __vue2_injectStyles(context) {
|
|
233
|
+
for (var o in __cssModules) {
|
|
234
|
+
this[o] = __cssModules[o];
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
var pc = /* @__PURE__ */ function() {
|
|
238
|
+
return __component__.exports;
|
|
239
|
+
}();
|
|
240
|
+
|
|
241
|
+
export { pc as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentinyvue/vue-dropdown",
|
|
3
|
+
"version": "2.21.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"module": "./lib/index.js",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"type": "module",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@opentinyvue/vue-renderless": "~3.21.0",
|
|
11
|
+
"@opentinyvue/vue-theme": "~3.21.0",
|
|
12
|
+
"@opentinyvue/vue-button": "~2.21.0",
|
|
13
|
+
"@opentinyvue/vue-button-group": "~2.21.0",
|
|
14
|
+
"@opentinyvue/vue-common": "~2.21.0",
|
|
15
|
+
"@opentinyvue/vue-icon": "~2.21.0",
|
|
16
|
+
"@opentinyvue/vue-dropdown-menu": "~2.21.0"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"types": "index.d.ts",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "pnpm -w build:ui $npm_package_name",
|
|
22
|
+
"//postversion": "pnpm build"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare const dropdownProps: {
|
|
2
|
+
modelValue: (StringConstructor | NumberConstructor)[];
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
trigger: StringConstructor;
|
|
5
|
+
size: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
default: string;
|
|
8
|
+
};
|
|
9
|
+
disabled: {
|
|
10
|
+
type: BooleanConstructor;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
splitButton: BooleanConstructor;
|
|
14
|
+
singleButton: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
showTimeout: {
|
|
19
|
+
type: NumberConstructor;
|
|
20
|
+
default: number;
|
|
21
|
+
};
|
|
22
|
+
hideTimeout: {
|
|
23
|
+
type: NumberConstructor;
|
|
24
|
+
default: number;
|
|
25
|
+
};
|
|
26
|
+
hideOnClick: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
tabindex: {
|
|
31
|
+
type: NumberConstructor;
|
|
32
|
+
default: number;
|
|
33
|
+
};
|
|
34
|
+
border: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
38
|
+
round: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
showIcon: {
|
|
43
|
+
type: BooleanConstructor;
|
|
44
|
+
default: boolean;
|
|
45
|
+
};
|
|
46
|
+
showSelfIcon: {
|
|
47
|
+
type: BooleanConstructor;
|
|
48
|
+
default: boolean;
|
|
49
|
+
};
|
|
50
|
+
menuOptions: {
|
|
51
|
+
type: ObjectConstructor;
|
|
52
|
+
default: () => {
|
|
53
|
+
options: never[];
|
|
54
|
+
textField: string;
|
|
55
|
+
popperClass: string;
|
|
56
|
+
placement: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
title: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: string;
|
|
62
|
+
};
|
|
63
|
+
inheritWidth: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
default: boolean;
|
|
66
|
+
};
|
|
67
|
+
suffixIcon: ObjectConstructor;
|
|
68
|
+
lazyShowPopper: {
|
|
69
|
+
type: BooleanConstructor;
|
|
70
|
+
default: boolean;
|
|
71
|
+
};
|
|
72
|
+
tiny_mode: StringConstructor;
|
|
73
|
+
tiny_mode_root: BooleanConstructor;
|
|
74
|
+
tiny_template: (ObjectConstructor | FunctionConstructor)[];
|
|
75
|
+
tiny_renderless: FunctionConstructor;
|
|
76
|
+
tiny_theme: StringConstructor;
|
|
77
|
+
tiny_chart_theme: ObjectConstructor;
|
|
78
|
+
};
|
|
79
|
+
declare const _default: any;
|
|
80
|
+
export default _default;
|
package/src/pc.vue.d.ts
ADDED