stk-table-vue 0.6.12 → 0.6.13

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.
@@ -1698,6 +1698,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1698
1698
  [TagType.TD]: tdMap
1699
1699
  };
1700
1700
  });
1701
+ function getRowIndex(rowIndex) {
1702
+ return rowIndex + (virtual_on ? virtualScroll.value.startIndex : 0);
1703
+ }
1701
1704
  function getHeaderTitle(col) {
1702
1705
  const colKey = colKeyGen.value(col);
1703
1706
  if (props.hideHeaderTitle === true || Array.isArray(props.hideHeaderTitle) && props.hideHeaderTitle.includes(colKey)) {
@@ -1758,8 +1761,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1758
1761
  emits("sort-change", col, order, toRaw(dataSourceCopy.value), sortConfig);
1759
1762
  }
1760
1763
  }
1761
- function onRowClick(e, row) {
1762
- emits("row-click", e, row);
1764
+ function onRowClick(e, row, rowIndex) {
1765
+ emits("row-click", e, row, { rowIndex });
1763
1766
  const isCurrentRow = props.rowKey ? currentRowKey.value === rowKeyGen(row) : currentRow.value === row;
1764
1767
  if (isCurrentRow) {
1765
1768
  if (!props.rowCurrentRevokable) {
@@ -1773,22 +1776,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1773
1776
  }
1774
1777
  emits("current-change", e, row, { select: !isCurrentRow });
1775
1778
  }
1776
- function onRowDblclick(e, row) {
1777
- emits("row-dblclick", e, row);
1779
+ function onRowDblclick(e, row, rowIndex) {
1780
+ emits("row-dblclick", e, row, { rowIndex });
1778
1781
  }
1779
1782
  function onHeaderMenu(e) {
1780
1783
  emits("header-row-menu", e);
1781
1784
  }
1782
- function onRowMenu(e, row) {
1783
- emits("row-menu", e, row);
1785
+ function onRowMenu(e, row, rowIndex) {
1786
+ emits("row-menu", e, row, { rowIndex });
1784
1787
  }
1785
- function onCellClick(e, row, col) {
1788
+ function onCellClick(e, row, col, rowIndex) {
1786
1789
  if (col.type === "expand") {
1787
1790
  toggleExpandRow(row, col);
1788
1791
  }
1789
1792
  if (props.cellActive) {
1790
1793
  const cellKey = cellKeyGen(row, col);
1791
- const result = { row, col, select: false };
1794
+ const result = { row, col, select: false, rowIndex };
1792
1795
  if (props.selectedCellRevokable && currentSelectedCellKey.value === cellKey) {
1793
1796
  currentSelectedCellKey.value = void 0;
1794
1797
  } else {
@@ -1797,7 +1800,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1797
1800
  }
1798
1801
  emits("cell-selected", e, result);
1799
1802
  }
1800
- emits("cell-click", e, row, col);
1803
+ emits("cell-click", e, row, col, { rowIndex });
1801
1804
  }
1802
1805
  function onHeaderCellClick(e, col) {
1803
1806
  emits("header-cell-click", e, col);
@@ -1811,8 +1814,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1811
1814
  function onCellMouseOver(e, row, col) {
1812
1815
  emits("cell-mouseover", e, row, col);
1813
1816
  }
1814
- function onCellMouseDown(e, row, col) {
1815
- emits("cell-mousedown", e, row, col);
1817
+ function onCellMouseDown(e, row, col, rowIndex) {
1818
+ emits("cell-mousedown", e, row, col, { rowIndex });
1816
1819
  }
1817
1820
  function onTableWheel(e) {
1818
1821
  if (props.smoothScroll) {
@@ -2262,27 +2265,27 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2262
2265
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(virtual_dataSourcePart), (row, rowIndex) => {
2263
2266
  var _a, _b;
2264
2267
  return openBlock(), createElementBlock("tr", {
2265
- id: unref(stkTableId) + "-" + (_ctx.rowKey ? rowKeyGen(row) : (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex),
2268
+ id: unref(stkTableId) + "-" + (_ctx.rowKey ? rowKeyGen(row) : getRowIndex(rowIndex)),
2266
2269
  ref_for: true,
2267
2270
  ref_key: "trRef",
2268
2271
  ref: trRef,
2269
- key: _ctx.rowKey ? rowKeyGen(row) : (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex,
2270
- "data-row-key": _ctx.rowKey ? rowKeyGen(row) : (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex,
2272
+ key: _ctx.rowKey ? rowKeyGen(row) : getRowIndex(rowIndex),
2273
+ "data-row-key": _ctx.rowKey ? rowKeyGen(row) : getRowIndex(rowIndex),
2271
2274
  class: normalizeClass({
2272
2275
  active: _ctx.rowKey ? rowKeyGen(row) === currentRowKey.value : row === currentRow.value,
2273
2276
  hover: props.showTrHoverClass && (_ctx.rowKey ? rowKeyGen(row) === currentHoverRowKey.value : row === currentHoverRowKey.value),
2274
- [_ctx.rowClassName(row, (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex)]: true,
2277
+ [_ctx.rowClassName(row, getRowIndex(rowIndex))]: true,
2275
2278
  expanded: row == null ? void 0 : row.__EXPANDED__,
2276
2279
  "expanded-row": row && row.__EXPANDED_ROW__
2277
2280
  }),
2278
2281
  style: normalizeStyle({
2279
2282
  "--row-height": row && row.__EXPANDED_ROW__ && props.virtual && ((_a = props.expandConfig) == null ? void 0 : _a.height) && ((_b = props.expandConfig) == null ? void 0 : _b.height) + "px"
2280
2283
  }),
2281
- onClick: (e) => onRowClick(e, row),
2282
- onDblclick: (e) => onRowDblclick(e, row),
2283
- onContextmenu: (e) => onRowMenu(e, row),
2284
+ onClick: (e) => onRowClick(e, row, getRowIndex(rowIndex)),
2285
+ onDblclick: (e) => onRowDblclick(e, row, getRowIndex(rowIndex)),
2286
+ onContextmenu: (e) => onRowMenu(e, row, getRowIndex(rowIndex)),
2284
2287
  onMouseover: (e) => onTrMouseOver(e, row),
2285
- onDrop: (e) => unref(onTrDrop)(e, (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex)
2288
+ onDrop: (e) => unref(onTrDrop)(e, getRowIndex(rowIndex))
2286
2289
  }, [
2287
2290
  unref(virtualX_on) ? (openBlock(), createElementBlock("td", _hoisted_7)) : createCommentVNode("", true),
2288
2291
  row && row.__EXPANDED_ROW__ ? (openBlock(), createElementBlock("td", {
@@ -2312,12 +2315,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2312
2315
  "seq-column": col.type === "seq",
2313
2316
  active: currentSelectedCellKey.value === cellKeyGen(row, col),
2314
2317
  "expand-cell": col.type === "expand",
2315
- expanded: col.type === "expand" && colKeyGen.value(row == null ? void 0 : row.__EXPANDED__) === colKeyGen.value(col),
2318
+ expanded: col.type === "expand" && (row.__EXPANDED__ ? colKeyGen.value(row.__EXPANDED__) === colKeyGen.value(col) : false),
2316
2319
  "drag-row-cell": col.type === "dragRow"
2317
2320
  }
2318
2321
  ]),
2319
- onClick: (e) => onCellClick(e, row, col),
2320
- onMousedown: (e) => onCellMouseDown(e, row, col),
2322
+ onClick: (e) => onCellClick(e, row, col, getRowIndex(rowIndex)),
2323
+ onMousedown: (e) => onCellMouseDown(e, row, col, getRowIndex(rowIndex)),
2321
2324
  onMouseenter: (e) => onCellMouseEnter(e, row, col),
2322
2325
  onMouseleave: (e) => onCellMouseLeave(e, row, col),
2323
2326
  onMouseover: (e) => onCellMouseOver(e, row, col)
@@ -2327,20 +2330,20 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2327
2330
  class: "table-cell-wrapper",
2328
2331
  col,
2329
2332
  row,
2330
- rowIndex: (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex,
2333
+ rowIndex: getRowIndex(rowIndex),
2331
2334
  colIndex,
2332
- cellValue: row == null ? void 0 : row[col.dataIndex],
2333
- expanded: (row == null ? void 0 : row.__EXPANDED__) || null
2335
+ cellValue: row && row[col.dataIndex],
2336
+ expanded: row && row.__EXPANDED__ || null
2334
2337
  }, null, 8, ["col", "row", "rowIndex", "colIndex", "cellValue", "expanded"])) : (openBlock(), createElementBlock("div", {
2335
2338
  key: 1,
2336
2339
  class: normalizeClass(["table-cell-wrapper", { "expanded-cell-wrapper": col.type === "expand" }]),
2337
2340
  title: col.type !== "seq" ? row == null ? void 0 : row[col.dataIndex] : ""
2338
2341
  }, [
2339
2342
  col.type === "seq" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2340
- createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex + 1), 1)
2343
+ createTextVNode(toDisplayString((props.seqConfig.startIndex || 0) + getRowIndex(rowIndex) + 1), 1)
2341
2344
  ], 64)) : col.type === "expand" ? (openBlock(), createElementBlock("span", _hoisted_12, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 1)) : col.type === "dragRow" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2342
2345
  createVNode(DragHandle, {
2343
- onDragstart: (e) => unref(onTrDragStart)(e, (unref(virtual_on) ? unref(virtualScroll).startIndex : 0) + rowIndex)
2346
+ onDragstart: (e) => unref(onTrDragStart)(e, getRowIndex(rowIndex))
2344
2347
  }, null, 8, ["onDragstart"]),
2345
2348
  createElementVNode("span", null, toDisplayString((row == null ? void 0 : row[col.dataIndex]) ?? ""), 1)
2346
2349
  ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 3 }, [
package/package.json CHANGED
@@ -1,75 +1,75 @@
1
- {
2
- "name": "stk-table-vue",
3
- "version": "0.6.12",
4
- "description": "Simple realtime virtual table for vue3 and vue2.7",
5
- "main": "./lib/stk-table-vue.js",
6
- "types": "./lib/src/StkTable/index.d.ts",
7
- "packageManager": "pnpm@10.7.0",
8
- "directories": {
9
- "test": "test"
10
- },
11
- "type": "module",
12
- "scripts": {
13
- "dev": "vite",
14
- "build": "vite build",
15
- "test": "vitest",
16
- "docs:dev": "vitepress dev docs-src",
17
- "docs:build": "vitepress build docs-src",
18
- "docs:preview": "vitepress preview docs-src",
19
- "docs:update": "cp -rf ./docs-src/.vitepress/dist/* ./docs"
20
- },
21
- "keywords": [
22
- "virtual table",
23
- "vue",
24
- "vue2",
25
- "vue3",
26
- "highlight",
27
- "sticky",
28
- "virtual",
29
- "table",
30
- "list"
31
- ],
32
- "files": [
33
- "lib",
34
- "src"
35
- ],
36
- "author": "japlus",
37
- "repository": {
38
- "type": "git",
39
- "url": "https://github.com/ja-plus/stk-table-vue"
40
- },
41
- "license": "MIT",
42
- "devDependencies": {
43
- "@types/d3-interpolate": "^3.0.4",
44
- "@types/mockjs": "^1.0.10",
45
- "@types/node": "^20.12.10",
46
- "@typescript-eslint/eslint-plugin": "^7.7.0",
47
- "@typescript-eslint/parser": "^7.7.0",
48
- "@vitejs/plugin-vue": "^5.1.4",
49
- "@vue/test-utils": "2.4.4",
50
- "eslint": "^8.57.0",
51
- "eslint-config-prettier": "^9.1.0",
52
- "eslint-plugin-html": "^8.1.0",
53
- "eslint-plugin-prettier": "^5.1.3",
54
- "eslint-plugin-vue": "^9.25.0",
55
- "happy-dom": "^12.10.3",
56
- "less": "^4.2.0",
57
- "mitt": "^3.0.1",
58
- "mockjs": "^1.1.0",
59
- "postcss": "^8.4.47",
60
- "postcss-discard-comments": "^6.0.2",
61
- "postcss-preset-env": "^9.5.11",
62
- "prettier": "^3.2.5",
63
- "typescript": "^5.4.5",
64
- "vite": "^5.4.10",
65
- "vite-plugin-dts": "3.9.1",
66
- "vitepress": "^1.5.0",
67
- "vitepress-demo-plugin": "^1.3.1",
68
- "vitest": "^2.1.3",
69
- "vue": "^3.5.12",
70
- "vue-eslint-parser": "^9.4.2"
71
- },
72
- "dependencies": {
73
- "d3-interpolate": "^3.0.1"
74
- }
1
+ {
2
+ "name": "stk-table-vue",
3
+ "version": "0.6.13",
4
+ "description": "Simple realtime virtual table for vue3 and vue2.7",
5
+ "main": "./lib/stk-table-vue.js",
6
+ "types": "./lib/src/StkTable/index.d.ts",
7
+ "packageManager": "pnpm@10.7.0",
8
+ "directories": {
9
+ "test": "test"
10
+ },
11
+ "type": "module",
12
+ "scripts": {
13
+ "dev": "vite",
14
+ "build": "vite build",
15
+ "test": "vitest",
16
+ "docs:dev": "vitepress dev docs-src",
17
+ "docs:build": "vitepress build docs-src",
18
+ "docs:preview": "vitepress preview docs-src",
19
+ "docs:update": "cp -rf ./docs-src/.vitepress/dist/* ./docs"
20
+ },
21
+ "keywords": [
22
+ "virtual table",
23
+ "vue",
24
+ "vue2",
25
+ "vue3",
26
+ "highlight",
27
+ "sticky",
28
+ "virtual",
29
+ "table",
30
+ "list"
31
+ ],
32
+ "files": [
33
+ "lib",
34
+ "src"
35
+ ],
36
+ "author": "japlus",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/ja-plus/stk-table-vue"
40
+ },
41
+ "license": "MIT",
42
+ "devDependencies": {
43
+ "@types/d3-interpolate": "^3.0.4",
44
+ "@types/mockjs": "^1.0.10",
45
+ "@types/node": "^20.12.10",
46
+ "@typescript-eslint/eslint-plugin": "^7.7.0",
47
+ "@typescript-eslint/parser": "^7.7.0",
48
+ "@vitejs/plugin-vue": "^5.1.4",
49
+ "@vue/test-utils": "2.4.4",
50
+ "eslint": "^8.57.0",
51
+ "eslint-config-prettier": "^9.1.0",
52
+ "eslint-plugin-html": "^8.1.0",
53
+ "eslint-plugin-prettier": "^5.1.3",
54
+ "eslint-plugin-vue": "^9.25.0",
55
+ "happy-dom": "^12.10.3",
56
+ "less": "^4.2.0",
57
+ "mitt": "^3.0.1",
58
+ "mockjs": "^1.1.0",
59
+ "postcss": "^8.4.47",
60
+ "postcss-discard-comments": "^6.0.2",
61
+ "postcss-preset-env": "^9.5.11",
62
+ "prettier": "^3.2.5",
63
+ "typescript": "^5.4.5",
64
+ "vite": "^5.4.10",
65
+ "vite-plugin-dts": "3.9.1",
66
+ "vitepress": "^1.5.0",
67
+ "vitepress-demo-plugin": "^1.3.1",
68
+ "vitest": "^2.1.3",
69
+ "vue": "^3.5.12",
70
+ "vue-eslint-parser": "^9.4.2"
71
+ },
72
+ "dependencies": {
73
+ "d3-interpolate": "^3.0.1"
74
+ }
75
75
  }