@opentinyvue/vue-cascader-node 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 CascaderNode from './src/index';
13
+ export default CascaderNode;
package/lib/index.js ADDED
@@ -0,0 +1,48 @@
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 CascaderNode = defineComponent({
25
+ name: $prefix + "CascaderNode",
26
+ componentName: "CascaderNode",
27
+ props: _extends({}, $props, {
28
+ node: {
29
+ required: true
30
+ },
31
+ nodeId: String
32
+ }),
33
+ setup: function setup(props, context) {
34
+ return $setup({
35
+ props,
36
+ context,
37
+ template
38
+ });
39
+ }
40
+ });
41
+ var version = "2.21.0";
42
+ CascaderNode.install = function(Vue) {
43
+ Vue.component(CascaderNode.name, CascaderNode);
44
+ };
45
+ CascaderNode.version = version;
46
+ export {
47
+ CascaderNode as default
48
+ };
@@ -0,0 +1,117 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/cascader-node/vue';
2
+ import { defineComponent, $prefix, setup, $props } from '@opentinyvue/vue-common';
3
+ import { IconLoading, IconChevronRight } from '@opentinyvue/vue-icon';
4
+
5
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
6
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
7
+ if (render) {
8
+ options.render = render;
9
+ options.staticRenderFns = staticRenderFns;
10
+ options._compiled = true;
11
+ }
12
+ var hook;
13
+ if (injectStyles) {
14
+ hook = injectStyles;
15
+ }
16
+ if (hook) {
17
+ if (options.functional) {
18
+ options._injectStyles = hook;
19
+ var originalRender = options.render;
20
+ options.render = function renderWithStyleInjection(h, context) {
21
+ hook.call(context);
22
+ return originalRender(h, context);
23
+ };
24
+ } else {
25
+ var existing = options.beforeCreate;
26
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
27
+ }
28
+ }
29
+ return {
30
+ exports: scriptExports,
31
+ options
32
+ };
33
+ }
34
+
35
+ function _extends() {
36
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
37
+ for (var e = 1; e < arguments.length; e++) {
38
+ var t = arguments[e];
39
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
40
+ }
41
+ return n;
42
+ }, _extends.apply(null, arguments);
43
+ }
44
+ var classes = {
45
+ "cascader-node__postfix": "text-sm fill-color-text-primary absolute top-1/2 right-4 -translate-y-2/4",
46
+ "cascader-node__label_disabled": "max-w-[theme(spacing.80)] flex-1 whitespace-nowrap overflow-hidden text-ellipsis",
47
+ // 正常状态
48
+ "cascader-node": "relative flex items-center pt-0 pr-10 pb-0 pl-3 h-8 leading-8 outline-0 m-1 cursor-pointer rounded hover:bg-color-bg-4",
49
+ "is-selectable": "",
50
+ "in-active-path": "text-color-brand bg-color-fill-6 fill-color-brand",
51
+ "in-checked-path": "text-color-brand bg-color-fill-6 fill-color-brand",
52
+ "in-active": "text-color-brand bg-color-fill-6 ",
53
+ "node-active": "fill-color-brand",
54
+ // 禁用时
55
+ "cascader-node_disabled": "cursor-not-allowed text-color-text-disabled rounded hover:bg-color-bg-1",
56
+ "in-active_disabled": "text-color-text-disabled"
57
+ };
58
+ var render = function render2() {
59
+ var _vm = this;
60
+ var _h = _vm.$createElement;
61
+ var _c = _vm._self._c || _h;
62
+ return _c("div", {
63
+ class: _vm.m(_vm.gcls("cascader-node"), _vm.gcls(!_vm.state.isDisabled && _vm.state.config.checkStrictly ? "is-selectable" : ""), _vm.gcls(!_vm.state.isDisabled && _vm.state.inActivePath ? "in-active-path" : ""), _vm.gcls(!_vm.state.isDisabled && _vm.state.inCheckedPath ? "in-checked-path" : ""), _vm.gcls(!_vm.state.isDisabled && _vm.state.isChecked ? "in-active" : ""), _vm.gcls(_vm.state.isDisabled ? "cascader-node_disabled" : ""), _vm.gcls(_vm.state.isDisabled ? "in-active_disabled" : "")),
64
+ attrs: {
65
+ "id": _vm.nodeId,
66
+ "role": "menuitem",
67
+ "data-tag": "tiny-cascader-node"
68
+ },
69
+ on: {
70
+ "click": _vm.handleNodeClick
71
+ }
72
+ }, [_c("span", {
73
+ class: [_vm.node ? _vm.gcls("cascader-node__label_disabled") : ""]
74
+ }, [_vm._v(_vm._s(_vm.state.nodeLabel))]), _vm.node.loading ? _c("icon-loading", {
75
+ class: _vm.gcls("cascader-node__postfix")
76
+ }) : !_vm.state.isLeaf ? _c("icon-chevron-right", {
77
+ class: _vm.m(_vm.gcls("cascader-node__postfix"), _vm.gcls(!_vm.state.isDisabled && _vm.state.inActivePath ? "node-active" : ""), _vm.gcls(!_vm.state.isDisabled && _vm.state.inCheckedPath ? "node-active" : ""), _vm.gcls(!_vm.state.isDisabled && _vm.state.isChecked ? "node-active" : ""))
78
+ }, [_vm._v(">")]) : _vm._e()], 1);
79
+ };
80
+ var staticRenderFns = [];
81
+ var __vue2_script = defineComponent({
82
+ name: $prefix + "CascaderNode",
83
+ components: {
84
+ IconLoading: IconLoading(),
85
+ IconChevronRight: IconChevronRight()
86
+ },
87
+ inheritAttrs: false,
88
+ emits: ["expand", "update:modelValue", "expand-change", "active-item-change", "change"],
89
+ inject: ["panel"],
90
+ props: _extends({}, $props, {
91
+ node: {
92
+ required: true
93
+ },
94
+ nodeId: String
95
+ }),
96
+ setup: function setup$1(props, context) {
97
+ return setup({
98
+ props,
99
+ context,
100
+ renderless,
101
+ api,
102
+ classes
103
+ });
104
+ }
105
+ });
106
+ var __cssModules = {};
107
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
108
+ function __vue2_injectStyles(context) {
109
+ for (var o in __cssModules) {
110
+ this[o] = __cssModules[o];
111
+ }
112
+ }
113
+ var mobileFirst = /* @__PURE__ */ function() {
114
+ return __component__.exports;
115
+ }();
116
+
117
+ export { mobileFirst as default };
package/lib/pc.js ADDED
@@ -0,0 +1,212 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/cascader-node/vue';
2
+ import { defineComponent, $prefix, setup, $props } from '@opentinyvue/vue-common';
3
+ import Checkbox from '@opentinyvue/vue-checkbox';
4
+ import Radio from '@opentinyvue/vue-radio';
5
+ import { isEqual } from '@opentinyvue/vue-renderless/common/object';
6
+ import { iconYes, iconLoadingShadow, iconChevronRight } from '@opentinyvue/vue-icon';
7
+ import '@opentinyvue/vue-theme/cascader-node/index.css';
8
+
9
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
10
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
11
+ if (render) {
12
+ options.render = render;
13
+ options.staticRenderFns = staticRenderFns;
14
+ options._compiled = true;
15
+ }
16
+ var hook;
17
+ if (injectStyles) {
18
+ hook = injectStyles;
19
+ }
20
+ if (hook) {
21
+ if (options.functional) {
22
+ options._injectStyles = hook;
23
+ var originalRender = options.render;
24
+ options.render = function renderWithStyleInjection(h, context) {
25
+ hook.call(context);
26
+ return originalRender(h, context);
27
+ };
28
+ } else {
29
+ var existing = options.beforeCreate;
30
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
31
+ }
32
+ }
33
+ return {
34
+ exports: scriptExports,
35
+ options
36
+ };
37
+ }
38
+
39
+ function _extends() {
40
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
41
+ for (var e = 1; e < arguments.length; e++) {
42
+ var t = arguments[e];
43
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
44
+ }
45
+ return n;
46
+ }, _extends.apply(null, arguments);
47
+ }
48
+ var __vue2_script = defineComponent({
49
+ name: $prefix + "CascaderNode",
50
+ components: {
51
+ TinyCheckbox: Checkbox,
52
+ TinyRadio: Radio,
53
+ IconYes: iconYes(),
54
+ IconLoading: iconLoadingShadow(),
55
+ IconChevronRight: iconChevronRight()
56
+ },
57
+ inheritAttrs: false,
58
+ emits: ["expand", "update:modelValue", "expand-change", "active-item-change", "change"],
59
+ inject: ["panel"],
60
+ props: _extends({}, $props, {
61
+ node: {
62
+ type: Object,
63
+ required: true
64
+ },
65
+ nodeId: String
66
+ }),
67
+ setup: function setup$1(props, context) {
68
+ return setup({
69
+ props,
70
+ context,
71
+ renderless,
72
+ api
73
+ });
74
+ },
75
+ render: function render() {
76
+ var _this = this;
77
+ var h = arguments[0];
78
+ var renderPrefix = function renderPrefix2() {
79
+ var _this$state = _this.state, isLeaf = _this$state.isLeaf, isChecked = _this$state.isChecked, config = _this$state.config;
80
+ var checkStrictly2 = config.checkStrictly, multiple2 = config.multiple;
81
+ if (multiple2) {
82
+ return renderCheckbox();
83
+ } else if (checkStrictly2) {
84
+ return renderRadio();
85
+ } else if (isLeaf && isChecked) {
86
+ return renderCheckIcon();
87
+ }
88
+ return null;
89
+ };
90
+ var renderPostfix = function renderPostfix2() {
91
+ var node = _this.node, state2 = _this.state;
92
+ if (node.loading) {
93
+ return renderLoadingIcon();
94
+ } else if (!state2.isLeaf) {
95
+ return renderExpandIcon();
96
+ }
97
+ return null;
98
+ };
99
+ var stopPropagation = function stopPropagation2(e) {
100
+ return e.stopPropagation();
101
+ };
102
+ var renderCheckbox = function renderCheckbox2() {
103
+ var state2 = _this.state, node = _this.node;
104
+ return h("tiny-checkbox", {
105
+ "attrs": {
106
+ "modelValue": node.checked,
107
+ "indeterminate": !node.checked && node.indeterminate,
108
+ "disabled": state2.isDisabled
109
+ },
110
+ "on": {
111
+ "change": _this.handleMultiCheckChange,
112
+ "click": stopPropagation
113
+ }
114
+ });
115
+ };
116
+ var renderRadio = function renderRadio2() {
117
+ var _this$state2 = _this.state, checkedValue = _this$state2.checkedValue, value = _this$state2.value, isDisabled = _this$state2.isDisabled;
118
+ if (isEqual(value, checkedValue)) {
119
+ value = checkedValue;
120
+ }
121
+ return h("tiny-radio", {
122
+ "attrs": {
123
+ "disabled": isDisabled,
124
+ "label": value
125
+ },
126
+ "on": {
127
+ "click": stopPropagation,
128
+ "change": _this.handleCheckChange
129
+ },
130
+ "model": {
131
+ value: checkedValue,
132
+ callback: function callback($$v) {
133
+ checkedValue = $$v;
134
+ }
135
+ }
136
+ }, [h("span")]);
137
+ };
138
+ var renderCheckIcon = function renderCheckIcon2() {
139
+ return h("icon-yes", {
140
+ "class": "tiny-cascader-node__prefix"
141
+ });
142
+ };
143
+ var renderLoadingIcon = function renderLoadingIcon2() {
144
+ return h("icon-loading", {
145
+ "class": "tiny-cascader-node__postfix"
146
+ });
147
+ };
148
+ var renderExpandIcon = function renderExpandIcon2() {
149
+ return h("icon-chevron-right", {
150
+ "class": "tiny-cascader-node__postfix"
151
+ });
152
+ };
153
+ var renderContent = function renderContent2() {
154
+ var panel = _this.panel, node = _this.node;
155
+ var render2 = panel.state.renderLabelFn;
156
+ var vnode = render2 ? render2({
157
+ node,
158
+ data: node.data
159
+ }) : null;
160
+ return h("span", {
161
+ "class": "tiny-cascader-node__label"
162
+ }, [vnode || node.label]);
163
+ };
164
+ var state = this.state;
165
+ var _state$config = state.config, checkStrictly = _state$config.checkStrictly, expandTrigger = _state$config.expandTrigger, multiple = _state$config.multiple;
166
+ var disabled = !checkStrictly && state.isDisabled;
167
+ var events = {};
168
+ events.on = {};
169
+ if (expandTrigger === "click") {
170
+ events.on.click = this.handleExpand;
171
+ } else {
172
+ var handler = function handler2(e) {
173
+ _this.handleExpand();
174
+ _this.$emit("expand", e);
175
+ };
176
+ events.on.mouseenter = handler;
177
+ events.on.focus = handler;
178
+ }
179
+ if (state.isLeaf && !(state.isDisabled || checkStrictly || multiple)) {
180
+ events.on.click = this.handleCheckChange;
181
+ }
182
+ return h("li", _extends({
183
+ attrs: {
184
+ role: "menuitem",
185
+ id: this.nodeId,
186
+ tabindex: disabled ? null : -1,
187
+ "aria-expanded": state.inActivePath
188
+ },
189
+ class: {
190
+ "tiny-cascader-node": true,
191
+ "is-selectable": checkStrictly,
192
+ "in-active-path": state.inActivePath,
193
+ "in-checked-path": state.inCheckedPath,
194
+ "is-active": state.isChecked,
195
+ "is-disabled": disabled
196
+ }
197
+ }, events), [renderPrefix(), renderContent(), renderPostfix()]);
198
+ }
199
+ });
200
+ var __vue2_render, __vue2_staticRenderFns;
201
+ var __cssModules = {};
202
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
203
+ function __vue2_injectStyles(context) {
204
+ for (var o in __cssModules) {
205
+ this[o] = __cssModules[o];
206
+ }
207
+ }
208
+ var pc = /* @__PURE__ */ function() {
209
+ return __component__.exports;
210
+ }();
211
+
212
+ export { pc as default };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@opentinyvue/vue-cascader-node",
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-checkbox": "~2.21.0",
13
+ "@opentinyvue/vue-radio": "~2.21.0",
14
+ "@opentinyvue/vue-icon": "~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 _default: any;
2
+ export default _default;
package/src/token.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export declare const classes: {
2
+ 'cascader-node__postfix': string;
3
+ 'cascader-node__label_disabled': string;
4
+ 'cascader-node': string;
5
+ 'is-selectable': string;
6
+ 'in-active-path': string;
7
+ 'in-checked-path': string;
8
+ 'in-active': string;
9
+ 'node-active': string;
10
+ 'cascader-node_disabled': string;
11
+ 'in-active_disabled': string;
12
+ };