vary-ui 3.21.51 → 3.21.52

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 (35) hide show
  1. package/dist/{Loading-5z79gQu9.js → Loading-DMFKMWpc.js} +2 -2
  2. package/dist/{Wrap-CPIflOtK.js → Wrap-GIpwRQ0Z.js} +1 -1
  3. package/dist/lib/Button/Button.js +2 -2
  4. package/dist/lib/Card/Card.js +2 -2
  5. package/dist/lib/Checkbox/Checkbox.js +2 -2
  6. package/dist/lib/CheckboxGroup/CheckboxGroup.js +3 -3
  7. package/dist/lib/Confirm/Confirm.js +2 -2
  8. package/dist/lib/Date/Date.js +4 -4
  9. package/dist/lib/Dialog/Dialog.js +1 -1
  10. package/dist/lib/Divider/Divider.js +1 -1
  11. package/dist/lib/Field/Field.js +2 -2
  12. package/dist/lib/Form/Form.js +1 -1
  13. package/dist/lib/Input/Input.js +3 -3
  14. package/dist/lib/Link/Link.js +2 -2
  15. package/dist/lib/Loading/Loading.js +3 -3
  16. package/dist/lib/Menu/Menu.js +2 -2
  17. package/dist/lib/Message/Message.js +2 -2
  18. package/dist/lib/Pagination/Pagination.js +5 -5
  19. package/dist/lib/Popover/Popover.js +2 -2
  20. package/dist/lib/Radio/Radio.js +2 -2
  21. package/dist/lib/RadioGroup/RadioGroup.js +2 -2
  22. package/dist/lib/Scene/Scene.js +1 -1
  23. package/dist/lib/Scroll/Scroll.js +2 -2
  24. package/dist/lib/Select/Select.js +5 -5
  25. package/dist/lib/Skeleton/Skeleton.js +1 -1
  26. package/dist/lib/Tab/Tab.js +2 -2
  27. package/dist/lib/TabPanel/TabPanel.js +1 -1
  28. package/dist/lib/Table/Table.js +149 -97
  29. package/dist/lib/TableColumn/TableColumn.js +1 -1
  30. package/dist/types/lib/Table/Table.vue.d.ts +25 -7
  31. package/dist/vary-ui.js +5 -5
  32. package/package.json +1 -1
  33. /package/dist/{_plugin-vue_export-helper-DN_H8P-u.js → _plugin-vue_export-helper-BwJJ-9J8.js} +0 -0
  34. /package/dist/{config-DVueulZb.js → config-BAKtXHgR.js} +0 -0
  35. /package/dist/{utils-D3Mk4Eng.js → utils-B7J83i5S.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, ref, onMounted, createVNode } from 'vue';
