persagy-vant 0.0.43 → 0.0.44

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/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$2 = (__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$2(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", {
@@ -17042,13 +17094,7 @@
17042
17094
  id: "high-voltage",
17043
17095
  text: "高压计量柜",
17044
17096
  selectable: false,
17045
- children: [{
17046
- id: "metering-cabinet-1",
17047
- text: "B3_高压计量柜_1#"
17048
- }, {
17049
- id: "metering-cabinet-2",
17050
- text: "B3_高压计量柜_2#"
17051
- }]
17097
+ children: []
17052
17098
  }]
17053
17099
  }, {
17054
17100
  id: "chiller-room",
@@ -17368,13 +17414,14 @@
17368
17414
  specialties: {
17369
17415
  type: Array,
17370
17416
  default: () => specialties
17371
- }
17417
+ },
17418
+ loadChildren: Function
17372
17419
  };
17373
17420
  const flattenItems$1 = (items) => items.flatMap((item) => [item, ...item.children ? flattenItems$1(item.children) : []]);
17374
17421
  var stdin_default$t = vue.defineComponent({
17375
17422
  name: name$o,
17376
17423
  props: objectSelectProps,
17377
- emits: ["update:show", "update:modelValue", "change", "confirm"],
17424
+ emits: ["update:show", "update:modelValue", "change", "confirm", "load", "load-error"],
17378
17425
  setup(props2, {
17379
17426
  emit
17380
17427
  }) {
@@ -17387,6 +17434,14 @@
17387
17434
  const expandedSelected = vue.ref(false);
17388
17435
  const searching = vue.ref(false);
17389
17436
  const keyword = vue.ref("");
17437
+ const loadedChildren = vue.shallowReactive(/* @__PURE__ */ new Map());
17438
+ const getChildren = (item) => loadedChildren.get(item.id) || item.children || [];
17439
+ const hydrateItems = (items) => items.map((item) => {
17440
+ const children = getChildren(item);
17441
+ return children.length ? extend$1({}, item, {
17442
+ children: hydrateItems(children)
17443
+ }) : item;
17444
+ });
17390
17445
  const currentSpecialtyItems = (specialty) => specialtyType.value === 0 ? specialty.deviceItems : specialty.systemItems;
17391
17446
  const expandOnlySpecialty = () => {
17392
17447
  if (props2.specialties.length === 1) {
@@ -17411,7 +17466,7 @@
17411
17466
  immediate: true
17412
17467
  });
17413
17468
  const selected = vue.computed(() => props2.modelValue);
17414
- const allItems = vue.computed(() => flattenItems$1([...props2.spaceItems, ...props2.specialties.flatMap((specialty) => [...specialty.deviceItems, ...specialty.systemItems])]));
17469
+ const allItems = vue.computed(() => flattenItems$1(hydrateItems([...props2.spaceItems, ...props2.specialties.flatMap((specialty) => [...specialty.deviceItems, ...specialty.systemItems])])));
17415
17470
  const selectedItems = vue.computed(() => allItems.value.filter((item) => selected.value.includes(item.id)));
17416
17471
  const searchResults = vue.computed(() => {
17417
17472
  const query = keyword.value.trim().toLowerCase();
@@ -17456,19 +17511,29 @@
17456
17511
  update([]);
17457
17512
  expandedSelected.value = false;
17458
17513
  };
17514
+ const onLoad = (item, children) => {
17515
+ loadedChildren.set(item.id, children);
17516
+ emit("load", item, children);
17517
+ };
17518
+ const onLoadError = (item, error) => {
17519
+ emit("load-error", item, error);
17520
+ };
17459
17521
  const renderTree = (items) => vue.createVNode("div", {
17460
17522
  "class": bem$o("tree-card")
17461
17523
  }, [vue.createVNode(TreeSelect, {
17462
17524
  "modelValue": selected.value,
17463
17525
  "expandedKeys": expandedKeys.value,
17464
- "items": items,
17526
+ "items": hydrateItems(items),
17465
17527
  "multiple": true,
17466
17528
  "showParentSelect": true,
17467
17529
  "cascade": false,
17530
+ "loadChildren": props2.loadChildren,
17468
17531
  "onUpdate:modelValue": update,
17469
17532
  "onUpdate:expandedKeys": (value) => {
17470
17533
  expandedKeys.value = value;
17471
- }
17534
+ },
17535
+ "onLoad": onLoad,
17536
+ "onLoad-error": onLoadError
17472
17537
  }, null)]);
17473
17538
  const renderSpecialty = (specialty) => {
17474
17539
  var _a;
@@ -24987,7 +25052,7 @@
24987
25052
  });
24988
25053
  }
24989
25054
  };
24990
- const version = "0.0.43";
25055
+ const version = "0.0.44";
24991
25056
  function install(app) {
24992
25057
  const components = [
24993
25058
  ActionBar,