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