vant 2.12.44 → 2.12.47

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
@@ -4936,13 +4936,41 @@ var Dialog_createNamespace = Object(create["a" /* createNamespace */])('dialog')
4936
4936
  }
4937
4937
  },
4938
4938
  onOpened: function onOpened() {
4939
+ var _this2 = this;
4940
+
4939
4941
  this.$emit('opened');
4942
+ this.$nextTick(function () {
4943
+ var _this2$$refs$dialog;
4944
+
4945
+ (_this2$$refs$dialog = _this2.$refs.dialog) == null ? void 0 : _this2$$refs$dialog.focus();
4946
+ });
4940
4947
  },
4941
4948
  onClosed: function onClosed() {
4942
4949
  this.$emit('closed');
4943
4950
  },
4951
+ onKeydown: function onKeydown(event) {
4952
+ var _this3 = this;
4953
+
4954
+ if (event.key === 'Escape' || event.key === 'Enter') {
4955
+ // skip keyboard events of child elements
4956
+ if (event.target !== this.$refs.dialog) {
4957
+ return;
4958
+ }
4959
+
4960
+ var onEventType = {
4961
+ Enter: this.showConfirmButton ? function () {
4962
+ return _this3.handleAction('confirm');
4963
+ } : utils["i" /* noop */],
4964
+ Escape: this.showCancelButton ? function () {
4965
+ return _this3.handleAction('cancel');
4966
+ } : utils["i" /* noop */]
4967
+ };
4968
+ onEventType[event.key]();
4969
+ this.$emit('keydown', event);
4970
+ }
4971
+ },
4944
4972
  genRoundButtons: function genRoundButtons() {
4945
- var _this2 = this;
4973
+ var _this4 = this;
4946
4974
 
4947
4975
  var h = this.$createElement;
4948
4976
  return h(goods_action, {
@@ -4958,7 +4986,7 @@ var Dialog_createNamespace = Object(create["a" /* createNamespace */])('dialog')
4958
4986
  "class": Dialog_bem('cancel'),
4959
4987
  "on": {
4960
4988
  "click": function click() {
4961
- _this2.handleAction('cancel');
4989
+ _this4.handleAction('cancel');
4962
4990
  }
4963
4991
  }
4964
4992
  }), this.showConfirmButton && h(goods_action_button, {
@@ -4972,13 +5000,13 @@ var Dialog_createNamespace = Object(create["a" /* createNamespace */])('dialog')
4972
5000
  "class": Dialog_bem('confirm'),
4973
5001
  "on": {
4974
5002
  "click": function click() {
4975
- _this2.handleAction('confirm');
5003
+ _this4.handleAction('confirm');
4976
5004
  }
4977
5005
  }
4978
5006
  })]);
4979
5007
  },
4980
5008
  genButtons: function genButtons() {
4981
- var _this3 = this,
5009
+ var _this5 = this,
4982
5010
  _ref;
4983
5011
 
4984
5012
  var h = this.$createElement;
@@ -4997,7 +5025,7 @@ var Dialog_createNamespace = Object(create["a" /* createNamespace */])('dialog')
4997
5025
  },
4998
5026
  "on": {
4999
5027
  "click": function click() {
5000
- _this3.handleAction('cancel');
5028
+ _this5.handleAction('cancel');
5001
5029
  }
5002
5030
  }
5003
5031
  }), this.showConfirmButton && h(es_button, {
@@ -5012,7 +5040,7 @@ var Dialog_createNamespace = Object(create["a" /* createNamespace */])('dialog')
5012
5040
  },
5013
5041
  "on": {
5014
5042
  "click": function click() {
5015
- _this3.handleAction('confirm');
5043
+ _this5.handleAction('confirm');
5016
5044
  }
5017
5045
  }
5018
5046
  })]);
@@ -5076,11 +5104,16 @@ var Dialog_createNamespace = Object(create["a" /* createNamespace */])('dialog')
5076
5104
  }],
5077
5105
  "attrs": {
5078
5106
  "role": "dialog",
5079
- "aria-labelledby": this.title || message
5107
+ "aria-labelledby": this.title || message,
5108
+ "tabIndex": 0
5080
5109
  },
5081
5110
  "class": [Dialog_bem([this.theme]), this.className],
5082
5111
  "style": {
5083
5112
  width: Object(unit["a" /* addUnit */])(this.width)
5113
+ },
5114
+ "ref": "dialog",
5115
+ "on": {
5116
+ "keydown": this.onKeydown
5084
5117
  }
