@v-c/table 1.0.0 → 1.0.2

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 (50) hide show
  1. package/dist/Table.js +1 -1
  2. package/package.json +5 -5
  3. package/dist/Body/BodyRow.cjs +0 -143
  4. package/dist/Body/ExpandedRow.cjs +0 -55
  5. package/dist/Body/MeasureCell.cjs +0 -39
  6. package/dist/Body/MeasureRow.cjs +0 -68
  7. package/dist/Body/index.cjs +0 -82
  8. package/dist/Cell/index.cjs +0 -202
  9. package/dist/Cell/useHoverState.cjs +0 -18
  10. package/dist/ColGroup.cjs +0 -51
  11. package/dist/FixedHolder/index.cjs +0 -142
  12. package/dist/Footer/Cell.cjs +0 -51
  13. package/dist/Footer/Row.cjs +0 -23
  14. package/dist/Footer/Summary.cjs +0 -19
  15. package/dist/Footer/SummaryContext.cjs +0 -12
  16. package/dist/Footer/index.cjs +0 -39
  17. package/dist/Header/Header.cjs +0 -89
  18. package/dist/Header/HeaderRow.cjs +0 -66
  19. package/dist/Panel/index.cjs +0 -13
  20. package/dist/Table.cjs +0 -739
  21. package/dist/VirtualTable/BodyGrid.cjs +0 -180
  22. package/dist/VirtualTable/BodyLine.cjs +0 -92
  23. package/dist/VirtualTable/VirtualCell.cjs +0 -87
  24. package/dist/VirtualTable/context.cjs +0 -21
  25. package/dist/VirtualTable/index.cjs +0 -337
  26. package/dist/_virtual/rolldown_runtime.cjs +0 -21
  27. package/dist/constant.cjs +0 -5
  28. package/dist/context/PerfContext.cjs +0 -14
  29. package/dist/context/TableContext.cjs +0 -21
  30. package/dist/hooks/useColumns/index.cjs +0 -127
  31. package/dist/hooks/useColumns/useWidthColumns.cjs +0 -57
  32. package/dist/hooks/useExpand.cjs +0 -56
  33. package/dist/hooks/useFixedInfo.cjs +0 -20
  34. package/dist/hooks/useFlattenRecords.cjs +0 -38
  35. package/dist/hooks/useFrame.cjs +0 -49
  36. package/dist/hooks/useHover.cjs +0 -20
  37. package/dist/hooks/useRowInfo.cjs +0 -53
  38. package/dist/hooks/useSticky.cjs +0 -27
  39. package/dist/hooks/useStickyOffsets.cjs +0 -41
  40. package/dist/index.cjs +0 -24
  41. package/dist/interface.cjs +0 -1
  42. package/dist/namePathType.cjs +0 -1
  43. package/dist/stickyScrollBar.cjs +0 -173
  44. package/dist/sugar/Column.cjs +0 -109
  45. package/dist/sugar/ColumnGroup.cjs +0 -109
  46. package/dist/utils/expandUtil.cjs +0 -38
  47. package/dist/utils/fixUtil.cjs +0 -49
  48. package/dist/utils/legacyUtil.cjs +0 -35
  49. package/dist/utils/offsetUtil.cjs +0 -12
  50. package/dist/utils/valueUtil.cjs +0 -28
