persagy-vant 0.0.42 → 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.
Files changed (67) hide show
  1. package/es/action-sheet/ActionSheet.d.ts +4 -0
  2. package/es/action-sheet/ActionSheet.mjs +4 -1
  3. package/es/action-sheet/index.css +1 -1
  4. package/es/action-sheet/index.d.ts +3 -0
  5. package/es/action-sheet/index.less +4 -0
  6. package/es/index.d.ts +1 -1
  7. package/es/index.mjs +1 -1
  8. package/es/locale/lang/en-US.d.ts +6 -0
  9. package/es/locale/lang/en-US.mjs +6 -0
  10. package/es/locale/lang/zh-CN.d.ts +6 -0
  11. package/es/locale/lang/zh-CN.mjs +6 -0
  12. package/es/object-select/ObjectSelect.d.ts +7 -2
  13. package/es/object-select/ObjectSelect.mjs +26 -13
  14. package/es/object-select/index.d.ts +5 -1
  15. package/es/tree-select/TreeSelect.d.ts +7 -1
  16. package/es/tree-select/TreeSelect.mjs +107 -54
  17. package/es/tree-select/index.css +1 -1
  18. package/es/tree-select/index.d.ts +6 -2
  19. package/es/tree-select/index.less +6 -0
  20. package/es/tree-select/style/index.mjs +1 -0
  21. package/es/tree-select/style/less.mjs +1 -0
  22. package/es/uploader/Uploader.d.ts +6 -1
  23. package/es/uploader/Uploader.mjs +80 -19
  24. package/es/uploader/index.css +1 -1
  25. package/es/uploader/index.d.ts +6 -2
  26. package/es/uploader/index.less +4 -0
  27. package/es/uploader/style/index.mjs +3 -0
  28. package/es/uploader/style/less.mjs +3 -0
  29. package/es/uploader/types.d.ts +2 -1
  30. package/lib/action-sheet/ActionSheet.d.ts +4 -0
  31. package/lib/action-sheet/ActionSheet.js +4 -1
  32. package/lib/action-sheet/index.css +1 -1
  33. package/lib/action-sheet/index.d.ts +3 -0
  34. package/lib/action-sheet/index.less +4 -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/locale/lang/en-US.d.ts +6 -0
  39. package/lib/locale/lang/en-US.js +6 -0
  40. package/lib/locale/lang/zh-CN.d.ts +6 -0
  41. package/lib/locale/lang/zh-CN.js +6 -0
  42. package/lib/object-select/ObjectSelect.d.ts +7 -2
  43. package/lib/object-select/ObjectSelect.js +25 -12
  44. package/lib/object-select/index.d.ts +5 -1
  45. package/lib/tree-select/TreeSelect.d.ts +7 -1
  46. package/lib/tree-select/TreeSelect.js +107 -52
  47. package/lib/tree-select/index.css +1 -1
  48. package/lib/tree-select/index.d.ts +6 -2
  49. package/lib/tree-select/index.less +6 -0
  50. package/lib/tree-select/style/index.js +1 -0
  51. package/lib/tree-select/style/less.js +1 -0
  52. package/lib/uploader/Uploader.d.ts +6 -1
  53. package/lib/uploader/Uploader.js +79 -18
  54. package/lib/uploader/index.css +1 -1
  55. package/lib/uploader/index.d.ts +6 -2
  56. package/lib/uploader/index.less +4 -0
  57. package/lib/uploader/style/index.js +3 -0
  58. package/lib/uploader/style/less.js +3 -0
  59. package/lib/uploader/types.d.ts +2 -1
  60. package/lib/vant.cjs.js +232 -98
  61. package/lib/vant.es.js +233 -99
  62. package/lib/vant.js +232 -98
  63. package/lib/vant.min.js +1 -1
  64. package/lib/web-types.json +1 -1
  65. package/package.json +1 -1
  66. package/skills/use-persagy-vant/references/business-component-catalog.md +1 -1
  67. package/skills/use-persagy-vant/references/component-catalog.md +2 -2
package/lib/vant.js CHANGED
@@ -656,6 +656,12 @@
656
656
  },
