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.
Files changed (78) hide show
  1. package/es/index.d.ts +1 -1
  2. package/es/index.mjs +1 -1
  3. package/es/location-select/LocationSelect.d.ts +19 -1
  4. package/es/location-select/LocationSelect.mjs +123 -19
  5. package/es/location-select/index.css +1 -1
  6. package/es/location-select/index.d.ts +14 -1
  7. package/es/location-select/index.less +1 -0
  8. package/es/location-select/style/index.mjs +1 -0
  9. package/es/location-select/style/less.mjs +1 -0
  10. package/es/location-select/types.d.ts +2 -0
  11. package/es/location-select/types.mjs +0 -0
  12. package/es/material-add/MaterialAdd.d.ts +19 -2
  13. package/es/material-add/MaterialAdd.mjs +99 -8
  14. package/es/material-add/index.css +1 -1
  15. package/es/material-add/index.d.ts +14 -2
  16. package/es/material-add/index.less +1 -1
  17. package/es/material-add/style/index.mjs +1 -0
  18. package/es/material-add/style/less.mjs +1 -0
  19. package/es/material-add/types.d.ts +7 -6
  20. package/es/object-select/ObjectSelect.d.ts +25 -3
  21. package/es/object-select/ObjectSelect.mjs +163 -30
  22. package/es/object-select/index.css +1 -1
  23. package/es/object-select/index.d.ts +18 -2
  24. package/es/object-select/index.less +1 -0
  25. package/es/object-select/style/index.mjs +1 -0
  26. package/es/object-select/style/less.mjs +1 -0
  27. package/es/object-select/types.d.ts +1 -0
  28. package/es/tree-select/TreeSelect.d.ts +7 -1
  29. package/es/tree-select/TreeSelect.mjs +107 -54
  30. package/es/tree-select/index.css +1 -1
  31. package/es/tree-select/index.d.ts +6 -2
  32. package/es/tree-select/index.less +6 -0
  33. package/es/tree-select/style/index.mjs +1 -0
  34. package/es/tree-select/style/less.mjs +1 -0
  35. package/lib/index.css +1 -1
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.js +1 -1
  38. package/lib/index.less +2 -2
  39. package/lib/location-select/LocationSelect.d.ts +19 -1
  40. package/lib/location-select/LocationSelect.js +121 -17
  41. package/lib/location-select/index.css +1 -1
  42. package/lib/location-select/index.d.ts +14 -1
  43. package/lib/location-select/index.less +1 -0
  44. package/lib/location-select/style/index.js +1 -0
  45. package/lib/location-select/style/less.js +1 -0
  46. package/lib/location-select/types.d.ts +2 -0
  47. package/lib/location-select/types.js +15 -0
  48. package/lib/material-add/MaterialAdd.d.ts +19 -2
  49. package/lib/material-add/MaterialAdd.js +97 -6
  50. package/lib/material-add/index.css +1 -1
  51. package/lib/material-add/index.d.ts +14 -2
  52. package/lib/material-add/index.less +1 -1
  53. package/lib/material-add/style/index.js +1 -0
  54. package/lib/material-add/style/less.js +1 -0
  55. package/lib/material-add/types.d.ts +7 -6
  56. package/lib/object-select/ObjectSelect.d.ts +25 -3
  57. package/lib/object-select/ObjectSelect.js +161 -28
  58. package/lib/object-select/index.css +1 -1
  59. package/lib/object-select/index.d.ts +18 -2
  60. package/lib/object-select/index.less +1 -0
  61. package/lib/object-select/style/index.js +1 -0
  62. package/lib/object-select/style/less.js +1 -0
  63. package/lib/object-select/types.d.ts +1 -0
  64. package/lib/tree-select/TreeSelect.d.ts +7 -1
  65. package/lib/tree-select/TreeSelect.js +107 -52
  66. package/lib/tree-select/index.css +1 -1
  67. package/lib/tree-select/index.d.ts +6 -2
  68. package/lib/tree-select/index.less +6 -0
  69. package/lib/tree-select/style/index.js +1 -0
  70. package/lib/tree-select/style/less.js +1 -0
  71. package/lib/vant.cjs.js +492 -118
  72. package/lib/vant.es.js +493 -119
  73. package/lib/vant.js +492 -118
  74. package/lib/vant.min.js +1 -1
  75. package/lib/web-types.json +1 -1
  76. package/package.json +1 -1
  77. package/skills/use-persagy-vant/references/business-component-catalog.md +3 -3
  78. package/skills/use-persagy-vant/references/component-catalog.md +1 -1
package/lib/vant.js CHANGED
@@ -8848,21 +8848,21 @@
8848
8848
  }, [renderChildren()]);
8849
8849
  }
8850
8850
  });
8851
- var __defProp$1 = Object.defineProperty;
8851
+ var __defProp = Object.defineProperty;
8852
8852
  var __defProps = Object.defineProperties;
8853
8853
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8854
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
8855
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
8856
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
8857
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8858
- var __spreadValues$1 = (a, b) => {
8854
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8855
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8856
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8857
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8858
+ var __spreadValues = (a, b) => {
8859
8859
  for (var prop in b || (b = {}))
8860
- if (__hasOwnProp$1.call(b, prop))
8861
- __defNormalProp$1(a, prop, b[prop]);
8862
- if (__getOwnPropSymbols$1)
8863
- for (var prop of __getOwnPropSymbols$1(b)) {
8864
- if (__propIsEnum$1.call(b, prop))
8865
- __defNormalProp$1(a, prop, b[prop]);
8860
+ if (__hasOwnProp.call(b, prop))
8861
+ __defNormalProp(a, prop, b[prop]);
8862
+ if (__getOwnPropSymbols)
8863
+ for (var prop of __getOwnPropSymbols(b)) {
8864
+ if (__propIsEnum.call(b, prop))
8865
+ __defNormalProp(a, prop, b[prop]);
8866
8866
  }
8867
8867
  return a;
8868
8868
  };
@@ -9108,7 +9108,7 @@
9108
9108
  name: tab.title,
9109
9109
  disabled: tab.disabled
9110
9110
  }));
