@opentinyvue/vue-cascader-menu 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 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 CascaderMenu from './src/index';
13
+ export default CascaderMenu;
package/lib/index.js ADDED
@@ -0,0 +1,50 @@
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, $props, $setup } from "@opentinyvue/vue-common";
11
+ import PcTemplate from "./pc.js";
12
+ import MobileFirstTemplate from "./mobile-first.js";
13
+ var template = function template2(mode) {
14
+ var _process$env;
15
+ var tinyMode = typeof process === "object" ? (_process$env = process.env) == null ? void 0 : _process$env.TINY_MODE : null;
16
+ if ("pc" === (tinyMode || mode)) {
17
+ return PcTemplate;
18
+ }
19
+ if ("mobile-first" === (tinyMode || mode)) {
20
+ return MobileFirstTemplate;
21
+ }
22
+ return PcTemplate;
23
+ };
24
+ var CascaderMenu = defineComponent({
25
+ name: $prefix + "CascaderMenu",
26
+ componentName: "CascaderMenu",
27
+ props: _extends({}, $props, {
28
+ nodes: {
29
+ type: Array,
30
+ required: true
31
+ },
32
+ index: Number,
33
+ onlyUsePanel: Boolean
34
+ }),
35
+ setup: function setup(props, context) {
36
+ return $setup({
37
+ props,
38
+ context,
39
+ template
40
+ });
41
+ }
42
+ });
43
+ var version = "2.21.0";
44
+ CascaderMenu.install = function(Vue) {
45
+ Vue.component(CascaderMenu.name, CascaderMenu);
46
+ };
47
+ CascaderMenu.version = version;
48
+ export {
49
+ CascaderMenu as default
50
+ };
@@ -0,0 +1,113 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/cascader-menu/vue';
2
+ import { defineComponent, $prefix, $props, setup } from '@opentinyvue/vue-common';
3
+ import Scrollbar from '@opentinyvue/vue-scrollbar';
4
+ import CascaderNode from '@opentinyvue/vue-cascader-node';
5
+
6
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
7
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
8
+ if (render) {
9
+ options.render = render;
10
+ options.staticRenderFns = staticRenderFns;
11
+ options._compiled = true;
12
+ }
13
+ var hook;
14
+ if (injectStyles) {
15
+ hook = injectStyles;
16
+ }
17
+ if (hook) {
18
+ if (options.functional) {
19
+ options._injectStyles = hook;
20
+ var originalRender = options.render;
21
+ options.render = function renderWithStyleInjection(h, context) {
22
+ hook.call(context);
23
+ return originalRender(h, context);
24
+ };
25
+ } else {
26
+ var existing = options.beforeCreate;
27
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
28
+ }
29
+ }
30
+ return {
31
+ exports: scriptExports,
32
+ options
33
+ };
34
+ }
35
+
36
+ function _extends() {
37
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
38
+ for (var e = 1; e < arguments.length; e++) {
39
+ var t = arguments[e];
40
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
41
+ }
42
+ return n;
43
+ }, _extends.apply(null, arguments);
44
+ }
45
+ var render = function render2() {
46
+ var _vm = this;
47
+ var _h = _vm.$createElement;
48
+ var _c = _vm._self._c || _h;
49
+ return _c("tiny-scrollbar", {
50
+ ref: "cascaderMenu",
51
+ class: _vm.m("min-w-[theme(spacing.54)] box-border text-color-text-primary pt-1"),
52
+ attrs: {
53
+ "data-tag": "tiny-cascader-menu",
54
+ "id": _vm.state.menuId,
55
+ "role": "menu",
56
+ "tag": "div",
57
+ "wrap-class": "overflow-auto h-auto pb-1.5 max-h-[theme(spacing.72)]",
58
+ "view-class": "relative min-h-full m-0 list-none box-border pb-1 "
59
+ }
60
+ }, [_vm.state.isEmpty ? _c("div", {
61
+ staticClass: "absolute top-1/2 left-1/2 -translate-x-2/4 -translate-y-2/4 text-center text-color-text-placeholder",
62
+ attrs: {
63
+ "data-tag": "tiny-cascader-menu__empty-text"
64
+ }
65
+ }, [_vm._v(" " + _vm._s(_vm.t("ui.cascader.noData")) + " ")]) : _vm._l(_vm.nodes, function(node, nodeIndex) {
66
+ return _c("cascader-node", {
67
+ key: node.uid,
68
+ attrs: {
69
+ "tiny_mode": "mobile-first",
70
+ "node": node,
71
+ "node-id": _vm.state.menuId + "-" + nodeIndex,
72
+ "data-haspopup": node.hasChildren,
73
+ "data-owns": node.hasChildren ? _vm.state.menuId : null
74
+ }
75
+ });
76
+ })], 2);
77
+ };
78
+ var staticRenderFns = [];
79
+ var __vue2_script = defineComponent({
80
+ name: $prefix + "CascaderMenu",
81
+ components: {
82
+ TinyScrollbar: Scrollbar,
83
+ CascaderNode
84
+ },
85
+ props: _extends({}, $props, {
86
+ nodes: {
87
+ type: Array,
88
+ required: true
89
+ },
90
+ index: Number
91
+ }),
92
+ inject: ["panel", "cascaderRoot"],
93
+ setup: function setup$1(props, context) {
94
+ return setup({
95
+ props,
96
+ context,
97
+ renderless,
98
+ api
99
+ });
100
+ }
101
+ });
102
+ var __cssModules = {};
103
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
104
+ function __vue2_injectStyles(context) {
105
+ for (var o in __cssModules) {
106
+ this[o] = __cssModules[o];
107
+ }
108
+ }
109
+ var mobileFirst = /* @__PURE__ */ function() {
110
+ return __component__.exports;
111
+ }();
112
+
113
+ export { mobileFirst as default };
package/lib/pc.js ADDED
@@ -0,0 +1,201 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/cascader-menu/vue';
2
+ import { defineComponent, $prefix, $props, setup, h } from '@opentinyvue/vue-common';
3
+ import { t } from '@opentinyvue/vue-locale';
4
+ import Scrollbar from '@opentinyvue/vue-scrollbar';
5
+ import CascaderNode from '@opentinyvue/vue-cascader-node';
6
+ import '@opentinyvue/vue-theme/cascader-menu/index.css';
7
+
8
+ function getDefaultExportFromCjs(x) {
9
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
10
+ }
11
+
12
+ var helper;
13
+ var hasRequiredHelper;
14
+ function requireHelper() {
15
+ if (hasRequiredHelper) return helper;
16
+ hasRequiredHelper = 1;
17
+ function _extends() {
18
+ return _extends = Object.assign ? Object.assign.bind() : function(a) {
19
+ for (var b, c = 1; c < arguments.length; c++) for (var d in b = arguments[c], b) Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d]);
20
+ return a;
21
+ }, _extends.apply(this, arguments);
22
+ }
23
+ var normalMerge = ["attrs", "props", "domProps"], toArrayMerge = ["class", "style", "directives"], functionalMerge = ["on", "nativeOn"], mergeJsxProps = function mergeJsxProps2(a) {
24
+ return a.reduce(function(c, a2) {
25
+ for (var b in a2) if (!c[b]) c[b] = a2[b];
26
+ else if (-1 !== normalMerge.indexOf(b)) c[b] = _extends({}, c[b], a2[b]);
27
+ else if (-1 !== toArrayMerge.indexOf(b)) {
28
+ var d = c[b] instanceof Array ? c[b] : [c[b]], e = a2[b] instanceof Array ? a2[b] : [a2[b]];
29
+ c[b] = [].concat(d, e);
30
+ } else if (-1 !== functionalMerge.indexOf(b)) {
31
+ for (var f in a2[b]) if (c[b][f]) {
32
+ var g = c[b][f] instanceof Array ? c[b][f] : [c[b][f]], h = a2[b][f] instanceof Array ? a2[b][f] : [a2[b][f]];
33
+ c[b][f] = [].concat(g, h);
34
+ } else c[b][f] = a2[b][f];
35
+ } else if ("hook" === b) for (var i in a2[b]) c[b][i] = c[b][i] ? mergeFn(c[b][i], a2[b][i]) : a2[b][i];
36
+ else c[b] = a2[b];
37
+ return c;
38
+ }, {});
39
+ }, mergeFn = function mergeFn2(a, b) {
40
+ return function() {
41
+ a && a.apply(this, arguments), b && b.apply(this, arguments);
42
+ };
43
+ };
44
+ helper = mergeJsxProps;
45
+ return helper;
46
+ }
47
+ var helperExports = requireHelper();
48
+ var _mergeJSXProps5 = /* @__PURE__ */ getDefaultExportFromCjs(helperExports);
49
+
50
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
51
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
52
+ if (render) {
53
+ options.render = render;
54
+ options.staticRenderFns = staticRenderFns;
55
+ options._compiled = true;
56
+ }
57
+ var hook;
58
+ if (injectStyles) {
59
+ hook = injectStyles;
60
+ }
61
+ if (hook) {
62
+ if (options.functional) {
63
+ options._injectStyles = hook;
64
+ var originalRender = options.render;
65
+ options.render = function renderWithStyleInjection(h, context) {
66
+ hook.call(context);
67
+ return originalRender(h, context);
68
+ };
69
+ } else {
70
+ var existing = options.beforeCreate;
71
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
72
+ }
73
+ }
74
+ return {
75
+ exports: scriptExports,
76
+ options
77
+ };
78
+ }
79
+
80
+ function _extends() {
81
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
82
+ for (var e = 1; e < arguments.length; e++) {
83
+ var t2 = arguments[e];
84
+ for (var r in t2) ({}).hasOwnProperty.call(t2, r) && (n[r] = t2[r]);
85
+ }
86
+ return n;
87
+ }, _extends.apply(null, arguments);
88
+ }
89
+ var renderNodeListFunc = function renderNodeListFunc2(_vm) {
90
+ return function() {
91
+ var events = {
92
+ on: {}
93
+ };
94
+ var menuId = _vm.state.menuId;
95
+ var isHoverMenu = _vm.panel.state.isHoverMenu;
96
+ if (isHoverMenu) {
97
+ events.on.expand = _vm.handleExpand;
98
+ }
99
+ var mapHandler = function mapHandler2(node, index) {
100
+ var uid = node.uid;
101
+ var hasChildren = node.hasChildren;
102
+ return h("cascader-node", _mergeJSXProps5([{
103
+ "key": uid,
104
+ "attrs": {
105
+ "node": node,
106
+ "node-id": menuId + "-" + index,
107
+ "data-haspopup": hasChildren,
108
+ "data-owns": hasChildren ? menuId : null
109
+ }
110
+ }, events]));
111
+ };
112
+ var nodes = _vm.nodes.map(mapHandler);
113
+ return [].concat(nodes, [isHoverMenu ? h("svg", {
114
+ "ref": "hoverZone",
115
+ "class": "tiny-cascader-menu__hover-zone"
116
+ }) : null]);
117
+ };
118
+ };
119
+ var CascaderMenu = defineComponent({
120
+ name: $prefix + "CascaderMenu",
121
+ components: {
122
+ TinyScrollbar: Scrollbar,
123
+ CascaderNode
124
+ },
125
+ props: _extends({}, $props, {
126
+ nodes: {
127
+ type: Array,
128
+ required: true
129
+ },
130
+ index: Number,
131
+ onlyUsePanel: Boolean
132
+ }),
133
+ inject: {
134
+ panel: {
135
+ value: "panel",
136
+ default: null
137
+ },
138
+ cascaderRoot: {
139
+ value: "cascaderRoot",
140
+ default: null
141
+ }
142
+ },
143
+ setup: function setup$1(props, context) {
144
+ return setup({
145
+ props,
146
+ context,
147
+ renderless,
148
+ api,
149
+ mono: true
150
+ });
151
+ },
152
+ render: function render() {
153
+ var h2 = arguments[0];
154
+ var parentVm = this.cascaderRoot || this.panel || this;
155
+ var noDataSlot = parentVm.slots["no-data"] && parentVm.slots["no-data"]();
156
+ var renderEmptyText = function renderEmptyText2() {
157
+ return noDataSlot ? h2("div", {
158
+ "class": "tiny-cascader-menu__no-data"
159
+ }, [noDataSlot]) : h2("div", {
160
+ "class": "tiny-cascader-menu__empty-text"
161
+ }, [t("ui.cascader.noData")]);
162
+ };
163
+ var renderNodeList = renderNodeListFunc(this);
164
+ var state = this.state;
165
+ var events = {
166
+ nativeOn: {}
167
+ };
168
+ if (this.panel.state.isHoverMenu) {
169
+ events.nativeOn.mousemove = this.handleMouseMove;
170
+ }
171
+ return h2("tiny-scrollbar", _extends({
172
+ attrs: {
173
+ role: "menu",
174
+ id: state.menuId
175
+ },
176
+ ref: "cascaderMenu",
177
+ class: "tiny-cascader-menu",
178
+ props: {
179
+ tag: "ul",
180
+ "wrap-class": "tiny-cascader-menu__wrap " + (this.onlyUsePanel ? "tiny-cascader-menu__wrap-expand" : ""),
181
+ "view-class": {
182
+ "tiny-cascader-menu__list": true,
183
+ "is-empty": state.isEmpty
184
+ }
185
+ }
186
+ }, events), [state.isEmpty ? renderEmptyText() : renderNodeList()]);
187
+ }
188
+ });
189
+ var __vue2_render, __vue2_staticRenderFns;
190
+ var __cssModules = {};
191
+ var __component__ = /* @__PURE__ */ normalizeComponent(CascaderMenu, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
192
+ function __vue2_injectStyles(context) {
193
+ for (var o in __cssModules) {
194
+ this[o] = __cssModules[o];
195
+ }
196
+ }
197
+ var pc = /* @__PURE__ */ function() {
198
+ return __component__.exports;
199
+ }();
200
+
201
+ export { pc as default };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@opentinyvue/vue-cascader-menu",
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-common": "~2.21.0",
11
+ "@opentinyvue/vue-renderless": "~3.21.0",
12
+ "@opentinyvue/vue-locale": "~2.21.0",
13
+ "@opentinyvue/vue-scrollbar": "~2.21.0",
14
+ "@opentinyvue/vue-cascader-node": "~2.21.0",
15
+ "@opentinyvue/vue-theme": "~3.21.0"
16
+ },
17
+ "license": "MIT",
18
+ "types": "index.d.ts",
19
+ "scripts": {
20
+ "build": "pnpm -w build:ui $npm_package_name",
21
+ "//postversion": "pnpm build"
22
+ }
23
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const CascaderMenu: any;
2
+ export default CascaderMenu;