@opentiny/vue-dropdown-item 3.1.0-alpha.0 → 3.5.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/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 DropdownItem from './src/index';
13
+ export default DropdownItem;
package/lib/index.js CHANGED
@@ -74,6 +74,24 @@ var DropdownItem = {
74
74
  type: {
75
75
  type: String,
76
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'
77
95
  }
78
96
  }),
79
97
  setup: function setup(props, context) {
@@ -92,6 +110,6 @@ DropdownItem.model = {
92
110
  DropdownItem.install = function (Vue) {
93
111
  Vue.component(DropdownItem.name, DropdownItem);
94
112
  };
95
- DropdownItem.version = '3.1.0-alpha.0';
113
+ DropdownItem.version = '3.5.0';
96
114
 
97
115
  export { DropdownItem as default };
package/lib/pc.js CHANGED
@@ -1,6 +1,7 @@
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';
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
+ import { resolveComponent, openBlock, createElementBlock, normalizeClass, withModifiers, createVNode, createCommentVNode, createElementVNode, createBlock, resolveDynamicComponent, renderSlot, toDisplayString, Fragment, renderList, withCtx } from 'vue';
4
5
 
5
6
  function _toConsumableArray(arr) {
6
7
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
@@ -28,42 +29,104 @@ function _nonIterableSpread() {
28
29
  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
  }
30
31
 
32
+ function styleInject(css, ref) {
33
+ if ( ref === void 0 ) ref = {};
34
+ var insertAt = ref.insertAt;
35
+
36
+ if (!css || typeof document === 'undefined') { return; }
37
+
38
+ var head = document.head || document.getElementsByTagName('head')[0];
39
+ var style = document.createElement('style');
40
+ style.type = 'text/css';
41
+
42
+ if (insertAt === 'top') {
43
+ if (head.firstChild) {
44
+ head.insertBefore(style, head.firstChild);
45
+ } else {
46
+ head.appendChild(style);
47
+ }
48
+ } else {
49
+ head.appendChild(style);
50
+ }
51
+
52
+ if (style.styleSheet) {
53
+ style.styleSheet.cssText = css;
54
+ } else {
55
+ style.appendChild(document.createTextNode(css));
56
+ }
57
+ }
58
+
59
+ 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)}";
60
+ styleInject(css_248z);
61
+
31
62
  var script = {
32
- props: [].concat(_toConsumableArray(props), ['command', 'disabled', 'divided', 'icon']),
63
+ name: $prefix + 'DropdownItem',
64
+ componentName: $prefix + 'DropdownItem',
65
+ emits: ['item-click'],
66
+ props: [].concat(_toConsumableArray(props), ['command', 'disabled', 'divided', 'icon', 'label', 'itemData', 'appendToBody', 'textField']),
67
+ components: {
68
+ iconDeltaLeft: iconDeltaLeft()
69
+ },
33
70
  setup: function setup$1(props, context) {
34
71
  return setup({
35
72
  props: props,
36
73
  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']
74
+ renderless: renderless,
75
+ api: api
47
76
  });
48
77
  }
49
78
  };
50
79
 
51
80
  var _hoisted_1 = ["aria-disabled", "tabindex"];
81
+ var _hoisted_2 = {
82
+ key: 0,
83
+ class: "tiny-dropdown-menu__item-expand"
84
+ };
85
+ var _hoisted_3 = {
86
+ class: "tiny-dropdown-menu__item-content"
87
+ };
52
88
  function render(_ctx, _cache, $props, $setup, $data, $options) {
89
+ var _component_icon_delta_left = resolveComponent("icon-delta-left");
90
+ var _component_tiny_dropdown_item = resolveComponent("tiny-dropdown-item");
53
91
  return openBlock(), createElementBlock("li", {
54
92
  class: normalizeClass(["tiny-dropdown-menu__item", {
55
93
  'is-disabled': $props.disabled,
56
94
  'tiny-dropdown-menu__item--divided': $props.divided
57
95
  }]),
58
- onClick: _cache[0] || (_cache[0] = withModifiers(function () {
96
+ ref: "dropdownItem",
97
+ onClick: _cache[0] || (_cache[0] = function () {
59
98
  return _ctx.handleClick && _ctx.handleClick.apply(_ctx, arguments);
60
- }, ["stop"])),
99
+ }),
100
+ onMousedown: _cache[1] || (_cache[1] = withModifiers(function () {}, ["stop"])),
61
101
  "aria-disabled": $props.disabled,
62
102
  tabindex: $props.disabled ? null : -1
63
- }, [$props.icon ? (openBlock(), createBlock(resolveDynamicComponent($props.icon), {
103
+ }, [$props.itemData.children && $props.itemData.children.length ? (openBlock(), createElementBlock("span", _hoisted_2, [createVNode(_component_icon_delta_left)])) : createCommentVNode("", true), createElementVNode("div", _hoisted_3, [$props.icon ? (openBlock(), createBlock(resolveDynamicComponent($props.icon), {
64
104
  key: 0,
65
105
  class: "tiny-svg-size"
66
- })) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default")], 10, _hoisted_1);
106
+ })) : createCommentVNode("", true), renderSlot(_ctx.$slots, "default", {
107
+ itemData: $props.itemData
108
+ }, function () {
109
+ return [createElementVNode("span", null, toDisplayString($props.label), 1)];
110
+ })]), $props.itemData.children && $props.itemData.children.length ? (openBlock(), createElementBlock("ul", {
111
+ key: 1,
112
+ class: normalizeClass(['tiny-dropdown-menu', 'tiny-dropdown-menu__item--child', _ctx.state.popperClass])
113
+ }, [(openBlock(true), createElementBlock(Fragment, null, renderList($props.itemData.children, function (item, index) {
114
+ return openBlock(), createBlock(_component_tiny_dropdown_item, {
115
+ key: index,
116
+ label: item[_ctx.state.textField],
117
+ itemData: item,
118
+ icon: item.icon,
119
+ disabled: item.disabled,
120
+ divided: item.divided
121
+ }, {
122
+ default: withCtx(function () {
123
+ return [renderSlot(_ctx.$slots, "default", {
124
+ itemData: item
125
+ })];
126
+ }),
127
+ _: 2
128
+ }, 1032, ["label", "itemData", "icon", "disabled", "divided"]);
129
+ }), 128))], 2)) : createCommentVNode("", true)], 42, _hoisted_1);
67
130
  }
68
131
 
69
132
  script.render = render;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentiny/vue-dropdown-item",
3
- "version": "3.1.0-alpha.0",
3
+ "version": "3.5.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -9,14 +9,15 @@
9
9
  "build:ui3": "cross-env BUILD_TARGET=single NODE_ENV=production node ../../example/build/build-ui.js"
10
10
  },