657
657
  vanTabs: {
658
658
  moreTitle: "更多标签"
659
+ },
660
+ vanUploader: {
661
+ sourcePickerTitle: "选择上传方式",
662
+ takePhoto: "拍照",
663
+ recordVideo: "拍视频",
664
+ chooseFromAlbum: "从相册选择"
659
665
  }
660
666
  };
661
667
  const lang = vue.ref("zh-CN");
@@ -3035,6 +3041,7 @@
3035
3041
  closeable: truthProp,
3036
3042
  cancelText: String,
3037
3043
  description: String,
3044
+ contentAdaptive: Boolean,
3038
3045
  closeOnPopstate: truthProp,
3039
3046
  closeOnClickAction: Boolean,
3040
3047
  safeAreaInsetBottom: truthProp
@@ -3143,7 +3150,9 @@
3143
3150
  }
3144
3151
  };
3145
3152
  return () => vue.createVNode(Popup, vue.mergeProps({
3146
- "class": bem$1I(),
3153
+ "class": bem$1I({
3154
+ "content-adaptive": props2.contentAdaptive
3155
+ }),
3147
3156
  "position": "bottom",
3148
3157
  "onUpdate:show": updateShow
3149
3158
  }, pick(props2, popupInheritKeys$2)), {
@@ -8839,21 +8848,21 @@
8839
8848
  }, [renderChildren()]);
8840
8849
  }
8841
8850
  });
8842
- var __defProp$1 = Object.defineProperty;
8851
+ var __defProp = Object.defineProperty;
8843
8852
  var __defProps = Object.defineProperties;
8844
8853
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8845
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
8846
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
8847
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
8848
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8849
- 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) => {
8850
8859
  for (var prop in b || (b = {}))
8851
- if (__hasOwnProp$1.call(b, prop))
8852
- __defNormalProp$1(a, prop, b[prop]);
8853
- if (__getOwnPropSymbols$1)
8854
- for (var prop of __getOwnPropSymbols$1(b)) {
8855
- if (__propIsEnum$1.call(b, prop))
8856
- __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]);
8857
8866
  }
8858
8867
  return a;
8859
8868
  };
@@ -9099,7 +9108,7 @@
9099
9108
  name: tab.title,
9100
9109
  disabled: tab.disabled
9101
9110
  }));
