bkui-vue 0.0.1-beta.42 → 0.0.1-beta.45

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 (142) hide show
  1. package/dist/index.cjs.js +20 -20
  2. package/dist/index.esm.js +170 -23
  3. package/dist/index.umd.js +20 -20
  4. package/dist/style.css +1 -1
  5. package/lib/alert/alert.variable.css +1 -0
  6. package/lib/alert/index.js +1 -0
  7. package/lib/animate-number/{animate-number.js → index.js} +1 -1
  8. package/lib/backtop/backtop.variable.css +1 -0
  9. package/lib/backtop/{backtop.js → index.js} +1 -1
  10. package/lib/badge/badge.variable.css +1 -0
  11. package/lib/badge/index.js +1 -0
  12. package/lib/breadcrumb/breadcrumb.variable.css +1 -0
  13. package/lib/breadcrumb/index.js +1 -0
  14. package/lib/button/button.variable.css +1 -0
  15. package/lib/button/index.js +1 -0
  16. package/lib/card/card.variable.css +1 -0
  17. package/lib/card/index.js +1 -0
  18. package/lib/checkbox/checkbox.variable.css +1 -0
  19. package/lib/checkbox/index.js +1 -0
  20. package/lib/code-diff/code-diff.variable.css +1 -0
  21. package/lib/code-diff/index.js +1 -0
  22. package/lib/collapse/index.js +1 -0
  23. package/lib/date-picker/date-picker.variable.css +1 -0
  24. package/lib/date-picker/index.js +1 -0
  25. package/lib/dialog/{dialog.js → index.js} +0 -0
  26. package/lib/directives/index.js +2 -0
  27. package/lib/directives/{directives.js.LICENSE.txt → index.js.LICENSE.txt} +0 -0
  28. package/lib/divider/divider.variable.css +1 -0
  29. package/lib/divider/{divider.js → index.js} +0 -0
  30. package/lib/dropdown/dropdown.variable.css +1 -0
  31. package/lib/dropdown/{dropdown.js → index.js} +0 -0
  32. package/lib/exception/exception.variable.css +1 -0
  33. package/lib/exception/{exception.js → index.js} +1 -1
  34. package/lib/fixed-navbar/fixed-navbar.variable.css +1 -0
  35. package/lib/fixed-navbar/{fixed-navbar.js → index.js} +1 -1
  36. package/lib/form/index.js +1 -0
  37. package/lib/icon/{icon.js → index.js} +0 -0
  38. package/lib/input/index.js +1 -0
  39. package/lib/input/input.css +3 -3
  40. package/lib/input/input.less +3 -3
  41. package/lib/input/input.variable.css +4 -3
  42. package/lib/link/{link.js → index.js} +0 -0
  43. package/lib/link/link.variable.css +1 -0
  44. package/lib/loading/index.js +1 -0
  45. package/lib/loading/loading.variable.css +1 -0
  46. package/lib/menu/index.js +1 -0
  47. package/lib/menu/menu.variable.css +1 -0
  48. package/lib/menu/submenu.variable.css +1 -0
  49. package/lib/message/{message.js → index.js} +0 -0
  50. package/lib/message/message.variable.css +1 -0
  51. package/lib/modal/index.js +1 -0
  52. package/lib/navigation/index.js +1 -0
  53. package/lib/navigation/navigation.variable.css +1 -0
  54. package/lib/notify/index.js +1 -0
  55. package/lib/notify/notify.variable.css +1 -0
  56. package/lib/pagination/index.js +1 -0
  57. package/lib/pagination/pagination.variable.css +1 -0
  58. package/lib/popover/index.js +1 -0
  59. package/lib/popover/popover.variable.css +1 -0
  60. package/lib/process/index.js +1 -0
  61. package/lib/process/process.variable.css +1 -0
  62. package/lib/progress/index.js +1 -0
  63. package/lib/progress/progress.variable.css +1 -0
  64. package/lib/radio/index.js +1 -0
  65. package/lib/radio/radio.variable.css +1 -0
  66. package/lib/rate/index.js +1 -0
  67. package/lib/resize-layout/index.js +1 -0
  68. package/lib/resize-layout/resize-layout.variable.css +1 -0
  69. package/lib/select/index.js +1 -0
  70. package/lib/select/select.variable.css +1 -0
  71. package/lib/shared/index.js +1 -0
  72. package/lib/sideslider/index.js +1 -0
  73. package/lib/sideslider/sideslider.variable.css +1 -0
  74. package/lib/slider/index.js +1 -0
  75. package/lib/slider/slider.variable.css +1 -0
  76. package/lib/steps/index.js +1 -0
  77. package/lib/steps/steps.variable.css +1 -0
  78. package/lib/styles/themes/themes.less +1 -0
  79. package/lib/swiper/index.js +1 -0
  80. package/lib/switcher/index.js +1 -0
  81. package/lib/switcher/switcher.variable.css +1 -0
  82. package/lib/tab/index.js +1 -0
  83. package/lib/tab/tab.variable.css +1 -0
  84. package/lib/table/index.d.ts +4 -0
  85. package/lib/table/index.js +1 -0
  86. package/lib/table/props.d.ts +20 -1
  87. package/lib/table/render.d.ts +32 -0
  88. package/lib/table/table.css +29 -3
  89. package/lib/table/table.d.ts +2 -0
  90. package/lib/table/table.less +31 -5
  91. package/lib/table/table.variable.css +32 -5
  92. package/lib/table/utils.d.ts +13 -0
  93. package/lib/tag/index.js +1 -0
  94. package/lib/tag/tag.variable.css +1 -0
  95. package/lib/tag-input/index.js +1 -0
  96. package/lib/tag-input/tag-input.variable.css +1 -0
  97. package/lib/timeline/{timeline.js → index.js} +0 -0
  98. package/lib/timeline/timeline.variable.css +1 -0
  99. package/lib/transfer/index.js +1 -0
  100. package/lib/transfer/transfer.variable.css +1 -0
  101. package/lib/tree/index.js +1 -0
  102. package/lib/tree/tree.variable.css +1 -0
  103. package/lib/virtual-render/index.js +1 -0
  104. package/package.json +1 -1
  105. package/lib/alert/alert.js +0 -1
  106. package/lib/badge/badge.js +0 -1
  107. package/lib/breadcrumb/breadcrumb.js +0 -1
  108. package/lib/button/button.js +0 -1
  109. package/lib/card/card.js +0 -1
  110. package/lib/checkbox/checkbox.js +0 -1
  111. package/lib/code-diff/code-diff.js +0 -1
  112. package/lib/collapse/collapse.js +0 -1
  113. package/lib/date-picker/date-picker.js +0 -1
  114. package/lib/directives/directives.js +0 -2
  115. package/lib/form/form.js +0 -1
  116. package/lib/input/input.js +0 -1
  117. package/lib/loading/loading.js +0 -1
  118. package/lib/menu/menu.js +0 -1
  119. package/lib/modal/modal.js +0 -1
  120. package/lib/navigation/navigation.js +0 -1
  121. package/lib/notify/notify.js +0 -1
  122. package/lib/pagination/pagination.js +0 -1
  123. package/lib/popover/popover.js +0 -1
  124. package/lib/process/process.js +0 -1
  125. package/lib/progress/progress.js +0 -1
  126. package/lib/radio/radio.js +0 -1
  127. package/lib/rate/rate.js +0 -1
  128. package/lib/resize-layout/resize-layout.js +0 -1
  129. package/lib/select/select.js +0 -1
  130. package/lib/shared/shared.js +0 -1
  131. package/lib/sideslider/sideslider.js +0 -1
  132. package/lib/slider/slider.js +0 -1
  133. package/lib/steps/steps.js +0 -1
  134. package/lib/swiper/swiper.js +0 -1
  135. package/lib/switcher/switcher.js +0 -1
  136. package/lib/tab/tab.js +0 -1
  137. package/lib/table/table.js +0 -1
  138. package/lib/tag/tag.js +0 -1
  139. package/lib/tag-input/tag-input.js +0 -1
  140. package/lib/transfer/transfer.js +0 -1
  141. package/lib/tree/tree.js +0 -1
  142. package/lib/virtual-render/virtual-render.js +0 -1
