mctable-react 1.0.5 → 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 CHANGED
@@ -55,16 +55,19 @@ You can also pass `settings`, `license`, or `onReady` if you need deeper access
55
55
  ## Changelog
56
56
 
57
57
  ```
58
- v1.0.5
59
- - Change detection fixes
58
+ v1.0.7
59
+ - Upgrade to `mctable` core library `v1.4.0`
60
+ - Change tracking of column validation triggers
60
61
  ```
61
62
 
62
63
  ```
63
- v1.0.4
64
- - Aligned with `mctable` core library `v1.3.0`
64
+ v1.0.6
65
+ - Aligned with `mctable` core library `v1.3.1`
65
66
  ```
66
67
 
67
68
  ```
68
- v1.0.3
69
- - Aligned with `mctable` core library `v1.2.3`
69
+ v1.0.5
70
+ - Change detection fixes
70
71
  ```
72
+
73
+
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.5",
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.3.0"
67
+ "mctable": "^1.4.0"
69
68
  }
70
69
  }