9102
- return actions.map((action, index) => __spreadProps(__spreadValues$1({}, action), {
9111
+ return actions.map((action, index) => __spreadProps(__spreadValues({}, action), {
9103
9112
  color: index === state.currentIndex ? "var(--van-primary-color)" : action.color,
9104
9113
  className: [action.className, bem$1d("more-option", {
9105
9114
  active: index === state.currentIndex
@@ -14218,21 +14227,25 @@
14218
14227
  }
14219
14228
  });
14220
14229
  const InfoCard = withInstall(stdin_default$K);
14221
- var __defProp = Object.defineProperty;
14222
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14223
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14224
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
14225
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14226
- var __spreadValues = (a, b) => {
14227
- for (var prop in b || (b = {}))
14228
- if (__hasOwnProp.call(b, prop))
14229
- __defNormalProp(a, prop, b[prop]);
14230
- if (__getOwnPropSymbols)
14231
- for (var prop of __getOwnPropSymbols(b)) {
14232
- if (__propIsEnum.call(b, prop))
14233
- __defNormalProp(a, prop, b[prop]);
14234
- }
14235
- 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
+ });
14236
14249
  };
14237
14250
  const [name$B, bem$B] = createNamespace("tree-select");
14238
14251
  const treeSelectProps = {
@@ -14244,20 +14257,31 @@
14244
14257
  selectableParent: Boolean,
14245
14258
  showParentSelect: Boolean,
14246
14259
  showSelectLevels: Array,
14247
- showDivider: truthProp
14260
+ showDivider: truthProp,
14261
+ loadChildren: Function
14248
14262
  };
14249
14263
  var stdin_default$J = vue.defineComponent({
14250
14264
  name: name$B,
14251
14265
  props: treeSelectProps,
14252
- emits: ["update:modelValue", "update:expandedKeys", "select", "expand"],
14266
+ emits: ["update:modelValue", "update:expandedKeys", "select", "expand", "load", "load-error"],
14253
14267
  setup(props2, {
14254
14268
  emit,
14255
14269
  slots
14256
14270
  }) {
14257
14271
  const selectedKeys = vue.computed(() => props2.modelValue);
14258
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());
14259
14276
  const isExpanded = (id) => expandedKeys.value.includes(id);
14260
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);
14261
14285
  const isSelectionVisible = (hasChildren, level) => {
14262
14286
  var _a;
14263
14287
  const configuredVisibility = (_a = props2.showSelectLevels) == null ? void 0 : _a[level];
@@ -14269,10 +14293,7 @@
14269
14293
  paddingLeft: `calc(var(--van-padding-md) + ${level * 16}px)`,
14270
14294
  "--van-tree-select-divider-left": `calc(var(--van-padding-md) + ${level * 16}px)`
14271
14295
  });
14272
- const getDescendantIds = (item) => {
14273
- var _a;
14274
- return ((_a = item.children) == null ? void 0 : _a.flatMap((child) => [child.id, ...getDescendantIds(child)])) || [];
14275
- };
14296
+ const getDescendantIds = (item) => getChildren(item).flatMap((child) => [child.id, ...getDescendantIds(child)]);
14276
14297
  const getSelectionState = (item) => {
14277
14298
  const descendantIds = getDescendantIds(item);
14278
14299
  if (!props2.cascade || !descendantIds.length) {
@@ -14287,11 +14308,11 @@
14287
14308
  };
14288
14309
  const syncParentSelection = (items, values) => {
14289
14310
  items.forEach((item) => {
14290
- var _a;
14291
- if (!((_a = item.children) == null ? void 0 : _a.length))
14311
+ const children = getChildren(item);
14312
+ if (!children.length)
14292
14313
  return;
14293
- syncParentSelection(item.children, values);
14294
- const childIds = item.children.map((child) => child.id);
14314
+ syncParentSelection(children, values);
14315
+ const childIds = children.map((child) => child.id);
14295
14316
  const index = values.indexOf(item.id);
14296
14317
  const allChildrenSelected = childIds.every((id) => values.includes(id));
14297
14318
  if (allChildrenSelected && index === -1)
@@ -14300,13 +14321,45 @@
14300
14321
  values.splice(index, 1);
14301
14322
  });
14302
14323
  };
14303
- const toggleExpanded = (id) => {
14324
+ const updateExpanded = (id, expanded) => {
14304
14325
  const next = expandedKeys.value.slice();
14305
14326
  const index = next.indexOf(id);
14306
- 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);
14307
14331
  emit("update:expandedKeys", next);
14308
- emit("expand", id, index === -1);
14332
+ emit("expand", id, expanded);
14309
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
+ });
14310
14363
  const updateSelected = (item, selected) => {
14311
14364
  if (item.disabled || item.selectable === false)
14312
14365
  return;
@@ -14325,12 +14378,13 @@
14325
14378
  emit("select", item, selected);
14326
14379
  };
14327
14380
  const renderNodes = (items, level = 0) => items.map((item) => {
14328
- var _a;
14329
- const hasChildren = !!((_a = item.children) == null ? void 0 : _a.length);
14381
+ const children = getChildren(item);
14382
+ const hasChildren = isBranch(item);
14330
14383
  const expanded = isExpanded(item.id);
14384
+ const loading = isLoading(item.id);
14331
14385
  const renderTitle = () => {
14332
- var _a2;
14333
- return ((_a2 = slots.title) == null ? void 0 : _a2.call(slots, {
14386
+ var _a;
14387
+ return ((_a = slots.title) == null ? void 0 : _a.call(slots, {
14334
14388
  item,
14335
14389
  level,
14336
14390
  hasChildren
@@ -14350,36 +14404,29 @@
14350
14404
  }
14351
14405
  const selectable = item.selectable !== false && isSelectionVisible(hasChildren, level);
14352
14406
  const selectionState = getSelectionState(item);
14353
- return vue.createVNode("div", {
14354
- "key": item.id,
14355
- "class": bem$B("node")
14356
- }, [vue.createVNode(Cell, {
14357
- "class": bem$B("cell", {
14358
- branch: hasChildren
14359
- }),
14360
- "title": item.text,
14361
- "border": props2.showDivider,
14362
- "style": getNodeStyle(level),
14363
- "rightSelect": selectable && selectionState !== "indeterminate" ? selectionState === "checked" : void 0,
14364
- "selectType": props2.multiple ? "checkbox" : "radio",
14365
- "onUpdate:rightSelect": (value) => updateSelected(item, value)
14366
- }, __spreadValues({
14407
+ const cellSlots = {
14367
14408
  title: () => [hasChildren ? vue.createVNode("button", {
14368
14409
  "type": "button",
14369
14410
  "class": bem$B("expand-control"),
14370
14411
  "disabled": item.disabled,
14412
+ "aria-busy": loading,
14413
+ "aria-disabled": loading,
14371
14414
  "onClick": (event) => {
14372
14415
  event.stopPropagation();
14373
- toggleExpanded(item.id);
14416
+ toggleExpanded(item);
14374
14417
  }
14375
- }, [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, {
14376
14422
  "name": "trangle-down",
14377
14423
  "class": bem$B("arrow", {
14378
14424
  expanded
14379
14425
  })
14380
14426
  }, null), vue.createVNode("span", null, [renderTitle()])]) : vue.createVNode("span", null, [renderTitle()])]
14381
- }, selectable && selectionState === "indeterminate" ? {
14382
- "right-select": () => vue.createVNode("button", {
14427
+ };
14428
+ if (selectable && selectionState === "indeterminate") {
14429
+ cellSlots["right-select"] = () => vue.createVNode("button", {
14383
14430
  "type": "button",
14384
14431
  "class": bem$B("indeterminate"),
14385
14432
  "aria-label": `部分选中${item.text}`,
@@ -14387,13 +14434,27 @@
14387
14434
  event.stopPropagation();
14388
14435
  updateSelected(item, true);
14389
14436
  }
14390
- }, null)
14391
- } : {})), 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, {
14392
14453
  "name": "van-tree-select-expand"
14393
14454
  }, {
14394
14455
  default: () => [hasChildren && expanded && vue.createVNode("div", {
14395
14456
  "class": bem$B("children")
14396
- }, [renderNodes(item.children, level + 1)])]
14457
+ }, [renderNodes(children, level + 1)])]
14397
14458
  })]);
14398
14459
  });
14399
14460
  return () => vue.createVNode("div", {
@@ -17033,13 +17094,7 @@
17033
17094
  id: "high-voltage",
17034
17095
  text: "高压计量柜",
17035
17096
  selectable: false,
17036
- children: [{
17037
- id: "metering-cabinet-1",
17038
- text: "B3_高压计量柜_1#"
17039
- }, {
17040
- id: "metering-cabinet-2",
17041
- text: "B3_高压计量柜_2#"
17042
- }]
17097
+ children: []
17043
17098
  }]
17044
17099
  }, {
17045
17100
  id: "chiller-room",
@@ -17359,13 +17414,14 @@
17359
17414
  specialties: {
17360
17415
  type: Array,
17361
17416
  default: () => specialties
17362
- }
17417
+ },
17418
+ loadChildren: Function
17363
17419
  };
17364
17420
  const flattenItems$1 = (items) => items.flatMap((item) => [item, ...item.children ? flattenItems$1(item.children) : []]);
17365
17421
  var stdin_default$t = vue.defineComponent({
17366
17422
  name: name$o,
17367
17423
  props: objectSelectProps,
17368
- emits: ["update:show", "update:modelValue", "change", "confirm"],
17424
+ emits: ["update:show", "update:modelValue", "change", "confirm", "load", "load-error"],
17369
17425
  setup(props2, {
17370
17426
  emit
17371
17427
  }) {
@@ -17378,6 +17434,14 @@
17378
17434
  const expandedSelected = vue.ref(false);
17379
17435
  const searching = vue.ref(false);
17380
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
+ });
17381
17445
  const currentSpecialtyItems = (specialty) => specialtyType.value === 0 ? specialty.deviceItems : specialty.systemItems;
17382
17446
  const expandOnlySpecialty = () => {
17383
17447
  if (props2.specialties.length === 1) {
@@ -17402,7 +17466,7 @@
17402
17466
  immediate: true
17403
17467
  });
17404
17468
  const selected = vue.computed(() => props2.modelValue);
17405
- 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])])));
17406
17470
  const selectedItems = vue.computed(() => allItems.value.filter((item) => selected.value.includes(item.id)));
