persagy-vant 0.0.43 → 0.0.45
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/es/index.d.ts +1 -1
- package/es/index.mjs +1 -1
- package/es/location-select/LocationSelect.d.ts +19 -1
- package/es/location-select/LocationSelect.mjs +123 -19
- package/es/location-select/index.css +1 -1
- package/es/location-select/index.d.ts +14 -1
- package/es/location-select/index.less +1 -0
- package/es/location-select/style/index.mjs +1 -0
- package/es/location-select/style/less.mjs +1 -0
- package/es/location-select/types.d.ts +2 -0
- package/es/location-select/types.mjs +0 -0
- package/es/material-add/MaterialAdd.d.ts +19 -2
- package/es/material-add/MaterialAdd.mjs +99 -8
- package/es/material-add/index.css +1 -1
- package/es/material-add/index.d.ts +14 -2
- package/es/material-add/index.less +1 -1
- package/es/material-add/style/index.mjs +1 -0
- package/es/material-add/style/less.mjs +1 -0
- package/es/material-add/types.d.ts +7 -6
- package/es/object-select/ObjectSelect.d.ts +25 -3
- package/es/object-select/ObjectSelect.mjs +163 -30
- package/es/object-select/index.css +1 -1
- package/es/object-select/index.d.ts +18 -2
- package/es/object-select/index.less +1 -0
- package/es/object-select/style/index.mjs +1 -0
- package/es/object-select/style/less.mjs +1 -0
- package/es/object-select/types.d.ts +1 -0
- package/es/tree-select/TreeSelect.d.ts +7 -1
- package/es/tree-select/TreeSelect.mjs +107 -54
- package/es/tree-select/index.css +1 -1
- package/es/tree-select/index.d.ts +6 -2
- package/es/tree-select/index.less +6 -0
- package/es/tree-select/style/index.mjs +1 -0
- package/es/tree-select/style/less.mjs +1 -0
- package/lib/index.css +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.less +2 -2
- package/lib/location-select/LocationSelect.d.ts +19 -1
- package/lib/location-select/LocationSelect.js +121 -17
- package/lib/location-select/index.css +1 -1
- package/lib/location-select/index.d.ts +14 -1
- package/lib/location-select/index.less +1 -0
- package/lib/location-select/style/index.js +1 -0
- package/lib/location-select/style/less.js +1 -0
- package/lib/location-select/types.d.ts +2 -0
- package/lib/location-select/types.js +15 -0
- package/lib/material-add/MaterialAdd.d.ts +19 -2
- package/lib/material-add/MaterialAdd.js +97 -6
- package/lib/material-add/index.css +1 -1
- package/lib/material-add/index.d.ts +14 -2
- package/lib/material-add/index.less +1 -1
- package/lib/material-add/style/index.js +1 -0
- package/lib/material-add/style/less.js +1 -0
- package/lib/material-add/types.d.ts +7 -6
- package/lib/object-select/ObjectSelect.d.ts +25 -3
- package/lib/object-select/ObjectSelect.js +161 -28
- package/lib/object-select/index.css +1 -1
- package/lib/object-select/index.d.ts +18 -2
- package/lib/object-select/index.less +1 -0
- package/lib/object-select/style/index.js +1 -0
- package/lib/object-select/style/less.js +1 -0
- package/lib/object-select/types.d.ts +1 -0
- package/lib/tree-select/TreeSelect.d.ts +7 -1
- package/lib/tree-select/TreeSelect.js +107 -52
- package/lib/tree-select/index.css +1 -1
- package/lib/tree-select/index.d.ts +6 -2
- package/lib/tree-select/index.less +6 -0
- package/lib/tree-select/style/index.js +1 -0
- package/lib/tree-select/style/less.js +1 -0
- package/lib/vant.cjs.js +492 -118
- package/lib/vant.es.js +493 -119
- package/lib/vant.js +492 -118
- package/lib/vant.min.js +1 -1
- package/lib/web-types.json +1 -1
- package/package.json +1 -1
- package/skills/use-persagy-vant/references/business-component-catalog.md +3 -3
- package/skills/use-persagy-vant/references/component-catalog.md +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -248,7 +248,7 @@ __reExport(stdin_exports, require("./uploader"), module.exports);
|
|
|
248
248
|
__reExport(stdin_exports, require("./video-preview"), module.exports);
|
|
249
249
|
__reExport(stdin_exports, require("./work-order-card"), module.exports);
|
|
250
250
|
__reExport(stdin_exports, require("./work-order-filter"), module.exports);
|
|
251
|
-
const version = "0.0.
|
|
251
|
+
const version = "0.0.45";
|
|
252
252
|
function install(app) {
|
|
253
253
|
const components = [
|
|
254
254
|
import_action_bar.ActionBar,
|
package/lib/index.less
CHANGED
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
@import "./uploader/index.less";
|
|
70
70
|
@import "./tabs/index.less";
|
|
71
71
|
@import "./tab/index.less";
|
|
72
|
-
@import "./object-select/index.less";
|
|
73
|
-
@import "./location-select/index.less";
|
|
74
72
|
@import "./cascader/index.less";
|
|
75
73
|
@import "./cell-group/index.less";
|
|
76
74
|
@import "./empty/index.less";
|
|
77
75
|
@import "./tree-select-panel/index.less";
|
|
78
76
|
@import "./radio-panel/index.less";
|
|
77
|
+
@import "./object-select/index.less";
|
|
78
|
+
@import "./location-select/index.less";
|
|
79
79
|
@import "./coupon-list/index.less";
|
|
80
80
|
@import "./checkbox-panel/index.less";
|
|
81
81
|
@import "./circle/index.less";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ExtractPropTypes, type PropType } from 'vue';
|
|
2
2
|
import { type Numeric } from '../utils';
|
|
3
3
|
import { type TreeSelectItem } from '../tree-select';
|
|
4
|
+
import type { LocationSelectSearch } from './types';
|
|
4
5
|
declare const props: {
|
|
5
6
|
show: BooleanConstructor;
|
|
6
7
|
modelValue: PropType<Numeric | undefined>;
|
|
@@ -16,6 +17,11 @@ declare const props: {
|
|
|
16
17
|
type: PropType<string[]>;
|
|
17
18
|
default: () => never[];
|
|
18
19
|
};
|
|
20
|
+
search: PropType<LocationSelectSearch>;
|
|
21
|
+
searchDebounce: {
|
|
22
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
23
|
+
default: number;
|
|
24
|
+
};
|
|
19
25
|
};
|
|
20
26
|
export declare type LocationSelectProps = ExtractPropTypes<typeof props>;
|
|
21
27
|
declare const _default: import("vue").DefineComponent<{
|
|
@@ -33,7 +39,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
33
39
|
type: PropType<string[]>;
|
|
34
40
|
default: () => never[];
|
|
35
41
|
};
|
|
36
|
-
|
|
42
|
+
search: PropType<LocationSelectSearch>;
|
|
43
|
+
searchDebounce: {
|
|
44
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
45
|
+
default: number;
|
|
46
|
+
};
|
|
47
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue" | "update:show" | "search-error")[], "change" | "update:modelValue" | "update:show" | "search-error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
37
48
|
show: BooleanConstructor;
|
|
38
49
|
modelValue: PropType<Numeric | undefined>;
|
|
39
50
|
title: {
|
|
@@ -48,14 +59,21 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
48
59
|
type: PropType<string[]>;
|
|
49
60
|
default: () => never[];
|
|
50
61
|
};
|
|
62
|
+
search: PropType<LocationSelectSearch>;
|
|
63
|
+
searchDebounce: {
|
|
64
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
65
|
+
default: number;
|
|
66
|
+
};
|
|
51
67
|
}>> & {
|
|
52
68
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
53
69
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
54
70
|
"onUpdate:show"?: ((...args: any[]) => any) | undefined;
|
|
71
|
+
"onSearch-error"?: ((...args: any[]) => any) | undefined;
|
|
55
72
|
}, {
|
|
56
73
|
title: string;
|
|
57
74
|
show: boolean;
|
|
58
75
|
items: TreeSelectItem[][];
|
|
59
76
|
tabTitles: string[];
|
|
77
|
+
searchDebounce: string | number;
|
|
60
78
|
}>;
|
|
61
79
|
export default _default;
|
|
@@ -15,6 +15,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
return to;
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __async = (__this, __arguments, generator) => {
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
var fulfilled = (value) => {
|
|
21
|
+
try {
|
|
22
|
+
step(generator.next(value));
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var rejected = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
step(generator.throw(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
35
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
36
|
+
});
|
|
37
|
+
};
|
|
18
38
|
var stdin_exports = {};
|
|
19
39
|
__export(stdin_exports, {
|
|
20
40
|
default: () => stdin_default
|
|
@@ -25,7 +45,9 @@ var import_utils = require("../utils");
|
|
|
25
45
|
var import_action_sheet = require("../action-sheet");
|
|
26
46
|
var import_cell = require("../cell");
|
|
27
47
|
var import_dialog = require("../dialog");
|
|
48
|
+
var import_empty = require("../empty");
|
|
28
49
|
var import_icon = require("../icon");
|
|
50
|
+
var import_loading = require("../loading");
|
|
29
51
|
var import_nav_bar = require("../nav-bar");
|
|
30
52
|
var import_search = require("../search");
|
|
31
53
|
var import_tab = require("../tab");
|
|
@@ -165,12 +187,14 @@ const props = {
|
|
|
165
187
|
type: Array,
|
|
166
188
|
default: () => locations
|
|
167
189
|
},
|
|
168
|
-
tabTitles: (0, import_utils.makeArrayProp)()
|
|
190
|
+
tabTitles: (0, import_utils.makeArrayProp)(),
|
|
191
|
+
search: Function,
|
|
192
|
+
searchDebounce: (0, import_utils.makeNumericProp)(300)
|
|
169
193
|
};
|
|
170
194
|
var stdin_default = (0, import_vue.defineComponent)({
|
|
171
195
|
name,
|
|
172
196
|
props,
|
|
173
|
-
emits: ["update:show", "update:modelValue", "change"],
|
|
197
|
+
emits: ["update:show", "update:modelValue", "change", "search-error"],
|
|
174
198
|
setup(props2, {
|
|
175
199
|
emit
|
|
176
200
|
}) {
|
|
@@ -180,6 +204,12 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
180
204
|
const customValue = (0, import_vue.ref)("");
|
|
181
205
|
const expandedKeys = (0, import_vue.ref)(["basement", "b3"]);
|
|
182
206
|
const query = (0, import_vue.ref)("");
|
|
207
|
+
const asyncSearchResults = (0, import_vue.ref)([]);
|
|
208
|
+
const searchLoading = (0, import_vue.ref)(false);
|
|
209
|
+
const searchFailed = (0, import_vue.ref)(false);
|
|
210
|
+
const searchedItems = (0, import_vue.shallowReactive)(/* @__PURE__ */ new Map());
|
|
211
|
+
let searchTimer;
|
|
212
|
+
let searchRequestId = 0;
|
|
183
213
|
const titles = (0, import_vue.computed)(() => props2.tabTitles.length ? props2.tabTitles : ["ABC\u5EA7\u5730\u4E0B\u5BA4", "A\u5EA7", "B\u5EA7", "C\u5EA7", "D\u5EA7"]);
|
|
184
214
|
const allItems = (0, import_vue.computed)(() => props2.items.flatMap(flatten));
|
|
185
215
|
const currentRoot = (0, import_vue.computed)(() => {
|
|
@@ -190,7 +220,48 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
190
220
|
var _a;
|
|
191
221
|
return ((_a = currentRoot.value) == null ? void 0 : _a.children) || [];
|
|
192
222
|
});
|
|
193
|
-
const searchResults = (0, import_vue.computed)(() =>
|
|
223
|
+
const searchResults = (0, import_vue.computed)(() => {
|
|
224
|
+
if (!query.value.trim())
|
|
225
|
+
return [];
|
|
226
|
+
if (props2.search)
|
|
227
|
+
return asyncSearchResults.value;
|
|
228
|
+
return allItems.value.filter((item) => item.text.includes(query.value));
|
|
229
|
+
});
|
|
230
|
+
const runSearch = (..._0) => __async(this, [..._0], function* (keyword = query.value.trim()) {
|
|
231
|
+
if (!props2.search || !keyword)
|
|
232
|
+
return;
|
|
233
|
+
const requestId = ++searchRequestId;
|
|
234
|
+
searchLoading.value = true;
|
|
235
|
+
searchFailed.value = false;
|
|
236
|
+
try {
|
|
237
|
+
const results = yield props2.search(keyword);
|
|
238
|
+
if (requestId !== searchRequestId)
|
|
239
|
+
return;
|
|
240
|
+
asyncSearchResults.value = results;
|
|
241
|
+
results.forEach((item) => searchedItems.set(item.id, item));
|
|
242
|
+
} catch (error) {
|
|
243
|
+
if (requestId !== searchRequestId)
|
|
244
|
+
return;
|
|
245
|
+
asyncSearchResults.value = [];
|
|
246
|
+
searchFailed.value = true;
|
|
247
|
+
emit("search-error", keyword, error);
|
|
248
|
+
} finally {
|
|
249
|
+
if (requestId === searchRequestId)
|
|
250
|
+
searchLoading.value = false;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
const scheduleSearch = () => {
|
|
254
|
+
if (searchTimer)
|
|
255
|
+
clearTimeout(searchTimer);
|
|
256
|
+
searchRequestId += 1;
|
|
257
|
+
searchLoading.value = false;
|
|
258
|
+
searchFailed.value = false;
|
|
259
|
+
asyncSearchResults.value = [];
|
|
260
|
+
if (props2.search && query.value.trim()) {
|
|
261
|
+
searchTimer = setTimeout(runSearch, Number(props2.searchDebounce));
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
(0, import_vue.watch)([query, () => props2.search], scheduleSearch);
|
|
194
265
|
(0, import_vue.watch)(() => props2.show, (show) => {
|
|
195
266
|
if (show) {
|
|
196
267
|
active.value = 0;
|
|
@@ -198,11 +269,16 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
198
269
|
expandedKeys.value = ["basement", "b3"];
|
|
199
270
|
}
|
|
200
271
|
});
|
|
272
|
+
(0, import_vue.onBeforeUnmount)(() => {
|
|
273
|
+
searchRequestId += 1;
|
|
274
|
+
if (searchTimer)
|
|
275
|
+
clearTimeout(searchTimer);
|
|
276
|
+
});
|
|
201
277
|
const close = () => emit("update:show", false);
|
|
202
278
|
const select = (value) => {
|
|
203
279
|
const selected = value[0];
|
|
204
280
|
if (selected !== void 0) {
|
|
205
|
-
const selectedItem = allItems.value.find((item) => item.id === selected);
|
|
281
|
+
const selectedItem = allItems.value.find((item) => item.id === selected) || searchedItems.get(selected);
|
|
206
282
|
emit("update:modelValue", selected);
|
|
207
283
|
emit("change", selected, selectedItem == null ? void 0 : selectedItem.text);
|
|
208
284
|
close();
|
|
@@ -217,6 +293,37 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
217
293
|
showCustom.value = false;
|
|
218
294
|
close();
|
|
219
295
|
};
|
|
296
|
+
const renderSearchContent = () => {
|
|
297
|
+
if (searchLoading.value)
|
|
298
|
+
return (0, import_vue.createVNode)("div", {
|
|
299
|
+
"class": bem("search-state")
|
|
300
|
+
}, [(0, import_vue.createVNode)(import_loading.Loading, {
|
|
301
|
+
"vertical": true
|
|
302
|
+
}, {
|
|
303
|
+
default: () => [(0, import_vue.createTextVNode)("\u52A0\u8F7D\u4E2D...")]
|
|
304
|
+
})]);
|
|
305
|
+
if (searchFailed.value)
|
|
306
|
+
return (0, import_vue.createVNode)(import_empty.Empty, {
|
|
307
|
+
"image": "network",
|
|
308
|
+
"description": "\u641C\u7D22\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"
|
|
309
|
+
}, null);
|
|
310
|
+
if (!searchResults.value.length)
|
|
311
|
+
return (0, import_vue.createVNode)(import_empty.Empty, {
|
|
312
|
+
"description": "\u6682\u65E0\u641C\u7D22\u7ED3\u679C"
|
|
313
|
+
}, null);
|
|
314
|
+
return (0, import_vue.createVNode)("div", {
|
|
315
|
+
"class": bem("card")
|
|
316
|
+
}, [searchResults.value.map((item, index) => (0, import_vue.createVNode)(import_cell.Cell, {
|
|
317
|
+
"key": item.id,
|
|
318
|
+
"title": item.text,
|
|
319
|
+
"rightSelect": props2.modelValue === item.id,
|
|
320
|
+
"selectType": "radio",
|
|
321
|
+
"border": index < searchResults.value.length - 1,
|
|
322
|
+
"clickable": true,
|
|
323
|
+
"onClick": () => select([item.id]),
|
|
324
|
+
"onUpdate:rightSelect": () => select([item.id])
|
|
325
|
+
}, null))]);
|
|
326
|
+
};
|
|
220
327
|
return () => (0, import_vue.createVNode)(import_action_sheet.ActionSheet, {
|
|
221
328
|
"show": props2.show,
|
|
222
329
|
"class": bem(),
|
|
@@ -247,23 +354,20 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
247
354
|
"modelValue": query.value,
|
|
248
355
|
"onUpdate:modelValue": ($event) => query.value = $event,
|
|
249
356
|
"class": bem("search"),
|
|
357
|
+
"variant": "pure",
|
|
250
358
|
"shape": "round",
|
|
251
359
|
"inputAlign": "left",
|
|
252
|
-
"placeholder": "\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD"
|
|
360
|
+
"placeholder": "\u8BF7\u8F93\u5165\u641C\u7D22\u5173\u952E\u8BCD",
|
|
361
|
+
"onSearch": () => {
|
|
362
|
+
if (props2.search) {
|
|
363
|
+
if (searchTimer)
|
|
364
|
+
clearTimeout(searchTimer);
|
|
365
|
+
runSearch();
|
|
366
|
+
}
|
|
367
|
+
}
|
|
253
368
|
}, null), query.value ? (0, import_vue.createVNode)("div", {
|
|
254
369
|
"class": bem("body")
|
|
255
|
-
}, [(0, import_vue.createVNode)(
|
|
256
|
-
"class": bem("card")
|
|
257
|
-
}, [searchResults.value.map((item) => (0, import_vue.createVNode)(import_cell.Cell, {
|
|
258
|
-
"key": item.id,
|
|
259
|
-
"title": item.text,
|
|
260
|
-
"rightSelect": props2.modelValue === item.id,
|
|
261
|
-
"selectType": "radio",
|
|
262
|
-
"border": true,
|
|
263
|
-
"clickable": true,
|
|
264
|
-
"onClick": () => select([item.id]),
|
|
265
|
-
"onUpdate:rightSelect": () => select([item.id])
|
|
266
|
-
}, null))])]) : (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)(import_tabs.Tabs, {
|
|
370
|
+
}, [renderSearchContent()]) : (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)(import_tabs.Tabs, {
|
|
267
371
|
"active": active.value,
|
|
268
372
|
"onUpdate:active": ($event) => active.value = $event,
|
|
269
373
|
"showMore": showMore.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.van-location-select{display:flex;flex-direction:column;height:calc(100vh - 96px);overflow:hidden;background:var(--van-gray-2)}.van-location-select>.van-action-sheet__content{display:flex;flex:1;flex-direction:column;min-height:0;gap:0;padding:0;overflow:hidden}.van-location-select__nav{flex:none;--van-nav-bar-background-color: var(--van-gray-2)}.van-location-select__nav .van-nav-bar__left--slot{left:var(--van-padding-md)}.van-location-select__nav .van-nav-bar__right--slot{display:flex;gap:12px;padding-right:var(--van-padding-md)}.van-location-select__search{flex:none;padding:8px var(--van-padding-md);--van-search-padding: 0;--van-search-background-color: var(--van-gray-2);--van-search-content-background-color: var(--van-white)}.van-location-select__search .van-search__field{padding-left:0}.van-location-select__tabs{flex:none;padding-left:8px;--van-tab-font-size: var(--van-font-size-md);--van-tabs-line-height: 44px;--van-tabs-nav-background-color: transparent}.van-location-select__body{flex:1;min-height:0;padding:12px var(--van-padding-md);overflow-y:auto}.van-location-select__card{overflow:hidden;background:var(--van-white);border-radius:8px}.van-location-select__root-option{margin-bottom:8px;background:var(--van-white);border-radius:8px}
|
|
1
|
+
.van-location-select{display:flex;flex-direction:column;height:calc(100vh - 96px);overflow:hidden;background:var(--van-gray-2)}.van-location-select>.van-action-sheet__content{display:flex;flex:1;flex-direction:column;min-height:0;gap:0;padding:0;overflow:hidden}.van-location-select__nav{flex:none;--van-nav-bar-background-color: var(--van-gray-2)}.van-location-select__nav .van-nav-bar__left--slot{left:var(--van-padding-md)}.van-location-select__nav .van-nav-bar__right--slot{display:flex;gap:12px;padding-right:var(--van-padding-md)}.van-location-select__search{flex:none;padding:8px var(--van-padding-md);--van-search-padding: 0;--van-search-background-color: var(--van-gray-2);--van-search-content-background-color: var(--van-white)}.van-location-select__search .van-search__field{padding-left:0}.van-location-select__tabs{flex:none;padding-left:8px;--van-tab-font-size: var(--van-font-size-md);--van-tabs-line-height: 44px;--van-tabs-nav-background-color: transparent}.van-location-select__body{flex:1;min-height:0;padding:12px var(--van-padding-md);overflow-y:auto}.van-location-select__card{overflow:hidden;background:var(--van-white);border-radius:8px}.van-location-select__search-state{display:flex;align-items:center;justify-content:center;min-height:160px}.van-location-select__root-option{margin-bottom:8px;background:var(--van-white);border-radius:8px}
|
|
@@ -13,7 +13,12 @@ export declare const LocationSelect: import("../utils").WithInstall<import("vue"
|
|
|
13
13
|
type: import("vue").PropType<string[]>;
|
|
14
14
|
default: () => never[];
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
search: import("vue").PropType<import("./types").LocationSelectSearch>;
|
|
17
|
+
searchDebounce: {
|
|
18
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
19
|
+
default: number;
|
|
20
|
+
};
|
|
21
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue" | "update:show" | "search-error")[], "change" | "update:modelValue" | "update:show" | "search-error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
17
22
|
show: BooleanConstructor;
|
|
18
23
|
modelValue: import("vue").PropType<import("../utils").Numeric | undefined>;
|
|
19
24
|
title: {
|
|
@@ -28,18 +33,26 @@ export declare const LocationSelect: import("../utils").WithInstall<import("vue"
|
|
|
28
33
|
type: import("vue").PropType<string[]>;
|
|
29
34
|
default: () => never[];
|
|
30
35
|
};
|
|
36
|
+
search: import("vue").PropType<import("./types").LocationSelectSearch>;
|
|
37
|
+
searchDebounce: {
|
|
38
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
39
|
+
default: number;
|
|
40
|
+
};
|
|
31
41
|
}>> & {
|
|
32
42
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
33
43
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
34
44
|
"onUpdate:show"?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
"onSearch-error"?: ((...args: any[]) => any) | undefined;
|
|
35
46
|
}, {
|
|
36
47
|
title: string;
|
|
37
48
|
show: boolean;
|
|
38
49
|
items: import("..").TreeSelectItem[][];
|
|
39
50
|
tabTitles: string[];
|
|
51
|
+
searchDebounce: string | number;
|
|
40
52
|
}>>;
|
|
41
53
|
export default LocationSelect;
|
|
42
54
|
export type { LocationSelectProps } from './LocationSelect';
|
|
55
|
+
export type { LocationSelectSearch } from './types';
|
|
43
56
|
declare module 'vue' {
|
|
44
57
|
interface GlobalComponents {
|
|
45
58
|
VanLocationSelect: typeof LocationSelect;
|
|
@@ -11,5 +11,6 @@
|
|
|
11
11
|
&__tabs { flex: none; padding-left: 8px; --van-tab-font-size: var(--van-font-size-md); --van-tabs-line-height: 44px; --van-tabs-nav-background-color: transparent; }
|
|
12
12
|
&__body { flex: 1; min-height: 0; padding: 12px var(--van-padding-md); overflow-y: auto; }
|
|
13
13
|
&__card { overflow: hidden; background: var(--van-white); border-radius: 8px; }
|
|
14
|
+
&__search-state { display: flex; align-items: center; justify-content: center; min-height: 160px; }
|
|
14
15
|
&__root-option { margin-bottom: 8px; background: var(--van-white); border-radius: 8px; }
|
|
15
16
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var stdin_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ExtractPropTypes, type PropType } from 'vue';
|
|
2
|
-
import type { MaterialAddCategory, MaterialAddItem } from './types';
|
|
2
|
+
import type { MaterialAddCategory, MaterialAddItem, MaterialAddSearch } from './types';
|
|
3
3
|
declare const materialAddProps: {
|
|
4
4
|
show: BooleanConstructor;
|
|
5
5
|
modelValue: {
|
|
@@ -54,6 +54,11 @@ declare const materialAddProps: {
|
|
|
54
54
|
type: PropType<string>;
|
|
55
55
|
default: string;
|
|
56
56
|
};
|
|
57
|
+
search: PropType<MaterialAddSearch>;
|
|
58
|
+
searchDebounce: {
|
|
59
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
60
|
+
default: number;
|
|
61
|
+
};
|
|
57
62
|
};
|
|
58
63
|
export declare type MaterialAddProps = ExtractPropTypes<typeof materialAddProps>;
|
|
59
64
|
declare const _default: import("vue").DefineComponent<{
|
|
@@ -110,7 +115,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
110
115
|
type: PropType<string>;
|
|
111
116
|
default: string;
|
|
112
117
|
};
|
|
113
|
-
|
|
118
|
+
search: PropType<MaterialAddSearch>;
|
|
119
|
+
searchDebounce: {
|
|
120
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
121
|
+
default: number;
|
|
122
|
+
};
|
|
123
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("change" | "update:modelValue" | "update:show" | "confirm" | "search-error")[], "change" | "update:modelValue" | "update:show" | "confirm" | "search-error", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<ExtractPropTypes<{
|
|
114
124
|
show: BooleanConstructor;
|
|
115
125
|
modelValue: {
|
|
116
126
|
type: PropType<number[]>;
|
|
@@ -164,17 +174,24 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
164
174
|
type: PropType<string>;
|
|
165
175
|
default: string;
|
|
166
176
|
};
|
|
177
|
+
search: PropType<MaterialAddSearch>;
|
|
178
|
+
searchDebounce: {
|
|
179
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
180
|
+
default: number;
|
|
181
|
+
};
|
|
167
182
|
}>> & {
|
|
168
183
|
onChange?: ((...args: any[]) => any) | undefined;
|
|
169
184
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
170
185
|
"onUpdate:show"?: ((...args: any[]) => any) | undefined;
|
|
171
186
|
onConfirm?: ((...args: any[]) => any) | undefined;
|
|
187
|
+
"onSearch-error"?: ((...args: any[]) => any) | undefined;
|
|
172
188
|
}, {
|
|
173
189
|
title: string;
|
|
174
190
|
modelValue: number[];
|
|
175
191
|
show: boolean;
|
|
176
192
|
confirmText: string;
|
|
177
193
|
items: MaterialAddItem[];
|
|
194
|
+
searchDebounce: string | number;
|
|
178
195
|
categories: MaterialAddCategory[];
|
|
179
196
|
showCommonTab: boolean;
|
|
180
197
|
showAllTab: boolean;
|
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
var stdin_exports = {};
|
|
29
49
|
__export(stdin_exports, {
|
|
30
50
|
default: () => stdin_default
|
|
@@ -35,7 +55,9 @@ var import_action_sheet = require("../action-sheet");
|
|
|
35
55
|
var import_blue_mark = require("../blue-mark");
|
|
36
56
|
var import_bottom_action_bar = require("../bottom-action-bar");
|
|
37
57
|
var import_filter_tag = require("../filter-tag");
|
|
58
|
+
var import_empty = require("../empty");
|
|
38
59
|
var import_icon = require("../icon");
|
|
60
|
+
var import_loading = require("../loading");
|
|
39
61
|
var import_nav_bar = require("../nav-bar");
|
|
40
62
|
var import_search = require("../search");
|
|
41
63
|
var import_swipe = require("../swipe");
|
|
@@ -354,12 +376,14 @@ const materialAddProps = {
|
|
|
354
376
|
commonTabText: (0, import_utils.makeStringProp)("\u5E38\u7528\u7269\u6599"),
|
|
355
377
|
allTabText: (0, import_utils.makeStringProp)("\u5168\u90E8\u7269\u6599"),
|
|
356
378
|
materialTabText: (0, import_utils.makeStringProp)("\u7269\u8D44"),
|
|
357
|
-
toolTabText: (0, import_utils.makeStringProp)("\u5DE5\u5177")
|
|
379
|
+
toolTabText: (0, import_utils.makeStringProp)("\u5DE5\u5177"),
|
|
380
|
+
search: Function,
|
|
381
|
+
searchDebounce: (0, import_utils.makeNumericProp)(300)
|
|
358
382
|
};
|
|
359
383
|
var stdin_default = (0, import_vue.defineComponent)({
|
|
360
384
|
name,
|
|
361
385
|
props: materialAddProps,
|
|
362
|
-
emits: ["update:show", "update:modelValue", "change", "confirm"],
|
|
386
|
+
emits: ["update:show", "update:modelValue", "change", "confirm", "search-error"],
|
|
363
387
|
setup(props, {
|
|
364
388
|
emit
|
|
365
389
|
}) {
|
|
@@ -375,6 +399,10 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
375
399
|
const activeKind = (0, import_vue.ref)(getDefaultKind());
|
|
376
400
|
const keyword = (0, import_vue.ref)("");
|
|
377
401
|
const searching = (0, import_vue.ref)(false);
|
|
402
|
+
const searchLoading = (0, import_vue.ref)(false);
|
|
403
|
+
const searchFailed = (0, import_vue.ref)(false);
|
|
404
|
+
let searchTimer;
|
|
405
|
+
let searchRequestId = 0;
|
|
378
406
|
const expandedKeys = (0, import_vue.ref)([]);
|
|
379
407
|
const expandedSelected = (0, import_vue.ref)(false);
|
|
380
408
|
const detailItem = (0, import_vue.ref)();
|
|
@@ -457,6 +485,11 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
457
485
|
activeTab.value = getDefaultTab();
|
|
458
486
|
activeKind.value = getDefaultKind();
|
|
459
487
|
keyword.value = "";
|
|
488
|
+
searchLoading.value = false;
|
|
489
|
+
searchFailed.value = false;
|
|
490
|
+
searchRequestId += 1;
|
|
491
|
+
if (searchTimer)
|
|
492
|
+
clearTimeout(searchTimer);
|
|
460
493
|
searching.value = false;
|
|
461
494
|
expandedKeys.value = getDefaultExpandedKeys();
|
|
462
495
|
expandedSelected.value = false;
|
|
@@ -474,6 +507,40 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
474
507
|
expandedKeys.value = getDefaultExpandedKeys();
|
|
475
508
|
}
|
|
476
509
|
});
|
|
510
|
+
const runSearch = (..._0) => __async(this, [..._0], function* (query = keyword.value.trim()) {
|
|
511
|
+
if (!props.search || !query)
|
|
512
|
+
return;
|
|
513
|
+
const requestId = ++searchRequestId;
|
|
514
|
+
searchLoading.value = true;
|
|
515
|
+
searchFailed.value = false;
|
|
516
|
+
try {
|
|
517
|
+
yield props.search(query);
|
|
518
|
+
} catch (error) {
|
|
519
|
+
if (requestId !== searchRequestId)
|
|
520
|
+
return;
|
|
521
|
+
searchFailed.value = true;
|
|
522
|
+
emit("search-error", query, error);
|
|
523
|
+
} finally {
|
|
524
|
+
if (requestId === searchRequestId)
|
|
525
|
+
searchLoading.value = false;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
const scheduleSearch = () => {
|
|
529
|
+
if (searchTimer)
|
|
530
|
+
clearTimeout(searchTimer);
|
|
531
|
+
searchRequestId += 1;
|
|
532
|
+
searchLoading.value = false;
|
|
533
|
+
searchFailed.value = false;
|
|
534
|
+
if (props.search && keyword.value.trim()) {
|
|
535
|
+
searchTimer = setTimeout(runSearch, Number(props.searchDebounce));
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
(0, import_vue.watch)([keyword, () => props.search], scheduleSearch);
|
|
539
|
+
(0, import_vue.onBeforeUnmount)(() => {
|
|
540
|
+
searchRequestId += 1;
|
|
541
|
+
if (searchTimer)
|
|
542
|
+
clearTimeout(searchTimer);
|
|
543
|
+
});
|
|
477
544
|
const setActiveTab = (tab) => {
|
|
478
545
|
activeTab.value = tab;
|
|
479
546
|
if (tab === "all") {
|
|
@@ -540,9 +607,25 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
540
607
|
}, null);
|
|
541
608
|
const renderList = () => (0, import_vue.createVNode)("div", {
|
|
542
609
|
"class": bem("material-list")
|
|
543
|
-
}, [visibleItems.value.length ? visibleItems.value.map((item) => renderMaterialCell(item, props.items.indexOf(item))) : (0, import_vue.createVNode)(
|
|
544
|
-
"
|
|
545
|
-
},
|
|
610
|
+
}, [visibleItems.value.length ? visibleItems.value.map((item) => renderMaterialCell(item, props.items.indexOf(item))) : (0, import_vue.createVNode)(import_empty.Empty, {
|
|
611
|
+
"description": "\u6682\u65E0\u5339\u914D\u7269\u6599"
|
|
612
|
+
}, null)]);
|
|
613
|
+
const renderSearchContent = () => {
|
|
614
|
+
if (searchLoading.value)
|
|
615
|
+
return (0, import_vue.createVNode)("div", {
|
|
616
|
+
"class": bem("search-state")
|
|
617
|
+
}, [(0, import_vue.createVNode)(import_loading.Loading, {
|
|
618
|
+
"vertical": true
|
|
619
|
+
}, {
|
|
620
|
+
default: () => [(0, import_vue.createTextVNode)("\u52A0\u8F7D\u4E2D...")]
|
|
621
|
+
})]);
|
|
622
|
+
if (searchFailed.value)
|
|
623
|
+
return (0, import_vue.createVNode)(import_empty.Empty, {
|
|
624
|
+
"image": "network",
|
|
625
|
+
"description": "\u641C\u7D22\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5"
|
|
626
|
+
}, null);
|
|
627
|
+
return renderList();
|
|
628
|
+
};
|
|
546
629
|
const renderCatalog = () => {
|
|
547
630
|
const catalogItems = getCatalogItems();
|
|
548
631
|
const defaultExpandedKeys = getDefaultExpandedKeys();
|
|
@@ -701,11 +784,19 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
701
784
|
"modelValue": keyword.value,
|
|
702
785
|
"onUpdate:modelValue": ($event) => keyword.value = $event,
|
|
703
786
|
"class": bem("search"),
|
|
787
|
+
"variant": "pure",
|
|
704
788
|
"shape": "round",
|
|
705
789
|
"inputAlign": "left",
|
|
706
790
|
"autofocus": true,
|
|
707
791
|
"showAction": true,
|
|
708
792
|
"placeholder": "\u641C\u7D22\u7269\u8D44/\u5DE5\u5177\u540D\u79F0",
|
|
793
|
+
"onSearch": () => {
|
|
794
|
+
if (props.search) {
|
|
795
|
+
if (searchTimer)
|
|
796
|
+
clearTimeout(searchTimer);
|
|
797
|
+
runSearch();
|
|
798
|
+
}
|
|
799
|
+
},
|
|
709
800
|
"onCancel": () => {
|
|
710
801
|
searching.value = false;
|
|
711
802
|
keyword.value = "";
|
|
@@ -759,7 +850,7 @@ var stdin_default = (0, import_vue.defineComponent)({
|
|
|
759
850
|
default: () => [props.toolTabText]
|
|
760
851
|
})])]), (0, import_vue.createVNode)("div", {
|
|
761
852
|
"class": bem("body")
|
|
762
|
-
}, [searching.value && !keyword.value.trim() ? null : searching.value
|
|
853
|
+
}, [searching.value && !keyword.value.trim() ? null : searching.value ? renderSearchContent() : activeTab.value === "common" ? renderList() : renderCatalog()]), (0, import_vue.createVNode)("div", {
|
|
763
854
|
"class": bem("footer")
|
|
764
855
|
}, [renderSelectPanel(), (0, import_vue.createVNode)(import_bottom_action_bar.BottomActionBar, {
|
|
765
856
|
"fixed": false,
|