package/dist/index.esm.js CHANGED
@@ -2370,29 +2370,38 @@ bkIcon.inheritAttrs = false;
2370
2370
  bkIcon.displayName = "bkIcon";
2371
2371
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 744.64L789.6 462.72 880 554.56 512 928 144 554.56 234.4 462.72 512 744.64z"}},{"type":"element","name":"path","attributes":{"d":"M144 187.68L234.4 96 512 377.76 789.6 96 880 187.68 512 561.28 144 187.68z"}}]}');
2372
2372
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M279.36 512L561.28 789.6 469.44 880 96 512 469.44 144 561.28 234.4 279.36 512z"}},{"type":"element","name":"path","attributes":{"d":"M836.32 144L928 234.4 646.08 512 928 789.6 836.32 880 462.72 512 836.32 144z"}}]}');
2373
- const data$w = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M697.6 281.6l48 48-176 176 176 176-48 48-224-224L697.6 281.6z"}},{"type":"element","name":"path","attributes":{"d":"M505.6 281.6l48 48-176 176 176 176-48 48-224-224L505.6 281.6z"}}]}');
2373
+ const data$x = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M697.6 281.6l48 48-176 176 176 176-48 48-224-224L697.6 281.6z"}},{"type":"element","name":"path","attributes":{"d":"M505.6 281.6l48 48-176 176 176 176-48 48-224-224L505.6 281.6z"}}]}');
2374
2374
  const angleDoubleLeft = (props, context) => {
2375
2375
  const p2 = __spreadValues(__spreadValues({}, props), context.attrs);
2376
2376
  return createVNode(bkIcon, mergeProps(p2, {
2377
- "data": data$w,
2377
+ "data": data$x,
2378
2378
  "name": "angleDoubleLeft"
2379
2379
  }), null);
2380
2380
  };