17407
17471
  const searchResults = vue.computed(() => {
17408
17472
  const query = keyword.value.trim().toLowerCase();
@@ -17447,19 +17511,29 @@
17447
17511
  update([]);
17448
17512
  expandedSelected.value = false;
17449
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
+ };
17450
17521
  const renderTree = (items) => vue.createVNode("div", {
17451
17522
  "class": bem$o("tree-card")
17452
17523
  }, [vue.createVNode(TreeSelect, {
17453
17524
  "modelValue": selected.value,
17454
17525
  "expandedKeys": expandedKeys.value,
17455
- "items": items,
17526
+ "items": hydrateItems(items),
17456
17527
  "multiple": true,
17457
17528
  "showParentSelect": true,
17458
17529
  "cascade": false,
17530
+ "loadChildren": props2.loadChildren,
17459
17531
  "onUpdate:modelValue": update,
17460
17532
  "onUpdate:expandedKeys": (value) => {
17461
17533
  expandedKeys.value = value;
17462
- }
17534
+ },
17535
+ "onLoad": onLoad,
17536
+ "onLoad-error": onLoadError
17463
17537
  }, null)]);
17464
17538
  const renderSpecialty = (specialty) => {
17465
17539
  var _a;
@@ -20404,6 +20478,7 @@
20404
20478
  accept: makeStringProp("image/*"),
20405
20479
  capture: String,
20406
20480
  multiple: Boolean,
20481
+ sourcePicker: Boolean,
20407
20482
  label: String,
20408
20483
  required: Boolean,
20409
20484
  disabled: Boolean,
@@ -20433,21 +20508,26 @@
20433
20508
  var stdin_default$7 = vue.defineComponent({
20434
20509
  name: name$3,
20435
20510
  props: uploaderProps,
20436
- emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
20511
+ emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "select-source", "update:modelValue"],
20437
20512
  setup(props2, {
20438
20513
  emit,
20439
20514
  slots
20440
20515
  }) {
20441
20516
  const inputRef = vue.ref();
20517
+ const cameraInputRef = vue.ref();
20518
+ const videoInputRef = vue.ref();
20519
+ const sourcePickerVisible = vue.ref(false);
20442
20520
  const urls = [];
20443
20521
  const getDetail = (index = props2.modelValue.length) => ({
20444
20522
  name: props2.name,
20445
20523
  index
20446
20524
  });
20447
20525
  const resetInput = () => {
20448
- if (inputRef.value) {
20449
- inputRef.value.value = "";
20450
- }
20526
+ [inputRef, cameraInputRef, videoInputRef].forEach((input) => {
20527
+ if (input.value) {
20528
+ input.value.value = "";
20529
+ }
20530
+ });
20451
20531
  };
20452
20532
  const onAfterRead = (items) => {
20453
20533
  resetInput();
@@ -20583,21 +20663,69 @@
20583
20663
  "class": bem$3("required")
20584
20664
  }, [vue.createTextVNode("*")]), props2.label]);
