@v-c/table 1.1.4 → 1.1.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/dist/Body/BodyRow.js +1 -0
- package/dist/Cell/index.js +70 -24
- package/package.json +2 -2
package/dist/Body/BodyRow.js
CHANGED
package/dist/Cell/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { useInjectTableContext } from "../context/TableContext.js";
|
|
|
2
2
|
import { useInjectPerfContext } from "../context/PerfContext.js";
|
|
3
3
|
import { validateValue } from "../utils/valueUtil.js";
|
|
4
4
|
import useHoverState from "./useHoverState.js";
|
|
5
|
-
import { computed, createVNode, defineComponent, isVNode, mergeProps } from "vue";
|
|
5
|
+
import { computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef, toRaw, watch } from "vue";
|
|
6
6
|
import { clsx, warning } from "@v-c/util";
|
|
7
7
|
import { filterEmpty, getStylePxValue } from "@v-c/util/dist/props-util";
|
|
8
8
|
import getValue from "@v-c/util/dist/utils/get";
|
|
@@ -90,10 +90,11 @@ var Cell = /* @__PURE__ */ defineComponent({
|
|
|
90
90
|
const [absScroll = 0, scrollWidth = 0] = tableContext.scrollInfo || [];
|
|
91
91
|
return [isFixStart.value && fixedStartShadow ? absScroll - (offsetFixedStartShadow || 0) >= 1 : false, isFixEnd && fixedEndShadow ? scrollWidth - absScroll - (offsetFixedEndShadow || 0) > 1 : false];
|
|
92
92
|
});
|
|
93
|
-
|
|
94
|
-
const {
|
|
95
|
-
const
|
|
96
|
-
const
|
|
93
|
+
const computeContent = () => {
|
|
94
|
+
const { record, dataIndex, index, renderIndex, render, rowType } = props;
|
|
95
|
+
const rawProps = toRaw(props);
|
|
96
|
+
const column = rawProps.column;
|
|
97
|
+
const colIndex = rawProps.colIndex;
|
|
97
98
|
const mergedRenderIndex = renderIndex ?? index ?? 0;
|
|
98
99
|
const [childNode, legacyCellProps] = resolveCellRender({
|
|
99
100
|
record,
|
|
@@ -103,6 +104,69 @@ var Cell = /* @__PURE__ */ defineComponent({
|
|
|
103
104
|
render,
|
|
104
105
|
perfRecord
|
|
105
106
|
});
|
|
107
|
+
let rawChildNode = childNode;
|
|
108
|
+
const renderCell = rowType === "header" ? tableContext.headerCell : rowType === "body" ? tableContext.bodyCell : void 0;
|
|
109
|
+
if (renderCell && column) {
|
|
110
|
+
const ctxIndex = rowType === "header" ? colIndex ?? 0 : mergedRenderIndex;
|
|
111
|
+
const renderCellNode = rowType === "body" ? renderCell({
|
|
112
|
+
column,
|
|
113
|
+
index: ctxIndex,
|
|
114
|
+
text: childNode,
|
|
115
|
+
record
|
|
116
|
+
}) : renderCell({
|
|
117
|
+
column,
|
|
118
|
+
index: ctxIndex,
|
|
119
|
+
text: childNode
|
|
120
|
+
});
|
|
121
|
+
if (Array.isArray(renderCellNode)) {
|
|
122
|
+
const filteredNodes = filterEmpty(renderCellNode);
|
|
123
|
+
if (filteredNodes.length > 0) rawChildNode = filteredNodes;
|
|
124
|
+
} else if (renderCellNode !== null && renderCellNode !== void 0) rawChildNode = renderCellNode;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
rawChildNode,
|
|
128
|
+
legacyCellProps
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
let readContent;
|
|
132
|
+
if (typeof props.shouldCellUpdate === "function") {
|
|
133
|
+
let dirty = true;
|
|
134
|
+
let cached;
|
|
135
|
+
const tick = shallowRef(0);
|
|
136
|
+
watch([
|
|
137
|
+
() => props.record,
|
|
138
|
+
() => props.dataIndex,
|
|
139
|
+
() => props.index,
|
|
140
|
+
() => props.renderIndex,
|
|
141
|
+
() => props.render,
|
|
142
|
+
() => props.rowType,
|
|
143
|
+
() => props.children,
|
|
144
|
+
() => tableContext.bodyCell,
|
|
145
|
+
() => tableContext.headerCell
|
|
146
|
+
], (next, prev) => {
|
|
147
|
+
const nextRecord = next[0];
|
|
148
|
+
const prevRecord = prev[0];
|
|
149
|
+
if (props.shouldCellUpdate && !props.shouldCellUpdate(nextRecord, prevRecord)) return;
|
|
150
|
+
dirty = true;
|
|
151
|
+
tick.value += 1;
|
|
152
|
+
});
|
|
153
|
+
readContent = () => {
|
|
154
|
+
tick.value;
|
|
155
|
+
if (dirty || !cached) {
|
|
156
|
+
cached = computeContent();
|
|
157
|
+
dirty = false;
|
|
158
|
+
}
|
|
159
|
+
return cached;
|
|
160
|
+
};
|
|
161
|
+
} else {
|
|
162
|
+
const contentMemo = computed(computeContent);
|
|
163
|
+
readContent = () => contentMemo.value;
|
|
164
|
+
}
|
|
165
|
+
return () => {
|
|
166
|
+
const { component: Component = "td", ellipsis, scope, prefixCls, className, style, align, record, index, rowType, colSpan, rowSpan, hoverRowSpan, fixStart, fixEnd, fixedStartShadow, fixedEndShadow, zIndex, zIndexReverse, additionalProps = {}, isSticky, appendNode } = props;
|
|
167
|
+
const cellPrefixCls = `${prefixCls}-cell`;
|
|
168
|
+
const mergedAppendNode = appendNode ?? slots?.appendNode?.();
|
|
169
|
+
const { rawChildNode, legacyCellProps } = readContent();
|
|
106
170
|
const fixedStyle = {};
|
|
107
171
|
const [showFixStartShadow, showFixEndShadow] = shadowInfo.value;
|
|
108
172
|
if (isFixStart.value) {
|
|
@@ -128,25 +192,7 @@ var Cell = /* @__PURE__ */ defineComponent({
|
|
|
128
192
|
(additionalProps.onMouseLeave || additionalProps.onMouseleave)?.(event);
|
|
129
193
|
};
|
|
130
194
|
if (mergedColSpan === 0 || mergedRowSpan === 0) return null;
|
|
131
|
-
let mergedChildNode =
|
|
132
|
-
const renderCell = rowType === "header" ? tableContext.headerCell : rowType === "body" ? tableContext.bodyCell : void 0;
|
|
133
|
-
if (renderCell && column) {
|
|
134
|
-
const ctxIndex = rowType === "header" ? colIndex ?? 0 : mergedRenderIndex;
|
|
135
|
-
const renderCellNode = rowType === "body" ? renderCell({
|
|
136
|
-
column,
|
|
137
|
-
index: ctxIndex,
|
|
138
|
-
text: childNode,
|
|
139
|
-
record
|
|
140
|
-
}) : renderCell({
|
|
141
|
-
column,
|
|
142
|
-
index: ctxIndex,
|
|
143
|
-
text: childNode
|
|
144
|
-
});
|
|
145
|
-
if (Array.isArray(renderCellNode)) {
|
|
146
|
-
const filteredNodes = filterEmpty(renderCellNode);
|
|
147
|
-
if (filteredNodes.length > 0) mergedChildNode = filteredNodes;
|
|
148
|
-
} else if (renderCellNode !== null && renderCellNode !== void 0) mergedChildNode = renderCellNode;
|
|
149
|
-
}
|
|
195
|
+
let mergedChildNode = rawChildNode;
|
|
150
196
|
const title = additionalProps.title ?? getTitleFromCellRenderChildren({
|
|
151
197
|
rowType,
|
|
152
198
|
ellipsis,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/table",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.5",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"vue": "^3.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@v-c/resize-observer": "^1.1.2",
|
|
23
24
|
"@v-c/util": "^1.0.19",
|
|
24
|
-
"@v-c/resize-observer": "^1.1.0",
|
|
25
25
|
"@v-c/virtual-list": "^1.0.8"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|