11
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"
12
+ "@opentiny/vue-common": "~3.5.0",
13
+ "@opentiny/vue-icon": "~3.5.0",
14
+ "@opentiny/vue-renderless": "~3.5.0",
15
+ "@opentiny/vue-popup": "~3.5.0",
16
+ "@opentiny/vue-button": "~3.5.0",
17
+ "@opentiny/vue-theme": "~3.5.0",
18
+ "@opentiny/vue-theme-mobile": "~3.5.0"
19
19
  },
20
20
  "license": "MIT",
21
+ "types": "index.d.ts",
21
22
  "sideEffects": false
22
23
  }
package/src/index.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ icon: (ObjectConstructor | StringConstructor)[];
3
+ disabled: BooleanConstructor;
4
+ divided: BooleanConstructor;
5
+ command: {};
6
+ title: StringConstructor;
7
+ titleClass: StringConstructor;
8
+ options: {
9
+ type: ArrayConstructor;
10
+ default: () => never[];
11
+ };
12
+ type: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ }, () => any, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
17
+ icon: (ObjectConstructor | StringConstructor)[];
18
+ disabled: BooleanConstructor;
19
+ divided: BooleanConstructor;
20
+ command: {};
21
+ title: StringConstructor;
22
+ titleClass: StringConstructor;
23
+ options: {
24
+ type: ArrayConstructor;
25
+ default: () => never[];
26
+ };
27
+ type: {
28
+ type: StringConstructor;
29
+ default: string;
30
+ };
31
+ }>>, {
32
+ type: string;
33
+ disabled: boolean;
34
+ options: unknown[];
35
+ divided: boolean;
36
+ }>;
37
+ export default _default;
@@ -0,0 +1,50 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ modelValue: null;
3
+ title: StringConstructor;
4
+ disabled: BooleanConstructor;
5
+ titleClass: StringConstructor;
6
+ options: {
7
+ type: ArrayConstructor;
8
+ default: () => never[];
9
+ };
10
+ icon: ObjectConstructor;
11
+ type: {
12
+ type: StringConstructor;
13
+ default: string;
14
+ };
15
+ }, {
16
+ t: any;
17
+ vm: any;
18
+ f: (props: any, attrs?: {}) => {};
19
+ a: (attrs: any, filters: any, include: any) => {};
20
+ d: (props: any) => void;
21
+ dp: (props: any) => void;
22
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("click" | "change" | "update:modelValue" | "close" | "confirm" | "open" | "opened" | "closed")[], "click" | "change" | "update:modelValue" | "close" | "confirm" | "open" | "opened" | "closed", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
23
+ modelValue: null;
24
+ title: StringConstructor;
25
+ disabled: BooleanConstructor;
26
+ titleClass: StringConstructor;
27
+ options: {
28
+ type: ArrayConstructor;
29
+ default: () => never[];
30
+ };
31
+ icon: ObjectConstructor;
32
+ type: {
33
+ type: StringConstructor;
34
+ default: string;
35
+ };
36
+ }>> & {
37
+ onChange?: ((...args: any[]) => any) | undefined;
38
+ onClick?: ((...args: any[]) => any) | undefined;
39
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
40
+ onClose?: ((...args: any[]) => any) | undefined;
41
+ onConfirm?: ((...args: any[]) => any) | undefined;
42
+ onOpen?: ((...args: any[]) => any) | undefined;
43
+ onOpened?: ((...args: any[]) => any) | undefined;
44
+ onClosed?: ((...args: any[]) => any) | undefined;
45
+ }, {
46
+ type: string;
47
+ disabled: boolean;
48
+ options: unknown[];
49
+ }>;
50
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import '@opentiny/vue-theme-mobile/dropdown-item/index.css';
2
+ declare const _default: {
3
+ directives: {
4
+ Clickoutside: any;
5
+ };
6
+ props: string[];
7
+ components: {
8
+ IconYes: any;
9
+ TinyPopup: any;
10
+ TinyButton: any;
11
+ };
12
+ emits: string[];
13
+ setup(props: any, context: any): {
14
+ t: any;
15
+ vm: any;
16
+ f: (props: any, attrs?: {}) => {};
17
+ a: (attrs: any, filters: any, include: any) => {};
18
+ d: (props: any) => void;
19
+ dp: (props: any) => void;
20
+ };
21
+ };
22
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import '@opentiny/vue-theme/dropdown-item/index.css';
2
+ declare const _default: {
3
+ props: string[];
4
+ setup(props: any, context: any): {
5
+ t: any;
6
+ vm: any;
7
+ f: (props: any, attrs?: {}) => {};
8
+ a: (attrs: any, filters: any, include: any) => {};
9
+ d: (props: any) => void;
10
+ dp: (props: any) => void;
11
+ };
12
+ };
13
+ export default _default;