@opentiny/vue-dropdown-item 3.1.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 ADDED
@@ -0,0 +1,97 @@
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
+ }),
79
+ setup: function setup(props, context) {
80
+ return $setup({
81
+ props: props,
82
+ context: context,
83
+ template: template
84
+ });
85
+ }
86
+ };
87
+
88
+ DropdownItem.model = {
89
+ prop: 'modelValue',
90
+ event: 'update:modelValue'
91
+ };
92
+ DropdownItem.install = function (Vue) {
93
+ Vue.component(DropdownItem.name, DropdownItem);
94
+ };
95
+ DropdownItem.version = '3.1.0-alpha.0';
96
+
97
+ export { DropdownItem as default };
package/lib/mobile.js ADDED
@@ -0,0 +1,175 @@
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
+ import { resolveComponent, resolveDirective, withDirectives, openBlock, createElementBlock, normalizeClass, normalizeStyle, createVNode, withCtx, renderSlot, Fragment, renderList, createElementVNode, createBlock, resolveDynamicComponent, toDisplayString, createCommentVNode, createTextVNode, vShow } from 'vue';
9
+
10
+ function _toConsumableArray(arr) {
11
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
12
+ }
13
+ function _arrayWithoutHoles(arr) {
14
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
15
+ }
16
+ function _iterableToArray(iter) {
17
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
18
+ }
19
+ function _unsupportedIterableToArray(o, minLen) {
20
+ if (!o) return;
21
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
22
+ var n = Object.prototype.toString.call(o).slice(8, -1);
23
+ if (n === "Object" && o.constructor) n = o.constructor.name;
24
+ if (n === "Map" || n === "Set") return Array.from(o);
25
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
26
+ }
27
+ function _arrayLikeToArray(arr, len) {
28
+ if (len == null || len > arr.length) len = arr.length;
29
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
30
+ return arr2;
31
+ }
32
+ function _nonIterableSpread() {
33
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
34
+ }
35
+
36
+ var script = {
37
+ directives: {
38
+ Clickoutside: Clickoutside
39
+ },
40
+ props: [].concat(_toConsumableArray(props), ['modelValue', 'title', 'disabled', 'titleClass', 'options', 'icon', 'type']),
41
+ components: {
42
+ IconYes: iconYes(),
43
+ TinyPopup: Popup,
44
+ TinyButton: Button
45
+ },
46
+ emits: ['update:modelValue'],
47
+ setup: function setup$1(props, context) {
48
+ return setup({
49
+ props: props,
50
+ context: context,
51
+ renderless: renderless,
52
+ api: api
53
+ });
54
+ }
55
+ };
56
+
57
+ var _hoisted_1 = {
58
+ key: 0,
59
+ class: "tiny-mobile-dropdown-item__options"
60
+ };
61
+ var _hoisted_2 = ["onClick"];
62
+ var _hoisted_3 = {
63
+ class: "tiny-mobile-dropdown-item__option-icon"
64
+ };
65
+ var _hoisted_4 = {
66
+ class: "tiny-mobile-dropdown-item__option-title"
67
+ };
68
+ var _hoisted_5 = {
69
+ class: "tiny-mobile-dropdown-item__option-value"
70
+ };
71
+ var _hoisted_6 = {
72
+ key: 1,
73
+ class: "tiny-mobile-dropdown-item__filter"
74
+ };
75
+ var _hoisted_7 = {
76
+ class: "tiny-mobile-dropdown-item__filter-wrap"
77
+ };
78
+ var _hoisted_8 = {
79
+ class: "tiny-mobile-dropdown-item__filter-title"
80
+ };
81
+ var _hoisted_9 = ["onClick"];
82
+ var _hoisted_10 = {
83
+ class: "tiny-mobile-dropdown-item__filter-operate"
84
+ };
85
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
86
+ var _component_icon_yes = resolveComponent("icon-yes");
87
+ var _component_tiny_button = resolveComponent("tiny-button");
88
+ var _component_tiny_popup = resolveComponent("tiny-popup");
89
+ var _directive_clickoutside = resolveDirective("clickoutside");
90
+ return withDirectives((openBlock(), createElementBlock("div", {
91
+ ref: "wrapper",
92
+ class: normalizeClass(['tiny-mobile-dropdown-item--' + _ctx.state.direction, "tiny-mobile-dropdown-item"]),
93
+ onClick: _cache[1] || (_cache[1] = function () {
94
+ return _ctx.clickWrapper && _ctx.clickWrapper.apply(_ctx, arguments);
95
+ }),
96
+ style: normalizeStyle(_ctx.state.itemStyle)
97
+ }, [createVNode(_component_tiny_popup, {
98
+ modelValue: _ctx.state.showPopup,
99
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = function ($event) {
100
+ return _ctx.state.showPopup = $event;
101
+ }),
102
+ popupClass: "tiny-mobile-dropdown-item__content",
103
+ overlay: _ctx.state.overlay,
104
+ "close-on-click-overlay": _ctx.state.closeOnClickOverlay,
105
+ closeable: false,
106
+ position: _ctx.state.direction === 'down' ? 'top' : 'bottom',
107
+ duration: _ctx.state.transition ? _ctx.state.duration : 0,
108
+ onOpen: _ctx.open,
109
+ onClose: _ctx.close,
110
+ onOpened: _ctx.opened,
111
+ onClosed: _ctx.closed
112
+ }, {
113
+ default: withCtx(function () {
114
+ return [renderSlot(_ctx.$slots, "default", {}, function () {
115
+ return [$props.type === 'selection' ? (openBlock(), createElementBlock("div", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList($props.options, function (item, index) {
116
+ return openBlock(), createElementBlock("div", {
117
+ class: normalizeClass(["tiny-mobile-dropdown-item__cell tiny-mobile-dropdown-item__option", item.value === $props.modelValue ? 'is-active' : '']),
118
+ key: index,
119
+ tabindex: "0",
120
+ onClick: function onClick($event) {
121
+ return _ctx.clickItem(item.value);
122
+ }
123
+ }, [createElementVNode("div", _hoisted_3, [renderSlot(_ctx.$slots, "icon", {}, function () {
124
+ return [(openBlock(), createBlock(resolveDynamicComponent($props.icon)))];
125
+ })]), createElementVNode("div", _hoisted_4, [renderSlot(_ctx.$slots, "title", {
126
+ titleData: item
127
+ }, function () {
128
+ return [createElementVNode("span", {
129
+ style: normalizeStyle({
130
+ color: item.value === $props.modelValue && _ctx.state.activeColor ? _ctx.state.activeColor : ''
131
+ })
132
+ }, toDisplayString(item.text), 5)];
133
+ })]), createElementVNode("div", _hoisted_5, [item.value === $props.modelValue ? (openBlock(), createBlock(_component_icon_yes, {
134
+ key: 0,
135
+ fill: _ctx.state.activeColor ? _ctx.state.activeColor : '#f36f64'
136
+ }, null, 8, ["fill"])) : createCommentVNode("", true)])], 10, _hoisted_2);
137
+ }), 128))])) : createCommentVNode("", true), $props.type === 'filter' ? withDirectives((openBlock(), createElementBlock("div", _hoisted_6, [createElementVNode("div", _hoisted_7, [(openBlock(true), createElementBlock(Fragment, null, renderList($props.options, function (item, key) {
138
+ return openBlock(), createElementBlock("div", {
139
+ key: key,
140
+ class: "tiny-mobile-dropdown-item__cell tiny-mobile-dropdown-item__filter-item"
141
+ }, [createElementVNode("span", _hoisted_8, toDisplayString(item.title), 1), createElementVNode("ul", null, [(openBlock(true), createElementBlock(Fragment, null, renderList($props.options.length === 0 ? item.data = [] : item.data, function (tag, tagkey) {
142
+ return openBlock(), createElementBlock("li", {
143
+ class: normalizeClass(["tiny-mobile-dropdown-item__filter-li", [$props.modelValue[key].indexOf(tag.value) > -1 ? 'checked' : '']]),
144
+ style: normalizeStyle(_ctx.getOptionStyle(tag, $props.modelValue[key])),
145
+ onClick: function onClick($event) {
146
+ return _ctx.tagClick(key, tag, $event);
147
+ },
148
+ key: tagkey
149
+ }, toDisplayString(tag.text), 15, _hoisted_9);
150
+ }), 128))])]);
151
+ }), 128))]), createElementVNode("div", _hoisted_10, [createVNode(_component_tiny_button, {
152
+ onClick: _ctx.reset
153
+ }, {
154
+ default: withCtx(function () {
155
+ return [createTextVNode("Reset")];
156
+ }),
157
+ _: 1
158
+ }, 8, ["onClick"]), createVNode(_component_tiny_button, {
159
+ type: "primary",
160
+ onClick: _ctx.confirm
161
+ }, {
162
+ default: withCtx(function () {
163
+ return [createTextVNode("OK")];
164
+ }),
165
+ _: 1
166
+ }, 8, ["onClick"])])])), [[_directive_clickoutside, _ctx.clickOutside]]) : createCommentVNode("", true)];
167
+ })];
168
+ }),
169
+ _: 3
170
+ }, 8, ["modelValue", "overlay", "close-on-click-overlay", "position", "duration", "onOpen", "onClose", "onOpened", "onClosed"])], 6)), [[vShow, _ctx.state.showWrapper]]);
171
+ }
172
+
173
+ script.render = render;
174
+
175
+ export { script as default };
package/lib/pc.js ADDED
@@ -0,0 +1,71 @@
1
+ import { setup, props } from '@opentiny/vue-common';
2
+ import '@opentiny/vue-theme/dropdown-item/index.css';
3
+ import { openBlock, createElementBlock, normalizeClass, withModifiers, createBlock, resolveDynamicComponent, createCommentVNode, renderSlot } from 'vue';
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
+ var script = {
32
+ props: [].concat(_toConsumableArray(props), ['command', 'disabled', 'divided', 'icon']),
33
+ setup: function setup$1(props, context) {
34
+ return setup({
35
+ props: props,
36
+ context: context,
37
+ renderless: function renderless(props, hooks, _ref) {
38
+ var dispatch = _ref.dispatch,
39
+ vm = _ref.vm;
40
+ return {
41
+ handleClick: function handleClick() {
42
+ dispatch('TinyDropdown', 'menu-item-click', [props.itemData, vm]);
43
+ }
44
+ };
45
+ },
46
+ api: ['handleClick']
47
+ });
48
+ }
49
+ };
50
+
51
+ var _hoisted_1 = ["aria-disabled", "tabindex"];
52
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
53
+ return openBlock(), createElementBlock("li", {
54
+ class: normalizeClass(["tiny-dropdown-menu__item", {
55
+ 'is-disabled': $props.disabled,
56
+ 'tiny-dropdown-menu__item--divided': $props.divided
57
+ }]),
58
+ onClick: _cache[0] || (_cache[0] = withModifiers(function () {
59
+ return _ctx.handleClick && _ctx.handleClick.apply(_ctx, arguments);
60
+ }, ["stop"])),
61
+ "aria-disabled": $props.disabled,
62
+ tabindex: $props.disabled ? null : -1
63
+ }, [$props.icon ? (openBlock(), createBlock(resolveDynamicComponent($props.icon), {
64
+ key: 0,
65
+ class: "tiny-svg-size"
66
+ })) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default")], 10, _hoisted_1);
67
+ }
68
+
69
+ script.render = render;
70
+
71
+ export { script as default };
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@opentiny/vue-dropdown-item",
3
+ "version": "3.1.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": "~3.1.0-alpha.0",
13
+ "@opentiny/vue-icon": "~3.1.0-alpha.0",
14
+ "@opentiny/vue-renderless": "~3.1.0-alpha.0",
15
+ "@opentiny/vue-popup": "~3.1.0-alpha.0",
16
+ "@opentiny/vue-button": "~3.1.0-alpha.0",
17
+ "@opentiny/vue-theme": "~3.1.0-alpha.0",
18
+ "@opentiny/vue-theme-mobile": "~3.1.0-alpha.0"
19
+ },
20
+ "license": "MIT",
21
+ "sideEffects": false
22
+ }