2381
2381
  angleDoubleLeft.displayName = "angleDoubleLeft";
2382
2382
  angleDoubleLeft.inheritAttrs = false;
2383
2383
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M744.64 512L462.72 789.6 554.56 880 928 512 554.56 144 462.72 234.4 744.64 512z"}},{"type":"element","name":"path","attributes":{"d":"M187.68 144L96 234.4 377.76 512 96 789.6 187.68 880 561.28 512 187.68 144z"}}]}');
2384
- const data$v = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M358.4 729.6l-48-48 176-176-176-176 48-48 224 224L358.4 729.6z"}},{"type":"element","name":"path","attributes":{"d":"M550.4 729.6l-48-48 176-176-176-176 48-48 224 224L550.4 729.6z"}}]}');
2384
+ const data$w = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M358.4 729.6l-48-48 176-176-176-176 48-48 224 224L358.4 729.6z"}},{"type":"element","name":"path","attributes":{"d":"M550.4 729.6l-48-48 176-176-176-176 48-48 224 224L550.4 729.6z"}}]}');
2385
2385
  const angleDoubleRight = (props, context) => {
2386
2386
  const p2 = __spreadValues(__spreadValues({}, props), context.attrs);
2387
2387
  return createVNode(bkIcon, mergeProps(p2, {
2388
- "data": data$v,
2388
+ "data": data$w,
2389
2389
  "name": "angleDoubleRight"
2390
2390
  }), null);
2391
2391
  };
2392
2392
  angleDoubleRight.displayName = "angleDoubleRight";
2393
2393
  angleDoubleRight.inheritAttrs = false;