9111
- return actions.map((action, index) => __spreadProps(__spreadValues$1({}, action), {
9111
+ return actions.map((action, index) => __spreadProps(__spreadValues({}, action), {
9112
9112
  color: index === state.currentIndex ? "var(--van-primary-color)" : action.color,
9113
9113
  className: [action.className, bem$1d("more-option", {
9114
9114
  active: index === state.currentIndex
@@ -14227,21 +14227,25 @@
14227
14227
  }
14228
14228
  });
14229
14229
  const InfoCard = withInstall(stdin_default$K);
14230
- var __defProp = Object.defineProperty;
14231
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14232
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14233
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
14234
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14235
- var __spreadValues = (a, b) => {
14236
- for (var prop in b || (b = {}))
14237
- if (__hasOwnProp.call(b, prop))
14238
- __defNormalProp(a, prop, b[prop]);
14239
- if (__getOwnPropSymbols)
14240
- for (var prop of __getOwnPropSymbols(b)) {
14241
- if (__propIsEnum.call(b, prop))
14242
- __defNormalProp(a, prop, b[prop]);
14243
- }
14244
- return a;
14230
+ var __async$5 = (__this, __arguments, generator) => {
14231
+ return new Promise((resolve, reject) => {
14232
+ var fulfilled = (value) => {
14233
+ try {
14234
+ step(generator.next(value));
14235
+ } catch (e) {
14236
+ reject(e);
14237
+ }
14238
+ };
14239
+ var rejected = (value) => {
14240
+ try {
14241
+ step(generator.throw(value));
14242
+ } catch (e) {
14243
+ reject(e);
14244
+ }
14245
+ };
14246
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
14247
+ step((generator = generator.apply(__this, __arguments)).next());
14248
+ });
14245
14249
  };
14246
14250
  const [name$B, bem$B] = createNamespace("tree-select");
14247
14251
  const treeSelectProps = {
@@ -14253,20 +14257,31 @@
14253
14257
  selectableParent: Boolean,
14254
14258
  showParentSelect: Boolean,
14255
14259
  showSelectLevels: Array,
14256
- showDivider: truthProp
14260
+ showDivider: truthProp,
14261
+ loadChildren: Function
14257
14262
  };
14258
14263
  var stdin_default$J = vue.defineComponent({
14259
14264
  name: name$B,
14260
14265
  props: treeSelectProps,
14261
- emits: ["update:modelValue", "update:expandedKeys", "select", "expand"],
14266
+ emits: ["update:modelValue", "update:expandedKeys", "select", "expand", "load", "load-error"],
14262
14267
  setup(props2, {
14263
14268
  emit,
14264
14269
  slots
14265
14270
  }) {
14266
14271
  const selectedKeys = vue.computed(() => props2.modelValue);
14267
14272
  const expandedKeys = vue.computed(() => props2.expandedKeys);
14273
+ const resolvedChildren = vue.shallowReactive(/* @__PURE__ */ new Map());
14274
+ const loadingKeys = vue.shallowReactive(/* @__PURE__ */ new Set());
14275
+ const loadedKeys = vue.shallowReactive(/* @__PURE__ */ new Set());
14268
14276
  const isExpanded = (id) => expandedKeys.value.includes(id);
14269
14277
  const isSelected = (id) => selectedKeys.value.includes(id);
14278
+ const isLoading = (id) => loadingKeys.has(id);
14279
+ const getChildren = (item) => {
14280
+ var _a;
14281
+ return ((_a = item.children) == null ? void 0 : _a.length) ? item.children : resolvedChildren.get(item.id) || item.children || [];
14282
+ };
14283
+ const isLoadable = (item) => !!props2.loadChildren && Array.isArray(item.children) && !item.children.length && !loadedKeys.has(item.id);
14284
+ const isBranch = (item) => !!getChildren(item).length || isLoadable(item) || isLoading(item.id);
14270
14285
  const isSelectionVisible = (hasChildren, level) => {
14271
14286
  var _a;
14272
14287
  const configuredVisibility = (_a = props2.showSelectLevels) == null ? void 0 : _a[level];
@@ -14278,10 +14293,7 @@
14278
14293
  paddingLeft: `calc(var(--van-padding-md) + ${level * 16}px)`,
14279
14294
  "--van-tree-select-divider-left": `calc(var(--van-padding-md) + ${level * 16}px)`
14280
14295
  });
14281
- const getDescendantIds = (item) => {
14282
- var _a;
14283
- return ((_a = item.children) == null ? void 0 : _a.flatMap((child) => [child.id, ...getDescendantIds(child)])) || [];
14284
- };
14296
+ const getDescendantIds = (item) => getChildren(item).flatMap((child) => [child.id, ...getDescendantIds(child)]);
14285
14297
  const getSelectionState = (item) => {
14286
14298
  const descendantIds = getDescendantIds(item);
14287
14299
  if (!props2.cascade || !descendantIds.length) {
@@ -14296,11 +14308,11 @@
14296
14308
  };
14297
14309
  const syncParentSelection = (items, values) => {
14298
14310
  items.forEach((item) => {
14299
- var _a;
14300
- if (!((_a = item.children) == null ? void 0 : _a.length))
14311
+ const children = getChildren(item);
14312
+ if (!children.length)
14301
14313
  return;
14302
- syncParentSelection(item.children, values);
14303
- const childIds = item.children.map((child) => child.id);
14314
+ syncParentSelection(children, values);
14315
+ const childIds = children.map((child) => child.id);
14304
14316
  const index = values.indexOf(item.id);
14305
14317
  const allChildrenSelected = childIds.every((id) => values.includes(id));
14306
14318
  if (allChildrenSelected && index === -1)
@@ -14309,13 +14321,45 @@
14309
14321
  values.splice(index, 1);
14310
14322
  });
14311
14323
  };
14312
- const toggleExpanded = (id) => {
14324
+ const updateExpanded = (id, expanded) => {
14313
14325
  const next = expandedKeys.value.slice();
14314
14326
  const index = next.indexOf(id);
14315
- index === -1 ? next.push(id) : next.splice(index, 1);
14327
+ if (expanded && index === -1)
14328
+ next.push(id);
14329
+ if (!expanded && index !== -1)
14330
+ next.splice(index, 1);
14316
14331
  emit("update:expandedKeys", next);
14317
- emit("expand", id, index === -1);
14332
+ emit("expand", id, expanded);
14318
14333
  };
14334
+ const toggleExpanded = (item) => __async$5(this, null, function* () {
14335
+ const {
14336
+ id
14337
+ } = item;
14338
+ if (isLoading(id))
14339
+ return;
14340
+ if (isExpanded(id)) {
14341
+ updateExpanded(id, false);
14342
+ return;
14343
+ }
14344
+ if (isLoadable(item)) {
14345
+ loadingKeys.add(id);
14346
+ try {
14347
+ const result = yield props2.loadChildren(item);
14348
+ const children = Array.isArray(result) ? result : [];
14349
+ resolvedChildren.set(id, children);
14350
+ loadedKeys.add(id);
14351
+ emit("load", item, children);
14352
+ if (children.length)
14353
+ updateExpanded(id, true);
14354
+ } catch (error) {
14355
+ emit("load-error", item, error);
14356
+ } finally {
14357
+ loadingKeys.delete(id);
14358
+ }
14359
+ return;
14360
+ }
14361
+ updateExpanded(id, true);
14362
+ });
14319
14363
  const updateSelected = (item, selected) => {
14320
14364
  if (item.disabled || item.selectable === false)
14321
14365
  return;
@@ -14334,12 +14378,13 @@
14334
14378
  emit("select", item, selected);
14335
14379
  };
14336
14380
  const renderNodes = (items, level = 0) => items.map((item) => {
14337
- var _a;
14338
- const hasChildren = !!((_a = item.children) == null ? void 0 : _a.length);
14381
+ const children = getChildren(item);
14382
+ const hasChildren = isBranch(item);
14339
14383
  const expanded = isExpanded(item.id);
14384
+ const loading = isLoading(item.id);
14340
14385
  const renderTitle = () => {
14341
- var _a2;
14342
- return ((_a2 = slots.title) == null ? void 0 : _a2.call(slots, {
14386
+ var _a;
14387
+ return ((_a = slots.title) == null ? void 0 : _a.call(slots, {
14343
14388
  item,
14344
14389
  level,
14345
14390
  hasChildren
@@ -14359,36 +14404,29 @@
14359
14404
  }
14360
14405
  const selectable = item.selectable !== false && isSelectionVisible(hasChildren, level);
14361
14406
  const selectionState = getSelectionState(item);
14362
- return vue.createVNode("div", {
14363
- "key": item.id,
14364
- "class": bem$B("node")
14365
- }, [vue.createVNode(Cell, {
14366
- "class": bem$B("cell", {
14367
- branch: hasChildren
14368
- }),
14369
- "title": item.text,
14370
- "border": props2.showDivider,
14371
- "style": getNodeStyle(level),
14372
- "rightSelect": selectable && selectionState !== "indeterminate" ? selectionState === "checked" : void 0,
14373
- "selectType": props2.multiple ? "checkbox" : "radio",
14374
- "onUpdate:rightSelect": (value) => updateSelected(item, value)
14375
- }, __spreadValues({
14407
+ const cellSlots = {
14376
14408
  title: () => [hasChildren ? vue.createVNode("button", {
14377
14409
  "type": "button",
14378
14410
  "class": bem$B("expand-control"),
14379
14411
  "disabled": item.disabled,
14412
+ "aria-busy": loading,
14413
+ "aria-disabled": loading,
14380
14414
  "onClick": (event) => {
14381
14415
  event.stopPropagation();
14382
- toggleExpanded(item.id);
14416
+ toggleExpanded(item);
14383
14417
  }
14384
- }, [vue.createVNode(Icon, {
14418
+ }, [loading ? vue.createVNode(Loading, {
14419
+ "class": bem$B("loading"),
14420
+ "size": "var(--van-tree-select-arrow-size)"
14421
+ }, null) : vue.createVNode(Icon, {
14385
14422
  "name": "trangle-down",
14386
14423
  "class": bem$B("arrow", {
14387
14424
  expanded
14388
14425
  })
14389
14426
  }, null), vue.createVNode("span", null, [renderTitle()])]) : vue.createVNode("span", null, [renderTitle()])]
14390
- }, selectable && selectionState === "indeterminate" ? {
14391
- "right-select": () => vue.createVNode("button", {
14427
+ };
14428
+ if (selectable && selectionState === "indeterminate") {
14429
+ cellSlots["right-select"] = () => vue.createVNode("button", {
14392
14430
  "type": "button",
14393
14431
  "class": bem$B("indeterminate"),
14394
14432
  "aria-label": `部分选中${item.text}`,
@@ -14396,13 +14434,27 @@
14396
14434
  event.stopPropagation();
14397
14435
  updateSelected(item, true);
14398
14436
  }
14399
- }, null)
14400
- } : {})), vue.createVNode(vue.Transition, {
14437
+ }, null);
14438
+ }
14439
+ return vue.createVNode("div", {
14440
+ "key": item.id,
14441
+ "class": bem$B("node")
14442
+ }, [vue.createVNode(Cell, {
14443
+ "class": bem$B("cell", {
14444
+ branch: hasChildren
14445
+ }),
14446
+ "title": item.text,
14447
+ "border": props2.showDivider,
14448
+ "style": getNodeStyle(level),
14449
+ "rightSelect": selectable && selectionState !== "indeterminate" ? selectionState === "checked" : void 0,
14450
+ "selectType": props2.multiple ? "checkbox" : "radio",
14451
+ "onUpdate:rightSelect": (value) => updateSelected(item, value)
14452
+ }, cellSlots), vue.createVNode(vue.Transition, {
14401
14453
  "name": "van-tree-select-expand"
14402
14454
  }, {
14403
14455
  default: () => [hasChildren && expanded && vue.createVNode("div", {
14404
14456
  "class": bem$B("children")
14405
- }, [renderNodes(item.children, level + 1)])]
14457
+ }, [renderNodes(children, level + 1)])]
14406
14458
  })]);
14407
14459
  });
14408
14460
  return () => vue.createVNode("div", {
@@ -14412,6 +14464,26 @@
14412
14464
  });
14413
14465
  const TreeSelect = withInstall(stdin_default$J);
14414
14466
  var stdin_default$I = TreeSelect;
14467
+ var __async$4 = (__this, __arguments, generator) => {
14468
+ return new Promise((resolve, reject) => {
14469
+ var fulfilled = (value) => {
14470
+ try {
14471
+ step(generator.next(value));
14472
+ } catch (e) {
14473
+ reject(e);
14474
+ }
14475
+ };
14476
+ var rejected = (value) => {
14477
+ try {
14478
+ step(generator.throw(value));
14479
+ } catch (e) {
14480
+ reject(e);
14481
+ }
14482
+ };
14483
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
14484
+ step((generator = generator.apply(__this, __arguments)).next());
14485
+ });
14486
+ };
14415
14487
  const [name$A, bem$A] = createNamespace("location-select");
14416
14488
  const locations = [[{
14417
14489
  id: "basement",
@@ -14546,12 +14618,14 @@
14546
14618
  type: Array,
14547
14619
  default: () => locations
14548
14620
  },
14549
- tabTitles: makeArrayProp()
14621
+ tabTitles: makeArrayProp(),
14622
+ search: Function,
14623
+ searchDebounce: makeNumericProp(300)
14550
14624
  };
14551
14625
  var stdin_default$H = vue.defineComponent({
14552
14626
  name: name$A,
14553
14627
  props: props$1,
14554
- emits: ["update:show", "update:modelValue", "change"],
14628
+ emits: ["update:show", "update:modelValue", "change", "search-error"],
14555
14629
  setup(props2, {
14556
14630
  emit
14557
14631
  }) {
@@ -14561,6 +14635,12 @@
14561
14635
  const customValue = vue.ref("");
14562
14636
  const expandedKeys = vue.ref(["basement", "b3"]);
14563
14637
  const query = vue.ref("");
14638
+ const asyncSearchResults = vue.ref([]);
14639
+ const searchLoading = vue.ref(false);
14640
+ const searchFailed = vue.ref(false);
14641
+ const searchedItems = vue.shallowReactive(/* @__PURE__ */ new Map());
14642
+ let searchTimer;
14643
+ let searchRequestId = 0;
14564
14644
  const titles = vue.computed(() => props2.tabTitles.length ? props2.tabTitles : ["ABC座地下室", "A座", "B座", "C座", "D座"]);
14565
14645
  const allItems = vue.computed(() => props2.items.flatMap(flatten));
14566
14646
  const currentRoot = vue.computed(() => {
@@ -14571,7 +14651,48 @@
14571
14651
  var _a;
14572
14652
  return ((_a = currentRoot.value) == null ? void 0 : _a.children) || [];
14573
14653
  });
14574
- const searchResults = vue.computed(() => query.value ? allItems.value.filter((item) => item.text.includes(query.value)) : []);
14654
+ const searchResults = vue.computed(() => {
14655
+ if (!query.value.trim())
14656
+ return [];
14657
+ if (props2.search)
14658
+ return asyncSearchResults.value;
14659
+ return allItems.value.filter((item) => item.text.includes(query.value));
14660
+ });
14661
+ const runSearch = (..._0) => __async$4(this, [..._0], function* (keyword = query.value.trim()) {
14662
+ if (!props2.search || !keyword)
14663
+ return;
14664
+ const requestId = ++searchRequestId;
14665
+ searchLoading.value = true;
14666
+ searchFailed.value = false;
14667
+ try {
14668
+ const results = yield props2.search(keyword);
14669
+ if (requestId !== searchRequestId)
14670
+ return;
14671
+ asyncSearchResults.value = results;
14672
+ results.forEach((item) => searchedItems.set(item.id, item));
14673
+ } catch (error) {
14674
+ if (requestId !== searchRequestId)
14675
+ return;
14676
+ asyncSearchResults.value = [];
14677
+ searchFailed.value = true;
14678
+ emit("search-error", keyword, error);
14679
+ } finally {
14680
+ if (requestId === searchRequestId)
14681
+ searchLoading.value = false;
14682
+ }
14683
+ });
14684
+ const scheduleSearch = () => {
14685
+ if (searchTimer)
14686
+ clearTimeout(searchTimer);
14687
+ searchRequestId += 1;
14688
+ searchLoading.value = false;
14689
+ searchFailed.value = false;
14690
+ asyncSearchResults.value = [];
14691
+ if (props2.search && query.value.trim()) {
14692
+ searchTimer = setTimeout(runSearch, Number(props2.searchDebounce));
14693
+ }
14694
+ };
14695
+ vue.watch([query, () => props2.search], scheduleSearch);
14575
14696
  vue.watch(() => props2.show, (show) => {
14576
14697
  if (show) {
14577
14698
  active.value = 0;
@@ -14579,11 +14700,16 @@
14579
14700
  expandedKeys.value = ["basement", "b3"];
14580
14701
  }
14581
14702
  });
14703
+ vue.onBeforeUnmount(() => {
14704
+ searchRequestId += 1;
14705
+ if (searchTimer)
14706
+ clearTimeout(searchTimer);
14707
+ });
14582
14708
  const close = () => emit("update:show", false);
14583
14709
  const select = (value) => {
14584
14710
  const selected = value[0];
14585
14711
  if (selected !== void 0) {
14586
- const selectedItem = allItems.value.find((item) => item.id === selected);
14712
+ const selectedItem = allItems.value.find((item) => item.id === selected) || searchedItems.get(selected);
14587
14713
  emit("update:modelValue", selected);
14588
14714
  emit("change", selected, selectedItem == null ? void 0 : selectedItem.text);
14589
14715
  close();
@@ -14598,6 +14724,37 @@
14598
14724
  showCustom.value = false;
14599
14725
  close();
14600
14726
  };
14727
+ const renderSearchContent = () => {
14728
+ if (searchLoading.value)
14729
+ return vue.createVNode("div", {
14730
+ "class": bem$A("search-state")
14731
+ }, [vue.createVNode(Loading, {
14732
+ "vertical": true
14733
+ }, {
14734
+ default: () => [vue.createTextVNode("加载中...")]
14735
+ })]);
14736
+ if (searchFailed.value)
14737
+ return vue.createVNode(Empty, {
14738
+ "image": "network",
14739
+ "description": "搜索失败,请重试"
14740
+ }, null);
14741
+ if (!searchResults.value.length)
14742
+ return vue.createVNode(Empty, {
14743
+ "description": "暂无搜索结果"
14744
+ }, null);
14745
+ return vue.createVNode("div", {
14746
+ "class": bem$A("card")
14747
+ }, [searchResults.value.map((item, index) => vue.createVNode(Cell, {
14748
+ "key": item.id,
14749
+ "title": item.text,
14750
+ "rightSelect": props2.modelValue === item.id,
14751
+ "selectType": "radio",
14752
+ "border": index < searchResults.value.length - 1,
14753
+ "clickable": true,
14754
+ "onClick": () => select([item.id]),
14755
+ "onUpdate:rightSelect": () => select([item.id])
14756
+ }, null))]);
14757
+ };
14601
14758
  return () => vue.createVNode(ActionSheet, {
14602
14759
  "show": props2.show,
14603
14760
  "class": bem$A(),
@@ -14628,23 +14785,20 @@
14628
14785
  "modelValue": query.value,
14629
14786
  "onUpdate:modelValue": ($event) => query.value = $event,
14630
14787
  "class": bem$A("search"),
14788
+ "variant": "pure",
14631
14789
  "shape": "round",
14632
14790
  "inputAlign": "left",
14633
- "placeholder": "请输入搜索关键词"
14791
+ "placeholder": "请输入搜索关键词",
14792
+ "onSearch": () => {
14793
+ if (props2.search) {
14794
+ if (searchTimer)
14795
+ clearTimeout(searchTimer);
14796
+ runSearch();
14797
+ }
14798
+ }
14634
14799
  }, null), query.value ? vue.createVNode("div", {
14635
14800
  "class": bem$A("body")
14636
- }, [vue.createVNode("div", {
14637
- "class": bem$A("card")
14638
- }, [searchResults.value.map((item) => vue.createVNode(Cell, {
14639
- "key": item.id,
14640
- "title": item.text,
14641
- "rightSelect": props2.modelValue === item.id,
14642
- "selectType": "radio",
14643
- "border": true,
14644
- "clickable": true,
14645
- "onClick": () => select([item.id]),
14646
- "onUpdate:rightSelect": () => select([item.id])
14647
- }, null))])]) : vue.createVNode(vue.Fragment, null, [vue.createVNode(Tabs, {
14801
+ }, [renderSearchContent()]) : vue.createVNode(vue.Fragment, null, [vue.createVNode(Tabs, {
14648
14802
  "active": active.value,
14649
14803
  "onUpdate:active": ($event) => active.value = $event,
14650
14804
  "showMore": showMore.value,
@@ -15312,6 +15466,26 @@
15312
15466
  });
15313
15467
  const MaterialDetail = withInstall(stdin_default$D);
15314
15468
  var stdin_default$C = MaterialDetail;
15469
+ var __async$3 = (__this, __arguments, generator) => {
15470
+ return new Promise((resolve, reject) => {
15471
+ var fulfilled = (value) => {
15472
+ try {
15473
+ step(generator.next(value));
15474
+ } catch (e) {
15475
+ reject(e);
15476
+ }
15477
+ };
15478
+ var rejected = (value) => {
15479
+ try {
15480
+ step(generator.throw(value));
15481
+ } catch (e) {
15482
+ reject(e);
15483
+ }
15484
+ };
15485
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
15486
+ step((generator = generator.apply(__this, __arguments)).next());
15487
+ });
15488
+ };
15315
15489
  const [name$w, bem$w] = createNamespace("material-add");
15316
15490
  const defaultItems = [{
15317
15491
  id: "refrigerant",
@@ -15619,12 +15793,14 @@
15619
15793
  commonTabText: makeStringProp("常用物料"),
15620
15794
  allTabText: makeStringProp("全部物料"),
15621
15795
  materialTabText: makeStringProp("物资"),
15622
- toolTabText: makeStringProp("工具")
15796
+ toolTabText: makeStringProp("工具"),
15797
+ search: Function,
15798
+ searchDebounce: makeNumericProp(300)
15623
15799
  };
15624
15800
  var stdin_default$B = vue.defineComponent({
15625
15801
  name: name$w,
15626
15802
  props: materialAddProps,
15627
- emits: ["update:show", "update:modelValue", "change", "confirm"],
15803
+ emits: ["update:show", "update:modelValue", "change", "confirm", "search-error"],
15628
15804
  setup(props2, {
15629
15805
  emit
15630
15806
  }) {
@@ -15640,6 +15816,10 @@
15640
15816
  const activeKind = vue.ref(getDefaultKind());
15641
15817
  const keyword = vue.ref("");
15642
15818
  const searching = vue.ref(false);
15819
+ const searchLoading = vue.ref(false);
15820
+ const searchFailed = vue.ref(false);
15821
+ let searchTimer;
15822
+ let searchRequestId = 0;
15643
15823
  const expandedKeys = vue.ref([]);
15644
15824
  const expandedSelected = vue.ref(false);
15645
15825
  const detailItem = vue.ref();
@@ -15711,6 +15891,11 @@
15711
15891
  activeTab.value = getDefaultTab();
15712
15892
  activeKind.value = getDefaultKind();
15713
15893
  keyword.value = "";
15894
+ searchLoading.value = false;
15895
+ searchFailed.value = false;
15896
+ searchRequestId += 1;
15897
+ if (searchTimer)
15898
+ clearTimeout(searchTimer);
15714
15899
  searching.value = false;
15715
15900
  expandedKeys.value = getDefaultExpandedKeys();
15716
15901
  expandedSelected.value = false;
@@ -15728,6 +15913,40 @@
15728
15913
  expandedKeys.value = getDefaultExpandedKeys();
15729
15914
  }
15730
15915
  });
15916
+ const runSearch = (..._0) => __async$3(this, [..._0], function* (query = keyword.value.trim()) {
15917
+ if (!props2.search || !query)
15918
+ return;
15919
+ const requestId = ++searchRequestId;
15920
+ searchLoading.value = true;
15921
+ searchFailed.value = false;
15922
+ try {
15923
+ yield props2.search(query);
15924
+ } catch (error) {
15925
+ if (requestId !== searchRequestId)
15926
+ return;
15927
+ searchFailed.value = true;
15928
+ emit("search-error", query, error);
15929
+ } finally {
15930
+ if (requestId === searchRequestId)
15931
+ searchLoading.value = false;
15932
+ }
15933
+ });
15934
+ const scheduleSearch = () => {
15935
+ if (searchTimer)
15936
+ clearTimeout(searchTimer);
15937
+ searchRequestId += 1;
15938
+ searchLoading.value = false;
15939
+ searchFailed.value = false;
15940
+ if (props2.search && keyword.value.trim()) {
15941
+ searchTimer = setTimeout(runSearch, Number(props2.searchDebounce));
15942
+ }
15943
+ };
15944
+ vue.watch([keyword, () => props2.search], scheduleSearch);
15945
+ vue.onBeforeUnmount(() => {
15946
+ searchRequestId += 1;
15947
+ if (searchTimer)
15948
+ clearTimeout(searchTimer);
15949
+ });
15731
15950
  const setActiveTab = (tab) => {
15732
15951
  activeTab.value = tab;
15733
15952
  if (tab === "all") {
@@ -15794,9 +16013,25 @@
15794
16013
  }, null);
15795
16014
  const renderList = () => vue.createVNode("div", {
15796
16015
  "class": bem$w("material-list")
15797
- }, [visibleItems.value.length ? visibleItems.value.map((item) => renderMaterialCell(item, props2.items.indexOf(item))) : vue.createVNode("div", {
15798
- "class": bem$w("empty")
15799
- }, [vue.createTextVNode("暂无匹配物料")])]);
16016
+ }, [visibleItems.value.length ? visibleItems.value.map((item) => renderMaterialCell(item, props2.items.indexOf(item))) : vue.createVNode(Empty, {
16017
+ "description": "暂无匹配物料"
16018
+ }, null)]);
16019
+ const renderSearchContent = () => {
16020
+ if (searchLoading.value)
16021
+ return vue.createVNode("div", {
16022
+ "class": bem$w("search-state")
16023
+ }, [vue.createVNode(Loading, {
16024
+ "vertical": true
16025
+ }, {
16026
+ default: () => [vue.createTextVNode("加载中...")]
16027
+ })]);
16028
+ if (searchFailed.value)
16029
+ return vue.createVNode(Empty, {
16030
+ "image": "network",
16031
+ "description": "搜索失败,请重试"
16032
+ }, null);
16033
+ return renderList();
16034
+ };
15800
16035
  const renderCatalog = () => {
15801
16036
  const catalogItems = getCatalogItems();
15802
16037
  const defaultExpandedKeys = getDefaultExpandedKeys();
@@ -15853,11 +16088,19 @@
15853
16088
  "modelValue": keyword.value,
15854
16089
  "onUpdate:modelValue": ($event) => keyword.value = $event,
15855
16090
  "class": bem$w("search"),
16091
+ "variant": "pure",
15856
16092
  "shape": "round",
15857
16093
  "inputAlign": "left",
15858
16094
  "autofocus": true,
15859
16095
  "showAction": true,
15860
16096
  "placeholder": "搜索物资/工具名称",
16097
+ "onSearch": () => {
16098
+ if (props2.search) {
16099
+ if (searchTimer)
16100
+ clearTimeout(searchTimer);
16101
+ runSearch();
16102
+ }
16103
+ },
15861
16104
  "onCancel": () => {
15862
16105
  searching.value = false;
15863
16106
  keyword.value = "";
@@ -15911,7 +16154,7 @@
15911
16154
  default: () => [props2.toolTabText]
15912
16155
  })])]), vue.createVNode("div", {
15913
16156
  "class": bem$w("body")
15914
- }, [searching.value && !keyword.value.trim() ? null : searching.value || activeTab.value === "common" ? renderList() : renderCatalog()]), vue.createVNode("div", {
16157
+ }, [searching.value && !keyword.value.trim() ? null : searching.value ? renderSearchContent() : activeTab.value === "common" ? renderList() : renderCatalog()]), vue.createVNode("div", {
15915
16158
  "class": bem$w("footer")
15916
16159
  }, [renderSelectPanel(), vue.createVNode(BottomActionBar, {
15917
16160
  "fixed": false,
@@ -17007,6 +17250,26 @@
17007
17250
  }
17008
17251
  });
17009
17252
  const NumberKeyboard = withInstall(stdin_default$u);
17253
+ var __async$2 = (__this, __arguments, generator) => {
17254
+ return new Promise((resolve, reject) => {
17255
+ var fulfilled = (value) => {
17256
+ try {
17257
+ step(generator.next(value));
17258
+ } catch (e) {
17259
+ reject(e);
17260
+ }
17261
+ };
17262
+ var rejected = (value) => {
17263
+ try {
17264
+ step(generator.throw(value));
17265
+ } catch (e) {
17266
+ reject(e);
17267
+ }
17268
+ };
17269
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
17270
+ step((generator = generator.apply(__this, __arguments)).next());
17271
+ });
17272
+ };
17010
17273
  const [name$o, bem$o] = createNamespace("object-select");
17011
17274
  const spaceItems = [{
17012
17275
  id: "shenzhen-hq",
@@ -17042,13 +17305,7 @@
17042
17305
  id: "high-voltage",
17043
17306
  text: "高压计量柜",
17044
17307
  selectable: false,
17045
- children: [{
17046
- id: "metering-cabinet-1",
17047
- text: "B3_高压计量柜_1#"
17048
- }, {
17049
- id: "metering-cabinet-2",
17050
- text: "B3_高压计量柜_2#"
17051
- }]
17308
+ children: []
17052
17309
  }]
17053
17310
  }, {
17054
17311
  id: "chiller-room",
@@ -17368,13 +17625,16 @@
17368
17625
  specialties: {
17369
17626
  type: Array,
17370
17627
  default: () => specialties
17371
- }
17628
+ },
17629
+ loadChildren: Function,
17630
+ search: Function,
17631
+ searchDebounce: makeNumericProp(300)
17372
17632
  };
17373
17633
  const flattenItems$1 = (items) => items.flatMap((item) => [item, ...item.children ? flattenItems$1(item.children) : []]);
17374
17634
  var stdin_default$t = vue.defineComponent({
17375
17635
  name: name$o,
17376
17636
  props: objectSelectProps,
17377
- emits: ["update:show", "update:modelValue", "change", "confirm"],
17637
+ emits: ["update:show", "update:modelValue", "change", "confirm", "load", "load-error", "search-error"],
17378
17638
  setup(props2, {
17379
17639
  emit
17380
17640
  }) {
@@ -17387,6 +17647,20 @@
17387
17647
  const expandedSelected = vue.ref(false);
17388
17648
  const searching = vue.ref(false);
17389
17649
  const keyword = vue.ref("");
17650
+ const asyncSearchResults = vue.ref([]);
17651
+ const searchLoading = vue.ref(false);
17652
+ const searchFailed = vue.ref(false);
17653
+ const searchedItems = vue.shallowReactive(/* @__PURE__ */ new Map());
17654
+ let searchTimer;
17655
+ let searchRequestId = 0;
17656
+ const loadedChildren = vue.shallowReactive(/* @__PURE__ */ new Map());
17657
+ const getChildren = (item) => loadedChildren.get(item.id) || item.children || [];
17658
+ const hydrateItems = (items) => items.map((item) => {
17659
+ const children = getChildren(item);
17660
+ return children.length ? extend$1({}, item, {
17661
+ children: hydrateItems(children)
17662
+ }) : item;
17663
+ });
17390
17664
  const currentSpecialtyItems = (specialty) => specialtyType.value === 0 ? specialty.deviceItems : specialty.systemItems;
17391
17665
  const expandOnlySpecialty = () => {
17392
17666
  if (props2.specialties.length === 1) {
@@ -17400,6 +17674,12 @@
17400
17674
  view.value = 0;
17401
17675
  specialtyType.value = 0;
17402
17676
  keyword.value = "";
17677
+ asyncSearchResults.value = [];
17678
+ searchLoading.value = false;
17679
+ searchFailed.value = false;
17680
+ searchRequestId += 1;
17681
+ if (searchTimer)
17682
+ clearTimeout(searchTimer);
17403
17683
  searching.value = false;
17404
17684
  expandedSelected.value = false;
17405
17685
  expandedSpecialties.value = {
@@ -17411,14 +17691,65 @@
17411
17691
  immediate: true
17412
17692
  });
17413
17693
  const selected = vue.computed(() => props2.modelValue);
17414
- const allItems = vue.computed(() => flattenItems$1([...props2.spaceItems, ...props2.specialties.flatMap((specialty) => [...specialty.deviceItems, ...specialty.systemItems])]));
17415
- const selectedItems = vue.computed(() => allItems.value.filter((item) => selected.value.includes(item.id)));
17694
+ const allItems = vue.computed(() => flattenItems$1(hydrateItems([...props2.spaceItems, ...props2.specialties.flatMap((specialty) => [...specialty.deviceItems, ...specialty.systemItems])])));
17695
+ const selectedItems = vue.computed(() => {
17696
+ const items = /* @__PURE__ */ new Map();
17697
+ allItems.value.forEach((item) => items.set(item.id, item));
17698
+ searchedItems.forEach((item) => items.set(item.id, item));
17699
+ return selected.value.flatMap((id) => {
17700
+ const item = items.get(id);
17701
+ return item ? [item] : [];
17702
+ });
17703
+ });
17416
17704
  const searchResults = vue.computed(() => {
17417
17705
  const query = keyword.value.trim().toLowerCase();
17418
17706
  if (!query)
17419
17707
  return [];
17708
+ if (props2.search)
17709
+ return asyncSearchResults.value;
17420
17710
  return allItems.value.filter((item) => item.text.toLowerCase().includes(query));
17421
17711
  });
17712
+ const runSearch = (..._0) => __async$2(this, [..._0], function* (query = keyword.value.trim()) {
17713
+ if (!props2.search || !query)
17714
+ return;
17715
+ const requestId = ++searchRequestId;
17716
+ searchLoading.value = true;
17717
+ searchFailed.value = false;
17718
+ try {
17719
+ const results = yield props2.search(query);
17720
+ if (requestId !== searchRequestId)
17721
+ return;
17722
+ asyncSearchResults.value = results;
17723
+ results.forEach((item) => searchedItems.set(item.id, item));
17724
+ } catch (error) {
17725
+ if (requestId !== searchRequestId)
17726
+ return;
17727
+ asyncSearchResults.value = [];
17728
+ searchFailed.value = true;
17729
+ emit("search-error", query, error);
17730
+ } finally {
17731
+ if (requestId === searchRequestId)
17732
+ searchLoading.value = false;
17733
+ }
17734
+ });
17735
+ const scheduleSearch = () => {
17736
+ if (searchTimer)
17737
+ clearTimeout(searchTimer);
17738
+ searchRequestId += 1;
17739
+ searchLoading.value = false;
17740
+ searchFailed.value = false;
17741
+ asyncSearchResults.value = [];
17742
+ const query = keyword.value.trim();
17743
+ if (!props2.search || !query)
17744
+ return;
17745
+ searchTimer = setTimeout(runSearch, Number(props2.searchDebounce));
17746
+ };
17747
+ vue.watch([keyword, () => props2.search], scheduleSearch);
17748
+ vue.onBeforeUnmount(() => {
17749
+ searchRequestId += 1;
17750
+ if (searchTimer)
17751
+ clearTimeout(searchTimer);
17752
+ });
17422
17753
  const renderHighlightedText = (text) => {
17423
17754
  const query = keyword.value.trim();
17424
17755
  if (!query)
@@ -17456,19 +17787,29 @@
17456
17787
  update([]);
17457
17788
  expandedSelected.value = false;
17458
17789
  };
17790
+ const onLoad = (item, children) => {
17791
+ loadedChildren.set(item.id, children);
17792
+ emit("load", item, children);
17793
+ };
17794
+ const onLoadError = (item, error) => {
17795
+ emit("load-error", item, error);
17796
+ };
17459
17797
  const renderTree = (items) => vue.createVNode("div", {
17460
17798
  "class": bem$o("tree-card")
17461
17799
  }, [vue.createVNode(TreeSelect, {
17462
17800
  "modelValue": selected.value,
17463
17801
  "expandedKeys": expandedKeys.value,
17464
- "items": items,
17802
+ "items": hydrateItems(items),
17465
17803
  "multiple": true,
17466
17804
  "showParentSelect": true,
17467
17805
  "cascade": false,
17806
+ "loadChildren": props2.loadChildren,
17468
17807
  "onUpdate:modelValue": update,
17469
17808
  "onUpdate:expandedKeys": (value) => {
17470
17809
  expandedKeys.value = value;
17471
- }
17810
+ },
17811
+ "onLoad": onLoad,
17812
+ "onLoad-error": onLoadError
17472
17813
  }, null)]);
17473
17814
  const renderSpecialty = (specialty) => {
17474
17815
  var _a;
@@ -17489,6 +17830,45 @@
17489
17830
  }, null), expanded && renderTree(items)]);
17490
17831
  };
17491
17832
  const close = () => emit("update:show", false);
17833
+ const renderSearchContent = () => {
17834
+ if (!keyword.value.trim())
17835
+ return;
17836
+ if (searchLoading.value) {
17837
+ return vue.createVNode("div", {
17838
+ "class": bem$o("search-state")
17839
+ }, [vue.createVNode(Loading, {
17840
+ "vertical": true
17841
+ }, {
17842
+ default: () => [vue.createTextVNode("加载中...")]
17843
+ })]);
17844
+ }
17845
+ if (searchFailed.value) {
17846
+ return vue.createVNode(Empty, {
17847
+ "image": "network",
17848
+ "description": "搜索失败,请重试"
17849
+ }, null);
17850
+ }
17851
+ if (!searchResults.value.length) {
17852
+ return vue.createVNode(Empty, {
17853
+ "description": "暂无搜索结果"
17854
+ }, null);
17855
+ }
17856
+ return vue.createVNode("div", {
17857
+ "class": bem$o("tree-card", {
17858
+ search: true
17859
+ })
17860
+ }, [searchResults.value.map((item) => vue.createVNode(Cell, {
17861
+ "key": item.id,
17862
+ "rightSelect": selected.value.includes(item.id),
17863
+ "selectType": "checkbox",
17864
+ "border": true,
17865
+ "clickable": true,
17866
+ "onClick": () => toggleSearchItem(item),
17867
+ "onUpdate:rightSelect": () => toggleSearchItem(item)
17868
+ }, {
17869
+ title: () => renderHighlightedText(item.text)
17870
+ }))]);
17871
+ };
17492
17872
  return () => vue.createVNode(ActionSheet, {
17493
17873
  "show": props2.show,
17494
17874
  "class": bem$o(),
@@ -17499,10 +17879,18 @@
17499
17879
  "modelValue": keyword.value,
17500
17880
  "onUpdate:modelValue": ($event) => keyword.value = $event,
17501
17881
  "class": bem$o("search"),
17882
+ "variant": "pure",
17502
17883
  "shape": "round",
17503
17884
  "inputAlign": "left",
17504
17885
  "autofocus": true,
17505
17886
  "placeholder": "搜索对象",
17887
+ "onSearch": () => {
17888
+ if (props2.search) {
17889
+ if (searchTimer)
17890
+ clearTimeout(searchTimer);
17891
+ runSearch();
17892
+ }
17893
+ },
17506
17894
  "onCancel": () => {
17507
17895
  searching.value = false;
17508
17896
  keyword.value = "";
@@ -17541,21 +17929,7 @@
17541
17929
  }, null)]
17542
17930
  })]), vue.createVNode("div", {
17543
17931
  "class": bem$o("body")
17544
- }, [searching.value ? keyword.value && vue.createVNode("div", {
17545
- "class": bem$o("tree-card", {
17546
- search: true
17547
- })
17548
- }, [searchResults.value.map((item) => vue.createVNode(Cell, {
17549
- "key": item.id,
17550
- "rightSelect": selected.value.includes(item.id),
17551
- "selectType": "checkbox",
17552
- "border": true,
17553
- "clickable": true,
17554
- "onClick": () => toggleSearchItem(item),
17555
- "onUpdate:rightSelect": () => toggleSearchItem(item)
17556
- }, {
17557
- title: () => renderHighlightedText(item.text)
17558
- }))]) : view.value === 0 ? renderTree(props2.spaceItems) : vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
17932
+ }, [searching.value ? renderSearchContent() : view.value === 0 ? renderTree(props2.spaceItems) : vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
17559
17933
  "class": bem$o("type-tabs")
17560
17934
  }, [vue.createVNode(FilterTag, {
17561
17935
  "selected": specialtyType.value === 0,
@@ -24987,7 +25361,7 @@
24987
25361
  });
24988
25362
  }
24989
25363
  };
24990
- const version = "0.0.43";
25364
+ const version = "0.0.45";
24991
25365
  function install(app) {
24992
25366
  const components = [
24993
25367
  ActionBar,