@opentinyvue/vue-cascader-mobile 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,2 @@
1
+ import CascaderMobile from './src/mobile-first.vue';
2
+ export default CascaderMobile;
package/lib/index.js ADDED
@@ -0,0 +1,546 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/cascader-mobile/vue';
2
+ import { defineComponent, $prefix, $props, setup } from '@opentinyvue/vue-common';
3
+ import { IconCheck, IconYes, IconLoading, IconCheckedSur, IconHalfselect, IconSearch } from '@opentinyvue/vue-icon';
4
+ import Button from '@opentinyvue/vue-button';
5
+ import ActionSheet from '@opentinyvue/vue-action-sheet';
6
+ import Exception from '@opentinyvue/vue-exception';
7
+ import { t } from '@opentinyvue/vue-locale';
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 t2 = arguments[e];
43
+ for (var r in t2) ({}).hasOwnProperty.call(t2, r) && (n[r] = t2[r]);
44
+ }
45
+ return n;
46
+ }, _extends.apply(null, arguments);
47
+ }
48
+ var render$1 = function render$12() {
49
+ var _vm = this;
50
+ var _h = _vm.$createElement;
51
+ var _c = _vm._self._c || _h;
52
+ return _c("div", {
53
+ staticClass: "flex items-start leading-5.5 py-3 cursor-pointer select-none",
54
+ on: {
55
+ "click": function click($event) {
56
+ return _vm.$emit("click", $event);
57
+ }
58
+ }
59
+ }, [_vm.multiple ? _c(_vm.selected ? "icon-checked-sur" : "icon-check", {
60
+ tag: "component",
61
+ class: ["flex-none mt-1 mr-2", _vm.selected ? "fill-color-brand" : "fill-color-icon-disabled"],
62
+ attrs: {
63
+ "custom-class": "w-4.5 h-4.5"
64
+ }
65
+ }) : _vm._e(), _c("div", {
66
+ class: ["flex-auto flex w-full text-sm", {
67
+ "truncate": _vm.ellipsis
68
+ }, {
69
+ "text-color-brand": !_vm.multiple && _vm.selected
70
+ }]
71
+ }, [_vm._t("default", function() {
72
+ return [_c("div", {
73
+ class: ["flex-auto", {
74
+ "truncate": _vm.ellipsis
75
+ }]
76
+ }, [_c("div", {
77
+ staticClass: "flex"
78
+ }, [_c("div", {
79
+ class: [{
80
+ "min-w-[theme(spacing.14)]": !_vm.textField3
81
+ }, {
82
+ "truncate": _vm.ellipsis
83
+ }]
84
+ }, [_vm._v(" " + _vm._s(_vm.data[_vm.textField]) + " ")]), _vm.textField2 ? _c("div", {
85
+ class: ["ml-5 text-color-text-placeholder", {
86
+ "truncate": _vm.ellipsis
87
+ }]
88
+ }, [_vm._v(" " + _vm._s(_vm.data[_vm.textField2]) + " ")]) : _vm._e()]), _vm.textField3 ? _c("div", {
89
+ class: ["text-color-text-placeholder", {
90
+ "truncate": _vm.ellipsis
91
+ }]
92
+ }, [_vm._v(" " + _vm._s(_vm.data[_vm.textField3]) + " ")]) : _vm._e()]), !_vm.loading && !_vm.multiple && _vm.selected ? _c("div", {
93
+ staticClass: "flex flex-none w-5 items-center justify-center ml-2"
94
+ }, [_c("IconYes", {
95
+ staticClass: "fill-color-brand",
96
+ attrs: {
97
+ "custom-class": "w-5 h-5"
98
+ }
99
+ })], 1) : _vm._e(), _vm.option.loading ? _c("div", {
100
+ staticClass: "flex flex-none w-5 items-center justify-center ml-2"
101
+ }, [_c("svg", {
102
+ staticClass: "animate-[spin_1.5s_linear_infinite] fill-current",
103
+ attrs: {
104
+ "viewBox": "25 25 50 50"
105
+ }
106
+ }, [_c("circle", {
107
+ staticClass: "stroke-color-brand tiny-loading-path",
108
+ attrs: {
109
+ "cx": "50",
110
+ "cy": "50",
111
+ "r": "24",
112
+ "fill": "none"
113
+ }
114
+ })])]) : _vm._e()];
115
+ })], 2)], 1);
116
+ };
117
+ var staticRenderFns$1 = [];
118
+ var __vue2_script$1 = {
119
+ emits: ["click"],
120
+ components: {
121
+ IconCheck: IconCheck(),
122
+ IconYes: IconYes(),
123
+ IconLoading: IconLoading(),
124
+ IconCheckedSur: IconCheckedSur(),
125
+ IconHalfselect: IconHalfselect()
126
+ },
127
+ props: ["selected", "ellipsis", "multiple", "option", "textField", "textField2", "textField3", "loading"],
128
+ computed: {
129
+ data: function data() {
130
+ return this.option.data || this.option;
131
+ }
132
+ }
133
+ };
134
+ var __cssModules$1 = {};
135
+ var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1);
136
+ function __vue2_injectStyles$1(context) {
137
+ for (var o in __cssModules$1) {
138
+ this[o] = __cssModules$1[o];
139
+ }
140
+ }
141
+ var Option = /* @__PURE__ */ function() {
142
+ return __component__$1.exports;
143
+ }();
144
+ var $constants = {
145
+ defaultNodeConfig: {
146
+ lazy: false,
147
+ load: null,
148
+ isLeaf: "leaf",
149
+ afterLoad: null,
150
+ currentNodeKey: null,
151
+ checkStrictly: false,
152
+ checkDescendants: null,
153
+ defaultCheckedKeys: null,
154
+ defaultExpandedKeys: null,
155
+ autoExpandParent: null,
156
+ defaultExpandAll: null,
157
+ filterNodeMethod: null
158
+ }
159
+ };
160
+ var __vue2_script = defineComponent({
161
+ name: $prefix + "CascaderMobile",
162
+ emits: ["click", "search-click", "node-expand", "close", "update:modelValue", "confirm", "update:visible", "update:text"],
163
+ components: {
164
+ TinyActionSheet: ActionSheet,
165
+ TinyOption: Option,
166
+ TinyButton: Button,
167
+ TinyException: Exception,
168
+ IconSearch: IconSearch()
169
+ },
170
+ props: _extends({}, $props, {
171
+ _constants: {
172
+ type: Object,
173
+ default: function _default() {
174
+ return $constants;
175
+ }
176
+ },
177
+ data: {
178
+ type: Array,
179
+ default: function _default2() {
180
+ return [];
181
+ }
182
+ },
183
+ modelValue: [Number, String, Array],
184
+ visible: {
185
+ type: Boolean,
186
+ default: false
187
+ },
188
+ ellipsis: {
189
+ type: Boolean,
190
+ default: false
191
+ },
192
+ valueField: {
193
+ type: String,
194
+ default: "id"
195
+ },
196
+ placeholder: {
197
+ type: [String, Array],
198
+ default: t("ui.select.placeholder")
199
+ },
200
+ childrenField: {
201
+ type: String,
202
+ default: "children"
203
+ },
204
+ textField: {
205
+ type: String,
206
+ default: "label"
207
+ },
208
+ textField2: {
209
+ type: String,
210
+ default: ""
211
+ },
212
+ textField3: {
213
+ type: String,
214
+ default: ""
215
+ },
216
+ title: String,
217
+ textSplit: {
218
+ type: String,
219
+ default: " / "
220
+ },
221
+ showHeader: {
222
+ type: Boolean,
223
+ default: true
224
+ },
225
+ multiple: Boolean,
226
+ searchConfig: {
227
+ type: Object,
228
+ default: function _default3() {
229
+ return {
230
+ options: [],
231
+ searchMethod: null,
232
+ openSearchSlot: false
233
+ };
234
+ }
235
+ },
236
+ nodeConfig: {
237
+ type: Object,
238
+ default: function _default4() {
239
+ return $constants.defaultNodeConfig;
240
+ }
241
+ }
242
+ }),
243
+ setup: function setup$1(props, context) {
244
+ return setup({
245
+ props,
246
+ context,
247
+ renderless,
248
+ api,
249
+ mono: true
250
+ });
251
+ }
252
+ });
253
+ var render = function render2() {
254
+ var _vm = this;
255
+ var _h = _vm.$createElement;
256
+ var _c = _vm._self._c || _h;
257
+ return _c("div", {
258
+ directives: [{
259
+ name: "show",
260
+ rawName: "v-show",
261
+ value: _vm.visible,
262
+ expression: "visible"
263
+ }],
264
+ attrs: {
265
+ "data-tag": "tiny-cascader-mobile"
266
+ }
267
+ }, [_c("tiny-action-sheet", {
268
+ attrs: {
269
+ "tiny_mode": "mobile-first",
270
+ "title": _vm.title,
271
+ "show-footer": "",
272
+ "visible": _vm.state.toggle,
273
+ "show-header": !_vm.state.search.show,
274
+ "custom-class": ["min-h-[95%] pb-4"]
275
+ },
276
+ on: {
277
+ "update:visible": function updateVisible($event) {
278
+ return _vm.$emit("update:visible", $event);
279
+ },
280
+ "close": _vm.close
281
+ },
282
+ scopedSlots: _vm._u([{
283
+ key: "body-top",
284
+ fn: function fn() {
285
+ return [_c("div", {
286
+ directives: [{
287
+ name: "show",
288
+ rawName: "v-show",
289
+ value: !_vm.state.search.show,
290
+ expression: "!state.search.show"
291
+ }],
292
+ staticClass: "h-11 flex-none flex items-center border-b-0.5 border-color-border-separator overflow-auto whitespace-nowrap scrollbar-size-0"
293
+ }, [_c("div", {
294
+ staticClass: "px-4 flex"
295
+ }, [_vm._l(_vm.state.computedNavList, function(option, index) {
296
+ return _c("div", {
297
+ key: index,
298
+ staticClass: "flex-none flex leading-5.5"
299
+ }, [index <= _vm.state.level ? [index !== 0 ? _c("span", {
300
+ staticClass: "px-2 text-color-text-placeholder"
301
+ }, [_vm._v("/")]) : _vm._e(), _c("span", {
302
+ class: ["flex-none max-w-[theme(spacing.24)] truncate", {
303
+ "text-color-brand": index === _vm.state.level
304
+ }, _vm.disabledNavOption(index, option) ? "text-color-text-disabled" : "cursor-pointer"],
305
+ on: {
306
+ "click": function click($event) {
307
+ return _vm.setLevel(index, option);
308
+ }
309
+ }
310
+ }, [_vm._v(_vm._s(option.data[_vm.textField]))])] : _vm._e()], 2);
311
+ }), _c("div", {
312
+ staticClass: "flex-auto"
313
+ })], 2)]), _c("div", {
314
+ directives: [{
315
+ name: "show",
316
+ rawName: "v-show",
317
+ value: _vm.state.search.show,
318
+ expression: "state.search.show"
319
+ }],
320
+ staticClass: "flex leading-6 pt-4 pb-4 px-4 text-base items-center",
321
+ attrs: {
322
+ "data-tag": "search-header"
323
+ }
324
+ }, [_c("div", {
325
+ staticClass: "flex-auto flex items-center h-8 py-1 px-3 bg-color-bg-4 rounded-full"
326
+ }, [_c("IconSearch", {
327
+ staticClass: "mr-1 fill-color-icon-disabled",
328
+ attrs: {
329
+ "custom-class": "h-4 w-4"
330
+ }
331
+ }), _c("input", {
332
+ directives: [{
333
+ name: "model",
334
+ rawName: "v-model",
335
+ value: _vm.state.search.input,
336
+ expression: "state.search.input"
337
+ }],
338
+ staticClass: "h-5 flex-auto text-xs bg-transparent outline-0",
339
+ attrs: {
340
+ "placeholder": _vm.t("ui.select.pleaseSearch")
341
+ },
342
+ domProps: {
343
+ "value": _vm.state.search.input
344
+ },
345
+ on: {
346
+ "input": [function($event) {
347
+ if ($event.target.composing) return;
348
+ _vm.$set(_vm.state.search, "input", $event.target.value);
349
+ }, _vm.searchMethod]
350
+ }
351
+ })], 1), _c("div", {
352
+ staticClass: "flex items-center pl-3 cursor-pointer"
353
+ }, [_c("div", {
354
+ on: {
355
+ "click": function click($event) {
356
+ return _vm.searchBoxToggle(false);
357
+ }
358
+ }
359
+ }, [_vm._v(_vm._s(_vm.t("ui.base.cancel")))])])])];
360
+ },
361
+ proxy: true
362
+ }, {
363
+ key: "header-left",
364
+ fn: function fn() {
365
+ return [!_vm.state.search.show ? _c("IconSearch", {
366
+ staticClass: "cursor-pointer",
367
+ attrs: {
368
+ "custom-class": "h-5 w-5"
369
+ },
370
+ on: {
371
+ "click": function click($event) {
372
+ return _vm.searchBoxToggle(true);
373
+ }
374
+ }
375
+ }) : _vm._e()];
376
+ },
377
+ proxy: true
378
+ }, {
379
+ key: "footer",
380
+ fn: function fn() {
381
+ return [_c("tiny-button", {
382
+ directives: [{
383
+ name: "show",
384
+ rawName: "v-show",
385
+ value: _vm.state.showButton,
386
+ expression: "state.showButton"
387
+ }],
388
+ staticClass: "flex-1 mx-4 sm:mx-0",
389
+ attrs: {
390
+ "tiny_mode": "mobile-first",
391
+ "type": "primary",
392
+ "reset-time": 0
393
+ },
394
+ on: {
395
+ "click": _vm.confirm
396
+ }
397
+ }, [_vm._v(_vm._s(_vm.t("ui.button.confirm")))])];
398
+ },
399
+ proxy: true
400
+ }])
401
+ }, [_c("div", {
402
+ directives: [{
403
+ name: "show",
404
+ rawName: "v-show",
405
+ value: !_vm.state.search.show,
406
+ expression: "!state.search.show"
407
+ }],
408
+ staticClass: "flex-auto",
409
+ attrs: {
410
+ "data-tag": "tabs"
411
+ }
412
+ }, _vm._l(_vm.state.options, function(currentList, index) {
413
+ return _c("div", {
414
+ directives: [{
415
+ name: "show",
416
+ rawName: "v-show",
417
+ value: index === _vm.state.level,
418
+ expression: "index === state.level"
419
+ }],
420
+ key: index,
421
+ staticClass: "flex flex-col px-4 overflow-auto pt-2",
422
+ attrs: {
423
+ "data-tag": "tab-item"
424
+ }
425
+ }, _vm._l(currentList, function(item, itemIndex) {
426
+ return _c("tiny-option", {
427
+ key: item.data[_vm.valueField],
428
+ attrs: {
429
+ "multiple": _vm.multiple,
430
+ "ellipsis": _vm.ellipsis,
431
+ "text-field": _vm.textField,
432
+ "text-field2": _vm.textField2,
433
+ "text-field3": _vm.textField3,
434
+ "loading": _vm.state.loading,
435
+ "option": item,
436
+ "selected": _vm.isSelected(item)
437
+ },
438
+ on: {
439
+ "click": function click($event) {
440
+ return _vm.selectOption(item, $event);
441
+ }
442
+ }
443
+ }, [_vm._t("default", null, {
444
+ "item": item,
445
+ "index": itemIndex
446
+ })], 2);
447
+ }), 1);
448
+ }), 0), _c("div", {
449
+ directives: [{
450
+ name: "show",
451
+ rawName: "v-show",
452
+ value: _vm.state.search.show,
453
+ expression: "state.search.show"
454
+ }],
455
+ staticClass: "flex flex-col flex-auto",
456
+ attrs: {
457
+ "data-tag": "search-box"
458
+ }
459
+ }, [_c("div", {
460
+ staticClass: "flex-auto overflow-auto flex flex-col",
461
+ attrs: {
462
+ "data-tag": "search-body"
463
+ }
464
+ }, [_c("div", {
465
+ directives: [{
466
+ name: "show",
467
+ rawName: "v-show",
468
+ value: _vm.state.search.filterOptions.length,
469
+ expression: "state.search.filterOptions.length"
470
+ }],
471
+ class: ["flex flex-col px-4"]
472
+ }, _vm._l(_vm.state.search.filterOptions, function(item, index) {
473
+ return _c("tiny-option", {
474
+ key: index,
475
+ attrs: {
476
+ "multiple": _vm.multiple,
477
+ "ellipsis": _vm.ellipsis,
478
+ "text-field": _vm.textField,
479
+ "text-field2": _vm.textField2,
480
+ "text-field3": _vm.textField3,
481
+ "option": item,
482
+ "selected": _vm.isSelected(item)
483
+ },
484
+ on: {
485
+ "click": function click($event) {
486
+ return _vm.searchSelectHandler(item, index);
487
+ }
488
+ }
489
+ }, [_vm.searchConfig.openSearchSlot ? _vm._t("search-item", null, {
490
+ "item": item,
491
+ "index": index
492
+ }) : _vm._t("default", function() {
493
+ return [_c("div", {
494
+ class: ["flex-auto", {
495
+ "truncate": _vm.ellipsis
496
+ }]
497
+ }, _vm._l(_vm.renderSearchOption(item[_vm.textField]), function(text, textIndex) {
498
+ return _c("span", {
499
+ key: text
500
+ }, [textIndex ? _c("span", {
501
+ staticClass: "text-color-brand"
502
+ }, [_vm._v(_vm._s(_vm.state.search.input))]) : _vm._e(), _vm._v(_vm._s(text) + " ")]);
503
+ }), 0)];
504
+ }, {
505
+ "item": item,
506
+ "index": index
507
+ })], 2);
508
+ }), 1), _c("div", {
509
+ directives: [{
510
+ name: "show",
511
+ rawName: "v-show",
512
+ value: _vm.state.search.input && !_vm.state.search.filterOptions.length,
513
+ expression: "state.search.input && !state.search.filterOptions.length"
514
+ }],
515
+ staticClass: "w-full flex justify-center items-center text-center flex-auto"
516
+ }, [_c("tiny-exception", {
517
+ attrs: {
518
+ "component-page": "",
519
+ "type": "noresult",
520
+ "tiny_mode": "mobile-first",
521
+ "tiny_mode_root": ""
522
+ }
523
+ })], 1)])])])], 1);
524
+ };
525
+ var staticRenderFns = [];
526
+ var __cssModules = {};
527
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
528
+ function __vue2_injectStyles(context) {
529
+ for (var o in __cssModules) {
530
+ this[o] = __cssModules[o];
531
+ }
532
+ }
533
+ var CascaderMobile = /* @__PURE__ */ function() {
534
+ return __component__.exports;
535
+ }();
536
+ var version = "2.21.0";
537
+ CascaderMobile.model = {
538
+ prop: "modelValue",
539
+ event: "update:modelValue"
540
+ };
541
+ CascaderMobile.install = function(Vue) {
542
+ Vue.component(CascaderMobile.name, CascaderMobile);
543
+ };
544
+ CascaderMobile.version = version;
545
+
546
+ export { CascaderMobile as default };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@opentinyvue/vue-cascader-mobile",
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-button": "~2.21.0",
11
+ "@opentinyvue/vue-action-sheet": "~2.21.0",
12
+ "@opentinyvue/vue-exception": "~2.21.0",
13
+ "@opentinyvue/vue-common": "~2.21.0",
14
+ "@opentinyvue/vue-renderless": "~3.21.0",
15
+ "@opentinyvue/vue-icon": "~2.21.0",
16
+ "@opentinyvue/vue-locale": "~2.21.0"
17
+ },
18
+ "license": "MIT",
19
+ "types": "index.d.ts",
20
+ "scripts": {
21
+ "build": "pnpm -w build:ui $npm_package_name",
22
+ "//postversion": "pnpm build"
23
+ }
24
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue/types/vue").ExtendedVue<import("vue").default, any, any, any, Record<"option" | "ellipsis" | "selected" | "textField" | "multiple" | "loading" | "textField2" | "textField3", any>>;
2
+ export default _default;