2394
2394
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 279.36L789.6 561.28 880 469.44 512 96 144 469.44 234.4 561.28 512 279.36z"}},{"type":"element","name":"path","attributes":{"d":"M144 836.32L234.4 928 512 646.08 789.6 928 880 836.32 512 462.72 144 836.32z"}}]}');
2395
- JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 256L96 704 187.04 704 512 704 836.96 704 928 704 512 256z"}}]}');
2395
+ const data$v = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 256L96 704 187.04 704 512 704 836.96 704 928 704 512 256z"}}]}');
2396
+ const angleDownFill = (props, context) => {
2397
+ const p2 = __spreadValues(__spreadValues({}, props), context.attrs);
2398
+ return createVNode(bkIcon, mergeProps(p2, {
2399
+ "data": data$v,
2400
+ "name": "angleDownFill"
2401
+ }), null);
2402
+ };
2403
+ angleDownFill.displayName = "angleDownFill";
2404
+ angleDownFill.inheritAttrs = false;
2396
2405
  JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M512 762.56L98.72 349.28 189.28 258.72 512 581.44 834.72 258.72 925.28 349.28 512 762.56z"}}]}');
2397
2406
  const data$u = JSON.parse('{"type":"element","name":"svg","attributes":{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 1024 1024","style":"width: 1em; height: 1em; vertical-align: middle;fill: currentColor;overflow: hidden;"},"elements":[{"type":"element","name":"path","attributes":{"d":"M288 448L336 400 512 576 688 400 736 448 512 672z"}}]}');
