@opentiny/vue-dropdown-item 3.6.7 → 3.8.2

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 CHANGED
@@ -15,16 +15,34 @@ function _extends() {
15
15
  import { defineComponent, $prefix, $props, $setup } from "@opentiny/vue-common";
16
16
  import PcTemplate from "./pc.js";
17
17
  import MobileTemplate from "./mobile.js";
18
+ import MobileFirstTemplate from "./mobile-first.js";
18
19
  var template = function template2(mode) {
19
- if ("mobile" === (process.env.TINY_MODE || mode))
20
- return MobileTemplate;
21
- else
20
+ if ("pc" === (process.env.TINY_MODE || mode)) {
22
21
  return PcTemplate;
22
+ }
23
+ if ("mobile" === (process.env.TINY_MODE || mode)) {
24
+ return MobileTemplate;
25
+ }
26
+ if ("mobile-first" === (process.env.TINY_MODE || mode)) {
27
+ return MobileFirstTemplate;
28
+ }
29
+ return PcTemplate;
30
+ };
31
+ var $constants = {
32
+ ICON_MAP: {
33
+ leftWardArrow: "icon-delta-left"
34
+ }
23
35
  };
24
36
  var DropdownItem = defineComponent({
25
37
  name: $prefix + "DropdownItem",
26
38
  componentName: "TinyDropdownItem",
27
39
  props: _extends({}, $props, {
40
+ _constants: {
41
+ type: Object,
42
+ default: function _default() {
43
+ return $constants;
44
+ }
45
+ },
28
46
  icon: [String, Object],
29
47
  disabled: Boolean,
30
48
  divided: Boolean,
@@ -33,7 +51,7 @@ var DropdownItem = defineComponent({
33
51
  titleClass: String,
34
52
  options: {
35
53
  type: Array,
36
- default: function _default() {
54
+ default: function _default2() {
37
55
  return [];
38
56
  }
39
57
  },
@@ -47,7 +65,7 @@ var DropdownItem = defineComponent({
47
65
  },
48
66
  itemData: {
49
67
  type: Object,
50
- default: function _default2() {
68
+ default: function _default3() {
51
69
  return {};
52
70
  }
53
71
  },
@@ -58,6 +76,24 @@ var DropdownItem = defineComponent({
58
76
  textField: {
59
77
  type: String,
60
78
  default: "label"
79
+ },
80
+ selected: {
81
+ type: Boolean,
82
+ default: false
83
+ },
84
+ selectedField: {
85
+ type: String,
86
+ default: "selected"
87
+ },
88
+ multiStage: {
89
+ type: Boolean,
90
+ default: false
91
+ },
92
+ currentIndex: {
93
+ type: Number,
94
+ default: function _default4() {
95
+ return -1;
96
+ }
61
97
  }
62
98
  }),
63
99
  setup: function setup(props, context) {
@@ -0,0 +1,100 @@
1
+ import { defineComponent, props, setup as _setup } from "@opentiny/vue-common";
2
+ import { renderless, api } from "@opentiny/vue-renderless/dropdown-item/mf";
3
+ import { openBlock, createElementBlock, normalizeClass, withModifiers, createElementVNode, createBlock, resolveDynamicComponent, createCommentVNode, renderSlot } from "vue";
4
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
5
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
6
+ if (it)
7
+ return (it = it.call(o)).next.bind(it);
8
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
9
+ if (it)
10
+ o = it;
11
+ var i = 0;
12
+ return function() {
13
+ if (i >= o.length)
14
+ return { done: true };
15
+ return { done: false, value: o[i++] };
16
+ };
17
+ }
18
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
19
+ }
20
+ function _unsupportedIterableToArray(o, minLen) {
21
+ if (!o)
22
+ return;
23
+ if (typeof o === "string")
24
+ return _arrayLikeToArray(o, minLen);
25
+ var n = Object.prototype.toString.call(o).slice(8, -1);
26
+ if (n === "Object" && o.constructor)
27
+ n = o.constructor.name;
28
+ if (n === "Map" || n === "Set")
29
+ return Array.from(o);
30
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
31
+ return _arrayLikeToArray(o, minLen);
32
+ }
33
+ function _arrayLikeToArray(arr, len) {
34
+ if (len == null || len > arr.length)
35
+ len = arr.length;
36
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
37
+ arr2[i] = arr[i];
38
+ return arr2;
39
+ }
40
+ var _export_sfc = function _export_sfc2(sfc, props) {
41
+ var target = sfc.__vccOpts || sfc;
42
+ for (var _iterator = _createForOfIteratorHelperLoose(props), _step; !(_step = _iterator()).done; ) {
43
+ var _step$value = _step.value, key = _step$value[0], val = _step$value[1];
44
+ target[key] = val;
45
+ }
46
+ return target;
47
+ };
48
+
49
+ var _sfc_main = defineComponent({
50
+ props: [].concat(props, ["disabled", "icon", "itemData", "selected", "label", "level", "currentIndex"]),
51
+ setup: function setup(props2, context) {
52
+ return _setup({
53
+ props: props2,
54
+ context,
55
+ renderless,
56
+ api
57
+ });
58
+ }
59
+ });
60
+ var _hoisted_1 = ["aria-disabled", "tabindex"];
61
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
62
+ return openBlock(), createElementBlock("li", {
63
+ onMouseenter: _cache[0] || (_cache[0] = function() {
64
+ return _ctx.mouseEnter && _ctx.mouseEnter.apply(_ctx, arguments);
65
+ }),
66
+ onMouseleave: _cache[1] || (_cache[1] = function() {
67
+ return _ctx.mouseLeave && _ctx.mouseLeave.apply(_ctx, arguments);
68
+ }),
69
+ class: normalizeClass(["list-none leading-10 sm:leading-8 m-0 cursor-pointer outline-0 min-w-[4.5rem] max-w-[13.5rem] w-full [&_svg]:sm:w-3.5 [&_svg]:sm:h-3.5 [&_svg]:sm:mr-1.5 [&_svg]:mr-2 [&_svg]:align-text-bottom", {
70
+ "text-color-text-primary active:bg-color-bg-4 visited:text-color-brand hover:bg-color-bg-4 focus:bg-color-bg-4": !_ctx.disabled
71
+ }, {
72
+ "cursor-not-allowed text-color-text-disabled [&_svg]:fill-color-text-disabled": _ctx.disabled
73
+ }, {
74
+ "text-color-brand-focus": _ctx.dataStore.checkedStatus && _ctx.selected
75
+ }, {
76
+ "!px-0 sm:!px-0": _ctx.dataStore.multiStage
77
+ }]),
78
+ onClick: _cache[2] || (_cache[2] = withModifiers(function() {
79
+ return _ctx.handleClick && _ctx.handleClick.apply(_ctx, arguments);
80
+ }, ["stop"])),
81
+ "aria-disabled": _ctx.disabled,
82
+ tabindex: _ctx.disabled ? null : -1
83
+ }, [createElementVNode(
84
+ "div",
85
+ {
86
+ ref: "level",
87
+ class: normalizeClass(["sm:text-xs text-sm", _ctx.level === "2" ? "mx-6 overflow-hidden text-ellipsis whitespace-nowrap" : "mx-4 sm:mx-3 overflow-hidden text-ellipsis whitespace-nowrap"])
88
+ },
89
+ [_ctx.icon ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), {
90
+ key: 0,
91
+ class: "sm:w-3.5 sm:h-3.5 sm:mr-1.5 mr-2 align-text-bottom"
92
+ })) : createCommentVNode("v-if", true), renderSlot(_ctx.$slots, "default")],
93
+ 2
94
+ /* CLASS */
95
+ )], 42, _hoisted_1);
96
+ }
97
+ var mobileFirst = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
98
+ export {
99
+ mobileFirst as default
100
+ };
package/lib/mobile.js CHANGED
@@ -51,7 +51,7 @@ var _export_sfc = function _export_sfc2(sfc, props) {
51
51
  return target;
52
52
  };
53
53
 
54
- var _sfc_main = /* @__PURE__ */ defineComponent({
54
+ var _sfc_main = defineComponent({
55
55
  directives: {
56
56
  Clickoutside
57
57
  },
package/lib/pc.js CHANGED
@@ -2,7 +2,7 @@ import { defineComponent, $prefix, props, setup as _setup } from "@opentiny/vue-
2
2
  import { renderless, api } from "@opentiny/vue-renderless/dropdown-item/vue";
3
3
  import { iconDeltaLeft } from "@opentiny/vue-icon";
4
4
  import "@opentiny/vue-theme/dropdown-item/index.css";
5
- import { resolveComponent, openBlock, createElementBlock, normalizeClass, withModifiers, createVNode, createCommentVNode, createElementVNode, createBlock, resolveDynamicComponent, renderSlot, toDisplayString, Fragment, renderList, withCtx } from "vue";
5
+ import { resolveComponent, openBlock, createElementBlock, Fragment, createCommentVNode, createElementVNode, normalizeClass, withModifiers, createBlock, resolveDynamicComponent, renderSlot, toDisplayString, renderList, withCtx } from "vue";
6
6
  function _createForOfIteratorHelperLoose(o, allowArrayLike) {
7
7
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
8
8
  if (it)
@@ -48,7 +48,7 @@ var _export_sfc = function _export_sfc2(sfc, props) {
48
48
  return target;
49
49
  };
50
50
 
51
- var _sfc_main = /* @__PURE__ */ defineComponent({
51
+ var _sfc_main = defineComponent({
52
52
  name: $prefix + "DropdownItem",
53
53
  componentName: $prefix + "DropdownItem",
54
54
  emits: ["item-click"],
@@ -67,74 +67,83 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
67
67
  });
68
68
  var _hoisted_1 = ["aria-disabled", "tabindex"];
69
69
  var _hoisted_2 = {
70
- key: 0,
71
- class: "tiny-dropdown-menu__item-expand"
70
+ class: "tiny-dropdown-item__wrap"
72
71
  };
73
72
  var _hoisted_3 = {
74
- class: "tiny-dropdown-menu__item-content"
73
+ key: 0,
74
+ class: "tiny-dropdown-item__expand tiny-dropdown-menu__item-expand"
75
+ };
76
+ var _hoisted_4 = {
77
+ class: "tiny-dropdown-item__content tiny-dropdown-menu__item-content"
75
78
  };
76
79
  function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
77
- var _component_icon_delta_left = resolveComponent("icon-delta-left");
78
80
  var _component_tiny_dropdown_item = resolveComponent("tiny-dropdown-item");
79
- return openBlock(), createElementBlock("li", {
80
- class: normalizeClass(["tiny-dropdown-menu__item", {
81
- "is-disabled": _ctx.disabled,
82
- "tiny-dropdown-menu__item--divided": _ctx.divided
83
- }]),
84
- ref: "dropdownItem",
85
- onClick: _cache[0] || (_cache[0] = function() {
86
- return _ctx.handleClick && _ctx.handleClick.apply(_ctx, arguments);
87
- }),
88
- onMousedown: _cache[1] || (_cache[1] = withModifiers(function() {
89
- }, ["stop"])),
90
- "aria-disabled": _ctx.disabled,
91
- tabindex: _ctx.disabled ? null : -1
92
- }, [_ctx.itemData.children && _ctx.itemData.children.length ? (openBlock(), createElementBlock("span", _hoisted_2, [createVNode(_component_icon_delta_left)])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_3, [_ctx.icon ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), {
93
- key: 0,
94
- class: "tiny-svg-size"
95
- })) : createCommentVNode("v-if", true), renderSlot(_ctx.$slots, "default", {
96
- itemData: _ctx.itemData
97
- }, function() {
98
- return [createElementVNode(
99
- "span",
100
- null,
101
- toDisplayString(_ctx.label),
102
- 1
103
- /* TEXT */
104
- )];
105
- })]), _ctx.itemData.children && _ctx.itemData.children.length ? (openBlock(), createElementBlock(
106
- "ul",
107
- {
108
- key: 1,
109
- class: normalizeClass(["tiny-dropdown-menu", "tiny-dropdown-menu__item--child", _ctx.state.popperClass])
110
- },
111
- [(openBlock(true), createElementBlock(
112
- Fragment,
113
- null,
114
- renderList(_ctx.itemData.children, function(item, index) {
115
- return openBlock(), createBlock(_component_tiny_dropdown_item, {
116
- key: index,
117
- label: item[_ctx.state.textField],
118
- itemData: item,
119
- icon: item.icon,
120
- disabled: item.disabled,
121
- divided: item.divided
122
- }, {
123
- default: withCtx(function() {
124
- return [renderSlot(_ctx.$slots, "default", {
125
- itemData: item
126
- })];
127
- }),
128
- _: 2
129
- /* DYNAMIC */
130
- }, 1032, ["label", "itemData", "icon", "disabled", "divided"]);
81
+ return openBlock(), createElementBlock(
82
+ Fragment,
83
+ null,
84
+ [createCommentVNode(" TINY-TODO: tiny-dropdown-menu__item命名不规范,后续统一有个迭代去掉 "), createElementVNode("li", {
85
+ class: normalizeClass(["tiny-dropdown-item tiny-dropdown-menu__item", {
86
+ "is-disabled": _ctx.disabled,
87
+ "tiny-dropdown-item--divided tiny-dropdown-menu__item--divided": _ctx.divided,
88
+ "has-children": _ctx.itemData.children && _ctx.itemData.children.length
89
+ }]),
90
+ ref: "dropdownItem",
91
+ onClick: _cache[0] || (_cache[0] = function() {
92
+ return _ctx.handleClick && _ctx.handleClick.apply(_ctx, arguments);
131
93
  }),
132
- 128
133
- /* KEYED_FRAGMENT */
134
- ))],
135
- 2
136
- /* CLASS */
137
- )) : createCommentVNode("v-if", true)], 42, _hoisted_1);
94
+ onMousedown: _cache[1] || (_cache[1] = withModifiers(function() {
95
+ }, ["stop"])),
96
+ "aria-disabled": _ctx.disabled,
97
+ tabindex: _ctx.disabled ? null : -1
98
+ }, [createElementVNode("div", _hoisted_2, [_ctx.itemData.children && _ctx.itemData.children.length ? (openBlock(), createElementBlock("span", _hoisted_3, [(openBlock(), createBlock(resolveDynamicComponent(_ctx.state.getIcon)))])) : createCommentVNode("v-if", true), createElementVNode("div", _hoisted_4, [_ctx.icon ? (openBlock(), createBlock(resolveDynamicComponent(_ctx.icon), {
99
+ key: 0,
100
+ class: "tiny-svg-size"
101
+ })) : createCommentVNode("v-if", true), renderSlot(_ctx.$slots, "default", {
102
+ itemData: _ctx.itemData
103
+ }, function() {
104
+ return [createElementVNode(
105
+ "span",
106
+ null,
107
+ toDisplayString(_ctx.label),
108
+ 1
109
+ /* TEXT */
110
+ )];
111
+ })]), _ctx.itemData.children && _ctx.itemData.children.length ? (openBlock(), createElementBlock(
112
+ "ul",
113
+ {
114
+ key: 1,
115
+ class: normalizeClass(["tiny-dropdown-menu", "tiny-dropdown-item--child tiny-dropdown-menu__item--child", _ctx.state.popperClass])
116
+ },
117
+ [(openBlock(true), createElementBlock(
118
+ Fragment,
119
+ null,
120
+ renderList(_ctx.itemData.children, function(item, index) {
121
+ return openBlock(), createBlock(_component_tiny_dropdown_item, {
122
+ key: index,
123
+ label: item[_ctx.state.textField],
124
+ "item-data": item,
125
+ icon: item.icon,
126
+ disabled: item.disabled,
127
+ divided: item.divided
128
+ }, {
129
+ default: withCtx(function() {
130
+ return [renderSlot(_ctx.$slots, "default", {
131
+ itemData: item
132
+ })];
133
+ }),
134
+ _: 2
135
+ /* DYNAMIC */
136
+ }, 1032, ["label", "item-data", "icon", "disabled", "divided"]);
137
+ }),
138
+ 128
139
+ /* KEYED_FRAGMENT */
140
+ ))],
141
+ 2
142
+ /* CLASS */
143
+ )) : createCommentVNode("v-if", true)])], 42, _hoisted_1)],
144
+ 2112
145
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
146
+ );
138
147
  }
139
148
  var pc = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
140
149
  export {
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@opentiny/vue-dropdown-item",
3
- "version": "3.6.7",
3
+ "version": "3.8.2",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
+ "module": "./lib/index.js",
6
7
  "dependencies": {
7
- "@opentiny/vue-common": "~3.6.7",
8
- "@opentiny/vue-icon": "~3.6.7",
9
- "@opentiny/vue-renderless": "~3.6.6",
10
- "@opentiny/vue-popup": "~3.6.7",
11
- "@opentiny/vue-button": "~3.6.7"
8
+ "@opentiny/vue-common": "~3.8.2",
9
+ "@opentiny/vue-icon": "~3.8.2",
10
+ "@opentiny/vue-renderless": "~3.8.2",
11
+ "@opentiny/vue-popup": "~3.8.2",
12
+ "@opentiny/vue-button": "~3.8.2"
12
13
  },
13
14
  "license": "MIT",
14
15
  "types": "index.d.ts",
package/src/index.d.ts CHANGED
@@ -1,75 +1,2 @@
1
- declare const _default: import("@vue/runtime-core").DefineComponent<{
2
- icon: (StringConstructor | ObjectConstructor)[];
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
- label: {
17
- type: StringConstructor;
18
- default: string;
19
- };
20
- itemData: {
21
- type: ObjectConstructor;
22
- default: () => {};
23
- };
24
- appendToBody: {
25
- type: BooleanConstructor;
26
- default: boolean;
27
- };
28
- textField: {
29
- type: StringConstructor;
30
- default: string;
31
- };
32
- }, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
33
- [key: string]: any;
34
- }>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("@vue/runtime-core").ExtractPropTypes<{
35
- icon: (StringConstructor | ObjectConstructor)[];
36
- disabled: BooleanConstructor;
37
- divided: BooleanConstructor;
38
- command: {};
39
- title: StringConstructor;
40
- titleClass: StringConstructor;
41
- options: {
42
- type: ArrayConstructor;
43
- default: () => never[];
44
- };
45
- type: {
46
- type: StringConstructor;
47
- default: string;
48
- };
49
- label: {
50
- type: StringConstructor;
51
- default: string;
52
- };
53
- itemData: {
54
- type: ObjectConstructor;
55
- default: () => {};
56
- };
57
- appendToBody: {
58
- type: BooleanConstructor;
59
- default: boolean;
60
- };
61
- textField: {
62
- type: StringConstructor;
63
- default: string;
64
- };
65
- }>>, {
66
- type: string;
67
- disabled: boolean;
68
- textField: string;
69
- label: string;
70
- options: unknown[];
71
- divided: boolean;
72
- itemData: Record<string, any>;
73
- appendToBody: boolean;
74
- }>;
1
+ declare const _default: any;
75
2
  export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _sfc_main: any;
2
+ export default _sfc_main;
@@ -1,2 +1,2 @@
1
- declare const _sfc_main: import("@vue/runtime-core").DefineComponent<unknown, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<unknown>, {}>;
1
+ declare const _sfc_main: any;
2
2
  export default _sfc_main;
package/src/pc.vue.d.ts CHANGED
@@ -1,17 +1,2 @@
1
- declare const _sfc_main: import("@vue/runtime-core").DefineComponent<Readonly<{
2
- [x: string]: any;
3
- }>, {
4
- t: (this: any, path: any, options?: any) => any;
5
- vm: any;
6
- f: (props: any, attrs?: {}) => {};
7
- a: (attrs: any, filters: any, include: any) => {};
8
- d: (props: any) => void;
9
- dp: (props: any) => void;
10
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "item-click"[], "item-click", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("@vue/runtime-core").ExtractPropTypes<Readonly<{
11
- [x: string]: any;
12
- }>>> & {
13
- "onItem-click"?: ((...args: any[]) => any) | undefined;
14
- }, {
15
- [x: string]: any;
16
- }>;
1
+ declare const _sfc_main: any;
17
2
  export default _sfc_main;