@opentiny/vue-dropdown-item 2.5.0-alpha.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/lib/index.js +115 -0
- package/lib/mobile.js +276 -0
- package/lib/pc.js +224 -0
- package/package.json +22 -0
package/lib/index.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { $prefix, $props, $setup } from '@opentiny/vue-common';
|
|
2
|
+
import PCTemplate from './pc';
|
|
3
|
+
import MobileTemplate from './mobile';
|
|
4
|
+
|
|
5
|
+
function ownKeys(object, enumerableOnly) {
|
|
6
|
+
var keys = Object.keys(object);
|
|
7
|
+
if (Object.getOwnPropertySymbols) {
|
|
8
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
9
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
10
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
11
|
+
})), keys.push.apply(keys, symbols);
|
|
12
|
+
}
|
|
13
|
+
return keys;
|
|
14
|
+
}
|
|
15
|
+
function _objectSpread2(target) {
|
|
16
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
17
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
18
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
19
|
+
_defineProperty(target, key, source[key]);
|
|
20
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
21
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return target;
|
|
25
|
+
}
|
|
26
|
+
function _defineProperty(obj, key, value) {
|
|
27
|
+
key = _toPropertyKey(key);
|
|
28
|
+
if (key in obj) {
|
|
29
|
+
Object.defineProperty(obj, key, {
|
|
30
|
+
value: value,
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
obj[key] = value;
|
|
37
|
+
}
|
|
38
|
+
return obj;
|
|
39
|
+
}
|
|
40
|
+
function _toPrimitive(input, hint) {
|
|
41
|
+
if (typeof input !== "object" || input === null) return input;
|
|
42
|
+
var prim = input[Symbol.toPrimitive];
|
|
43
|
+
if (prim !== undefined) {
|
|
44
|
+
var res = prim.call(input, hint || "default");
|
|
45
|
+
if (typeof res !== "object") return res;
|
|
46
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
47
|
+
}
|
|
48
|
+
return (hint === "string" ? String : Number)(input);
|
|
49
|
+
}
|
|
50
|
+
function _toPropertyKey(arg) {
|
|
51
|
+
var key = _toPrimitive(arg, "string");
|
|
52
|
+
return typeof key === "symbol" ? key : String(key);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var template = function template(mode) {
|
|
56
|
+
if (process.env.TINY_MODE === 'pc') return PCTemplate;else if (process.env.TINY_MODE === 'mobile') return MobileTemplate;else return mode === 'mobile' ? MobileTemplate : PCTemplate;
|
|
57
|
+
};
|
|
58
|
+
var DropdownItem = {
|
|
59
|
+
name: $prefix + 'DropdownItem',
|
|
60
|
+
componentName: 'TinyDropdownItem',
|
|
61
|
+
props: _objectSpread2(_objectSpread2({}, $props), {}, {
|
|
62
|
+
icon: [String, Object],
|
|
63
|
+
disabled: Boolean,
|
|
64
|
+
divided: Boolean,
|
|
65
|
+
command: {},
|
|
66
|
+
title: String,
|
|
67
|
+
titleClass: String,
|
|
68
|
+
options: {
|
|
69
|
+
type: Array,
|
|
70
|
+
default: function _default() {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
type: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: 'selection'
|
|
77
|
+
},
|
|
78
|
+
label: {
|
|
79
|
+
type: String,
|
|
80
|
+
default: ''
|
|
81
|
+
},
|
|
82
|
+
itemData: {
|
|
83
|
+
type: Object,
|
|
84
|
+
default: function _default() {
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
appendToBody: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: true
|
|
91
|
+
},
|
|
92
|
+
textField: {
|
|
93
|
+
type: String,
|
|
94
|
+
default: 'label'
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
97
|
+
setup: function setup(props, context) {
|
|
98
|
+
return $setup({
|
|
99
|
+
props: props,
|
|
100
|
+
context: context,
|
|
101
|
+
template: template
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
DropdownItem.model = {
|
|
107
|
+
prop: 'modelValue',
|
|
108
|
+
event: 'update:modelValue'
|
|
109
|
+
};
|
|
110
|
+
DropdownItem.install = function (Vue) {
|
|
111
|
+
Vue.component(DropdownItem.name, DropdownItem);
|
|
112
|
+
};
|
|
113
|
+
DropdownItem.version = '2.5.0-alpha.0';
|
|
114
|
+
|
|
115
|
+
export { DropdownItem as default };
|
package/lib/mobile.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { renderless, api } from '@opentiny/vue-renderless/dropdown-item/vue';
|
|
2
|
+
import { setup, props } from '@opentiny/vue-common';
|
|
3
|
+
import { iconYes } from '@opentiny/vue-icon';
|
|
4
|
+
import Popup from '@opentiny/vue-popup';
|
|
5
|
+
import Button from '@opentiny/vue-button';
|
|
6
|
+
import Clickoutside from '@opentiny/vue-renderless/common/deps/clickoutside';
|
|
7
|
+
import '@opentiny/vue-theme-mobile/dropdown-item/index.css';
|
|
8
|
+
|
|
9
|
+
function _toConsumableArray(arr) {
|
|
10
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
11
|
+
}
|
|
12
|
+
function _arrayWithoutHoles(arr) {
|
|
13
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
14
|
+
}
|
|
15
|
+
function _iterableToArray(iter) {
|
|
16
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
17
|
+
}
|
|
18
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
19
|
+
if (!o) return;
|
|
20
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
21
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
24
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
25
|
+
}
|
|
26
|
+
function _arrayLikeToArray(arr, len) {
|
|
27
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
28
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
29
|
+
return arr2;
|
|
30
|
+
}
|
|
31
|
+
function _nonIterableSpread() {
|
|
32
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var script = {
|
|
36
|
+
directives: {
|
|
37
|
+
Clickoutside: Clickoutside
|
|
38
|
+
},
|
|
39
|
+
props: [].concat(_toConsumableArray(props), ['modelValue', 'title', 'disabled', 'titleClass', 'options', 'icon', 'type']),
|
|
40
|
+
components: {
|
|
41
|
+
IconYes: iconYes(),
|
|
42
|
+
TinyPopup: Popup,
|
|
43
|
+
TinyButton: Button
|
|
44
|
+
},
|
|
45
|
+
emits: ['update:modelValue'],
|
|
46
|
+
setup: function setup$1(props, context) {
|
|
47
|
+
return setup({
|
|
48
|
+
props: props,
|
|
49
|
+
context: context,
|
|
50
|
+
renderless: renderless,
|
|
51
|
+
api: api
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
|
|
57
|
+
/* server only */
|
|
58
|
+
, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
59
|
+
if (typeof shadowMode !== 'boolean') {
|
|
60
|
+
createInjectorSSR = createInjector;
|
|
61
|
+
createInjector = shadowMode;
|
|
62
|
+
shadowMode = false;
|
|
63
|
+
} // Vue.extend constructor export interop.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
var options = typeof script === 'function' ? script.options : script; // render functions
|
|
67
|
+
|
|
68
|
+
if (template && template.render) {
|
|
69
|
+
options.render = template.render;
|
|
70
|
+
options.staticRenderFns = template.staticRenderFns;
|
|
71
|
+
options._compiled = true; // functional template
|
|
72
|
+
|
|
73
|
+
if (isFunctionalTemplate) {
|
|
74
|
+
options.functional = true;
|
|
75
|
+
}
|
|
76
|
+
} // scopedId
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
if (scopeId) {
|
|
80
|
+
options._scopeId = scopeId;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var hook;
|
|
84
|
+
|
|
85
|
+
if (moduleIdentifier) {
|
|
86
|
+
// server build
|
|
87
|
+
hook = function hook(context) {
|
|
88
|
+
// 2.3 injection
|
|
89
|
+
context = context || // cached call
|
|
90
|
+
this.$vnode && this.$vnode.ssrContext || // stateful
|
|
91
|
+
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext; // functional
|
|
92
|
+
// 2.2 with runInNewContext: true
|
|
93
|
+
|
|
94
|
+
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
95
|
+
context = __VUE_SSR_CONTEXT__;
|
|
96
|
+
} // inject component styles
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if (style) {
|
|
100
|
+
style.call(this, createInjectorSSR(context));
|
|
101
|
+
} // register component module identifier for async chunk inference
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (context && context._registeredComponents) {
|
|
105
|
+
context._registeredComponents.add(moduleIdentifier);
|
|
106
|
+
}
|
|
107
|
+
}; // used by ssr in case component is cached and beforeCreate
|
|
108
|
+
// never gets called
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
options._ssrRegister = hook;
|
|
112
|
+
} else if (style) {
|
|
113
|
+
hook = shadowMode ? function () {
|
|
114
|
+
style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
|
|
115
|
+
} : function (context) {
|
|
116
|
+
style.call(this, createInjector(context));
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (hook) {
|
|
121
|
+
if (options.functional) {
|
|
122
|
+
// register for functional component in vue file
|
|
123
|
+
var originalRender = options.render;
|
|
124
|
+
|
|
125
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
126
|
+
hook.call(context);
|
|
127
|
+
return originalRender(h, context);
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
// inject component registration as beforeCreate hook
|
|
131
|
+
var existing = options.beforeCreate;
|
|
132
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return script;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var normalizeComponent_1 = normalizeComponent;
|
|
140
|
+
|
|
141
|
+
var __vue_script__ = script;
|
|
142
|
+
var __vue_render__ = function __vue_render__() {
|
|
143
|
+
var _vm = this;
|
|
144
|
+
var _h = _vm.$createElement;
|
|
145
|
+
var _c = _vm._self._c || _h;
|
|
146
|
+
return _c('div', {
|
|
147
|
+
directives: [{
|
|
148
|
+
name: "show",
|
|
149
|
+
rawName: "v-show",
|
|
150
|
+
value: _vm.state.showWrapper,
|
|
151
|
+
expression: "state.showWrapper"
|
|
152
|
+
}],
|
|
153
|
+
ref: "wrapper",
|
|
154
|
+
staticClass: "tiny-mobile-dropdown-item",
|
|
155
|
+
class: 'tiny-mobile-dropdown-item--' + _vm.state.direction,
|
|
156
|
+
style: _vm.state.itemStyle,
|
|
157
|
+
on: {
|
|
158
|
+
"click": _vm.clickWrapper
|
|
159
|
+
}
|
|
160
|
+
}, [_c('tiny-popup', {
|
|
161
|
+
attrs: {
|
|
162
|
+
"popupClass": "tiny-mobile-dropdown-item__content",
|
|
163
|
+
"overlay": _vm.state.overlay,
|
|
164
|
+
"close-on-click-overlay": _vm.state.closeOnClickOverlay,
|
|
165
|
+
"closeable": false,
|
|
166
|
+
"position": _vm.state.direction === 'down' ? 'top' : 'bottom',
|
|
167
|
+
"duration": _vm.state.transition ? _vm.state.duration : 0
|
|
168
|
+
},
|
|
169
|
+
on: {
|
|
170
|
+
"open": _vm.open,
|
|
171
|
+
"close": _vm.close,
|
|
172
|
+
"opened": _vm.opened,
|
|
173
|
+
"closed": _vm.closed
|
|
174
|
+
},
|
|
175
|
+
model: {
|
|
176
|
+
value: _vm.state.showPopup,
|
|
177
|
+
callback: function callback($$v) {
|
|
178
|
+
_vm.$set(_vm.state, "showPopup", $$v);
|
|
179
|
+
},
|
|
180
|
+
expression: "state.showPopup"
|
|
181
|
+
}
|
|
182
|
+
}, [_vm._t("default", function () {
|
|
183
|
+
return [_vm.type === 'selection' ? _c('div', {
|
|
184
|
+
staticClass: "tiny-mobile-dropdown-item__options"
|
|
185
|
+
}, _vm._l(_vm.options, function (item, index) {
|
|
186
|
+
return _c('div', {
|
|
187
|
+
key: index,
|
|
188
|
+
staticClass: "tiny-mobile-dropdown-item__cell tiny-mobile-dropdown-item__option",
|
|
189
|
+
class: item.value === _vm.modelValue ? 'is-active' : '',
|
|
190
|
+
attrs: {
|
|
191
|
+
"tabindex": "0"
|
|
192
|
+
},
|
|
193
|
+
on: {
|
|
194
|
+
"click": function click($event) {
|
|
195
|
+
return _vm.clickItem(item.value);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, [_c('div', {
|
|
199
|
+
staticClass: "tiny-mobile-dropdown-item__option-icon"
|
|
200
|
+
}, [_vm._t("icon", function () {
|
|
201
|
+
return [_c(_vm.icon, {
|
|
202
|
+
tag: "component"
|
|
203
|
+
})];
|
|
204
|
+
})], 2), _vm._v(" "), _c('div', {
|
|
205
|
+
staticClass: "tiny-mobile-dropdown-item__option-title"
|
|
206
|
+
}, [_vm._t("title", function () {
|
|
207
|
+
return [_c('span', {
|
|
208
|
+
style: {
|
|
209
|
+
color: item.value === _vm.modelValue && _vm.state.activeColor ? _vm.state.activeColor : ''
|
|
210
|
+
}
|
|
211
|
+
}, [_vm._v(_vm._s(item.text))])];
|
|
212
|
+
}, {
|
|
213
|
+
"titleData": item
|
|
214
|
+
})], 2), _vm._v(" "), _c('div', {
|
|
215
|
+
staticClass: "tiny-mobile-dropdown-item__option-value"
|
|
216
|
+
}, [item.value === _vm.modelValue ? _c('icon-yes', {
|
|
217
|
+
attrs: {
|
|
218
|
+
"fill": _vm.state.activeColor ? _vm.state.activeColor : '#f36f64'
|
|
219
|
+
}
|
|
220
|
+
}) : _vm._e()], 1)]);
|
|
221
|
+
}), 0) : _vm._e(), _vm._v(" "), _vm.type === 'filter' ? _c('div', {
|
|
222
|
+
directives: [{
|
|
223
|
+
name: "clickoutside",
|
|
224
|
+
rawName: "v-clickoutside",
|
|
225
|
+
value: _vm.clickOutside,
|
|
226
|
+
expression: "clickOutside"
|
|
227
|
+
}],
|
|
228
|
+
staticClass: "tiny-mobile-dropdown-item__filter"
|
|
229
|
+
}, [_c('div', {
|
|
230
|
+
staticClass: "tiny-mobile-dropdown-item__filter-wrap"
|
|
231
|
+
}, _vm._l(_vm.options, function (item, key) {
|
|
232
|
+
return _c('div', {
|
|
233
|
+
key: key,
|
|
234
|
+
staticClass: "tiny-mobile-dropdown-item__cell tiny-mobile-dropdown-item__filter-item"
|
|
235
|
+
}, [_c('span', {
|
|
236
|
+
staticClass: "tiny-mobile-dropdown-item__filter-title"
|
|
237
|
+
}, [_vm._v(_vm._s(item.title))]), _vm._v(" "), _c('ul', _vm._l(_vm.options.length === 0 ? item.data = [] : item.data, function (tag, tagkey) {
|
|
238
|
+
return _c('li', {
|
|
239
|
+
key: tagkey,
|
|
240
|
+
staticClass: "tiny-mobile-dropdown-item__filter-li",
|
|
241
|
+
class: [_vm.modelValue[key].indexOf(tag.value) > -1 ? 'checked' : ''],
|
|
242
|
+
style: _vm.getOptionStyle(tag, _vm.modelValue[key]),
|
|
243
|
+
on: {
|
|
244
|
+
"click": function click($event) {
|
|
245
|
+
return _vm.tagClick(key, tag, $event);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}, [_vm._v("\n " + _vm._s(tag.text) + "\n ")]);
|
|
249
|
+
}), 0)]);
|
|
250
|
+
}), 0), _vm._v(" "), _c('div', {
|
|
251
|
+
staticClass: "tiny-mobile-dropdown-item__filter-operate"
|
|
252
|
+
}, [_c('tiny-button', {
|
|
253
|
+
on: {
|
|
254
|
+
"click": _vm.reset
|
|
255
|
+
}
|
|
256
|
+
}, [_vm._v("Reset")]), _vm._v(" "), _c('tiny-button', {
|
|
257
|
+
attrs: {
|
|
258
|
+
"type": "primary"
|
|
259
|
+
},
|
|
260
|
+
on: {
|
|
261
|
+
"click": _vm.confirm
|
|
262
|
+
}
|
|
263
|
+
}, [_vm._v("OK")])], 1)]) : _vm._e()];
|
|
264
|
+
})], 2)], 1);
|
|
265
|
+
};
|
|
266
|
+
var __vue_staticRenderFns__ = [];
|
|
267
|
+
var __vue_inject_styles__ = undefined;
|
|
268
|
+
var __vue_scope_id__ = undefined;
|
|
269
|
+
var __vue_module_identifier__ = undefined;
|
|
270
|
+
var __vue_is_functional_template__ = false;
|
|
271
|
+
var __vue_component__ = normalizeComponent_1({
|
|
272
|
+
render: __vue_render__,
|
|
273
|
+
staticRenderFns: __vue_staticRenderFns__
|
|
274
|
+
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
275
|
+
|
|
276
|
+
export { __vue_component__ as default };
|
package/lib/pc.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { $prefix, setup, props } from '@opentiny/vue-common';
|
|
2
|
+
import { renderless, api } from '@opentiny/vue-renderless/dropdown-item/vue';
|
|
3
|
+
import { iconDeltaLeft } from '@opentiny/vue-icon';
|
|
4
|
+
|
|
5
|
+
function _toConsumableArray(arr) {
|
|
6
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
7
|
+
}
|
|
8
|
+
function _arrayWithoutHoles(arr) {
|
|
9
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
10
|
+
}
|
|
11
|
+
function _iterableToArray(iter) {
|
|
12
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
13
|
+
}
|
|
14
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
15
|
+
if (!o) return;
|
|
16
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
17
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
18
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
19
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
20
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
21
|
+
}
|
|
22
|
+
function _arrayLikeToArray(arr, len) {
|
|
23
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
24
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
25
|
+
return arr2;
|
|
26
|
+
}
|
|
27
|
+
function _nonIterableSpread() {
|
|
28
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function styleInject(css, ref) {
|
|
32
|
+
if ( ref === void 0 ) ref = {};
|
|
33
|
+
var insertAt = ref.insertAt;
|
|
34
|
+
|
|
35
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
36
|
+
|
|
37
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
38
|
+
var style = document.createElement('style');
|
|
39
|
+
style.type = 'text/css';
|
|
40
|
+
|
|
41
|
+
if (insertAt === 'top') {
|
|
42
|
+
if (head.firstChild) {
|
|
43
|
+
head.insertBefore(style, head.firstChild);
|
|
44
|
+
} else {
|
|
45
|
+
head.appendChild(style);
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
head.appendChild(style);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (style.styleSheet) {
|
|
52
|
+
style.styleSheet.cssText = css;
|
|
53
|
+
} else {
|
|
54
|
+
style.appendChild(document.createTextNode(css));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
var css_248z = "[class*=tiny-] li.tiny-dropdown-menu__item{--ti-dropdown-menu-item-hover-bg-color:var(--ti-base-color-hover-background);--ti-dropdown-menu-item-hover-text-color:var(--ti-base-color-brand-6);--ti-dropdown-menu-item-active-bg-color:var(--ti-base-color-brand-6);--ti-dropdown-menu-item-active-text-color:var(--ti-base-color-white);--ti-dropdown-menu-item-disabled-text-color:var(--ti-common-color-text-disabled);--ti-dropdown-menu-item-text-color:#333;--ti-dropdown-menu-item-height:1.5;--ti-dropdown-menu-item-padding-vertical:6px;--ti-dropdown-menu-item-padding-horizontal:20px;--ti-dropdown-menu-item-border-radius:0;--ti-dropdown-menu-item-max-width:130px;--ti-dropdown-menu-item-divided-bg-color:var(--ti-base-color-white);--ti-dropdown-menu-item-divided-margin-top:var(--ti-common-space-base);list-style:none;line-height:var(--ti-dropdown-menu-item-height);padding:var(--ti-dropdown-menu-item-padding-vertical) var(--ti-dropdown-menu-item-padding-horizontal);margin:0;font-size:var(--ti-common-font-size-base);color:var(--ti-dropdown-menu-item-text-color);cursor:pointer;outline:0;position:relative;word-break:break-all;max-width:var(--ti-dropdown-menu-item-max-width);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}[class*=tiny-] li.tiny-dropdown-menu__item .tiny-dropdown-menu__item--child{position:absolute;right:100%;top:0;display:none}[class*=tiny-] li.tiny-dropdown-menu__item:focus,[class*=tiny-] li.tiny-dropdown-menu__item:not(.is-disabled):hover{background-color:var(--ti-dropdown-menu-item-hover-bg-color);color:var(--ti-dropdown-menu-item-hover-text-color);border-radius:var(--ti-dropdown-menu-item-border-radius)}[class*=tiny-] li.tiny-dropdown-menu__item:focus>.tiny-dropdown-menu__item-content svg,[class*=tiny-] li.tiny-dropdown-menu__item:focus>.tiny-dropdown-menu__item-expand svg,[class*=tiny-] li.tiny-dropdown-menu__item:not(.is-disabled):hover>.tiny-dropdown-menu__item-content svg,[class*=tiny-] li.tiny-dropdown-menu__item:not(.is-disabled):hover>.tiny-dropdown-menu__item-expand svg{fill:var(--ti-dropdown-menu-item-hover-text-color)}[class*=tiny-] li.tiny-dropdown-menu__item:focus>.tiny-dropdown-menu__item--child,[class*=tiny-] li.tiny-dropdown-menu__item:not(.is-disabled):hover>.tiny-dropdown-menu__item--child{display:block}[class*=tiny-] li.tiny-dropdown-menu__item:not(.is-disabled):active{background-color:var(--ti-dropdown-menu-item-active-bg-color);color:var(--ti-dropdown-menu-item-active-text-color);border-radius:var(--ti-dropdown-menu-item-border-radius)}[class*=tiny-] li.tiny-dropdown-menu__item:not(.is-disabled):active svg{fill:var(--ti-dropdown-menu-item-active-text-color)}[class*=tiny-] li.tiny-dropdown-menu__item svg{margin-right:5px;margin-top:-2px}[class*=tiny-] li.tiny-dropdown-menu__item.is-disabled{cursor:not-allowed;color:var(--ti-dropdown-menu-item-disabled-text-color)}[class*=tiny-] li.tiny-dropdown-menu__item .tiny-dropdown-menu__item-expand{display:inline-block;height:100%;margin-left:-20px;width:20px}[class*=tiny-] li.tiny-dropdown-menu__item .tiny-dropdown-menu__item-expand .tiny-svg{width:.6em;height:.6em;margin-left:5px}.tiny-dropdown-menu__item--divided{position:relative;margin-top:6px;border-top:1px solid #e4e7ed}.tiny-dropdown-menu__item--divided:before{height:6px;display:block;margin:0 -20px;background-color:var(--ti-dropdown-menu-item-divided-bg-color)}";
|
|
59
|
+
styleInject(css_248z);
|
|
60
|
+
|
|
61
|
+
var script = {
|
|
62
|
+
name: $prefix + 'DropdownItem',
|
|
63
|
+
componentName: $prefix + 'DropdownItem',
|
|
64
|
+
emits: ['item-click'],
|
|
65
|
+
props: [].concat(_toConsumableArray(props), ['command', 'disabled', 'divided', 'icon', 'label', 'itemData', 'appendToBody', 'textField']),
|
|
66
|
+
components: {
|
|
67
|
+
iconDeltaLeft: iconDeltaLeft()
|
|
68
|
+
},
|
|
69
|
+
setup: function setup$1(props, context) {
|
|
70
|
+
return setup({
|
|
71
|
+
props: props,
|
|
72
|
+
context: context,
|
|
73
|
+
renderless: renderless,
|
|
74
|
+
api: api
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier
|
|
80
|
+
/* server only */
|
|
81
|
+
, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
|
|
82
|
+
if (typeof shadowMode !== 'boolean') {
|
|
83
|
+
createInjectorSSR = createInjector;
|
|
84
|
+
createInjector = shadowMode;
|
|
85
|
+
shadowMode = false;
|
|
86
|
+
} // Vue.extend constructor export interop.
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
var options = typeof script === 'function' ? script.options : script; // render functions
|
|
90
|
+
|
|
91
|
+
if (template && template.render) {
|
|
92
|
+
options.render = template.render;
|
|
93
|
+
options.staticRenderFns = template.staticRenderFns;
|
|
94
|
+
options._compiled = true; // functional template
|
|
95
|
+
|
|
96
|
+
if (isFunctionalTemplate) {
|
|
97
|
+
options.functional = true;
|
|
98
|
+
}
|
|
99
|
+
} // scopedId
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if (scopeId) {
|
|
103
|
+
options._scopeId = scopeId;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var hook;
|
|
107
|
+
|
|
108
|
+
if (moduleIdentifier) {
|
|
109
|
+
// server build
|
|
110
|
+
hook = function hook(context) {
|
|
111
|
+
// 2.3 injection
|
|
112
|
+
context = context || // cached call
|
|
113
|
+
this.$vnode && this.$vnode.ssrContext || // stateful
|
|
114
|
+
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext; // functional
|
|
115
|
+
// 2.2 with runInNewContext: true
|
|
116
|
+
|
|
117
|
+
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
|
118
|
+
context = __VUE_SSR_CONTEXT__;
|
|
119
|
+
} // inject component styles
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if (style) {
|
|
123
|
+
style.call(this, createInjectorSSR(context));
|
|
124
|
+
} // register component module identifier for async chunk inference
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
if (context && context._registeredComponents) {
|
|
128
|
+
context._registeredComponents.add(moduleIdentifier);
|
|
129
|
+
}
|
|
130
|
+
}; // used by ssr in case component is cached and beforeCreate
|
|
131
|
+
// never gets called
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
options._ssrRegister = hook;
|
|
135
|
+
} else if (style) {
|
|
136
|
+
hook = shadowMode ? function () {
|
|
137
|
+
style.call(this, createInjectorShadow(this.$root.$options.shadowRoot));
|
|
138
|
+
} : function (context) {
|
|
139
|
+
style.call(this, createInjector(context));
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (hook) {
|
|
144
|
+
if (options.functional) {
|
|
145
|
+
// register for functional component in vue file
|
|
146
|
+
var originalRender = options.render;
|
|
147
|
+
|
|
148
|
+
options.render = function renderWithStyleInjection(h, context) {
|
|
149
|
+
hook.call(context);
|
|
150
|
+
return originalRender(h, context);
|
|
151
|
+
};
|
|
152
|
+
} else {
|
|
153
|
+
// inject component registration as beforeCreate hook
|
|
154
|
+
var existing = options.beforeCreate;
|
|
155
|
+
options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return script;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var normalizeComponent_1 = normalizeComponent;
|
|
163
|
+
|
|
164
|
+
var __vue_script__ = script;
|
|
165
|
+
var __vue_render__ = function __vue_render__() {
|
|
166
|
+
var _vm = this;
|
|
167
|
+
var _h = _vm.$createElement;
|
|
168
|
+
var _c = _vm._self._c || _h;
|
|
169
|
+
return _c('li', {
|
|
170
|
+
ref: "dropdownItem",
|
|
171
|
+
staticClass: "tiny-dropdown-menu__item",
|
|
172
|
+
class: {
|
|
173
|
+
'is-disabled': _vm.disabled,
|
|
174
|
+
'tiny-dropdown-menu__item--divided': _vm.divided
|
|
175
|
+
},
|
|
176
|
+
attrs: {
|
|
177
|
+
"aria-disabled": _vm.disabled,
|
|
178
|
+
"tabindex": _vm.disabled ? null : -1
|
|
179
|
+
},
|
|
180
|
+
on: {
|
|
181
|
+
"click": _vm.handleClick,
|
|
182
|
+
"mousedown": function mousedown($event) {
|
|
183
|
+
$event.stopPropagation();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}, [_vm.itemData.children && _vm.itemData.children.length ? _c('span', {
|
|
187
|
+
staticClass: "tiny-dropdown-menu__item-expand"
|
|
188
|
+
}, [_c('icon-delta-left')], 1) : _vm._e(), _vm._v(" "), _c('div', {
|
|
189
|
+
staticClass: "tiny-dropdown-menu__item-content"
|
|
190
|
+
}, [_vm.icon ? _c(_vm.icon, {
|
|
191
|
+
tag: "component",
|
|
192
|
+
staticClass: "tiny-svg-size"
|
|
193
|
+
}) : _vm._e(), _vm._v(" "), _vm._t("default", function () {
|
|
194
|
+
return [_c('span', [_vm._v(_vm._s(_vm.label))])];
|
|
195
|
+
}, {
|
|
196
|
+
"itemData": _vm.itemData
|
|
197
|
+
})], 2), _vm._v(" "), _vm.itemData.children && _vm.itemData.children.length ? _c('ul', {
|
|
198
|
+
class: ['tiny-dropdown-menu', 'tiny-dropdown-menu__item--child', _vm.state.popperClass]
|
|
199
|
+
}, _vm._l(_vm.itemData.children, function (item, index) {
|
|
200
|
+
return _c('tiny-dropdown-item', {
|
|
201
|
+
key: index,
|
|
202
|
+
attrs: {
|
|
203
|
+
"label": item[_vm.state.textField],
|
|
204
|
+
"itemData": item,
|
|
205
|
+
"icon": item.icon,
|
|
206
|
+
"disabled": item.disabled,
|
|
207
|
+
"divided": item.divided
|
|
208
|
+
}
|
|
209
|
+
}, [_vm._t("default", null, {
|
|
210
|
+
"itemData": item
|
|
211
|
+
})], 2);
|
|
212
|
+
}), 1) : _vm._e()]);
|
|
213
|
+
};
|
|
214
|
+
var __vue_staticRenderFns__ = [];
|
|
215
|
+
var __vue_inject_styles__ = undefined;
|
|
216
|
+
var __vue_scope_id__ = undefined;
|
|
217
|
+
var __vue_module_identifier__ = undefined;
|
|
218
|
+
var __vue_is_functional_template__ = false;
|
|
219
|
+
var __vue_component__ = normalizeComponent_1({
|
|
220
|
+
render: __vue_render__,
|
|
221
|
+
staticRenderFns: __vue_staticRenderFns__
|
|
222
|
+
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);
|
|
223
|
+
|
|
224
|
+
export { __vue_component__ as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentiny/vue-dropdown-item",
|
|
3
|
+
"version": "2.5.0-alpha.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"lint": "eslint src/**/*{.js,.html,.vue} --quiet",
|
|
8
|
+
"build:ui2": "cross-env BUILD_TARGET=single NODE_ENV=production node ../../build/build-ui.js",
|
|
9
|
+
"build:ui3": "cross-env BUILD_TARGET=single NODE_ENV=production node ../../example/build/build-ui.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@opentiny/vue-common": "~2.5.0-alpha.0",
|
|
13
|
+
"@opentiny/vue-icon": "~2.5.0-alpha.0",
|
|
14
|
+
"@opentiny/vue-renderless": "~3.5.0",
|
|
15
|
+
"@opentiny/vue-popup": "~2.5.0-alpha.0",
|
|
16
|
+
"@opentiny/vue-button": "~2.5.0-alpha.0",
|
|
17
|
+
"@opentiny/vue-theme": "~3.5.0",
|
|
18
|
+
"@opentiny/vue-theme-mobile": "~3.5.0"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"sideEffects": false
|
|
22
|
+
}
|