2398
2407
  const angleDown = (props, context) => {
@@ -11969,13 +11978,24 @@ var Component$6 = defineComponent({
11969
11978
  });
11970
11979
  const BkVirtualRender = withInstall(Component$6);
11971
11980
  const BORDER_OPRIONS = ["none", "row", "col", "outer"];
11981
+ var SortScope = /* @__PURE__ */ ((SortScope2) => {
11982
+ SortScope2["CURRENT"] = "current";
11983
+ SortScope2["ALL"] = "all";
11984
+ return SortScope2;
11985
+ })(SortScope || {});
11972
11986
  const tableProps = {
11973
11987
  data: PropTypes.arrayOf(PropTypes.any).def([]),
11974
11988
  columns: PropTypes.arrayOf(PropTypes.shape({
11975
11989
  label: PropTypes.oneOfType([PropTypes.func.def(() => ""), PropTypes.string.def("")]),
11976
11990
  field: PropTypes.oneOfType([PropTypes.func.def(() => ""), PropTypes.string.def("")]),
11977
11991
  render: PropTypes.oneOfType([PropTypes.func.def(() => ""), PropTypes.string.def("")]),
11978
- width: PropTypes.oneOfType([PropTypes.number.def(void 0), PropTypes.string.def("auto")])
11992
+ width: PropTypes.oneOfType([PropTypes.number.def(void 0), PropTypes.string.def("auto")]),
11993
+ type: PropTypes.commonType(["selection", "index", "expand"], "columnType").def(""),
11994
+ sort: PropTypes.oneOfType([PropTypes.shape({
11995
+ sortby: PropTypes.string.def(""),
11996
+ sortFn: PropTypes.func.def(null),
11997
+ sortScope: PropTypes.commonType(Object.values(SortScope)).def("current")
11998
+ }), PropTypes.bool]).def(false)
11979
11999
  })),
11980
12000
  activeColumn: PropTypes.oneOfType([PropTypes.number.def(-1), PropTypes.arrayOf(PropTypes.number.def(-1))]),
11981
12001
  columnPick: PropTypes.commonType(["multi", "single", "disabled"], "columnPick").def("disabled"),
@@ -11984,6 +12004,11 @@ const tableProps = {
11984
12004
  rowHeight: PropTypes.oneOfType([PropTypes.number, PropTypes.func]).def(40),
11985
12005
  headHeight: PropTypes.number.def(40),
11986
12006
  showHead: PropTypes.bool.def(true),
12007
+ thead: PropTypes.shape({
12008
+ height: PropTypes.number.def(40),
12009
+ isShow: PropTypes.bool.def(true),
12010
+ cellFn: PropTypes.func.def(null)
12011
+ }),
11987
12012
  virtualEnabled: PropTypes.bool.def(false),
11988
12013
  border: PropTypes.arrayOf(PropTypes.commonType(BORDER_OPRIONS, "border")).def(["row"]),
11989
12014
  pagination: PropTypes.oneOfType([PropTypes.bool.def(false), PropTypes.object.def({})]).def(false),
@@ -12575,6 +12600,26 @@ const resolvePaginationOption = (propPagination, defVal) => {
12575
12600
  }
12576
12601
  return {};
12577
12602
  };
12603
+ const resolveHeadConfig = (props) => {
12604
+ const {
12605
+ showHead,
12606
+ headHeight,
12607
+ thead = {}
12608
+ } = props;
12609
+ return Object.assign({}, {
12610
+ isShow: showHead,
12611
+ height: headHeight
12612
+ }, __spreadValues({}, thead));
12613
+ };
12614
+ let EVENTS;
12615
+ (function(EVENTS2) {
12616
+ EVENTS2["ON_SORT_BY_CLICK"] = "onSortByClick";
12617
+ })(EVENTS || (EVENTS = {}));
12618
+ let SortType;
12619
+ (function(SortType2) {
12620
+ SortType2["ASC"] = "asc";
12621
+ SortType2["DESC"] = "desc";
12622
+ })(SortType || (SortType = {}));
12578
12623
  class TableRender {
12579
12624
  constructor(props, ctx, reactiveProp, colgroups) {
12580
12625
  __publicField(this, "getColumnClass", (colIndex) => `${this.uuid}-column-${colIndex}`);
@@ -12584,11 +12629,18 @@ class TableRender {
12584
12629
  this.colgroups = colgroups;
12585
12630
  this.plugins = new TablePlugins(props, ctx);
12586
12631
  this.uuid = random(8);
12632
+ this.events = /* @__PURE__ */ new Map();
12587
12633
  }
12588
12634
  get propActiveCols() {
12589
12635
  return this.reactiveProp.activeColumns;
12590
12636
  }
12591
12637
  renderTableHeadSchema() {
12638
+ const {
12639
+ isShow = true
12640
+ } = resolveHeadConfig(this.props);
12641
+ if (!isShow) {
12642
+ return null;
12643
+ }
12592
12644
  return createVNode("table", {
12593
12645
  "cellpadding": 0,
12594
12646
  "cellspacing": 0
@@ -12607,6 +12659,26 @@ class TableRender {
12607
12659
  "onChange": (current) => this.hanlePageChange(current)
12608
12660
  }), null);
12609
12661
  }
12662
+ on(eventName, wartcher) {
12663
+ if (!this.events.has(eventName)) {
12664
+ this.events.set(eventName, []);
12665
+ }
12666
+ this.events.get(eventName).push(wartcher);
12667
+ return this;
12668
+ }
12669
+ destroy() {
12670
+ this.events.clear();
12671
+ this.events = null;
12672
+ }
12673
+ emitEvent(eventName, args) {
12674
+ if (this.events.has(eventName)) {
12675
+ this.events.get(eventName).forEach((evet) => {
12676
+ if (typeof evet === "function") {
12677
+ Reflect.apply(evet, this, args);
12678
+ }
12679
+ });
12680
+ }
12681
+ }
12610
12682
  handlePageLimitChange(limit) {
12611
12683
  Object.assign(this.props.pagination, {
12612
12684
  limit
@@ -12640,8 +12712,61 @@ class TableRender {
12640
12712
  }
12641
12713
  }
12642
12714
  renderHeader() {
12715
+ const config = resolveHeadConfig(this.props);
12716
+ const {
12717
+ cellFn
12718
+ } = config;
12643
12719
  const rowStyle = {
12644
- "--row-height": `${resolvePropVal(this.props, "headHeight", ["thead"])}px`
12720
+ "--row-height": `${resolvePropVal(config, "height", ["thead"])}px`
12721
+ };
12722
+ const hanldeSortClick = (e, column, index, type) => {
12723
+ var _a, _b;
12724
+ e.stopImmediatePropagation();
12725
+ e.stopPropagation();
12726
+ e.preventDefault();
12727
+ const fieldName = column.field;
12728
+ const getVal = (row) => this.getRowText(row, fieldName, column);
12729
+ const sortFn0 = (a2, b2) => {
12730
+ const val0 = getVal(a2);
12731
+ const val1 = getVal(b2);
12732
+ if (typeof val0 === "number" && typeof val1 === "number") {
12733
+ return val0 - val1;
12734
+ }
12735
+ return String.prototype.localeCompare.call(val0, val1);
12736
+ };
12737
+ Object.assign(column, {
12738
+ _sort_reg: type
12739
+ });
12740
+ const sortFn = typeof ((_a = column.sort) == null ? void 0 : _a.sortFn) === "function" ? (_b = column.sort) == null ? void 0 : _b.sortFn : sortFn0;
12741
+ const execFn = (_a2, _b2) => sortFn(_a2, _b2) * (type === SortType.DESC ? -1 : 1);
12742
+ this.emitEvent(EVENTS.ON_SORT_BY_CLICK, [{
12743
+ sortFn: execFn,
12744
+ column,
12745
+ index,
12746
+ type
12747
+ }]);
12748
+ };
12749
+ const renderHeadCell = (column, index) => {
12750
+ const cells = [];
12751
+ if (column.sort) {
12752
+ const sortReg = column["_sort_reg"];
12753
+ const sortCell = createVNode("span", {
12754
+ "class": "head-cell-sort"
12755
+ }, [createVNode(angleDownFill, {
12756
+ "class": ["sort-action", "sort-asc", sortReg === SortType.ASC ? "active" : ""],
12757
+ "onClick": (e) => hanldeSortClick(e, column, index, SortType.ASC)
12758
+ }, null), createVNode(angleUpFill, {
12759
+ "class": ["sort-action", "sort-desc", sortReg === SortType.DESC ? "active" : ""],
12760
+ "onClick": (e) => hanldeSortClick(e, column, index, SortType.DESC)
12761
+ }, null)]);
12762
+ cells.push(sortCell);
12763
+ }
12764
+ if (typeof cellFn === "function") {
12765
+ cells.unshift(cellFn(column, index));
12766
+ return cells;
12767
+ }
12768
+ cells.unshift(resolvePropVal(column, "label", [column, index]));
12769
+ return cells;
12645
12770
  };
12646
12771
  return createVNode("thead", {
12647
12772
  "style": rowStyle
@@ -12654,24 +12779,24 @@ class TableRender {
12654
12779
  "onClick": () => this.handleColumnHeadClick(index)
12655
12780
  }, [createVNode("div", {
12656
12781
  "class": "cell"
12657
- }, [resolvePropVal(column, "label", [column])])]))])]);
12782
+ }, [renderHeadCell(column, index)])]))])]);
12658
12783
  }
