mctable-react 1.0.3 → 1.0.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 +10 -0
- package/dist/index.js +26 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -54,6 +54,16 @@ You can also pass `settings`, `license`, or `onReady` if you need deeper access
|
|
|
54
54
|
|
|
55
55
|
## Changelog
|
|
56
56
|
|
|
57
|
+
```
|
|
58
|
+
v1.0.5
|
|
59
|
+
- Change detection fixes
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
v1.0.4
|
|
64
|
+
- Aligned with `mctable` core library `v1.3.0`
|
|
65
|
+
```
|
|
66
|
+
|
|
57
67
|
```
|
|
58
68
|
v1.0.3
|
|
59
69
|
- Aligned with `mctable` core library `v1.2.3`
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,26 @@ function __stableSignature(value) {
|
|
|
42
42
|
return "[unserializable]";
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
function __areRecordsEqual(prevRecords, nextRecords) {
|
|
46
|
+
if (prevRecords === nextRecords) return true;
|
|
47
|
+
if (prevRecords.length !== nextRecords.length) return false;
|
|
48
|
+
for (let index = 0; index < prevRecords.length; index++) {
|
|
49
|
+
if (__stableSignature(prevRecords[index]) !== __stableSignature(nextRecords[index])) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
function __areColumnsEqual(prevColumns, nextColumns) {
|
|
56
|
+
if (prevColumns === nextColumns) return true;
|
|
57
|
+
if (prevColumns.length !== nextColumns.length) return false;
|
|
58
|
+
for (let index = 0; index < prevColumns.length; index++) {
|
|
59
|
+
if (__stableSignature(prevColumns[index]) !== __stableSignature(nextColumns[index])) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
45
65
|
function __getWidthOnlyChanges({
|
|
46
66
|
prevRecords,
|
|
47
67
|
prevColumns,
|
|
@@ -94,11 +114,6 @@ var McTableReact = React.forwardRef(
|
|
|
94
114
|
records: records ?? [],
|
|
95
115
|
columns: columns ?? []
|
|
96
116
|
});
|
|
97
|
-
const lastSigRef = React.useRef({
|
|
98
|
-
recordCount: (records ?? []).length,
|
|
99
|
-
columnsCount: (columns ?? []).length,
|
|
100
|
-
columnsSig: __stableSignature(columns ?? [])
|
|
101
|
-
});
|
|
102
117
|
const [readyTick, setReadyTick] = React.useState(0);
|
|
103
118
|
const effectiveSettings = React.useMemo(() => {
|
|
104
119
|
const hasAnyResizeCallback = onColumnResizeStart !== void 0 || onColumnResizing !== void 0 || onColumnResizeEnd !== void 0 || onRowResizeStart !== void 0 || onRowResizing !== void 0 || onRowResizeEnd !== void 0;
|
|
@@ -183,27 +198,18 @@ var McTableReact = React.forwardRef(
|
|
|
183
198
|
const prevColumns = lastDataRef.current.columns;
|
|
184
199
|
const nextRecords = records !== void 0 ? records : prevRecords;
|
|
185
200
|
const nextColumns = columns !== void 0 ? columns : prevColumns;
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const didChange = recordCountChanged || columnsChanged;
|
|
201
|
+
const recordsChanged = records !== void 0 && (nextRecords.length !== prevRecords.length || !__areRecordsEqual(prevRecords, nextRecords));
|
|
202
|
+
const columnsChanged = columns !== void 0 && (nextColumns.length !== prevColumns.length || !__areColumnsEqual(prevColumns, nextColumns));
|
|
203
|
+
const didChange = recordsChanged || columnsChanged;
|
|
204
|
+
if (!didChange) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
193
207
|
if (records !== void 0) {
|
|
194
208
|
lastDataRef.current.records = nextRecords;
|
|
195
209
|
}
|
|
196
210
|
if (columns !== void 0) {
|
|
197
211
|
lastDataRef.current.columns = nextColumns;
|
|
198
212
|
}
|
|
199
|
-
if (!didChange) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
lastSigRef.current = {
|
|
203
|
-
recordCount: nextRecordCount,
|
|
204
|
-
columnsCount: nextColumnsCount,
|
|
205
|
-
columnsSig: nextColumnsSig
|
|
206
|
-
};
|
|
207
213
|
const widthOnlyChanges = __getWidthOnlyChanges({
|
|
208
214
|
prevRecords,
|
|
209
215
|
prevColumns,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mctable-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -65,6 +65,6 @@
|
|
|
65
65
|
"vite": "^5.4.12"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"mctable": "^1.
|
|
68
|
+
"mctable": "^1.3.0"
|
|
69
69
|
}
|
|
70
70
|
}
|