2
- import { c as config } from './config-DVueulZb.js';
3
- import { _ as _export_sfc } from './_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from './config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from './_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _a;
6
6
  var _sfc_main = /* @__PURE__ */ defineComponent({
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, createVNode } from 'vue';
2
- import { _ as _export_sfc } from './_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from './_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  props: {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, createVNode } from 'vue';
2
- import { c as config } from '../../config-DVueulZb.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from '../../config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  console.log(config);
6
6
  var _sfc_main = /* @__PURE__ */ defineComponent({
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, createVNode, createTextVNode } from 'vue';
2
- import { c as config } from '../../config-DVueulZb.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from '../../config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  props: {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, ref, watch, inject, createVNode } from 'vue';
2
- import { c as config } from '../../config-DVueulZb.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from '../../config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  props: {
@@ -1,8 +1,8 @@
1
1
  import { defineComponent, ref, watch, provide, createVNode } from 'vue';
2
- import { i as isArray } from '../../utils-D3Mk4Eng.js';
2
+ import { i as isArray } from '../../utils-B7J83i5S.js';
3
3
  import Checkbox from '../Checkbox/Checkbox.js';
4
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
5
- import '../../config-DVueulZb.js';
4
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
5
+ import '../../config-BAKtXHgR.js';
6
6
 
7
7
  var _sfc_main = /* @__PURE__ */ defineComponent({
8
8
  props: {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, createVNode, createApp, h } from 'vue';
2
2
  import Button from '../Button/Button.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
4
- import '../../config-DVueulZb.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
+ import '../../config-BAKtXHgR.js';
5
5
 
6
6
  var _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  props: {
@@ -1,11 +1,11 @@
1
1
  import { defineComponent, shallowRef, ref, reactive, watch, createVNode, createTextVNode } from 'vue';
2
- import { n as now, e as isTime, g as isYear, h as isMonth, d as isDate, f as isDateTime } from '../../utils-D3Mk4Eng.js';
2
+ import { n as now, e as isTime, g as isYear, h as isMonth, d as isDate, f as isDateTime } from '../../utils-B7J83i5S.js';
3
3
  import Popover from '../Popover/Popover.js';
4
4
  import Scroll from '../Scroll/Scroll.js';
5
5
  import Link from '../Link/Link.js';
6
- import { W as Wrap } from '../../Wrap-CPIflOtK.js';
7
- import { c as config } from '../../config-DVueulZb.js';
8
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
6
+ import { W as Wrap } from '../../Wrap-GIpwRQ0Z.js';
7
+ import { c as config } from '../../config-BAKtXHgR.js';
8
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
9
9
 
10
10
  const weeks = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
11
11
  const months = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"].map((r, i) => {
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, ref, watch, onMounted, onBeforeUnmount, createVNode, createTextVNode } from 'vue';
2
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  props: {
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, createVNode } from 'vue';
2
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  props: {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, inject, createVNode } from 'vue';
2
- import { c as config } from '../../config-DVueulZb.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from '../../config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  props: {
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, provide, createVNode } from 'vue';
2
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  props: {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, watch, createVNode, mergeProps } from 'vue';
2
- import { W as Wrap } from '../../Wrap-CPIflOtK.js';
3
- import { c as isFun } from '../../utils-D3Mk4Eng.js';
4
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { W as Wrap } from '../../Wrap-GIpwRQ0Z.js';
3
+ import { c as isFun } from '../../utils-B7J83i5S.js';
4
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
5
5
 
6
6
  var _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  inheritAttrs: false,
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, computed, createVNode } from 'vue';
2
- import { c as config } from '../../config-DVueulZb.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from '../../config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  props: {
@@ -1,7 +1,7 @@
1
1
  import { shallowRef, createApp, h } from 'vue';
2
- import { L as Loading } from '../../Loading-5z79gQu9.js';
3
- import { c as config } from '../../config-DVueulZb.js';
4
- import '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { L as Loading } from '../../Loading-DMFKMWpc.js';
3
+ import { c as config } from '../../config-BAKtXHgR.js';
4
+ import '../../_plugin-vue_export-helper-BwJJ-9J8.js';
5
5
 
6
6
  const defaultOptions = {
7
7
  lock: false,
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, watch, createVNode } from 'vue';
2
- import { k as debounce } from '../../utils-D3Mk4Eng.js';
2
+ import { k as debounce } from '../../utils-B7J83i5S.js';
3
3
  import Scroll from '../Scroll/Scroll.js';
4
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
4
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
5
5
 
6
6
  var _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  props: {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, onMounted, h, createApp } from 'vue';
2
- import { c as config } from '../../config-DVueulZb.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from '../../config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _sfc_main = defineComponent({
6
6
  props: {
@@ -1,14 +1,14 @@
1
1
  import { defineComponent, ref, watch, createVNode, createTextVNode } from 'vue';
2
2
  import Select from '../Select/Select.js';
3
- import { c as config } from '../../config-DVueulZb.js';
4
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
5
- import '../../utils-D3Mk4Eng.js';
3
+ import { c as config } from '../../config-BAKtXHgR.js';
4
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
5
+ import '../../utils-B7J83i5S.js';
6
6
  import '../Popover/Popover.js';
7
- import '../../Wrap-CPIflOtK.js';
7
+ import '../../Wrap-GIpwRQ0Z.js';
8
8
  import '../Input/Input.js';
9
9
  import '../Checkbox/Checkbox.js';
10
10
  import '../Scroll/Scroll.js';
11
- import '../../Loading-5z79gQu9.js';
11
+ import '../../Loading-DMFKMWpc.js';
12
12
 
13
13
  var _sfc_main = /* @__PURE__ */ defineComponent({
14
14
  props: {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, shallowRef, ref, watch, onMounted, onBeforeUnmount, createVNode, nextTick } from 'vue';
2
- import { t as throttle } from '../../utils-D3Mk4Eng.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { t as throttle } from '../../utils-B7J83i5S.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  props: {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, ref, watch, createVNode, inject } from 'vue';
2
- import { c as config } from '../../config-DVueulZb.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { c as config } from '../../config-BAKtXHgR.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  var _sfc_main = /* @__PURE__ */ defineComponent({
6
6
  props: {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, watch, provide, createVNode } from 'vue';
2
2
  import Radio from '../Radio/Radio.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
4
- import '../../config-DVueulZb.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
+ import '../../config-BAKtXHgR.js';
5
5
 
6
6
  var _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  props: {
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, createElementBlock, openBlock, normalizeClass, renderSlot } from 'vue';
2
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /*@__PURE__*/ defineComponent({
5
5
  __name: 'Scene',
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, shallowRef, ref, onMounted, nextTick, onBeforeUnmount, createVNode } from 'vue';
2
- import { k as debounce } from '../../utils-D3Mk4Eng.js';
3
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { k as debounce } from '../../utils-B7J83i5S.js';
3
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
4
4
 
5
5
  /**
6
6
  * note:
@@ -1,13 +1,13 @@
1
1
  import { defineComponent, ref, shallowRef, reactive, watch, createVNode, createTextVNode, isVNode, nextTick } from 'vue';
2
- import { k as debounce } from '../../utils-D3Mk4Eng.js';
2
+ import { k as debounce } from '../../utils-B7J83i5S.js';
3
3
  import Popover from '../Popover/Popover.js';
4
- import { W as Wrap } from '../../Wrap-CPIflOtK.js';
4
+ import { W as Wrap } from '../../Wrap-GIpwRQ0Z.js';
5
5
  import Input from '../Input/Input.js';
6
6
  import Checkbox from '../Checkbox/Checkbox.js';
7
7
  import Scroll from '../Scroll/Scroll.js';
8
- import { c as config } from '../../config-DVueulZb.js';
9
- import { L as Loading } from '../../Loading-5z79gQu9.js';
10
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
8
+ import { c as config } from '../../config-BAKtXHgR.js';
9
+ import { L as Loading } from '../../Loading-DMFKMWpc.js';
10
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
11
11
 
12
12
  /******************************************************************************
13
13
  Copyright (c) Microsoft Corporation.
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, createVNode } from 'vue';
2
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  props: {
@@ -1,7 +1,7 @@
1
1
  import { defineComponent, ref, watch, onBeforeUnmount, createVNode } from 'vue';
2
- import { m as matchChildrenCoponent } from '../../utils-D3Mk4Eng.js';
2
+ import { m as matchChildrenCoponent } from '../../utils-B7J83i5S.js';
3
3
  import TabPanel from '../TabPanel/TabPanel.js';
4
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
4
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
5
5
 
6
6
  var _sfc_main = /* @__PURE__ */ defineComponent({
7
7
  props: {
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, createVNode } from 'vue';
2
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  setup(_props, {
@@ -1,11 +1,12 @@
1
- import { defineComponent, ref, reactive, shallowRef, nextTick, onMounted, watch, onBeforeMount, createVNode, createTextVNode } from 'vue';
2
- import { k as debounce, m as matchChildrenCoponent } from '../../utils-D3Mk4Eng.js';
1
+ import { defineComponent, getCurrentInstance, ref, shallowRef, reactive, nextTick, onMounted, watch, onBeforeMount, createVNode, createTextVNode } from 'vue';
2
+ import { k as debounce, m as matchChildrenCoponent } from '../../utils-B7J83i5S.js';
3
3
  import Checkbox from '../Checkbox/Checkbox.js';
4
4
  import Scroll from '../Scroll/Scroll.js';
5
5
  import TableColumn from '../TableColumn/TableColumn.js';
6
- import { c as config } from '../../config-DVueulZb.js';
7
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
6
+ import { c as config } from '../../config-BAKtXHgR.js';
7
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
8
8
 
9
+ let colKey = 0;
9
10
  var _sfc_main = /* @__PURE__ */ defineComponent({
10
11
  props: {
11
12
  data: {
@@ -29,9 +30,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
29
30
  default: false
30
31
  },
31
32
  selection: {
32
- type: Boolean,
33
- default: false
33
+ type: Array,
34
+ default: () => []
34
35
  },
36
+ // 默认选中的行
35
37
  placeholder: {
36
38
  type: String,
37
39
  default: ""
@@ -53,7 +55,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
53
55
  },
54
56
  rowKey: {
55
57
  type: [String, Function],
56
- default: "key"
58
+ default: ""
57
59
  },
58
60
  scrollX: {
59
61
  type: Boolean,
@@ -66,22 +68,41 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
66
68
  height: {
67
69
  type: String,
68
70
  default: ""
69
- }
71
+ },
72
+ autoSelectRowOnClick: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ // 点击行时只选中当前行
77
+ autoToggleRowOnClick: {
78
+ type: Boolean,
79
+ default: false
80
+ } // 点击行时切换当前行选中状态
70
81
  },
71
- emits: ["row-click", "selection-change", "sort-change", "cell-click"],
82
+ emits: ["row-click", "selection-change", "update:selection", "sort-change", "cell-click"],
72
83
  setup(_props, {
73
84
  emit: _emit,
74
85
  slots: _slots,
75
86
  attrs: _attrs,
76
87
  expose: _expose
77
88
  }) {
78
- if (!_props.rowKey) {
79
- console.warn("Miss Rowkey Prop");
80
- }
89
+ console.log(getCurrentInstance());
81
90
  const openDebug = _attrs.debug !== undefined; // 只要不是undefined就设置为true
82
91
  const rootRef = ref(null);
83
92
  // 启用选中功能时, 保存选中的行key
84
- const selectedRowMap = reactive({});
93
+ const selectedRowMap = ref({});
94
+ const updateSelectedRowMap = debounce(function (selection) {
95
+ console.log('updateSelectedRowMap', selection);
96
+ selectedRowMap.value = {}; // 清空selectedRowMap
97
+ selection.forEach(r => {
98
+ const key = getRowKey(r);
99
+ selectedRowMap.value[key] = r;
100
+ });
101
+ }, 200);
102
+ // 如果selection不为空, 则更新selectedRowMap
103
+ if (_props.selection.length > 0) {
104
+ updateSelectedRowMap();
105
+ }
85
106
  const showLeftShadow = ref(false); // 是否显示左浮动表格的阴影
86
107
  const showRightShadow = ref(false); // 是否显示右浮动表格的阴影
87
108
  const rowsHeight = ref([]); // 行高
@@ -101,19 +122,19 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
101
122
  const scrollBodyRightRef = shallowRef(null);
102
123
  const scrollBodyMainRef = shallowRef(null);
103
124
  const showFixedColumn = ref(false); // 是否显示固定列
125
+ const dataList = ref([]); // 数据列表
104
126
  const sortFields = reactive(Object.assign({
105
127
  prop: "",
106
128
  order: ""
107
129
  }, _props.defaultSort)); // 用来保存排序的依据
108
130
  const defineWidth = ref(0); // 定义的宽度
109
131
  function getRowKey(r) {
110
- // r: row, ri: rowIndex
111
- if (!_props.rowKey) {
112
- console.error("table component miss rowKey prop");
113
- }
114
132
  const rowKey = typeof _props.rowKey === "function" ? _props.rowKey({
115
133
  row: r
116
- }) : r[_props.rowKey];
134
+ }) : _props.rowKey ? r[_props.rowKey] : r['key'] || r['id'];
135
+ if (!rowKey) {
136
+ console.warn("table component miss rowKey prop");
137
+ }
117
138
  return rowKey;
118
139
  }
119
140
  const fixedLeftColumns = ref([]);
@@ -121,6 +142,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
121
142
  const mainColumns = ref([]);
122
143
  let mergeColumns = [];
123
144
  function init() {
145
+ const list = JSON.parse(JSON.stringify([..._props.data])); // 先从data中获取
146
+ dataList.value = list;
124
147
  mergeColumns = JSON.parse(JSON.stringify([..._props.columns])); // 先从columns中获取
125
148
  const slotColumns = _slots.default ? matchChildrenCoponent(_slots.default(), TableColumn) : [];
126
149
  slotColumns.forEach(r => {
@@ -157,16 +180,13 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
157
180
  const leftColumns = [];
158
181
  const rightColumns = [];
159
182
  const normalColumns = [];
160
- // 分离列
161
- let hasSelectionColumn = false;
162
183
  mergeColumns.forEach(c => {
163
184
  var _a;
164
185
  // 处理c.width为纯数字的情况, 如果是纯数字就加上px单位, 否则就保持原有规则
165
186
  c.width = c.width ? (c.width + '').replace('px', '') : 0;
166
187
  c.visible = (_a = c.visible) !== null && _a !== void 0 ? _a : true; // 所有列的默认visible设置为true
167
- if (c.prop === 'selection') {
168
- hasSelectionColumn = true; // 如果存在selection列, 则设置为true
169
- }
188
+ c.colKey = colKey++; // 给列添加一个唯一的key
189
+ if (c.prop === 'selection') ;
170
190
  if (c.visible === false) return; // visible为false的直接跳过
171
191
  if (c.fixed === "left") {
172
192
  leftColumns.push(c);
@@ -176,16 +196,16 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
176
196
  normalColumns.push(c);
177
197
  }
178
198
  });
179
- if (!hasSelectionColumn && _props.selection) {
180
- // 如果存在selection列, 则不添加
181
- // 如果不存在selection slot 或者 column中未定义, 且table中有selection属性, 就自动添加
182
- // 给mainColumn和leftColumn都添加一列
183
- leftColumns.unshift({
184
- label: "1",
185
- prop: "selection",
186
- align: "center"
187
- });
188
- }
199
+ // if (!hasSelectionColumn && _props.selection) {
200
+ // // 如果存在selection列, 则不添加
201
+ // // 如果不存在selection slot 或者 column中未定义, 且table中有selection属性, 就自动添加
202
+ // // 给mainColumn和leftColumn都添加一列
203
+ // leftColumns.unshift({
204
+ // label: "1",
205
+ // prop: "selection",
206
+ // align: "center",
207
+ // });
208
+ // }
189
209
  mainColumns.value = [...leftColumns, ...normalColumns, ...rightColumns];
190
210
  fixedLeftColumns.value = leftColumns;
191
211
  fixedRightColumns.value = rightColumns;
@@ -310,54 +330,79 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
310
330
  });
311
331
  mapSize();
312
332
  }
313
- _expose({
314
- // 切换全部状态, 全选或者全不选
315
- toggleAllSelection(selected) {
316
- if (selected) {
317
- _props.data.forEach((r, ri) => {
318
- const key = getRowKey(r);
319
- selectedRowMap[key] = r;
320
- });
321
- _emit("selection-change", _props.data);
322
- } else {
323
- Object.keys(selectedRowMap).forEach(key => {
324
- delete selectedRowMap[key];
325
- });
326
- _emit("selection-change", []);
327
- }
328
- },
329
- // 设置某一行的选中状态
330
- setRowSelection(row, selected, clearAll = false) {
331
- const key = getRowKey(row);
332
- if (clearAll) {
333
- // 如果需要清空所有选中的行, 则清空selectedRowMap
334
- Object.keys(selectedRowMap).forEach(key => {
335
- delete selectedRowMap[key];
336
- });
337
- }
338
- if (selected) {
339
- selectedRowMap[key] = row;
340
- } else {
341
- delete selectedRowMap[key];
342
- }
343
- _emit("selection-change", Object.values(selectedRowMap));
344
- },
345
- // 获取所有选中的行
346
- getAllSelection() {
347
- return Object.values(selectedRowMap);
348
- },
349
- // 清空所有选中的行
350
- clearAllSelection() {
351
- Object.keys(selectedRowMap).forEach(key => {
352
- delete selectedRowMap[key];
353
- });
354
- _emit("selection-change", []);
333
+ /**
334
+ * 选中状态发生变化时, 更新selection
335
+ */
336
+ function selectionChange(selection) {
337
+ updateSelectedRowMap(selection);
338
+ _emit("update:selection", selection);
339
+ _emit("selection-change", selection);
340
+ }
341
+ /**
342
+ * 切换全部状态, 全选或者全不选
343
+ * @param selected 是否选中
344
+ */
345
+ function toggleAllSelection(selected) {
346
+ if (selected) {
347
+ selectionChange(dataList.value);
348
+ } else {
349
+ selectionChange([]);
355
350
  }
351
+ }
352
+ /**
353
+ * 自动切换某一行的选中状态
354
+ * @param row 行数据
355
+ * @param clearAll 是否清空所有选中的行
356
+ */
357
+ function toggleRowSelection(row, clearAll = false) {
358
+ const key = getRowKey(row);
359
+ const map = clearAll ? {} : Object.assign({}, selectedRowMap.value);
360
+ if (map[key]) {
361
+ delete map[key];
362
+ } else {
363
+ map[key] = row;
364
+ }
365
+ selectionChange(Object.values(map));
366
+ }
367
+ /**
368
+ * 设置某一行的选中状态
369
+ * @param row 行数据
370
+ * @param selected 是否选中
371
+ * @param clearAll 是否清空所有选中的行
372
+ */
373
+ function setRowSelection(row, selected, clearAll = false) {
374
+ const key = getRowKey(row);
375
+ const map = clearAll ? {} : Object.assign({}, selectedRowMap.value);
376
+ if (selected) {
377
+ map[key] = row;
378
+ } else {
379
+ delete map[key];
380
+ }
381
+ selectionChange(Object.values(map));
382
+ }
383
+ /**
384
+ * 获取所有选中的行
385
+ * @returns 选中的行数据
386
+ */
387
+ function getAllSelection() {
388
+ return Object.values(selectedRowMap.value);
389
+ }
390
+ /**
391
+ * 清空所有选中的行
392
+ */
393
+ function clearAllSelection() {
394
+ selectionChange([]);
395
+ }
396
+ _expose({
397
+ toggleAllSelection,
398
+ toggleRowSelection,
399
+ setRowSelection,
400
+ getAllSelection,
401
+ clearAllSelection
356
402
  });
357
403
  onMounted(() => {
358
404
  init();
359
405
  nextTick(() => {
360
- init();
361
406
  initStyle();
362
407
  if (rootRef.value) {
363
408
  ro.observe(rootRef.value);
@@ -365,8 +410,9 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
365
410
  });
366
411
  });
367
412
  watch(() => _props.data, () => {
413
+ init();
368
414
  nextTick(() => {
369
- _props.data.length > 0 && initStyle();
415
+ initStyle();
370
416
  });
371
417
  }, {
372
418
  deep: true
@@ -379,6 +425,12 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
379
425
  }, {
380
426
  deep: true
381
427
  });
428
+ watch(() => _props.selection, (newVal, oldVal) => {
429
+ updateSelectedRowMap(newVal);
430
+ }, {
431
+ deep: true
432
+ // immediate: true
433
+ });
382
434
  onBeforeMount(() => {
383
435
  // 组件销毁前, 取消对元素的监控
384
436
  if (rootRef.value) {
@@ -394,22 +446,17 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
394
446
  // 多选框的列单独处理
395
447
  body = createVNode(Checkbox, {
396
448
  "key": "all",
397
- "partial": Object.keys(selectedRowMap).length > 0 && Object.keys(selectedRowMap).length < _props.data.length,
398
- "modelValue": Object.keys(selectedRowMap).length === _props.data.length ? true : false,
449
+ "partial": Object.keys(selectedRowMap.value).length > 0 && Object.keys(selectedRowMap.value).length < dataList.value.length,
450
+ "modelValue": dataList.value.length > 0 && Object.keys(selectedRowMap.value).length === dataList.value.length ? true : false,
399
451
  "onChange": v => {
400
452
  if (v) {
401
453
  // 全选
402
- _props.data.forEach((r, ri) => {
403
- const key = getRowKey(r);
404
- selectedRowMap[key] = r;
405
- });
454
+ toggleAllSelection(true);
406
455
  } else {
407
456
  // 取消全选
408
- Object.keys(selectedRowMap).forEach(k => {
409
- delete selectedRowMap[k];
410
- });
457
+ toggleAllSelection(false);
411
458
  }
412
- _emit("selection-change", Object.values(selectedRowMap));
459
+ _emit("selection-change", Object.values(selectedRowMap.value));
413
460
  }
414
461
  }, null);
415
462
  } else {
@@ -487,14 +534,12 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
487
534
  } else if (c.prop === "selection") {
488
535
  body = createVNode(Checkbox, {
489
536
  "key": rowKey,
490
- "modelValue": selectedRowMap[rowKey] ? true : false,
537
+ "modelValue": selectedRowMap.value[rowKey] ? true : false,
491
538
  "onChange": v => {
492
- if (v) {
493
- selectedRowMap[rowKey] = r;
494
- } else {
495
- delete selectedRowMap[rowKey];
539
+ if (!_props.autoSelectRowOnClick && !_props.autoToggleRowOnClick) {
540
+ // 如果这两个都没打开, 这里需要手动触发
541
+ toggleRowSelection(r);
496
542
  }
497
- _emit("selection-change", Object.values(selectedRowMap));
498
543
  }
499
544
  }, null);
500
545
  } else {
@@ -516,6 +561,13 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
516
561
  function cellClick(p) {
517
562
  // 点击单元格事件
518
563
  // console.log('cellClick', p)
564
+ if (_props.autoSelectRowOnClick) {
565
+ // 点击行时只选中当前行
566
+ setRowSelection(p.row, true, true);
567
+ } else if (_props.autoToggleRowOnClick) {
568
+ // 点击行时切换当前行选中状态
569
+ toggleRowSelection(p.row);
570
+ }
519
571
  _emit("cell-click", p);
520
572
  }
521
573
  return () => {
@@ -648,7 +700,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
648
700
  return createVNode("col", {
649
701
  "width": c.width && c.width !== 'minimal' ? c.width + 'px' : colsWidth.value[ci]
650
702
  }, null);
651
- })]), createVNode("tbody", null, [_props.data.map((r, ri) => {
703
+ })]), createVNode("tbody", null, [dataList.value.map((r, ri) => {
652
704
  return createVNode("tr", {
653
705
  "key": getRowKey(r),
654
706
  "class": [{
@@ -716,7 +768,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
716
768
  } : {}
717
769
  }, [createVNode("colgroup", null, [mainColumns.value.map((c, ci) => createVNode("col", {
718
770
  "width": c.width && c.width !== 'minimal' ? c.width + 'px' : colsWidth.value[ci]
719
- }, null))]), createVNode("tbody", null, [_props.data.map((r, ri) => createVNode("tr", {
771
+ }, null))]), createVNode("tbody", null, [dataList.value.map((r, ri) => createVNode("tr", {
720
772
  "key": getRowKey(r),
721
773
  "class": [{
722
774
  "v_table_tr--hover": ri === currentRowIndex.value
@@ -751,7 +803,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
751
803
  ri,
752
804
  ci
753
805
  })]);
754
- })]))])]), _props.data.length === 0 && createVNode("div", {
806
+ })]))])]), dataList.value.length === 0 && createVNode("div", {
755
807
  "class": "v_table_empty"
756
808
  }, [_slots.empty ? _slots.empty() : "Empty Data"])]
757
809
  }),
@@ -778,7 +830,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
778
830
  return createVNode("col", {
779
831
  "width": c.width && c.width !== 'minimal' ? c.width + 'px' : colsWidth.value[i]
780
832
  }, null);
781
- })]), createVNode("tbody", null, [_props.data.map((r, ri) => createVNode("tr", {
833
+ })]), createVNode("tbody", null, [dataList.value.map((r, ri) => createVNode("tr", {
782
834
  "key": getRowKey(r),
783
835
  "class": [{
784
836
  "v_table_tr--hover": ri === currentRowIndex.value
@@ -1,5 +1,5 @@
1
1
  import { defineComponent } from 'vue';
2
- import { _ as _export_sfc } from '../../_plugin-vue_export-helper-DN_H8P-u.js';
2
+ import { _ as _export_sfc } from '../../_plugin-vue_export-helper-BwJJ-9J8.js';
3
3
 
4
4
  var _sfc_main = /* @__PURE__ */ defineComponent({
5
5
  props: {
@@ -10,7 +10,6 @@ export type TableColumnProp = {
10
10
  sortable?: Slot | boolean;
11
11
  filter?: Slot | boolean;
12
12
  visible?: boolean;
13
- _maxWidth?: number;
14
13
  };
15
14
  declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
16
15
  data: {
@@ -34,8 +33,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
34
33
  default: boolean;
35
34
  };
36
35
  selection: {
37
- type: BooleanConstructor;
38
- default: boolean;
36
+ type: PropType<any[]>;
37
+ default: () => any[];
39
38
  };
40
39
  placeholder: {
41
40
  type: StringConstructor;
@@ -74,7 +73,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
74
73
  type: StringConstructor;
75
74
  default: string;
76
75
  };
77
- }>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("row-click" | "selection-change" | "sort-change" | "cell-click")[], "row-click" | "selection-change" | "sort-change" | "cell-click", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
76
+ autoSelectRowOnClick: {
77
+ type: BooleanConstructor;
78
+ default: boolean;
79
+ };
80
+ autoToggleRowOnClick: {
81
+ type: BooleanConstructor;
82
+ default: boolean;
83
+ };
84
+ }>, () => any, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("row-click" | "selection-change" | "update:selection" | "sort-change" | "cell-click")[], "row-click" | "selection-change" | "update:selection" | "sort-change" | "cell-click", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
78
85
  data: {
79
86
  type: PropType<any[]>;
80
87
  default: () => any[];
@@ -96,8 +103,8 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
96
103
  default: boolean;
97
104
  };
98
105
  selection: {
99
- type: BooleanConstructor;
100
- default: boolean;
106
+ type: PropType<any[]>;
107
+ default: () => any[];
101
108
  };
102
109
  placeholder: {
103
110
  type: StringConstructor;
@@ -136,9 +143,18 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
136
143
  type: StringConstructor;
137
144
  default: string;
138
145
  };
146
+ autoSelectRowOnClick: {
147
+ type: BooleanConstructor;
148
+ default: boolean;
149
+ };
150
+ autoToggleRowOnClick: {
151
+ type: BooleanConstructor;
152
+ default: boolean;
153
+ };
139
154
  }>> & Readonly<{
140
155
  "onRow-click"?: (...args: any[]) => any;
141
156
  "onSelection-change"?: (...args: any[]) => any;
157
+ "onUpdate:selection"?: (...args: any[]) => any;
142
158
  "onSort-change"?: (...args: any[]) => any;
143
159
  "onCell-click"?: (...args: any[]) => any;
144
160
  }>, {
@@ -147,7 +163,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
147
163
  hover: boolean;
148
164
  border: boolean | "full";
149
165
  stripe: boolean;
150
- selection: boolean;
166
+ selection: any[];
151
167
  placeholder: string;
152
168
  align: string;
153
169
  size: string;
@@ -158,5 +174,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
158
174
  scrollX: boolean;
159
175
  scrollY: boolean;
160
176
  height: string;
177
+ autoSelectRowOnClick: boolean;
178
+ autoToggleRowOnClick: boolean;
161
179
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
162
180
  export default _default;
package/dist/vary-ui.js CHANGED
@@ -17,7 +17,7 @@ import Scroll from './lib/Scroll/Scroll.js';
17
17
  import Select from './lib/Select/Select.js';
18
18
  import Skeleton from './lib/Skeleton/Skeleton.js';
19
19
  import { defineComponent, ref, watch, createVNode, onMounted, onBeforeUnmount, createTextVNode, createApp, h } from 'vue';
20
- import { _ as _export_sfc } from './_plugin-vue_export-helper-DN_H8P-u.js';
20
+ import { _ as _export_sfc } from './_plugin-vue_export-helper-BwJJ-9J8.js';
21
21
  import Tab from './lib/Tab/Tab.js';
22
22
  import Table from './lib/Table/Table.js';
23
23
  import TableColumn from './lib/TableColumn/TableColumn.js';
@@ -27,10 +27,10 @@ import RadioGroup from './lib/RadioGroup/RadioGroup.js';
27
27
  export { default as Message } from './lib/Message/Message.js';
28
28
  export { default as Confirm } from './lib/Confirm/Confirm.js';
29
29
  import './lib/Loading/Loading.js';
30
- import { c as config, s as setConfig } from './config-DVueulZb.js';
31
- export { k as debounce, i as isArray, b as isBoolean, d as isDate, f as isDateTime, c as isFun, h as isMonth, j as isNumber, a as isObject, e as isTime, g as isYear, m as matchChildrenCoponent, n as now, t as throttle } from './utils-D3Mk4Eng.js';
32
- import { L as Loading } from './Loading-5z79gQu9.js';
33
- import './Wrap-CPIflOtK.js';
30
+ import { c as config, s as setConfig } from './config-BAKtXHgR.js';
31
+ export { k as debounce, i as isArray, b as isBoolean, d as isDate, f as isDateTime, c as isFun, h as isMonth, j as isNumber, a as isObject, e as isTime, g as isYear, m as matchChildrenCoponent, n as now, t as throttle } from './utils-B7J83i5S.js';
32
+ import { L as Loading } from './Loading-DMFKMWpc.js';
33
+ import './Wrap-GIpwRQ0Z.js';
34
34
 
35
35
  var _sfc_main$2 = /* @__PURE__ */ defineComponent({
36
36
  props: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vary-ui",
3
- "version": "3.21.51",
3
+ "version": "3.21.52",
4
4
  "description": "vary-ui base vue3",
5
5
  "homepage": "https://varyui.com",
6
6
  "main": "dist/vary-ui.js",
File without changes
File without changes