5085
5118
  }, [Title, this.genContent(title, messageSlot), this.theme === 'round-button' ? this.genRoundButtons() : this.genButtons()])]);
5086
5119
  }
@@ -18064,10 +18097,10 @@ var getSkuComb = function getSkuComb(skuList, selectedSku) {
18064
18097
  var sku_helper_getSelectedSkuValues = function getSelectedSkuValues(skuTree, selectedSku) {
18065
18098
  var normalizedTree = normalizeSkuTree(skuTree);
18066
18099
  return Object.keys(selectedSku).reduce(function (selectedValues, skuKeyStr) {
18067
- var skuValues = normalizedTree[skuKeyStr];
18100
+ var skuValues = normalizedTree[skuKeyStr] || [];
18068
18101
  var skuValueId = selectedSku[skuKeyStr];
18069
18102
 
18070
- if (skuValueId !== UNSELECTED_SKU_VALUE_ID) {
18103
+ if (skuValueId !== UNSELECTED_SKU_VALUE_ID && skuValues.length > 0) {
18071
18104
  var skuValue = skuValues.filter(function (value) {
18072
18105
  return value.id === skuValueId;
18073
18106
  })[0];
@@ -21830,7 +21863,7 @@ var tabbar_createNamespace = Object(create["a" /* createNamespace */])('tabbar')
21830
21863
  var _this2 = this;
21831
21864
 
21832
21865
  this.children.forEach(function (item, index) {
21833
- item.nameMatched = (item.name || index) === _this2.value;
21866
+ item.nameMatched = item.name === _this2.value || index === _this2.value;
21834
21867
  });
21835
21868
  },
21836
21869
  triggerChange: function triggerChange(active, afterChange) {
@@ -21911,23 +21944,25 @@ var tabbar_item_createNamespace = Object(create["a" /* createNamespace */])('tab
21911
21944
  };
21912
21945
  },
21913
21946
  computed: {
21914
- routeMatched: function routeMatched() {
21915
- var to = this.to,
21916
- $route = this.$route;
21947
+ active: function active() {
21948
+ var routeMode = this.parent.route;
21917
21949
 
21918
- if (to && $route) {
21950
+ if (routeMode && '$route' in this) {
21951
+ var to = this.to,
21952
+ $route = this.$route;
21919
21953
  var config = Object(utils["f" /* isObject */])(to) ? to : {
21920
21954
  path: to
21921
21955
  };
21922
21956
  return !!$route.matched.find(function (r) {
21923
- var pathMatched = config.path === r.path;
21957
+ // vue-router 3.x $route.matched[0].path is empty in / and its children paths
21958
+ var path = r.path === '' ? '/' : r.path;
21959
+ var pathMatched = config.path === path;
21924
21960
  var nameMatched = Object(utils["c" /* isDef */])(config.name) && config.name === r.name;
21925
21961
  return pathMatched || nameMatched;
21926
21962
  });
21927
21963
  }
21928
- },
21929
- active: function active() {
21930
- return this.parent.route ? this.routeMatched : this.nameMatched;
21964
+
21965
+ return this.nameMatched;
21931
21966
  }
21932
21967
  },
21933
21968
  methods: {
@@ -22226,7 +22261,7 @@ TreeSelect.props = {
22226
22261
 
22227
22262
 
22228
22263
 
22229
- var version = '2.12.44';
22264
+ var version = '2.12.47';
22230
22265
 
22231
22266
  function install(Vue) {
22232
22267
  var components = [action_sheet, address_edit, address_list, es_area, badge, es_button, calendar, card, cascader, cell, cell_group, es_checkbox, checkbox_group, circle, col, collapse, collapse_item, contact_card, contact_edit, contact_list, count_down, es_coupon, coupon_cell, coupon_list, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, es_form, goods_action, goods_action_button, goods_action_icon, grid, grid_item, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, es_list, es_loading, locale["a" /* default */], nav_bar, notice_bar, notify, number_keyboard, es_overlay, pagination, panel, password_input, es_picker, popover, popup, es_progress, pull_refresh, es_radio, radio_group, es_rate, row, search, share_sheet, sidebar, sidebar_item, skeleton, es_sku, slider, es_step, stepper, steps, es_sticky, submit_bar, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, tabs, es_tag, es_toast, tree_select, uploader];