12659
12784
  renderTBody(rows) {
12660
- return createVNode("tbody", null, [rows.map((row, index) => {
12785
+ return createVNode("tbody", null, [rows.map((row, rowIndex) => {
12661
12786
  const rowStyle = {
12662
- "--row-height": `${resolvePropVal(this.props, "rowHeight", ["tbody", row, index])}px`
12787
+ "--row-height": `${resolvePropVal(this.props, "rowHeight", ["tbody", row, rowIndex])}px`
12663
12788
  };
12664
12789
  return createVNode("tr", {
12665
12790
  "style": rowStyle,
12666
- "onClick": (e) => this.handleRowClick(e, row, index, rows),
12667
- "onDblclick": (e) => this.handleRowDblClick(e, row, index, rows)
12668
- }, [this.props.columns.map((column, index2) => createVNode("td", {
12669
- "class": this.getColumnClass(index2),
12791
+ "onClick": (e) => this.handleRowClick(e, row, rowIndex, rows),
12792
+ "onDblclick": (e) => this.handleRowDblClick(e, row, rowIndex, rows)
12793
+ }, [this.props.columns.map((column, index) => createVNode("td", {
12794
+ "class": this.getColumnClass(index),
12670
12795
  "colspan": 1,
12671
12796
  "rowspan": 1
12672
12797
  }, [createVNode("div", {
12673
12798
  "class": "cell"
12674
- }, [this.renderCell(row, column, index2, rows)])]))]);
12799
+ }, [this.renderCell(row, column, rowIndex, rows)])]))]);
12675
12800
  })]);
12676
12801
  }