20585
20665
  };
20586
- const onClickUpload = (event) => emit("click-upload", event);
20666
+ const acceptTypes = () => props2.accept.split(",").map((type) => type.trim().toLowerCase()).filter(Boolean);
20667
+ const acceptsMediaType = (type) => acceptTypes().some((accept) => accept === `${type}/*` || accept.startsWith(`${type}/`));
20668
+ const triggerInput = (source2) => {
20669
+ const target = source2 === "camera" ? cameraInputRef.value : source2 === "video" ? videoInputRef.value : inputRef.value;
20670
+ if (target && !props2.disabled && !props2.readonly) {
20671
+ emit("select-source", source2);
20672
+ target.click();
20673
+ }
20674
+ };
20675
+ const onClickUpload = (event) => {
20676
+ emit("click-upload", event);
20677
+ if (props2.sourcePicker && !props2.disabled && !props2.readonly) {
20678
+ sourcePickerVisible.value = true;
20679
+ }
20680
+ };
20681
+ const renderInput = (input, accept, capture, multiple = false, hidden = false) => vue.createVNode("input", {
20682
+ "ref": input,
20683
+ "type": "file",
20684
+ "class": bem$3("input", {
20685
+ hidden
20686
+ }),
20687
+ "accept": accept,
20688
+ "capture": capture,
20689
+ "multiple": multiple,
20690
+ "disabled": props2.disabled,
20691
+ "onChange": onChange
20692
+ }, null);
20693
+ const renderSourcePicker = () => {
20694
+ if (!props2.sourcePicker)
20695
+ return;
20696
+ const actions = [];
20697
+ if (acceptsMediaType("image")) {
20698
+ actions.push({
20699
+ name: t("takePhoto"),
20700
+ callback: () => triggerInput("camera")
20701
+ });
20702
+ }
20703
+ if (acceptsMediaType("video")) {
20704
+ actions.push({
20705
+ name: t("recordVideo"),
20706
+ callback: () => triggerInput("video")
20707
+ });
20708
+ }
20709
+ actions.push({
20710
+ name: t("chooseFromAlbum"),
20711
+ callback: () => triggerInput("album")
20712
+ });
20713
+ return vue.createVNode(ActionSheet, {
20714
+ "show": sourcePickerVisible.value,
20715
+ "title": t("sourcePickerTitle"),
20716
+ "actions": actions,
20717
+ "contentAdaptive": true,
20718
+ "closeOnClickAction": true,
20719
+ "onUpdate:show": (show) => {
20720
+ sourcePickerVisible.value = show;
20721
+ }
20722
+ }, null);
20723
+ };
20587
20724
  const renderUpload = () => {
20588
20725
  if (props2.modelValue.length >= props2.maxCount || !props2.showUpload) {
20589
20726
  return;
20590
20727
  }
20591
- const Input = props2.readonly ? null : vue.createVNode("input", {
20592
- "ref": inputRef,
20593
- "type": "file",
20594
- "class": bem$3("input"),
20595
- "accept": props2.accept,
20596
- "capture": props2.capture,
20597
- "multiple": props2.multiple,
20598
- "disabled": props2.disabled,
20599
- "onChange": onChange
20600
- }, null);
20728
+ const Input = props2.readonly ? null : props2.sourcePicker ? [renderInput(inputRef, props2.accept, void 0, props2.multiple, true), acceptsMediaType("image") && renderInput(cameraInputRef, "image/*", props2.capture || "environment", false, true), acceptsMediaType("video") && renderInput(videoInputRef, "video/*", props2.capture || "environment", false, true)] : renderInput(inputRef, props2.accept, props2.capture, props2.multiple);
20601
20729
  if (slots.default) {
20602
20730
  return vue.createVNode("div", {
20603
20731
  "class": bem$3("input-wrapper"),
@@ -20617,8 +20745,14 @@
20617
20745
  "class": bem$3("upload-text")
20618
20746
  }, [props2.uploadText]), Input]);