@@ -1,180 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- const require_TableContext = require("../context/TableContext.cjs");
7
- const require_useFlattenRecords = require("../hooks/useFlattenRecords.cjs");
8
- const require_context = require("./context.cjs");
9
- const require_BodyLine = require("./BodyLine.cjs");
10
- let vue = require("vue");
11
- let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
12
- let _v_c_virtual_list = require("@v-c/virtual-list");
13
- _v_c_virtual_list = require_rolldown_runtime.__toESM(_v_c_virtual_list);
14
- var BodyGrid = /* @__PURE__ */ (0, vue.defineComponent)({
15
- name: "TableBodyGrid",
16
- props: ["data", "onScroll"],
17
- setup(props, { expose }) {
18
- const tableContext = require_TableContext.useInjectTableContext();
19
- const staticContext = require_context.useInjectStaticContext();
20
- const listRef = (0, vue.ref)(null);
21
- const flattenData = require_useFlattenRecords.default((0, vue.computed)(() => props.data), (0, vue.computed)(() => tableContext.childrenColumnName), (0, vue.computed)(() => tableContext.expandedKeys), (0, vue.computed)(() => tableContext.getRowKey));
22
- const columnsWidth = (0, vue.computed)(() => {
23
- let total = 0;
24
- return tableContext.flattenColumns.map(({ width, minWidth, key }) => {
25
- const finalWidth = Math.max(width || 0, minWidth || 0);
26
- total += finalWidth;
27
- return [
28
- key,
29
- finalWidth,
30
- total
31
- ];
32
- });
33
- });
34
- const columnsOffset = (0, vue.computed)(() => columnsWidth.value.map((colWidth) => colWidth[2]));
35
- (0, vue.watch)(columnsWidth, (newColumns) => {
36
- newColumns.forEach(([key, width]) => {
37
- tableContext.onColumnResize(key, width);
38
- });
39
- }, { immediate: true });
40
- const gridContext = (0, vue.reactive)({ columnsOffset: [] });
41
- (0, vue.watchEffect)(() => {
42
- gridContext.columnsOffset = columnsOffset.value;
43
- });
44
- require_context.useProvideGridContext(gridContext);
45
- const getRowSpan = (column, index, data) => {
46
- const record = (data ?? (0, vue.toRaw)(flattenData.value))[index]?.record;
47
- const { onCell } = column;
48
- if (onCell) return onCell(record, index)?.rowSpan ?? 1;
49
- return 1;
50
- };
51
- const extraRender = (info) => {
52
- const { start, end, getSize, offsetY } = info;
53
- const { flattenColumns } = (0, vue.toRaw)(tableContext);
54
- if (end < 0) return null;
55
- const rawData = (0, vue.toRaw)(flattenData.value);
56
- let firstRowSpanColumns = flattenColumns.filter((column) => getRowSpan(column, start, rawData) === 0);
57
- let startIndex = start;
58
- for (let i = start; i >= 0; i -= 1) {
59
- firstRowSpanColumns = firstRowSpanColumns.filter((column) => getRowSpan(column, i, rawData) === 0);
60
- if (!firstRowSpanColumns.length) {
61
- startIndex = i;
62
- break;
63
- }
64
- }
65
- let lastRowSpanColumns = flattenColumns.filter((column) => getRowSpan(column, end, rawData) !== 1);
66
- let endIndex = end;
67
- for (let i = end; i < rawData.length; i += 1) {
68
- lastRowSpanColumns = lastRowSpanColumns.filter((column) => getRowSpan(column, i, rawData) !== 1);
69
- if (!lastRowSpanColumns.length) {
70
- endIndex = Math.max(i - 1, end);
71
- break;
72
- }
73
- }
74
- const spanLines = [];
75
- for (let i = startIndex; i <= endIndex; i += 1) {
76
- if (!rawData[i]) continue;
77
- if (flattenColumns.some((column) => getRowSpan(column, i, rawData) > 1)) spanLines.push(i);
78
- }
79
- if (!spanLines.length) return null;
80
- return spanLines.map((index) => {
81
- const item = rawData[index];
82
- if (!item) return null;
83
- const rowKey = item.rowKey;
84
- const getHeight = (rowSpan) => {
85
- const endItemIndex = index + rowSpan - 1;
86
- const endItem = rawData[endItemIndex];
87
- if (!endItem || !endItem.record) {
88
- const endItemKey$1 = rawData[Math.min(endItemIndex, rawData.length - 1)].rowKey;
89
- const sizeInfo$2 = getSize(rowKey, endItemKey$1);
90
- return sizeInfo$2.bottom - sizeInfo$2.top;
91
- }
92
- const endItemKey = endItem.rowKey;
93
- const sizeInfo$1 = getSize(rowKey, endItemKey);
94
- return sizeInfo$1.bottom - sizeInfo$1.top;
95
- };
96
- const sizeInfo = getSize(rowKey);
97
- return (0, vue.createVNode)(require_BodyLine.default, {
98
- "key": index,
99
- "data": item,
100
- "rowKey": rowKey,
101
- "index": index,
102
- "style": { top: (0, _v_c_util_dist_props_util.getStylePxValue)(-offsetY + sizeInfo.top) },
103
- "extra": true,
104
- "getHeight": getHeight
105
- }, null);
106
- });
107
- };
108
- const exposed = {
109
- scrollTo: (config) => {
110
- if (!listRef.value) return;
111
- const { offset, ...restConfig } = config || {};
112
- if (offset) listRef.value.scrollTo({
113
- ...restConfig,
114
- offset,
115
- align: "top"
116
- });
117
- else listRef.value.scrollTo(config);
118
- },
119
- get nativeElement() {
120
- const native = listRef.value?.nativeElement;
121
- return native && typeof native === "object" && "value" in native ? native.value : native;
122
- }
123
- };
124
- Object.defineProperty(exposed, "scrollLeft", {
125
- get: () => listRef.value?.getScrollInfo().x || 0,
126
- set: (value) => {
127
- listRef.value?.scrollTo({ left: value });
128
- }
129
- });
130
- Object.defineProperty(exposed, "scrollTop", {
131
- get: () => listRef.value?.getScrollInfo().y || 0,
132
- set: (value) => {
133
- listRef.value?.scrollTo({ top: value });
134
- }
135
- });
136
- expose(exposed);
137
- return () => {
138
- const tblPrefixCls = `${tableContext.prefixCls}-tbody`;
139
- const wrapperComponent = staticContext.getComponent?.(["body", "wrapper"], "div") || "div";
140
- const horizontalScrollBarStyle = {};
141
- if (staticContext.sticky) {
142
- horizontalScrollBarStyle.position = "sticky";
143
- horizontalScrollBarStyle.bottom = 0;
144
- if (typeof staticContext.sticky === "object" && staticContext.sticky.offsetScroll) horizontalScrollBarStyle.bottom = staticContext.sticky.offsetScroll;
145
- }
146
- return (0, vue.createVNode)(_v_c_virtual_list.default, {
147
- "fullHeight": false,
148
- "ref": listRef,
149
- "prefixCls": `${tblPrefixCls}-virtual`,
150
- "styles": { horizontalScrollBar: horizontalScrollBarStyle },
151
- "class": tblPrefixCls,
152
- "height": staticContext.scrollY,
153
- "itemHeight": staticContext.listItemHeight || 24,
154
- "data": flattenData.value,
155
- "itemKey": (item) => item.rowKey,
156
- "component": wrapperComponent,
157
- "scrollWidth": tableContext.scrollX,
158
- "direction": tableContext.direction,
159
- "onVirtualScroll": ({ x }) => {
160
- props.onScroll?.({
161
- currentTarget: exposed.nativeElement,
162
- scrollLeft: x
163
- });
164
- },
165
- "onScroll": staticContext.onScroll,
166
- "extraRender": extraRender
167
- }, { default: (dataInfo) => {
168
- const { item, index, ...itemProps } = dataInfo;
169
- return (0, vue.createVNode)(require_BodyLine.default, {
170
- "data": dataInfo.item,
171
- "rowKey": item.rowKey,
172
- "index": index,
173
- "style": itemProps?.style
174
- }, null);
175
- } });
176
- };
177
- }
178
- });
179
- var BodyGrid_default = BodyGrid;
180
- exports.default = BodyGrid_default;
@@ -1,92 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- const require_index = require("../Cell/index.cjs");
7
- const require_useRowInfo = require("../hooks/useRowInfo.cjs");
8
- const require_expandUtil = require("../utils/expandUtil.cjs");
9
- const require_context = require("./context.cjs");
10
- const require_VirtualCell = require("./VirtualCell.cjs");
11
- let vue = require("vue");
12
- let _v_c_util = require("@v-c/util");
13
- function _isSlot(s) {
14
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !(0, vue.isVNode)(s);
15
- }
16
- var BodyLine = /* @__PURE__ */ (0, vue.defineComponent)({
17
- name: "TableBodyLine",
18
- props: [
19
- "data",
20
- "index",
21
- "className",
22
- "style",
23
- "rowKey",
24
- "extra",
25
- "getHeight"
26
- ],
27
- setup(props) {
28
- const staticContext = require_context.useInjectStaticContext();
29
- const rowInfo = require_useRowInfo.default((0, vue.computed)(() => props.data?.record), (0, vue.computed)(() => props.rowKey), (0, vue.computed)(() => props.index), (0, vue.computed)(() => props.data?.indent || 0));
30
- return () => {
31
- let _slot;
32
- const { data, index, className, rowKey, style, extra, getHeight } = props;
33
- const { record, indent, index: renderIndex } = data;
34
- const tableContext = rowInfo.tableContext;
35
- const RowComponent = staticContext.getComponent?.(["body", "row"], "div") || "div";
36
- const CellComponent = staticContext.getComponent?.(["body", "cell"], "div") || "div";
37
- const { rowSupportExpand, expanded, rowProps } = rowInfo;
38
- const expandedRowRender = tableContext.expandedRowRender;
39
- const expandedRowClassName = tableContext.expandedRowClassName;
40
- let expandRowNode;
41
- if (rowSupportExpand.value && expanded.value) {
42
- const expandContent = expandedRowRender(record, index, indent + 1, expanded.value);
43
- const expandedClsName = require_expandUtil.computedExpandedClassName(expandedRowClassName, record, index, indent);
44
- let additionalProps = {};
45
- if (tableContext.fixColumn) additionalProps = { style: { ["--virtual-width"]: `${tableContext.componentWidth}px` } };
46
- const rowCellCls = `${tableContext.prefixCls}-expanded-row-cell`;
47
- expandRowNode = (0, vue.createVNode)(RowComponent, { "class": (0, _v_c_util.clsx)(`${tableContext.prefixCls}-expanded-row`, `${tableContext.prefixCls}-expanded-row-level-${indent + 1}`, expandedClsName) }, { default: () => [(0, vue.createVNode)(require_index.default, {
48
- "component": CellComponent,
49
- "prefixCls": tableContext.prefixCls,
50
- "className": (0, _v_c_util.clsx)(rowCellCls, { [`${rowCellCls}-fixed`]: tableContext.fixColumn }),
51
- "additionalProps": additionalProps
52
- }, _isSlot(expandContent) ? expandContent : { default: () => [expandContent] })] });
53
- }
54
- const rowStyle = {
55
- ...style || {},
56
- width: typeof tableContext.scrollX === "number" ? `${tableContext.scrollX}px` : tableContext.scrollX
57
- };
58
- if (extra) {
59
- rowStyle.position = "absolute";
60
- rowStyle.pointerEvents = "none";
61
- }
62
- const rowPropsStyle = rowProps.value?.style;
63
- const mergedRowStyle = {
64
- ...rowStyle,
65
- ...typeof rowPropsStyle === "object" ? rowPropsStyle : {}
66
- };
67
- const rowNode = (0, vue.createVNode)(RowComponent, (0, vue.mergeProps)(rowProps.value, {
68
- "data-row-key": rowKey,
69
- "class": (0, _v_c_util.clsx)(className, `${tableContext.prefixCls}-row`, rowProps.value?.className, rowProps.value?.class, { [`${tableContext.prefixCls}-row-extra`]: extra }),
70
- "style": mergedRowStyle
71
- }), _isSlot(_slot = tableContext.flattenColumns.map((column, colIndex) => {
72
- return (0, vue.createVNode)(require_VirtualCell.default, {
73
- "key": colIndex,
74
- "component": CellComponent,
75
- "rowInfo": rowInfo,
76
- "column": column,
77
- "colIndex": colIndex,
78
- "indent": indent,
79
- "index": index,
80
- "renderIndex": renderIndex,
81
- "record": record,
82
- "inverse": extra,
83
- "getHeight": getHeight
84
- }, null);
85
- })) ? _slot : { default: () => [_slot] });
86
- if (rowSupportExpand.value) return (0, vue.createVNode)("div", null, [rowNode, expandRowNode]);
87
- return rowNode;
88
- };
89
- }
90
- });
91
- var BodyLine_default = BodyLine;
92
- exports.default = BodyLine_default;
@@ -1,87 +0,0 @@
1
- Object.defineProperties(exports, {
2
- __esModule: { value: true },
3
- [Symbol.toStringTag]: { value: "Module" }
4
- });
5
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
6
- const require_index = require("../Cell/index.cjs");
7
- const require_BodyRow = require("../Body/BodyRow.cjs");
8
- const require_context = require("./context.cjs");
9
- let vue = require("vue");
10
- let _v_c_util = require("@v-c/util");
11
- let _v_c_util_dist_props_util = require("@v-c/util/dist/props-util");
12
- function getColumnWidth(colIndex, colSpan, columnsOffset) {
13
- return columnsOffset[colIndex + (colSpan || 1)] - (columnsOffset[colIndex] || 0);
14
- }
15
- var VirtualCell = /* @__PURE__ */ (0, vue.defineComponent)({
16
- name: "TableVirtualCell",
17
- props: [
18
- "rowInfo",
19
- "column",
20
- "colIndex",
21
- "indent",
22
- "index",
23
- "component",
24
- "renderIndex",
25
- "record",
26
- "style",
27
- "className",
28
- "inverse",
29
- "getHeight"
30
- ],
31
- setup(props) {
32
- const gridContext = require_context.useInjectGridContext();
33
- return () => {
34
- const { rowInfo, column, colIndex, indent, index, component, renderIndex, record, style, className, inverse, getHeight } = props;
35
- const { render, dataIndex, className: columnClassName, width: colWidth } = column;
36
- const columnsOffset = gridContext.columnsOffset || [];
37
- const { key, fixedInfo, appendCellNode, additionalCellProps } = require_BodyRow.getCellProps(rowInfo, record, column, colIndex, indent, index);
38
- const { style: cellStyle, colSpan = 1, rowSpan = 1 } = additionalCellProps;
39
- const concatColWidth = getColumnWidth(colIndex - 1, colSpan, columnsOffset);
40
- const marginOffset = colSpan > 1 ? colWidth - concatColWidth : 0;
41
- const mergedStyle = {
42
- ...cellStyle && !Array.isArray(cellStyle) && typeof cellStyle === "object" ? cellStyle : {},
43
- ...style || {},
44
- flex: `0 0 ${concatColWidth}px`,
45
- width: `${concatColWidth}px`,
46
- marginRight: typeof marginOffset === "number" ? `${marginOffset}px` : marginOffset,
47
- pointerEvents: "auto"
48
- };
49
- const needHide = inverse ? rowSpan <= 1 : colSpan === 0 || rowSpan === 0 || rowSpan > 1;
50
- if (needHide) mergedStyle.visibility = "hidden";
51
- else if (inverse) mergedStyle.height = (0, _v_c_util_dist_props_util.getStylePxValue)(getHeight?.(rowSpan));
52
- const mergedRender = needHide ? () => null : render;
53
- const cellSpan = {};
54
- if (rowSpan === 0 || colSpan === 0) {
55
- cellSpan.rowSpan = 1;
56
- cellSpan.colSpan = 1;
57
- }
58
- return (0, vue.createVNode)(require_index.default, (0, vue.mergeProps)({
59
- "className": (0, _v_c_util.clsx)(columnClassName, className),
60
- "ellipsis": column.ellipsis,
61
- "align": column.align,
62
- "scope": column.rowScope,
63
- "component": component,
64
- "prefixCls": rowInfo.tableContext.prefixCls,
65
- "key": key,
66
- "record": record,
67
- "index": index,
68
- "renderIndex": renderIndex,
69
- "dataIndex": dataIndex,
70
- "render": mergedRender,
71
- "column": column,
72
- "rowType": "body",
73
- "shouldCellUpdate": column.shouldCellUpdate
74
- }, fixedInfo, {
75
- "appendNode": appendCellNode,
76
- "additionalProps": {
77
- ...additionalCellProps,
78
- style: mergedStyle,
79
- ...cellSpan
80
- }
81
- }), null);
82
- };
83
- }
84
- });
85
- var VirtualCell_default = VirtualCell;
86
- exports.default = VirtualCell_default;
87
- exports.getColumnWidth = getColumnWidth;
@@ -1,21 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
3
- let vue = require("vue");
4
- var StaticContextKey = Symbol("TableVirtualStaticContext");
5
- var GridContextKey = Symbol("TableVirtualGridContext");
6
- function useProvideStaticContext(value) {
7
- (0, vue.provide)(StaticContextKey, value);
8
- }
9
- function useInjectStaticContext() {
10
- return (0, vue.inject)(StaticContextKey, {});
11
- }
12
- function useProvideGridContext(value) {
13
- (0, vue.provide)(GridContextKey, value);
14
- }
15
- function useInjectGridContext() {
16
- return (0, vue.inject)(GridContextKey, {});
17
- }
18
- exports.useInjectGridContext = useInjectGridContext;
19
- exports.useInjectStaticContext = useInjectStaticContext;
20
- exports.useProvideGridContext = useProvideGridContext;
21
- exports.useProvideStaticContext = useProvideStaticContext;