stk-table-vue 0.3.4 → 0.3.5

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/README.md CHANGED
@@ -549,16 +549,19 @@ export type SortConfig<T extends Record<string, any>> = {
549
549
  ### 鼠标悬浮表头时,不展示title
550
550
  * 将 `StkTableColumn` 中的 `title` 字段置为 "" 空字符串。这样th中就没有title了。
551
551
  * 使用 `StkTableColumn` 中的 `customHeaderCell` 属性中,自定义表头渲染。
552
- ### 性能
553
- #### highlight
554
- * 在虚拟滚动下高亮强制使用 `css @keyframes` 实现动画。`setHighlightDimRow`/`setHighlightCellRow` 最后一个参数传入 `{method: 'css'}` 即可。(滚动后动画会中断)
555
- * 指定 `{method:'animation'}` 在虚拟滚动下使用animation api实现动画。好处是动画流畅,且滚动后动画不中断。坏处是不支持帧率配置。
552
+
553
+ ## Performance optimization
554
+ ### highlight
556
555
  * 配置 `props.highlightConfig.fps` 指定高亮帧率。降低帧率有利于性能。
557
- #### relative fixed
556
+ ### relative fixed
558
557
  * 配置 `props.cellFixedMode` 为 `relative` 时,将使用相对定位实现固定列与固定表头,相较于`sticky`的实现,渲染合成层更少。
559
558
  * 问题:若开启了纵向虚拟滚动,不开启横向虚拟滚动,且不设置某些列宽时。如果纵向滚动导致某些列宽变化,则会导致右侧固定列计算错误。
560
- #### tr 分层
561
- * 通过css选择器将 stk-table tbody tr 配置 `transform:translateZ(0)` 对每行 tr 进行分层。在 `customCell` 较多且复杂时,尝试开启此功能可能对性能有帮助。
559
+ ### tr 分层
560
+ * 通过css选择器将 stk-table tbody tr 配置 `transform:translateZ(0)` 对每行 tr 进行分层。对性能有帮助。
561
+ - 提升合成层可能导致黑底红字字体颜色发生变化。
562
+ - 以下情况尝试开启此功能。
563
+ - 在 `customCell` 较多且复杂时。
564
+ - 大量 highlight 动画时。
562
565
 
563
566
  ## Other
564
567
  * `$*$` 兼容注释
@@ -8,7 +8,10 @@ type Sorter<T> = boolean | ((data: T[], option: {
8
8
  export type CustomCellFunc<T extends Record<string, any>> = (props: {
9
9
  row: T;
10
10
  col: StkTableColumn<T>;
11
+ /** row[col.dataIndex] 的值 */
11
12
  cellValue: any;
13
+ rowIndex: number;
14
+ colIndex: number;
12
15
  }) => VNode;
13
16
  export type CustomHeaderCellFunc<T extends Record<string, any>> = (props: {
14
17
  col: StkTableColumn<T>;
@@ -909,11 +909,15 @@ function useVirtualScroll({
909
909
  return width;
910
910
  });
911
911
  function initVirtualScrollY(height) {
912
+ if (height !== void 0 && typeof height !== "number") {
913
+ console.warn("initVirtualScrollY: height must be a number");
914
+ height = 0;
915
+ }
912
916
  if (!virtual_on.value)
913
917
  return;
914
918
  const { offsetHeight, scrollTop } = tableContainerRef.value || {};
915
919
  const { rowHeight } = virtualScroll.value;
916
- const containerHeight = height ?? (offsetHeight || DEFAULT_TABLE_HEIGHT);
920
+ const containerHeight = height || offsetHeight || DEFAULT_TABLE_HEIGHT;
917
921
  const { headless, headerRowHeight } = props;
918
922
  let pageSize = Math.ceil(containerHeight / rowHeight);
919
923
  if (!headless) {
@@ -1706,10 +1710,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
1706
1710
  key: 0,
1707
1711
  col,
1708
1712
  row,
1709
- "row-index": rowIndex,
1710
- "col-index": colIndex,
1711
- "cell-value": row[col.dataIndex]
1712
- }, null, 8, ["col", "row", "row-index", "col-index", "cell-value"])) : (openBlock(), createElementBlock("div", {
1713
+ rowIndex,
1714
+ colIndex,
1715
+ cellValue: row[col.dataIndex]
1716
+ }, null, 8, ["col", "row", "rowIndex", "colIndex", "cellValue"])) : (openBlock(), createElementBlock("div", {
1713
1717
  key: 1,
1714
1718
  class: "table-cell-wrapper",
1715
1719
  title: !col.type ? row[col.dataIndex] : ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stk-table-vue",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "Simple realtime virtual table for vue3 and vue2.7",
5
5
  "main": "./lib/stk-table-vue.js",
6
6
  "types": "./lib/src/StkTable/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "author": "japlus",
33
33
  "repository": {
34
34
  "type": "git",
35
- "url": "https://gitee.com/japlus/stk-table-vue"
35
+ "url": "https://github.com/ja-plus/stk-table-vue"
36
36
  },
37
37
  "license": "MIT",
38
38
  "devDependencies": {
@@ -176,9 +176,9 @@
176
176
  v-if="col.customCell"
177
177
  :col="col"
178
178
  :row="row"
179
- :row-index="rowIndex"
180
- :col-index="colIndex"
181
- :cell-value="row[col.dataIndex]"
179
+ :rowIndex="rowIndex"
180
+ :colIndex="colIndex"
181
+ :cellValue="row[col.dataIndex]"
182
182
  />
183
183
  <div v-else class="table-cell-wrapper" :title="!col.type ? row[col.dataIndex] : ''">
184
184
  <template v-if="col.type === 'seq'">
@@ -5,7 +5,15 @@ export type Order = null | 'asc' | 'desc';
5
5
 
6
6
  type Sorter<T> = boolean | ((data: T[], option: { order: Order; column: any }) => T[]);
7
7
 
8
- export type CustomCellFunc<T extends Record<string, any>> = (props: { row: T; col: StkTableColumn<T>; cellValue: any }) => VNode;
8
+ export type CustomCellFunc<T extends Record<string, any>> = (props: {
9
+ row: T;
10
+ col: StkTableColumn<T>;
11
+ /** row[col.dataIndex] 的值 */
12
+ cellValue: any;
13
+ rowIndex: number;
14
+ colIndex: number;
15
+ }) => VNode;
16
+
9
17
  export type CustomHeaderCellFunc<T extends Record<string, any>> = (props: { col: StkTableColumn<T> }) => VNode;
10
18
 
11
19
  /** 表格列配置 */
@@ -143,10 +143,14 @@ export function useVirtualScroll<DT extends Record<string, any>>({
143
143
  * @param {number} [height] 虚拟滚动的高度
144
144
  */
145
145
  function initVirtualScrollY(height?: number) {
146
+ if (height !== void 0 && typeof height !== 'number') {
147
+ console.warn('initVirtualScrollY: height must be a number');
148
+ height = 0;
149
+ }
146
150
  if (!virtual_on.value) return;
147
151
  const { offsetHeight, scrollTop } = tableContainerRef.value || {};
148
152
  const { rowHeight } = virtualScroll.value;
149
- const containerHeight = height ?? (offsetHeight || DEFAULT_TABLE_HEIGHT);
153
+ const containerHeight = height || offsetHeight || DEFAULT_TABLE_HEIGHT;
150
154
  const { headless, headerRowHeight } = props;
151
155
  let pageSize = Math.ceil(containerHeight / rowHeight);
152
156
  if (!headless) {