20619
20747
  };
20620
- const chooseFile = () => {
20621
- if (inputRef.value && !props2.disabled) {
20748
+ const chooseFile = (source2) => {
20749
+ if (props2.disabled || props2.readonly)
20750
+ return;
20751
+ if (source2) {
20752
+ triggerInput(source2);
20753
+ } else if (props2.sourcePicker) {
20754
+ sourcePickerVisible.value = true;
20755
+ } else if (inputRef.value) {
20622
20756
  inputRef.value.click();
20623
20757
  }
20624
20758
  };
@@ -20638,7 +20772,7 @@
20638
20772
  "class": bem$3("wrapper", {
20639
20773
  disabled: props2.disabled
20640
20774
  })
20641
- }, [props2.uploadFirst ? vue.createVNode(vue.Fragment, null, [renderUpload(), renderPreviewList()]) : vue.createVNode(vue.Fragment, null, [renderPreviewList(), renderUpload()])])]);
20775
+ }, [props2.uploadFirst ? vue.createVNode(vue.Fragment, null, [renderUpload(), renderPreviewList()]) : vue.createVNode(vue.Fragment, null, [renderPreviewList(), renderUpload()])]), renderSourcePicker()]);
20642
20776
  }
20643
20777
  });
20644
20778
  const Uploader = withInstall(stdin_default$7);
@@ -24918,7 +25052,7 @@
24918
25052
  });
24919
25053
  }
24920
25054
  };
24921
- const version = "0.0.42";
25055
+ const version = "0.0.44";
24922
25056
  function install(app) {
24923
25057
  const components = [
24924
25058
  ActionBar,