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.cjs.js CHANGED
@@ -7610,21 +7610,21 @@ var stdin_default$1o = vue.defineComponent({
7610
7610
  }, [renderChildren()]);
7611
7611
  }
7612
7612
  });
7613
- var __defProp$1 = Object.defineProperty;
7613
+ var __defProp = Object.defineProperty;
7614
7614
  var __defProps = Object.defineProperties;
7615
7615
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7616
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
7617
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
7618
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
7619
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7620
- var __spreadValues$1 = (a, b) => {
7616
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7617
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7618
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7619
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7620
+ var __spreadValues = (a, b) => {
7621
7621
  for (var prop in b || (b = {}))
7622
- if (__hasOwnProp$1.call(b, prop))
7623
- __defNormalProp$1(a, prop, b[prop]);
7624
- if (__getOwnPropSymbols$1)
7625
- for (var prop of __getOwnPropSymbols$1(b)) {
7626
- if (__propIsEnum$1.call(b, prop))
7627
- __defNormalProp$1(a, prop, b[prop]);
7622
+ if (__hasOwnProp.call(b, prop))
7623
+ __defNormalProp(a, prop, b[prop]);
7624
+ if (__getOwnPropSymbols)
7625
+ for (var prop of __getOwnPropSymbols(b)) {
7626
+ if (__propIsEnum.call(b, prop))
7627
+ __defNormalProp(a, prop, b[prop]);
7628
7628
  }
7629
7629
  return a;
7630
7630
  };
@@ -7880,7 +7880,7 @@ var stdin_default$1n = vue.defineComponent({
7880
7880
  name: tab.title,
7881
7881
  disabled: tab.disabled
7882
7882
  }));
7883
- return actions.map((action, index) => __spreadProps(__spreadValues$1({}, action), {
7883
+ return actions.map((action, index) => __spreadProps(__spreadValues({}, action), {
7884
7884
  color: index === state.currentIndex ? "var(--van-primary-color)" : action.color,
7885
7885
  className: [action.className, bem$1d("more-option", {
7886
7886
  active: index === state.currentIndex
@@ -13034,21 +13034,25 @@ var stdin_default$K = vue.defineComponent({
13034
13034
  }
13035
13035
  });
13036
13036
  const InfoCard = withInstall(stdin_default$K);
13037
- var __defProp = Object.defineProperty;
13038
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13039
- var __hasOwnProp = Object.prototype.hasOwnProperty;
13040
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
13041
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13042
- var __spreadValues = (a, b) => {
13043
- for (var prop in b || (b = {}))
13044
- if (__hasOwnProp.call(b, prop))
13045
- __defNormalProp(a, prop, b[prop]);
13046
- if (__getOwnPropSymbols)
13047
- for (var prop of __getOwnPropSymbols(b)) {
13048
- if (__propIsEnum.call(b, prop))
13049
- __defNormalProp(a, prop, b[prop]);
13050
- }
13051
- return a;
13037
+ var __async$2 = (__this, __arguments, generator) => {
13038
+ return new Promise((resolve, reject) => {
13039
+ var fulfilled = (value) => {
13040
+ try {
13041
+ step(generator.next(value));
13042
+ } catch (e) {
13043
+ reject(e);
13044
+ }
13045
+ };
13046
+ var rejected = (value) => {
13047
+ try {
13048
+ step(generator.throw(value));
13049
+ } catch (e) {
13050
+ reject(e);
13051
+ }
13052
+ };
13053
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
13054
+ step((generator = generator.apply(__this, __arguments)).next());
13055
+ });
13052
13056
  };
13053
13057
  const [name$B, bem$B] = createNamespace("tree-select");
13054
13058
  const treeSelectProps = {
@@ -13060,20 +13064,31 @@ const treeSelectProps = {
13060
13064
  selectableParent: Boolean,
13061
13065
  showParentSelect: Boolean,
13062
13066
  showSelectLevels: Array,
13063
- showDivider: truthProp
13067
+ showDivider: truthProp,
13068
+ loadChildren: Function
13064
13069
  };
13065
13070
  var stdin_default$J = vue.defineComponent({
13066
13071
  name: name$B,
13067
13072
  props: treeSelectProps,
13068
- emits: ["update:modelValue", "update:expandedKeys", "select", "expand"],
13073
+ emits: ["update:modelValue", "update:expandedKeys", "select", "expand", "load", "load-error"],
13069
13074
  setup(props2, {
13070
13075
  emit,
13071
13076
  slots
13072
13077
  }) {
13073
13078
  const selectedKeys = vue.computed(() => props2.modelValue);
13074
13079
  const expandedKeys = vue.computed(() => props2.expandedKeys);
13080
+ const resolvedChildren = vue.shallowReactive(/* @__PURE__ */ new Map());
13081
+ const loadingKeys = vue.shallowReactive(/* @__PURE__ */ new Set());
13082
+ const loadedKeys = vue.shallowReactive(/* @__PURE__ */ new Set());
13075
13083
  const isExpanded = (id) => expandedKeys.value.includes(id);
13076
13084
  const isSelected = (id) => selectedKeys.value.includes(id);
13085
+ const isLoading = (id) => loadingKeys.has(id);
13086
+ const getChildren = (item) => {
13087
+ var _a;
13088
+ return ((_a = item.children) == null ? void 0 : _a.length) ? item.children : resolvedChildren.get(item.id) || item.children || [];
13089
+ };
13090
+ const isLoadable = (item) => !!props2.loadChildren && Array.isArray(item.children) && !item.children.length && !loadedKeys.has(item.id);
13091
+ const isBranch = (item) => !!getChildren(item).length || isLoadable(item) || isLoading(item.id);
13077
13092
  const isSelectionVisible = (hasChildren, level) => {
13078
13093
  var _a;
13079
13094
  const configuredVisibility = (_a = props2.showSelectLevels) == null ? void 0 : _a[level];
@@ -13085,10 +13100,7 @@ var stdin_default$J = vue.defineComponent({
13085
13100
  paddingLeft: `calc(var(--van-padding-md) + ${level * 16}px)`,
13086
13101
  "--van-tree-select-divider-left": `calc(var(--van-padding-md) + ${level * 16}px)`
13087
13102
  });
13088
- const getDescendantIds = (item) => {
13089
- var _a;
13090
- return ((_a = item.children) == null ? void 0 : _a.flatMap((child) => [child.id, ...getDescendantIds(child)])) || [];
13091
- };
13103
+ const getDescendantIds = (item) => getChildren(item).flatMap((child) => [child.id, ...getDescendantIds(child)]);
13092
13104
  const getSelectionState = (item) => {
13093
13105
  const descendantIds = getDescendantIds(item);
13094
13106
  if (!props2.cascade || !descendantIds.length) {
@@ -13103,11 +13115,11 @@ var stdin_default$J = vue.defineComponent({
13103
13115
  };
13104
13116
  const syncParentSelection = (items, values) => {
13105
13117
  items.forEach((item) => {
13106
- var _a;
13107
- if (!((_a = item.children) == null ? void 0 : _a.length))
13118
+ const children = getChildren(item);
13119
+ if (!children.length)
13108
13120
  return;
13109
- syncParentSelection(item.children, values);
13110
- const childIds = item.children.map((child) => child.id);
13121
+ syncParentSelection(children, values);
13122
+ const childIds = children.map((child) => child.id);
13111
13123
  const index = values.indexOf(item.id);
13112
13124
  const allChildrenSelected = childIds.every((id) => values.includes(id));
13113
13125
  if (allChildrenSelected && index === -1)
@@ -13116,13 +13128,45 @@ var stdin_default$J = vue.defineComponent({
13116
13128
  values.splice(index, 1);
13117
13129
  });
13118
13130
  };
13119
- const toggleExpanded = (id) => {
13131
+ const updateExpanded = (id, expanded) => {
13120
13132
  const next = expandedKeys.value.slice();
13121
13133
  const index = next.indexOf(id);
13122
- index === -1 ? next.push(id) : next.splice(index, 1);
13134
+ if (expanded && index === -1)
13135
+ next.push(id);
13136
+ if (!expanded && index !== -1)
13137
+ next.splice(index, 1);
13123
13138
  emit("update:expandedKeys", next);
13124
- emit("expand", id, index === -1);
13139
+ emit("expand", id, expanded);
13125
13140
  };
13141
+ const toggleExpanded = (item) => __async$2(this, null, function* () {
13142
+ const {
13143
+ id
13144
+ } = item;
13145
+ if (isLoading(id))
13146
+ return;
13147
+ if (isExpanded(id)) {
13148
+ updateExpanded(id, false);
13149
+ return;
13150
+ }
13151
+ if (isLoadable(item)) {
13152
+ loadingKeys.add(id);
13153
+ try {
13154
+ const result = yield props2.loadChildren(item);
13155
+ const children = Array.isArray(result) ? result : [];
13156
+ resolvedChildren.set(id, children);
13157
+ loadedKeys.add(id);
13158
+ emit("load", item, children);
13159
+ if (children.length)
13160
+ updateExpanded(id, true);
13161
+ } catch (error) {
13162
+ emit("load-error", item, error);
13163
+ } finally {
13164
+ loadingKeys.delete(id);
13165
+ }
13166
+ return;
13167
+ }
13168
+ updateExpanded(id, true);
13169
+ });
13126
13170
  const updateSelected = (item, selected) => {
13127
13171
  if (item.disabled || item.selectable === false)
13128
13172
  return;
@@ -13141,12 +13185,13 @@ var stdin_default$J = vue.defineComponent({
13141
13185
  emit("select", item, selected);
13142
13186
  };
13143
13187
  const renderNodes = (items, level = 0) => items.map((item) => {
13144
- var _a;
13145
- const hasChildren = !!((_a = item.children) == null ? void 0 : _a.length);
13188
+ const children = getChildren(item);
13189
+ const hasChildren = isBranch(item);
13146
13190
  const expanded = isExpanded(item.id);
13191
+ const loading = isLoading(item.id);
13147
13192
  const renderTitle = () => {
13148
- var _a2;
13149
- return ((_a2 = slots.title) == null ? void 0 : _a2.call(slots, {
13193
+ var _a;
13194
+ return ((_a = slots.title) == null ? void 0 : _a.call(slots, {
13150
13195
  item,
13151
13196
  level,
13152
13197
  hasChildren
@@ -13166,36 +13211,29 @@ var stdin_default$J = vue.defineComponent({
13166
13211
  }
13167
13212
  const selectable = item.selectable !== false && isSelectionVisible(hasChildren, level);
13168
13213
  const selectionState = getSelectionState(item);
13169
- return vue.createVNode("div", {
13170
- "key": item.id,
13171
- "class": bem$B("node")
13172
- }, [vue.createVNode(Cell, {
13173
- "class": bem$B("cell", {
13174
- branch: hasChildren
13175
- }),
13176
- "title": item.text,
13177
- "border": props2.showDivider,
13178
- "style": getNodeStyle(level),
13179
- "rightSelect": selectable && selectionState !== "indeterminate" ? selectionState === "checked" : void 0,
13180
- "selectType": props2.multiple ? "checkbox" : "radio",
13181
- "onUpdate:rightSelect": (value) => updateSelected(item, value)
13182
- }, __spreadValues({
13214
+ const cellSlots = {
13183
13215
  title: () => [hasChildren ? vue.createVNode("button", {
13184
13216
  "type": "button",
13185
13217
  "class": bem$B("expand-control"),
13186
13218
  "disabled": item.disabled,
13219
+ "aria-busy": loading,
13220
+ "aria-disabled": loading,
13187
13221
  "onClick": (event) => {
13188
13222
  event.stopPropagation();
13189
- toggleExpanded(item.id);
13223
+ toggleExpanded(item);
13190
13224
  }
13191
- }, [vue.createVNode(Icon, {
13225
+ }, [loading ? vue.createVNode(Loading, {
13226
+ "class": bem$B("loading"),
13227
+ "size": "var(--van-tree-select-arrow-size)"
13228
+ }, null) : vue.createVNode(Icon, {
13192
13229
  "name": "trangle-down",
13193
13230
  "class": bem$B("arrow", {
13194
13231
  expanded
13195
13232
  })
13196
13233
  }, null), vue.createVNode("span", null, [renderTitle()])]) : vue.createVNode("span", null, [renderTitle()])]
13197
- }, selectable && selectionState === "indeterminate" ? {
13198
- "right-select": () => vue.createVNode("button", {
13234
+ };
13235
+ if (selectable && selectionState === "indeterminate") {
13236
+ cellSlots["right-select"] = () => vue.createVNode("button", {
13199
13237
  "type": "button",
13200
13238
  "class": bem$B("indeterminate"),
13201
13239
  "aria-label": `部分选中${item.text}`,
@@ -13203,13 +13241,27 @@ var stdin_default$J = vue.defineComponent({
13203
13241
  event.stopPropagation();
13204
13242
  updateSelected(item, true);
13205
13243
  }
13206
- }, null)
13207
- } : {})), vue.createVNode(vue.Transition, {
13244
+ }, null);
13245
+ }
13246
+ return vue.createVNode("div", {
13247
+ "key": item.id,
13248
+ "class": bem$B("node")
13249
+ }, [vue.createVNode(Cell, {
13250
+ "class": bem$B("cell", {
13251
+ branch: hasChildren
13252
+ }),
13253
+ "title": item.text,
13254
+ "border": props2.showDivider,
13255
+ "style": getNodeStyle(level),
13256
+ "rightSelect": selectable && selectionState !== "indeterminate" ? selectionState === "checked" : void 0,
13257
+ "selectType": props2.multiple ? "checkbox" : "radio",
13258
+ "onUpdate:rightSelect": (value) => updateSelected(item, value)
13259
+ }, cellSlots), vue.createVNode(vue.Transition, {
13208
13260
  "name": "van-tree-select-expand"
13209
13261
  }, {
13210
13262
  default: () => [hasChildren && expanded && vue.createVNode("div", {
13211
13263
  "class": bem$B("children")
13212
- }, [renderNodes(item.children, level + 1)])]
13264
+ }, [renderNodes(children, level + 1)])]
13213
13265
  })]);
13214
13266
  });
13215
13267
  return () => vue.createVNode("div", {
@@ -15849,13 +15901,7 @@ const spaceItems = [{
15849
15901
  id: "high-voltage",
15850
15902
  text: "高压计量柜",
15851
15903
  selectable: false,
15852
- children: [{
15853
- id: "metering-cabinet-1",
15854
- text: "B3_高压计量柜_1#"
15855
- }, {
15856
- id: "metering-cabinet-2",
15857
- text: "B3_高压计量柜_2#"
15858
- }]
15904
+ children: []
15859
15905
  }]
15860
15906
  }, {
15861
15907
  id: "chiller-room",
@@ -16175,13 +16221,14 @@ const objectSelectProps = {
16175
16221
  specialties: {
16176
16222
  type: Array,
16177
16223
  default: () => specialties
16178
- }
16224
+ },
16225
+ loadChildren: Function
16179
16226
  };
16180
16227
  const flattenItems$1 = (items) => items.flatMap((item) => [item, ...item.children ? flattenItems$1(item.children) : []]);
16181
16228
  var stdin_default$t = vue.defineComponent({
16182
16229
  name: name$o,
16183
16230
  props: objectSelectProps,
16184
- emits: ["update:show", "update:modelValue", "change", "confirm"],
16231
+ emits: ["update:show", "update:modelValue", "change", "confirm", "load", "load-error"],
16185
16232
  setup(props2, {
16186
16233
  emit
16187
16234
  }) {
@@ -16194,6 +16241,14 @@ var stdin_default$t = vue.defineComponent({
16194
16241
  const expandedSelected = vue.ref(false);
16195
16242
  const searching = vue.ref(false);
16196
16243
  const keyword = vue.ref("");
16244
+ const loadedChildren = vue.shallowReactive(/* @__PURE__ */ new Map());
16245
+ const getChildren = (item) => loadedChildren.get(item.id) || item.children || [];
16246
+ const hydrateItems = (items) => items.map((item) => {
16247
+ const children = getChildren(item);
16248
+ return children.length ? extend({}, item, {
16249
+ children: hydrateItems(children)
16250
+ }) : item;
16251
+ });
16197
16252
  const currentSpecialtyItems = (specialty) => specialtyType.value === 0 ? specialty.deviceItems : specialty.systemItems;
16198
16253
  const expandOnlySpecialty = () => {
16199
16254
  if (props2.specialties.length === 1) {
@@ -16218,7 +16273,7 @@ var stdin_default$t = vue.defineComponent({
16218
16273
  immediate: true
16219
16274
  });
16220
16275
  const selected = vue.computed(() => props2.modelValue);
16221
- const allItems = vue.computed(() => flattenItems$1([...props2.spaceItems, ...props2.specialties.flatMap((specialty) => [...specialty.deviceItems, ...specialty.systemItems])]));
16276
+ const allItems = vue.computed(() => flattenItems$1(hydrateItems([...props2.spaceItems, ...props2.specialties.flatMap((specialty) => [...specialty.deviceItems, ...specialty.systemItems])])));
16222
16277
  const selectedItems = vue.computed(() => allItems.value.filter((item) => selected.value.includes(item.id)));
16223
16278
  const searchResults = vue.computed(() => {
16224
16279
  const query = keyword.value.trim().toLowerCase();
@@ -16263,19 +16318,29 @@ var stdin_default$t = vue.defineComponent({
16263
16318
  update([]);
16264
16319
  expandedSelected.value = false;
16265
16320
  };
16321
+ const onLoad = (item, children) => {
16322
+ loadedChildren.set(item.id, children);
16323
+ emit("load", item, children);
16324
+ };
16325
+ const onLoadError = (item, error) => {
16326
+ emit("load-error", item, error);
16327
+ };
16266
16328
  const renderTree = (items) => vue.createVNode("div", {
16267
16329
  "class": bem$o("tree-card")
16268
16330
  }, [vue.createVNode(TreeSelect, {
16269
16331
  "modelValue": selected.value,
16270
16332
  "expandedKeys": expandedKeys.value,
16271
- "items": items,
16333
+ "items": hydrateItems(items),
16272
16334
  "multiple": true,
16273
16335
  "showParentSelect": true,
16274
16336
  "cascade": false,
16337
+ "loadChildren": props2.loadChildren,
16275
16338
  "onUpdate:modelValue": update,
16276
16339
  "onUpdate:expandedKeys": (value) => {
16277
16340
  expandedKeys.value = value;
16278
- }
16341
+ },
16342
+ "onLoad": onLoad,
16343
+ "onLoad-error": onLoadError
16279
16344
  }, null)]);
16280
16345
  const renderSpecialty = (specialty) => {
16281
16346
  var _a;
@@ -21400,7 +21465,7 @@ const Lazyload = {
21400
21465
  });
21401
21466
  }
21402
21467
  };
21403
- const version = "0.0.43";
21468
+ const version = "0.0.44";
21404
21469
  function install(app) {
21405
21470
  const components = [
21406
21471
  ActionBar,