mctable-react 1.0.6 → 1.0.7
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 +6 -0
- package/dist/index.js +51 -0
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -54,6 +54,12 @@ You can also pass `settings`, `license`, or `onReady` if you need deeper access
|
|
|
54
54
|
|
|
55
55
|
## Changelog
|
|
56
56
|
|
|
57
|
+
```
|
|
58
|
+
v1.0.7
|
|
59
|
+
- Upgrade to `mctable` core library `v1.4.0`
|
|
60
|
+
- Change tracking of column validation triggers
|
|
61
|
+
```
|
|
62
|
+
|
|
57
63
|
```
|
|
58
64
|
v1.0.6
|
|
59
65
|
- Aligned with `mctable` core library `v1.3.1`
|
package/dist/index.js
CHANGED
|
@@ -62,6 +62,47 @@ function __areColumnsEqual(prevColumns, nextColumns) {
|
|
|
62
62
|
}
|
|
63
63
|
return true;
|
|
64
64
|
}
|
|
65
|
+
function __getValidationOnlyChanges({
|
|
66
|
+
prevRecords,
|
|
67
|
+
prevColumns,
|
|
68
|
+
nextRecords,
|
|
69
|
+
nextColumns
|
|
70
|
+
}) {
|
|
71
|
+
if (__stableSignature(prevRecords) !== __stableSignature(nextRecords)) return null;
|
|
72
|
+
if (prevColumns.length !== nextColumns.length) return null;
|
|
73
|
+
const validationChanges = [];
|
|
74
|
+
for (let index = 0; index < prevColumns.length; index++) {
|
|
75
|
+
const prevColumn = prevColumns[index];
|
|
76
|
+
const nextColumn = nextColumns[index];
|
|
77
|
+
const { validation: prevValidation, ...prevColumnWithoutValidation } = prevColumn;
|
|
78
|
+
const { validation: nextValidation, ...nextColumnWithoutValidation } = nextColumn;
|
|
79
|
+
if (__stableSignature(prevColumnWithoutValidation) !== __stableSignature(nextColumnWithoutValidation)) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const prevRequired = prevValidation?.required;
|
|
83
|
+
const nextRequired = nextValidation?.required;
|
|
84
|
+
const prevTypeMatch = prevValidation?.typeMatch;
|
|
85
|
+
const nextTypeMatch = nextValidation?.typeMatch;
|
|
86
|
+
if (prevRequired === nextRequired && prevTypeMatch === nextTypeMatch) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const settings = {
|
|
90
|
+
name: nextColumn.name
|
|
91
|
+
};
|
|
92
|
+
if (prevRequired !== nextRequired) {
|
|
93
|
+
settings.required = nextRequired ?? null;
|
|
94
|
+
}
|
|
95
|
+
if (prevTypeMatch !== nextTypeMatch) {
|
|
96
|
+
settings.typeMatch = nextTypeMatch ?? null;
|
|
97
|
+
}
|
|
98
|
+
validationChanges.push({
|
|
99
|
+
position: index + 1,
|
|
100
|
+
settings
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (validationChanges.length === 0) return null;
|
|
104
|
+
return validationChanges;
|
|
105
|
+
}
|
|
65
106
|
function __getWidthOnlyChanges({
|
|
66
107
|
prevRecords,
|
|
67
108
|
prevColumns,
|
|
@@ -216,10 +257,20 @@ var McTableReact = React.forwardRef(
|
|
|
216
257
|
nextRecords,
|
|
217
258
|
nextColumns
|
|
218
259
|
});
|
|
260
|
+
const validationOnlyChanges = __getValidationOnlyChanges({
|
|
261
|
+
prevRecords,
|
|
262
|
+
prevColumns,
|
|
263
|
+
nextRecords,
|
|
264
|
+
nextColumns
|
|
265
|
+
});
|
|
219
266
|
if (widthOnlyChanges) {
|
|
220
267
|
for (const change of widthOnlyChanges) {
|
|
221
268
|
table.api.setContentColumnWidth(change);
|
|
222
269
|
}
|
|
270
|
+
} else if (validationOnlyChanges) {
|
|
271
|
+
for (const change of validationOnlyChanges) {
|
|
272
|
+
table.api.updateContentColumnSettings(change.settings);
|
|
273
|
+
}
|
|
223
274
|
} else {
|
|
224
275
|
table.api.setData({
|
|
225
276
|
data: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mctable-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"build": "tsup src/index.ts --format esm --dts --clean --out-dir dist --external react --external react-dom --external react/jsx-runtime --external react/jsx-dev-runtime",
|
|
20
20
|
"start": "vite --open",
|
|
21
21
|
"release:npm": "npm pack --pack-destination .",
|
|
22
|
-
"prepare": "npm run build",
|
|
23
22
|
"prepack": "npm run build"
|
|
24
23
|
},
|
|
25
24
|
"keywords": [
|
|
@@ -65,6 +64,6 @@
|
|
|
65
64
|
"vite": "^5.4.12"
|
|
66
65
|
},
|
|
67
66
|
"dependencies": {
|
|
68
|
-
"mctable": "^1.
|
|
67
|
+
"mctable": "^1.4.0"
|
|
69
68
|
}
|
|
70
69
|
}
|