@opentinyvue/vue-cascader 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 Cascader from './src/index';
13
+ export default Cascader;
package/lib/index.js ADDED
@@ -0,0 +1,146 @@
1
+ function _extends() {
2
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
3
+ for (var e = 1; e < arguments.length; e++) {
4
+ var t2 = arguments[e];
5
+ for (var r in t2) ({}).hasOwnProperty.call(t2, r) && (n[r] = t2[r]);
6
+ }
7
+ return n;
8
+ }, _extends.apply(null, arguments);
9
+ }
10
+ import { defineComponent, $prefix, $setup, $props } from "@opentinyvue/vue-common";
11
+ import PcTemplate from "./pc.js";
12
+ import MobileFirstTemplate from "./mobile-first.js";
13
+ import { t } from "@opentinyvue/vue-locale";
14
+ var template = function template2(mode) {
15
+ var _process$env;
16
+ var tinyMode = typeof process === "object" ? (_process$env = process.env) == null ? void 0 : _process$env.TINY_MODE : null;
17
+ if ("pc" === (tinyMode || mode)) {
18
+ return PcTemplate;
19
+ }
20
+ if ("mobile-first" === (tinyMode || mode)) {
21
+ return MobileFirstTemplate;
22
+ }
23
+ return PcTemplate;
24
+ };
25
+ var $constants = {
26
+ placeholder: "ui.cascader.placeholder",
27
+ COMPONENT_NAME: {
28
+ FormItem: "FormItem"
29
+ },
30
+ EVENT_NAME: {
31
+ FormBlur: "form.blur",
32
+ FormChange: "form.change"
33
+ },
34
+ defaultNodeConfig: {
35
+ lazy: false,
36
+ load: null,
37
+ isLeaf: "leaf",
38
+ afterLoad: null,
39
+ currentNodeKey: null,
40
+ checkStrictly: false,
41
+ checkDescendants: null,
42
+ defaultCheckedKeys: null,
43
+ defaultExpandedKeys: null,
44
+ autoExpandParent: null,
45
+ defaultExpandAll: null,
46
+ filterNodeMethod: null
47
+ }
48
+ };
49
+ var cascaderProps = _extends({}, $props, {
50
+ _constants: {
51
+ type: Object,
52
+ default: function _default() {
53
+ return $constants;
54
+ }
55
+ },
56
+ autoSize: Boolean,
57
+ beforeFilter: {
58
+ type: Function,
59
+ default: function _default2() {
60
+ return function() {
61
+ };
62
+ }
63
+ },
64
+ clearable: Boolean,
65
+ collapseTags: Boolean,
66
+ debounce: {
67
+ type: Number,
68
+ default: 300
69
+ },
70
+ disabled: Boolean,
71
+ filterMethod: Function,
72
+ filterable: Boolean,
73
+ modelValue: {},
74
+ options: Array,
75
+ placeholder: {
76
+ type: String,
77
+ default: t("ui.select.placeholder")
78
+ },
79
+ popperAppendToBody: {
80
+ type: Boolean,
81
+ default: true
82
+ },
83
+ popperClass: String,
84
+ props: {
85
+ type: Object,
86
+ default: function _default3() {
87
+ return {};
88
+ }
89
+ },
90
+ separator: {
91
+ type: String,
92
+ default: " /"
93
+ },
94
+ showAllLevels: {
95
+ type: Boolean,
96
+ default: true
97
+ },
98
+ size: String,
99
+ shape: String,
100
+ label: String,
101
+ tip: String,
102
+ displayOnly: {
103
+ type: Boolean,
104
+ default: false
105
+ },
106
+ hoverExpand: {
107
+ type: Boolean,
108
+ default: false
109
+ },
110
+ // mf时,传入action-sheet的title
111
+ title: String,
112
+ showHeader: {
113
+ type: Boolean,
114
+ default: true
115
+ },
116
+ levelTitle: Array,
117
+ // 用来接受小屏下,传入的数组标题,赋值给 cascader-mobile的placeholder属性
118
+ blank: {
119
+ type: Boolean,
120
+ default: false
121
+ }
122
+ });
123
+ var Cascader = defineComponent({
124
+ name: $prefix + "Cascader",
125
+ componentName: "Cascader",
126
+ props: cascaderProps,
127
+ setup: function setup(props, context) {
128
+ return $setup({
129
+ props,
130
+ context,
131
+ template
132
+ });
133
+ }
134
+ });
135
+ var version = "2.21.0";
136
+ Cascader.model = {
137
+ prop: "modelValue",
138
+ event: "update:modelValue"
139
+ };
140
+ Cascader.install = function(Vue) {
141
+ Vue.component(Cascader.name, Cascader);
142
+ };
143
+ Cascader.version = version;
144
+ export {
145
+ Cascader as default
146
+ };
@@ -0,0 +1,464 @@
1
+ import { defineComponent, props, directive, setup, useBreakpoint, hooks } from '@opentinyvue/vue-common';
2
+ import Input from '@opentinyvue/vue-input';
3
+ import { IconClose, IconChevronDown, IconChevronUp, IconYes, IconChevronRight } from '@opentinyvue/vue-icon';
4
+ import CascaderMobile from '@opentinyvue/vue-cascader-mobile';
5
+ import { renderless, api } from '@opentinyvue/vue-renderless/cascader/vue';
6
+ import Clickoutside from '@opentinyvue/vue-renderless/common/deps/clickoutside';
7
+ import Scrollbar from '@opentinyvue/vue-scrollbar';
8
+ import CascaderPanel from '@opentinyvue/vue-cascader-panel';
9
+ import Tooltip from '@opentinyvue/vue-tooltip';
10
+
11
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
12
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
13
+ if (render) {
14
+ options.render = render;
15
+ options.staticRenderFns = staticRenderFns;
16
+ options._compiled = true;
17
+ }
18
+ var hook;
19
+ if (injectStyles) {
20
+ hook = injectStyles;
21
+ }
22
+ if (hook) {
23
+ if (options.functional) {
24
+ options._injectStyles = hook;
25
+ var originalRender = options.render;
26
+ options.render = function renderWithStyleInjection(h, context) {
27
+ hook.call(context);
28
+ return originalRender(h, context);
29
+ };
30
+ } else {
31
+ var existing = options.beforeCreate;
32
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
33
+ }
34
+ }
35
+ return {
36
+ exports: scriptExports,
37
+ options
38
+ };
39
+ }
40
+
41
+ var classes = {
42
+ "type-medium": "text-sm leading-9",
43
+ "type-small": "text-xs leading-8",
44
+ "type-mini": "text-xs leading-7",
45
+ "show-auto-width": "w-full"
46
+ };
47
+ var __vue2_script$1 = defineComponent({
48
+ props: [].concat(props, ["modelValue", "options", "props", "size", "placeholder", "disabled", "clearable", "filterable", "filterMethod", "separator", "showAllLevels", "collapseTags", "debounce", "beforeFilter", "popperClass", "placement", "popperOptions", "visibleArrow", "offset", "boundariesPadding", "arrowOffset", "popperAppendToBody", "autoSize", "displayOnly", "shape", "label", "tip", "hoverExpand"]),
49
+ directives: directive({
50
+ Clickoutside
51
+ }),
52
+ inheritAttrs: false,
53
+ provide: function provide() {
54
+ return {
55
+ cascaderRoot: this
56
+ };
57
+ },
58
+ components: {
59
+ TinyInput: Input,
60
+ TinyScrollbar: Scrollbar,
61
+ TinyCascaderPanel: CascaderPanel,
62
+ IconClose: IconClose(),
63
+ IconChevronDown: IconChevronDown(),
64
+ IconChevronUp: IconChevronUp(),
65
+ IconYes: IconYes(),
66
+ TinyTooltip: Tooltip
67
+ },
68
+ emits: ["update:modelValue", "change", "visible-change", "focus", "blur", "expand-change", "active-item-change", "remove-tag", "created"],
69
+ setup: function setup$1(props2, context) {
70
+ return setup({
71
+ props: props2,
72
+ context,
73
+ renderless,
74
+ api,
75
+ classes
76
+ });
77
+ }
78
+ });
79
+ var render$1 = function render$12() {
80
+ var _vm = this;
81
+ var _h = _vm.$createElement;
82
+ var _c = _vm._self._c || _h;
83
+ return _c("div", _vm._b({
84
+ directives: [{
85
+ name: "clickoutside",
86
+ rawName: "v-clickoutside",
87
+ value: function value() {
88
+ return _vm.toggleDropDownVisible(false);
89
+ },
90
+ expression: "() => toggleDropDownVisible(false)"
91
+ }],
92
+ class: _vm.m("inline-block relative text-sm", _vm.gcls("type-${state.realSize}"), _vm.gcls(_vm.state.showAutoWidth ? "show-auto-width" : "")),
93
+ attrs: {
94
+ "data-tag": "tiny-cascader"
95
+ },
96
+ on: {
97
+ "mouseenter": function mouseenter($event) {
98
+ _vm.state.inputHover = true;
99
+ },
100
+ "mouseleave": function mouseleave($event) {
101
+ _vm.state.inputHover = false;
102
+ },
103
+ "click": function click() {
104
+ return _vm.toggleDropDownVisible(_vm.state.readonly ? void 0 : true);
105
+ },
106
+ "keydown": _vm.handleKeyDown
107
+ }
108
+ }, "div", _vm.a(_vm.$attrs, ["class", "style"], true), false), [_c("div", {
109
+ ref: "reference",
110
+ attrs: {
111
+ "data-tag": "tiny-cascader-content"
112
+ }
113
+ }, [_c("tiny-input", {
114
+ ref: "input",
115
+ attrs: {
116
+ "model-value": _vm.state.multiple ? _vm.state.presentText : _vm.state.inputValue,
117
+ "size": _vm.state.realSize,
118
+ "placeholder": _vm.state.placeholder,
119
+ "readonly": _vm.state.readonly,
120
+ "disabled": _vm.state.isDisabled,
121
+ "display-only": _vm.displayOnly,
122
+ "display-only-content": _vm.state.multiple ? _vm.state.presentTags.map(function(item) {
123
+ return item.text;
124
+ }).join("; ") : "",
125
+ "validate-event": false
126
+ },
127
+ on: {
128
+ "focus": _vm.handleFocus,
129
+ "blur": _vm.handleBlur,
130
+ "update:modelValue": _vm.handleInput
131
+ },
132
+ scopedSlots: _vm._u([{
133
+ key: "suffix",
134
+ fn: function fn() {
135
+ return [_vm.state.clearBtnVisible ? _c("icon-close", {
136
+ key: "clear",
137
+ on: {
138
+ "click": function click($event) {
139
+ $event.stopPropagation();
140
+ return _vm.handleClear.apply(null, arguments);
141
+ }
142
+ }
143
+ }) : _c(_vm.state.dropDownVisible ? "icon-chevron-up" : "icon-chevron-down", {
144
+ key: "arrow-down",
145
+ tag: "component",
146
+ class: {
147
+ "fill-color-brand": _vm.state.dropDownVisible
148
+ },
149
+ on: {
150
+ "click": function click($event) {
151
+ $event.stopPropagation();
152
+ return _vm.toggleDropDownVisible();
153
+ }
154
+ }
155
+ })];
156
+ },
157
+ proxy: true
158
+ }])
159
+ }), _vm.state.multiple && !_vm.state.isDisplayOnly && !_vm.shape ? _c("div", {
160
+ ref: "tags-content",
161
+ attrs: {
162
+ "data-tag": "tiny-cascader__tags"
163
+ }
164
+ }, [_vm.filterable && !_vm.state.isDisabled ? _c("input", {
165
+ directives: [{
166
+ name: "model",
167
+ rawName: "v-model.trim",
168
+ value: _vm.state.inputValue,
169
+ expression: "state.inputValue",
170
+ modifiers: {
171
+ "trim": true
172
+ }
173
+ }],
174
+ staticClass: "flex-1 h-6 text-color-text-primary text-xs border-none outline-0 box-border",
175
+ attrs: {
176
+ "type": "text",
177
+ "data-tag": "tiny-cascader__search-input",
178
+ "placeholder": _vm.state.presentTags.length ? "" : _vm.placeholder
179
+ },
180
+ domProps: {
181
+ "value": _vm.state.inputValue
182
+ },
183
+ on: {
184
+ "focus": _vm.handleFocus,
185
+ "blur": [_vm.handleBlur, function($event) {
186
+ return _vm.$forceUpdate();
187
+ }],
188
+ "input": [function($event) {
189
+ if ($event.target.composing) return;
190
+ _vm.$set(_vm.state, "inputValue", $event.target.value.trim());
191
+ }, function(e) {
192
+ return _vm.handleInput(_vm.state.inputValue, e);
193
+ }],
194
+ "click": function click($event) {
195
+ $event.stopPropagation();
196
+ return _vm.toggleDropDownVisible(true);
197
+ },
198
+ "keydown": function keydown($event) {
199
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "delete", [8, 46], $event.key, ["Backspace", "Delete", "Del"])) return null;
200
+ return _vm.handleDelete.apply(null, arguments);
201
+ }
202
+ }
203
+ }) : _vm._e()]) : _vm._e()], 1), _c("tiny-tooltip", {
204
+ ref: "tooltip",
205
+ attrs: {
206
+ "manual": true,
207
+ "effect": "light",
208
+ "content": _vm.state.tooltipContent,
209
+ "placement": "top"
210
+ },
211
+ model: {
212
+ value: _vm.state.tooltipVisible,
213
+ callback: function callback($$v) {
214
+ _vm.$set(_vm.state, "tooltipVisible", $$v);
215
+ },
216
+ expression: "state.tooltipVisible"
217
+ }
218
+ }), _c("transition", {
219
+ attrs: {
220
+ "name": "tiny-zoom-in-top"
221
+ },
222
+ on: {
223
+ "after-leave": _vm.handleDropdownLeave
224
+ }
225
+ }, [_c("div", {
226
+ directives: [{
227
+ name: "show",
228
+ rawName: "v-show",
229
+ value: _vm.state.dropDownVisible,
230
+ expression: "state.dropDownVisible"
231
+ }],
232
+ ref: "popper",
233
+ class: _vm.m(_vm.popperClass, "my-1 mx-0 text-sm bg-color-bg-1 rounded shadow-md", _vm.autoSize ? "bg-transparent border-none shadow-none" : ""),
234
+ attrs: {
235
+ "data-tag": "tiny-cascader__dropdown"
236
+ },
237
+ on: {
238
+ "mousedown": function mousedown($event) {
239
+ $event.stopPropagation();
240
+ }
241
+ }
242
+ }, [_c("tiny-cascader-panel", {
243
+ directives: [{
244
+ name: "show",
245
+ rawName: "v-show",
246
+ value: !_vm.state.filtering,
247
+ expression: "!state.filtering"
248
+ }],
249
+ ref: "panel",
250
+ attrs: {
251
+ "tiny_mode": "mobile-first",
252
+ "options": _vm.options,
253
+ "props": _vm.state.config,
254
+ "border": false,
255
+ "render-label": _vm.slots.default
256
+ },
257
+ on: {
258
+ "expand-change": _vm.handleExpandChange,
259
+ "close": function close($event) {
260
+ return _vm.toggleDropDownVisible(false);
261
+ }
262
+ },
263
+ model: {
264
+ value: _vm.state.checkedValue,
265
+ callback: function callback($$v) {
266
+ _vm.$set(_vm.state, "checkedValue", $$v);
267
+ },
268
+ expression: "state.checkedValue"
269
+ }
270
+ }), _vm.filterable ? _c("tiny-scrollbar", {
271
+ directives: [{
272
+ name: "show",
273
+ rawName: "v-show",
274
+ value: _vm.state.filtering,
275
+ expression: "state.filtering"
276
+ }],
277
+ ref: "suggestionPanel",
278
+ staticClass: "bg-color-bg-1 border border-solid border-color-border-separator rounded",
279
+ attrs: {
280
+ "tag": "div",
281
+ "data-tag": "tiny-cascader__suggestion-panel",
282
+ "wrap-class": "overflow-auto pr-2 pb-2",
283
+ "view-class": "tiny-cascader__suggestion-list m-0 py-1.5 px-0 text-sm text-color-text-primary text-center"
284
+ },
285
+ on: {
286
+ "keydown": _vm.handleSuggestionKeyDown
287
+ },
288
+ scopedSlots: _vm._u([_vm.state.suggestions.length ? {
289
+ key: "default",
290
+ fn: function fn() {
291
+ return _vm._l(_vm.state.suggestions, function(item, index) {
292
+ return _c("div", {
293
+ key: item.uid,
294
+ class: ["flex justify-between items-center h-8 py-0 px-2 text-xs text-color-text-primary", "text-left outline-0 cursor-pointer", item.checked ? "text-color-brand-hover font-bold" : ""],
295
+ attrs: {
296
+ "data-tag": "tiny-cascader__suggestion-item",
297
+ "tabindex": -1
298
+ },
299
+ on: {
300
+ "click": function click($event) {
301
+ return _vm.handleSuggestionClick(index);
302
+ }
303
+ }
304
+ }, [_c("span", [_vm._v(_vm._s(item.text))]), item.checked ? _c("icon-yes", {
305
+ class: item.checked ? "fill-color-icon-hover" : ""
306
+ }) : _vm._e()], 1);
307
+ });
308
+ },
309
+ proxy: true
310
+ } : null], null, true)
311
+ }, [!_vm.state.suggestions.length ? _vm._t("empty", function() {
312
+ return [_c("div", {
313
+ staticClass: "my-2.5 mx-0 text-color-text-placeholder",
314
+ attrs: {
315
+ "data-tag": "tiny-cascader__empty-text"
316
+ }
317
+ }, [_vm._v(" " + _vm._s(_vm.t("ui.cascader.noMatch")) + " ")])];
318
+ }) : _vm._e()], 2) : _vm._e()], 1)])], 1);
319
+ };
320
+ var staticRenderFns$1 = [];
321
+ var __cssModules$1 = {};
322
+ var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1);
323
+ function __vue2_injectStyles$1(context) {
324
+ for (var o in __cssModules$1) {
325
+ this[o] = __cssModules$1[o];
326
+ }
327
+ }
328
+ var PcFirst = /* @__PURE__ */ function() {
329
+ return __component__$1.exports;
330
+ }();
331
+ var __vue2_script = defineComponent({
332
+ props: [].concat(props, ["modelValue", "options", "props", "size", "placeholder", "disabled", "clearable", "filterable", "filterMethod", "separator", "showAllLevels", "collapseTags", "debounce", "beforeFilter", "popperClass", "placement", "popperOptions", "visibleArrow", "offset", "boundariesPadding", "arrowOffset", "popperAppendToBody", "autoSize", "displayOnly", "shape", "label", "tip", "hoverExpand", "title", "showHeader", "levelTitle"]),
333
+ inheritAttrs: false,
334
+ components: {
335
+ TinyCascaderMobile: CascaderMobile,
336
+ TinyPcFirst: PcFirst,
337
+ TinyInput: Input,
338
+ IconChevronRight: IconChevronRight()
339
+ },
340
+ emits: ["update:modelValue", "change", "visible-change", "focus", "blur", "expand-change", "active-item-change", "remove-tag", "created"],
341
+ setup: function setup2(props2, ctx) {
342
+ var bp = useBreakpoint().current;
343
+ var visible = hooks.ref(false);
344
+ var showText = hooks.ref("");
345
+ var computedMobileProp = hooks.computed(function() {
346
+ var mobileProp = hooks.reactive({
347
+ _constants: props2._constants,
348
+ data: props2.options,
349
+ ellipsis: props2.ellipsis,
350
+ placeholder: Array.isArray(props2.levelTitle) && props2.levelTitle.length ? props2.levelTitle : props2.placeholder,
351
+ // 未传入有效的 levelTitle,则使用默认的placeholder
352
+ title: props2.title,
353
+ // 外层需要补充
354
+ valueField: props2.props.value || "value",
355
+ textField: props2.props.label || "label",
356
+ textField2: props2.props.textField2 || "",
357
+ // 外层props需要补充2,3属性
358
+ textField3: props2.props.textField3 || "",
359
+ childrenField: props2.props.children || "children",
360
+ textSplit: props2.separator,
361
+ showHeader: props2.showHeader,
362
+ // 外层需要补充
363
+ multiple: false,
364
+ // 不支持多选
365
+ searchConfig: {
366
+ filterable: props2.filterable,
367
+ filterMethod: props2.filterMethod
368
+ },
369
+ // 外层需要补充
370
+ nodeConfig: {
371
+ lazy: props2.props.lazy || false,
372
+ load: props2.props.lazyLoad || null,
373
+ isLeaf: props2.props.isLeaf || "leaf",
374
+ checkStrictly: props2.props.checkStrictly || false,
375
+ afterLoad: props2.props.afterLoad || null,
376
+ // 外层props需要补充以下属性
377
+ currentNodeKey: props2.props.currentNodeKey || null,
378
+ checkDescendants: props2.props.checkDescendants || null,
379
+ defaultCheckedKeys: props2.props.defaultCheckedKeys || null,
380
+ defaultExpandedKeys: props2.props.defaultExpandedKeys || null,
381
+ autoExpandParent: props2.props.autoExpandParent || null,
382
+ defaultExpandAll: props2.props.defaultExpandAll || null,
383
+ filterNodeMethod: props2.props.filterNodeMethod || null
384
+ }
385
+ });
386
+ return mobileProp;
387
+ });
388
+ var updateValue = function updateValue2(value) {
389
+ ctx.emit("update:modelValue", value);
390
+ visible.value = false;
391
+ };
392
+ var updateText = function updateText2(value) {
393
+ showText.value = value;
394
+ };
395
+ return {
396
+ bp,
397
+ visible,
398
+ showText,
399
+ computedMobileProp,
400
+ updateValue,
401
+ updateText
402
+ };
403
+ }
404
+ });
405
+ var render = function render2() {
406
+ var _vm = this;
407
+ var _h = _vm.$createElement;
408
+ var _c = _vm._self._c || _h;
409
+ return _vm.bp !== "default" ? _c("tiny-pc-first", _vm._b({
410
+ on: {
411
+ "update:modelValue": _vm.updateValue
412
+ }
413
+ }, "tiny-pc-first", _vm.$props, false)) : _c("div", [_c("tiny-input", {
414
+ attrs: {
415
+ "tiny_mode": "mobile-first",
416
+ "model-value": _vm.showText,
417
+ "disabled": _vm.disabled,
418
+ "placeholder": _vm.placeholder,
419
+ "readonly": ""
420
+ },
421
+ on: {
422
+ "click": function click($event) {
423
+ _vm.visible = true;
424
+ }
425
+ },
426
+ scopedSlots: _vm._u([{
427
+ key: "suffix",
428
+ fn: function fn() {
429
+ return [_c("div", [_c("icon-chevron-right", {
430
+ class: [_vm.visible ? "fill-color-brand" : "", _vm.disabled ? "fill-color-icon-placeholder sm:fill-color-icon-secondary" : "fill-color-icon-secondary"],
431
+ attrs: {
432
+ "custom-class": "w-5 h-5"
433
+ }
434
+ })], 1)];
435
+ },
436
+ proxy: true
437
+ }])
438
+ }), _c("tiny-cascader-mobile", _vm._b({
439
+ attrs: {
440
+ "model-value": _vm.modelValue,
441
+ "visible": _vm.visible
442
+ },
443
+ on: {
444
+ "update:modelValue": _vm.updateValue,
445
+ "close": function close($event) {
446
+ _vm.visible = false;
447
+ },
448
+ "update:text": _vm.updateText
449
+ }
450
+ }, "tiny-cascader-mobile", _vm.computedMobileProp, false))], 1);
451
+ };
452
+ var staticRenderFns = [];
453
+ var __cssModules = {};
454
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
455
+ function __vue2_injectStyles(context) {
456
+ for (var o in __cssModules) {
457
+ this[o] = __cssModules[o];
458
+ }
459
+ }
460
+ var mobileFirst = /* @__PURE__ */ function() {
461
+ return __component__.exports;
462
+ }();
463
+
464
+ export { mobileFirst as default };
package/lib/pc.js ADDED
@@ -0,0 +1,405 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/cascader/vue';
2
+ import { defineComponent, props, directive, setup } from '@opentinyvue/vue-common';
3
+ import Clickoutside from '@opentinyvue/vue-renderless/common/deps/clickoutside';
4
+ import { HighlightQuery } from '@opentinyvue/vue-directive';
5
+ import Input from '@opentinyvue/vue-input';
6
+ import Tag from '@opentinyvue/vue-tag';
7
+ import Scrollbar from '@opentinyvue/vue-scrollbar';
8
+ import CascaderPanel from '@opentinyvue/vue-cascader-panel';
9
+ import FilterBox from '@opentinyvue/vue-filter-box';
10
+ import Tooltip from '@opentinyvue/vue-tooltip';
11
+ import { iconClose, IconTriangleDown, IconUpWard, iconYes } from '@opentinyvue/vue-icon';
12
+ import '@opentinyvue/vue-theme/cascader/index.css';
13
+
14
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
15
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
16
+ if (render) {
17
+ options.render = render;
18
+ options.staticRenderFns = staticRenderFns;
19
+ options._compiled = true;
20
+ }
21
+ var hook;
22
+ if (injectStyles) {
23
+ hook = injectStyles;
24
+ }
25
+ if (hook) {
26
+ if (options.functional) {
27
+ options._injectStyles = hook;
28
+ var originalRender = options.render;
29
+ options.render = function renderWithStyleInjection(h, context) {
30
+ hook.call(context);
31
+ return originalRender(h, context);
32
+ };
33
+ } else {
34
+ var existing = options.beforeCreate;
35
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
36
+ }
37
+ }
38
+ return {
39
+ exports: scriptExports,
40
+ options
41
+ };
42
+ }
43
+
44
+ function _extends() {
45
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
46
+ for (var e = 1; e < arguments.length; e++) {
47
+ var t = arguments[e];
48
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
49
+ }
50
+ return n;
51
+ }, _extends.apply(null, arguments);
52
+ }
53
+ var __vue2_script = defineComponent({
54
+ props: [].concat(props, ["modelValue", "options", "props", "size", "placeholder", "disabled", "clearable", "filterable", "filterMethod", "separator", "showAllLevels", "collapseTags", "debounce", "beforeFilter", "popperClass", "placement", "popperOptions", "visibleArrow", "offset", "boundariesPadding", "arrowOffset", "popperAppendToBody", "autoSize", "displayOnly", "shape", "label", "tip", "hoverExpand", "blank"]),
55
+ emits: ["update:modelValue", "change", "visible-change", "focus", "blur", "expand-change", "active-item-change", "remove-tag", "created"],
56
+ directives: _extends({}, directive({
57
+ Clickoutside
58
+ }), {
59
+ HighlightQuery
60
+ }),
61
+ provide: function provide() {
62
+ return {
63
+ cascaderRoot: this
64
+ };
65
+ },
66
+ components: {
67
+ TinyInput: Input,
68
+ TinyTag: Tag,
69
+ TinyScrollbar: Scrollbar,
70
+ TinyFilterBox: FilterBox,
71
+ TinyCascaderPanel: CascaderPanel,
72
+ IconClose: iconClose(),
73
+ IconChevronDown: IconTriangleDown(),
74
+ IconChevronUp: IconUpWard(),
75
+ IconYes: iconYes(),
76
+ TinyTooltip: Tooltip
77
+ },
78
+ setup: function setup$1(props2, context) {
79
+ return setup({
80
+ props: props2,
81
+ context,
82
+ renderless,
83
+ api
84
+ });
85
+ }
86
+ });
87
+ var render = function render2() {
88
+ var _vm = this;
89
+ var _h = _vm.$createElement;
90
+ var _c = _vm._self._c || _h;
91
+ return _c("div", {
92
+ directives: [{
93
+ name: "clickoutside",
94
+ rawName: "v-clickoutside",
95
+ value: function value() {
96
+ return _vm.toggleDropDownVisible(false);
97
+ },
98
+ expression: "() => toggleDropDownVisible(false)"
99
+ }],
100
+ ref: "reference",
101
+ class: ["tiny-cascader", _vm.state.realSize && "tiny-cascader--" + _vm.state.realSize, {
102
+ "is-disabled": _vm.state.isDisabled
103
+ }, {
104
+ "tiny-cascader-multiple": _vm.state.multiple
105
+ }, {
106
+ "is-display-only": _vm.state.isDisplayOnly
107
+ }, {
108
+ "show-auto-width": _vm.state.showAutoWidth
109
+ }, {
110
+ "is-hover-expand": _vm.hoverExpand
111
+ }],
112
+ on: {
113
+ "mouseenter": function mouseenter($event) {
114
+ _vm.state.inputHover = true;
115
+ },
116
+ "mouseleave": function mouseleave($event) {
117
+ _vm.state.inputHover = false;
118
+ },
119
+ "click": function click() {
120
+ return _vm.toggleDropDownVisible(_vm.state.readonly ? void 0 : true);
121
+ },
122
+ "keydown": _vm.handleKeyDown
123
+ }
124
+ }, [_vm.shape === "filter" ? _c("tiny-filter-box", {
125
+ attrs: {
126
+ "show-close": _vm.clearable,
127
+ "placeholder": _vm.placeholder,
128
+ "disabled": _vm.state.isDisabled,
129
+ "label": _vm.label,
130
+ "tip": _vm.tip,
131
+ "value": _vm.state.multiple ? _vm.state.presentTags.map(function(item) {
132
+ return item.text;
133
+ }).join("; ") : _vm.state.inputValue,
134
+ "drop-down-visible": _vm.state.dropDownVisible,
135
+ "blank": _vm.blank
136
+ },
137
+ on: {
138
+ "click": function click($event) {
139
+ $event.stopPropagation();
140
+ return _vm.toggleDropDownVisible();
141
+ }
142
+ }
143
+ }) : _vm._e(), _c("div", {
144
+ staticClass: "tiny-cascader-content"
145
+ }, [_vm.shape !== "filter" ? _c("tiny-input", {
146
+ ref: "input",
147
+ class: {
148
+ "is-focus": _vm.state.dropDownVisible
149
+ },
150
+ attrs: {
151
+ "model-value": _vm.state.multiple ? _vm.state.presentText : _vm.state.inputValue,
152
+ "size": _vm.state.realSize,
153
+ "placeholder": _vm.state.placeholder,
154
+ "readonly": _vm.state.readonly,
155
+ "disabled": _vm.state.isDisabled,
156
+ "display-only": _vm.displayOnly,
157
+ "display-only-content": _vm.state.multiple ? _vm.state.presentTags.map(function(item) {
158
+ return item.text;
159
+ }).join("; ") : "",
160
+ "validate-event": false
161
+ },
162
+ on: {
163
+ "focus": _vm.handleFocus,
164
+ "blur": _vm.handleBlur,
165
+ "update:modelValue": function updateModelValue(val) {
166
+ return _vm.handleInput(val, {});
167
+ }
168
+ },
169
+ scopedSlots: _vm._u([{
170
+ key: "suffix",
171
+ fn: function fn() {
172
+ return [_vm.state.clearBtnVisible ? _c("icon-close", {
173
+ key: "clear",
174
+ class: ["tiny-input__icon", "tiny-input__icon-close"],
175
+ on: {
176
+ "click": function click($event) {
177
+ $event.stopPropagation();
178
+ return _vm.handleClear.apply(null, arguments);
179
+ }
180
+ }
181
+ }) : _c(_vm.state.dropDownVisible ? "icon-chevron-up" : "icon-chevron-down", {
182
+ key: "arrow-down",
183
+ tag: "component",
184
+ class: ["tiny-input__icon", _vm.state.dropDownVisible && "is-reverse"],
185
+ on: {
186
+ "click": function click($event) {
187
+ $event.stopPropagation();
188
+ return _vm.toggleDropDownVisible();
189
+ }
190
+ }
191
+ })];
192
+ },
193
+ proxy: true
194
+ }], null, false, 1295602185)
195
+ }) : _vm._e(), _vm.state.multiple && !_vm.state.isDisplayOnly && !_vm.shape ? _c("div", {
196
+ ref: "tags-content",
197
+ staticClass: "tiny-cascader__tags",
198
+ class: {
199
+ "is-expand-content": _vm.hoverExpand && !_vm.state.isDisabled && (_vm.state.inputHover || _vm.state.dropDownVisible)
200
+ }
201
+ }, [_vm.hoverExpand ? _c("tiny-tag", {
202
+ class: ["tiny-cascader__tags-collapse", {
203
+ "is-hidden": _vm.state.isHidden
204
+ }],
205
+ attrs: {
206
+ "type": _vm.state.tagTypeWhenMultiple,
207
+ "closable": false,
208
+ "size": _vm.state.tagSize
209
+ }
210
+ }, [_vm._v("+ " + _vm._s(_vm.state.collapseTagsLength) + " ")]) : _vm._e(), _vm._l(_vm.state.presentTags, function(tag, index) {
211
+ return _c("tiny-tag", {
212
+ key: tag.key,
213
+ attrs: {
214
+ "type": _vm.state.tagTypeWhenMultiple,
215
+ "size": _vm.state.tagSize,
216
+ "hit": tag.hitState,
217
+ "closable": tag.closable,
218
+ "disable-transitions": ""
219
+ },
220
+ on: {
221
+ "close": function close($event) {
222
+ return _vm.deleteTag(index);
223
+ }
224
+ },
225
+ nativeOn: {
226
+ "mouseenter": function mouseenter($event) {
227
+ return _vm.handleMouseenter.apply(null, arguments);
228
+ },
229
+ "mouseleave": function mouseleave($event) {
230
+ return _vm.handleMouseleave.apply(null, arguments);
231
+ }
232
+ }
233
+ }, [_c("span", [_vm._v(_vm._s(tag.text))])]);
234
+ }), _vm.filterable && !_vm.state.isDisabled ? _c("input", {
235
+ directives: [{
236
+ name: "model",
237
+ rawName: "v-model.trim",
238
+ value: _vm.state.inputValue,
239
+ expression: "state.inputValue",
240
+ modifiers: {
241
+ "trim": true
242
+ }
243
+ }],
244
+ staticClass: "tiny-cascader__search-input",
245
+ attrs: {
246
+ "type": "text",
247
+ "placeholder": _vm.state.presentTags.length ? "" : _vm.placeholder
248
+ },
249
+ domProps: {
250
+ "value": _vm.state.inputValue
251
+ },
252
+ on: {
253
+ "input": [function($event) {
254
+ if ($event.target.composing) return;
255
+ _vm.$set(_vm.state, "inputValue", $event.target.value.trim());
256
+ }, function(e) {
257
+ return _vm.handleInput(_vm.state.inputValue, e);
258
+ }],
259
+ "click": function click($event) {
260
+ $event.stopPropagation();
261
+ return _vm.toggleDropDownVisible(true);
262
+ },
263
+ "keydown": function keydown($event) {
264
+ if (!$event.type.indexOf("key") && _vm._k($event.keyCode, "delete", [8, 46], $event.key, ["Backspace", "Delete", "Del"])) return null;
265
+ return _vm.handleDelete.apply(null, arguments);
266
+ },
267
+ "blur": function blur($event) {
268
+ return _vm.$forceUpdate();
269
+ }
270
+ }
271
+ }) : _vm._e()], 2) : _vm._e()], 1), _c("tiny-tooltip", {
272
+ ref: "tooltip",
273
+ attrs: {
274
+ "manual": true,
275
+ "effect": "light",
276
+ "content": _vm.state.tooltipContent,
277
+ "placement": "top"
278
+ },
279
+ model: {
280
+ value: _vm.state.tooltipVisible,
281
+ callback: function callback($$v) {
282
+ _vm.$set(_vm.state, "tooltipVisible", $$v);
283
+ },
284
+ expression: "state.tooltipVisible"
285
+ }
286
+ }), _c("transition", {
287
+ attrs: {
288
+ "name": "tiny-zoom-in-top"
289
+ },
290
+ on: {
291
+ "after-leave": _vm.handleDropdownLeave
292
+ }
293
+ }, [_c("div", {
294
+ directives: [{
295
+ name: "show",
296
+ rawName: "v-show",
297
+ value: _vm.state.dropDownVisible,
298
+ expression: "state.dropDownVisible"
299
+ }],
300
+ ref: "popper",
301
+ class: ["tiny-popper", "tiny-cascader-dropdown", "tiny-cascader__dropdown", _vm.popperClass, {
302
+ "is-auto-size": _vm.autoSize,
303
+ "is-multiple": _vm.state.multiple
304
+ }],
305
+ on: {
306
+ "mousedown": function mousedown($event) {
307
+ $event.stopPropagation();
308
+ }
309
+ }
310
+ }, [_c("tiny-cascader-panel", {
311
+ directives: [{
312
+ name: "show",
313
+ rawName: "v-show",
314
+ value: !_vm.state.filtering,
315
+ expression: "!state.filtering"
316
+ }],
317
+ ref: "panel",
318
+ attrs: {
319
+ "options": _vm.options,
320
+ "props": _vm.state.config,
321
+ "border": false,
322
+ "render-label": _vm.slots.default,
323
+ "onlyUsePanel": false
324
+ },
325
+ on: {
326
+ "expand-change": _vm.handleExpandChange,
327
+ "close": function close($event) {
328
+ return _vm.toggleDropDownVisible(false);
329
+ },
330
+ "load-data": _vm.computePresentContent
331
+ },
332
+ model: {
333
+ value: _vm.state.checkedValue,
334
+ callback: function callback($$v) {
335
+ _vm.$set(_vm.state, "checkedValue", $$v);
336
+ },
337
+ expression: "state.checkedValue"
338
+ }
339
+ }), _vm.filterable ? _c("tiny-scrollbar", {
340
+ directives: [{
341
+ name: "show",
342
+ rawName: "v-show",
343
+ value: _vm.state.filtering,
344
+ expression: "state.filtering"
345
+ }],
346
+ ref: "suggestionPanel",
347
+ staticClass: "tiny-cascader__suggestion-panel",
348
+ attrs: {
349
+ "tag": "ul",
350
+ "view-class": "tiny-cascader__suggestion-list"
351
+ },
352
+ on: {
353
+ "keydown": _vm.handleSuggestionKeyDown
354
+ },
355
+ scopedSlots: _vm._u([_vm.state.suggestions.length ? {
356
+ key: "default",
357
+ fn: function fn() {
358
+ return _vm._l(_vm.state.suggestions, function(item, index) {
359
+ return _c("li", {
360
+ directives: [{
361
+ name: "highlight-query",
362
+ rawName: "v-highlight-query",
363
+ value: _vm.state.multiple ? _vm.state.presentText : _vm.state.inputValue,
364
+ expression: "state.multiple ? state.presentText : state.inputValue"
365
+ }],
366
+ key: item.uid,
367
+ class: ["tiny-cascader__suggestion-item", item.checked && "is-checked"],
368
+ attrs: {
369
+ "tabindex": -1
370
+ },
371
+ on: {
372
+ "click": function click($event) {
373
+ return _vm.handleSuggestionClick(index);
374
+ }
375
+ }
376
+ }, [_vm._t("filter", function() {
377
+ return [_c("span", [_vm._v(_vm._s(item.text))])];
378
+ }, {
379
+ "item": item.text
380
+ }), item.checked ? _c("icon-yes", {
381
+ staticClass: "icon-check"
382
+ }) : _vm._e()], 2);
383
+ });
384
+ },
385
+ proxy: true
386
+ } : null], null, true)
387
+ }, [!_vm.state.suggestions.length ? _vm._t("empty", function() {
388
+ return [_c("li", {
389
+ staticClass: "tiny-cascader__empty-text"
390
+ }, [_vm._v(" " + _vm._s(_vm.t("ui.cascader.noMatch")) + " ")])];
391
+ }) : _vm._e()], 2) : _vm._e()], 1)])], 1);
392
+ };
393
+ var staticRenderFns = [];
394
+ var __cssModules = {};
395
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
396
+ function __vue2_injectStyles(context) {
397
+ for (var o in __cssModules) {
398
+ this[o] = __cssModules[o];
399
+ }
400
+ }
401
+ var pc = /* @__PURE__ */ function() {
402
+ return __component__.exports;
403
+ }();
404
+
405
+ export { pc as default };
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@opentinyvue/vue-cascader",
3
+ "type": "module",
4
+ "version": "2.21.0",
5
+ "description": "",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "main": "./lib/index.js",
9
+ "module": "./lib/index.js",
10
+ "dependencies": {
11
+ "@opentinyvue/vue-cascader-mobile": "~2.21.0",
12
+ "@opentinyvue/vue-cascader-panel": "~2.21.0",
13
+ "@opentinyvue/vue-common": "~2.21.0",
14
+ "@opentinyvue/vue-directive": "~2.21.0",
15
+ "@opentinyvue/vue-filter-box": "~2.21.0",
16
+ "@opentinyvue/vue-icon": "~2.21.0",
17
+ "@opentinyvue/vue-input": "~2.21.0",
18
+ "@opentinyvue/vue-locale": "~2.21.0",
19
+ "@opentinyvue/vue-renderless": "~3.21.0",
20
+ "@opentinyvue/vue-scrollbar": "~2.21.0",
21
+ "@opentinyvue/vue-tag": "~2.21.0",
22
+ "@opentinyvue/vue-theme": "~3.21.0",
23
+ "@opentinyvue/vue-tooltip": "~2.21.0"
24
+ },
25
+ "types": "index.d.ts",
26
+ "scripts": {
27
+ "build": "pnpm -w build:ui $npm_package_name",
28
+ "//postversion": "pnpm build"
29
+ }
30
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ export declare const cascaderProps: {
2
+ _constants: {
3
+ type: ObjectConstructor;
4
+ default: () => {
5
+ placeholder: string;
6
+ COMPONENT_NAME: {
7
+ FormItem: string;
8
+ };
9
+ EVENT_NAME: {
10
+ FormBlur: string;
11
+ FormChange: string;
12
+ };
13
+ defaultNodeConfig: {
14
+ lazy: boolean;
15
+ load: null;
16
+ isLeaf: string;
17
+ afterLoad: null;
18
+ currentNodeKey: null;
19
+ checkStrictly: boolean;
20
+ checkDescendants: null;
21
+ defaultCheckedKeys: null;
22
+ defaultExpandedKeys: null;
23
+ autoExpandParent: null;
24
+ defaultExpandAll: null;
25
+ filterNodeMethod: null;
26
+ };
27
+ };
28
+ };
29
+ autoSize: BooleanConstructor;
30
+ beforeFilter: {
31
+ type: FunctionConstructor;
32
+ default: () => () => void;
33
+ };
34
+ clearable: BooleanConstructor;
35
+ collapseTags: BooleanConstructor;
36
+ debounce: {
37
+ type: NumberConstructor;
38
+ default: number;
39
+ };
40
+ disabled: BooleanConstructor;
41
+ filterMethod: FunctionConstructor;
42
+ filterable: BooleanConstructor;
43
+ modelValue: {};
44
+ options: ArrayConstructor;
45
+ placeholder: {
46
+ type: StringConstructor;
47
+ default: any;
48
+ };
49
+ popperAppendToBody: {
50
+ type: BooleanConstructor;
51
+ default: boolean;
52
+ };
53
+ popperClass: StringConstructor;
54
+ props: {
55
+ type: ObjectConstructor;
56
+ default: () => {};
57
+ };
58
+ separator: {
59
+ type: StringConstructor;
60
+ default: string;
61
+ };
62
+ showAllLevels: {
63
+ type: BooleanConstructor;
64
+ default: boolean;
65
+ };
66
+ size: StringConstructor;
67
+ shape: StringConstructor;
68
+ label: StringConstructor;
69
+ tip: StringConstructor;
70
+ displayOnly: {
71
+ type: BooleanConstructor;
72
+ default: boolean;
73
+ };
74
+ hoverExpand: {
75
+ type: BooleanConstructor;
76
+ default: boolean;
77
+ };
78
+ title: StringConstructor;
79
+ showHeader: {
80
+ type: BooleanConstructor;
81
+ default: boolean;
82
+ };
83
+ levelTitle: ArrayConstructor;
84
+ blank: {
85
+ type: BooleanConstructor;
86
+ default: boolean;
87
+ };
88
+ tiny_mode: StringConstructor;
89
+ tiny_mode_root: BooleanConstructor;
90
+ tiny_template: (ObjectConstructor | FunctionConstructor)[];
91
+ tiny_renderless: FunctionConstructor;
92
+ tiny_theme: StringConstructor;
93
+ tiny_chart_theme: ObjectConstructor;
94
+ };
95
+ declare const _default: any;
96
+ 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;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
package/src/token.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const classes: {
2
+ 'type-medium': string;
3
+ 'type-small': string;
4
+ 'type-mini': string;
5
+ 'show-auto-width': string;
6
+ };