12677
12802
  handleRowClick(e, row, index, rows) {
@@ -12680,8 +12805,14 @@ class TableRender {
12680
12805
  handleRowDblClick(e, row, index, rows) {
12681
12806
  this.context.emit("rowDblClick", e, row, index, rows, this);
12682
12807
  }
12808
+ getRowText(row, key, column) {
12809
+ if (column.type === "index") {
12810
+ return row.__$table_row_index;
12811
+ }
12812
+ return row[key];
12813
+ }
12683
12814
  renderCell(row, column, index, rows) {
12684
- const cell = row[resolvePropVal(column, "field", [column, row])];
12815
+ const cell = this.getRowText(row, resolvePropVal(column, "field", [column, row]), column);
12685
12816
  if (typeof column.render === "function") {
12686
12817
  return column.render(cell, row, index, rows);
12687
12818
  }
@@ -12714,6 +12845,7 @@ var Component$4 = defineComponent({
12714
12845
  })));
12715
12846
  const startIndex = ref(0);
12716
12847
  const endIndex = ref(0);
12848
+ let columnSortFn = null;
12717
12849
  let pagination2 = reactive({
12718
12850
  count: 0,
12719
12851
  limit: 10,
@@ -12754,15 +12886,29 @@ var Component$4 = defineComponent({
12754
12886
  }, {
12755
12887
  deep: true
12756
12888
  });
12757
- const tableRender = new TableRender(props, ctx, reactiveProp, colgroups);
12758
- const wrapperStyle = computed(() => ({
12759
- minHeight: resolveNumberOrStringToPix(props.minHeight, "auto")
12760
- }));
12889
+ const indexData = computed(() => props.data.map((item, index) => __spreadProps(__spreadValues({}, item), {
12890
+ __$table_row_index: index + 1
12891
+ })));
12892
+ const pageData = reactive([]);
12761
12893
  watchEffect(() => {
12762
12894
  pagination2 = resolvePaginationOption(props.pagination, pagination2);
12763
12895
  resetStartEndIndex();
12896
+ pageData.splice(0, pageData.length, ...indexData.value.slice(startIndex.value, endIndex.value));
12897
+ if (typeof columnSortFn === "function") {
12898
+ pageData.sort(columnSortFn);
12899
+ }
12764
12900
  });
12765
- const pageData = computed(() => props.data.slice(startIndex.value, endIndex.value));
12901
+ const tableRender = new TableRender(props, ctx, reactiveProp, colgroups);
12902
+ tableRender.on(EVENTS.ON_SORT_BY_CLICK, (args) => {
12903
+ const {
12904
+ sortFn
12905
+ } = args;
12906
+ columnSortFn = sortFn;
12907
+ pageData.sort(columnSortFn);
12908
+ });
12909
+ const wrapperStyle = computed(() => ({
12910
+ minHeight: resolveNumberOrStringToPix(props.minHeight, "auto")
12911
+ }));
12766
12912
  const localPagination = computed(() => {
12767
12913
  if (!props.pagination) {
12768
12914
  return null;
@@ -12810,6 +12956,7 @@ var Component$4 = defineComponent({
12810
12956
  onBeforeUnmount(() => {
12811
12957
  observerIns.stop();
12812
12958
  observerIns = null;
12959
+ tableRender.destroy();
12813
12960
  });
12814
12961
  ctx.expose({
12815
12962
  plugins: tableRender.plugins
@@ -12820,11 +12967,11 @@ var Component$4 = defineComponent({
12820
12967
  "ref": root
12821
12968
  }, [createVNode("div", {
12822
12969
  "class": headClass
12823
- }, [props.showHead && tableRender.renderTableHeadSchema()]), createVNode(BkVirtualRender, {
12970
+ }, [tableRender.renderTableHeadSchema()]), createVNode(BkVirtualRender, {
12824
12971
  "lineHeight": props.rowHeight,
12825
12972
  "class": contentClass,
12826
12973
  "style": contentStyle.value,
12827
- "list": pageData.value,
12974
+ "list": pageData,
12828
12975
  "onContentScroll": handleScrollChanged,
12829
12976
  "throttleDelay": 0,
12830
12977
  "enabled": props.virtualEnabled