@cratis/components.migrator 4.14.1 → 4.14.3

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
@@ -181,27 +181,16 @@ The transform never guesses through JSX spreads, dynamic legacy values, duplicat
181
181
 
182
182
  ## `change-handler`
183
183
 
184
- `cratis-components-change-handler` resolves affected Components-owned JSX identifiers imported with aliases or namespaces from `@cratis/components/Dropdown`, `@cratis/components/CommandForm`, and `@cratis/components/CommandForm/fields`. It rewrites only a structurally-proven single forwarding callback:
184
+ `cratis-components-change-handler` resolves Components-owned JSX identifiers imported with aliases or namespaces from `@cratis/components/Dropdown`, `@cratis/components/CommandForm`, and `@cratis/components/CommandForm/fields`. It rewrites structurally-proven single forwarding callbacks on standalone `Dropdown` and CommandForm field `onValueChange` props:
185
185
 
186
186
  ```tsx
187
- // Safe rewrites
187
+ // Before
188
188
  <Dropdown onChange={(event) => setRole(event.value)} />
189
- <InputTextField onChange={(event) => setName(event.target.value)} />
190
- <CheckboxField onChange={({ target: { checked } }) => setEnabled(checked)} />
191
-
192
- // become
189
+ // After
193
190
  <Dropdown onChange={(value) => setRole(value)} />
194
- <InputTextField onChange={(value) => setName(value)} />
195
- <CheckboxField onChange={(value) => setEnabled(value)} />
196
191
  ```
197
192
 
198
- The affected CommandForm fields cover legacy `target`/`currentTarget` `value`, `checked`, and `valueAsNumber` payloads, plus `DropdownField`/`MultiSelectField` `event.value`. Already-semantic callbacks and callback references such as `onChange={setValue}` are unchanged.
199
-
200
- The transform changes a callback's shape, not where it lives. With Arc 22.16.0, `CommandForm` calls an
201
- `onChange` placed on a field with the new value at runtime, but the Components 4 CommandForm field
202
- types do not declare `onChange`, so type-checked TSX reports TS2322 on a field that keeps one. Move
203
- those side effects to `CommandForm`'s `onFieldChange` callback. The standalone `Dropdown` declares
204
- `onChange` and is not affected. The [Components 3 to 4 migration guide](https://cratis.io/components/migration/3-to-4/) covers this case.
193
+ For Components 4 CommandForm fields, the codemod leaves `onChange` unchanged and reports an actionable diagnostic instead of changing its callback. Arc's `asCommandFormField` wrappers do not expose `onChange` as a field prop in Components 4, so keeping the attribute would produce TS2322 even if the callback were rewritten. Move its side effects to the enclosing `CommandForm`'s `onFieldChange(command, fieldName, oldValue, newValue, validationInfo?)` callback. Legacy `onValueChange` field callbacks with a proven event payload are rewritten to semantic values; already-semantic `onValueChange` callbacks are untouched. The [Components 3 to 4 migration guide](https://cratis.io/components/migration/3-to-4/) covers this case.
205
194
 
206
195
  Multi-statement, multi-use, wrong-payload, destructuring-with-default/rest, and native-event-dependent callbacks are refused, reported, and annotated once:
207
196
 
@@ -68,7 +68,7 @@
68
68
  {
69
69
  "name": "@cratis/components",
70
70
  "role": "core",
71
- "version": "4.0.0",
71
+ "version": "4.14.3",
72
72
  "releaseMajorRange": ">=4 <5",
73
73
  "independentRelease": false,
74
74
  "private": false,
@@ -92,7 +92,7 @@
92
92
  {
93
93
  "name": "@cratis/eslint-plugin-components",
94
94
  "role": "eslint",
95
- "version": "4.0.0",
95
+ "version": "4.14.3",
96
96
  "releaseMajorRange": ">=4 <5",
97
97
  "independentRelease": false,
98
98
  "private": false,
@@ -105,7 +105,7 @@
105
105
  {
106
106
  "name": "@cratis/components.migrator",
107
107
  "role": "migrator",
108
- "version": "4.0.0",
108
+ "version": "4.14.3",
109
109
  "releaseMajorRange": ">=4 <5",
110
110
  "independentRelease": false,
111
111
  "private": false,
@@ -116,13 +116,13 @@
116
116
  {
117
117
  "name": "@cratis/components.conformance",
118
118
  "role": "conformance",
119
- "version": "4.0.0",
119
+ "version": "4.14.3",
120
120
  "releaseMajorRange": ">=4 <5",
121
121
  "independentRelease": false,
122
122
  "private": false,
123
123
  "packageAccess": "public",
124
124
  "peerDependencies": {
125
- "@cratis/components": ">=4 <5",
125
+ "@cratis/components": "4.14.3",
126
126
  "react": "^19.0.0",
127
127
  "react-dom": "^19.0.0"
128
128
  },
@@ -132,13 +132,13 @@
132
132
  {
133
133
  "name": "@cratis/components.mui",
134
134
  "role": "renderer-adapter",
135
- "version": "4.0.0",
135
+ "version": "4.14.3",
136
136
  "releaseMajorRange": ">=4 <5",
137
137
  "independentRelease": false,
138
138
  "private": false,
139
139
  "packageAccess": "public",
140
140
  "peerDependencies": {
141
- "@cratis/components": ">=4 <5",
141
+ "@cratis/components": "4.14.3",
142
142
  "@emotion/react": ">=11.5 <12",
143
143
  "@emotion/styled": ">=11.11 <12",
144
144
  "@mui/material": ">=9 <10",
@@ -188,13 +188,13 @@
188
188
  {
189
189
  "name": "@cratis/components.primereact",
190
190
  "role": "renderer-adapter",
191
- "version": "4.0.0",
191
+ "version": "4.14.3",
192
192
  "releaseMajorRange": ">=4 <5",
193
193
  "independentRelease": false,
194
194
  "private": false,
195
195
  "packageAccess": "public",
196
196
  "peerDependencies": {
197
- "@cratis/components": ">=4 <5",
197
+ "@cratis/components": "4.14.3",
198
198
  "@primereact/core": ">=11 <12",
199
199
  "@primereact/ui": ">=11 <12",
200
200
  "@primeuix/themes": ">=3 <4",
@@ -256,13 +256,13 @@
256
256
  {
257
257
  "name": "@cratis/components.primereact10",
258
258
  "role": "renderer-adapter",
259
- "version": "4.0.0",
259
+ "version": "4.14.3",
260
260
  "releaseMajorRange": ">=4 <5",
261
261
  "independentRelease": false,
262
262
  "private": false,
263
263
  "packageAccess": "public",
264
264
  "peerDependencies": {
265
- "@cratis/components": ">=4 <5",
265
+ "@cratis/components": "4.14.3",
266
266
  "primereact": ">=10.9.9 <11",
267
267
  "react": "^19.0.0",
268
268
  "react-dom": "^19.0.0"
@@ -96,6 +96,14 @@ export function transformChangeHandlers(fileName, text, options = {}) {
96
96
  if (!ts.isJsxAttribute(attribute)) continue;
97
97
  const propName = attribute.name.getText(sourceFile);
98
98
  if (propName !== 'onChange' && propName !== 'onValueChange') continue;
99
+ if (target.group === 'CommandForm' && propName === 'onChange') {
100
+ report(
101
+ attribute,
102
+ target.component,
103
+ "Components 4 field props do not accept onChange; move the handler to the enclosing CommandForm's onFieldChange(command, fieldName, oldValue, newValue, validationInfo?)",
104
+ );
105
+ continue;
106
+ }
99
107
  if (
100
108
  !attribute.initializer ||
101
109
  !ts.isJsxExpression(attribute.initializer) ||
@@ -98,10 +98,16 @@ export function validateBundledManifest(manifest, migratorVersion) {
98
98
  const packageEntry = manifest.packages?.find(
99
99
  ({ name }) => name === '@cratis/components.migrator',
100
100
  );
101
+ if (packageEntry?.version !== migratorVersion) {
102
+ throw new Error(
103
+ `Bundled compatibility manifest pins @cratis/components.migrator at ${packageEntry?.version ?? '<missing>'} but this package is ${migratorVersion}. ` +
104
+ 'This is a packaging defect in this migrator release, not a problem with your project. ' +
105
+ 'Report it at https://github.com/Cratis/Components/issues.',
106
+ );
107
+ }
101
108
  if (
102
- packageEntry?.version !== migratorVersion ||
103
- packageEntry?.independentRelease !== false ||
104
- !semver.satisfies(migratorVersion, packageEntry?.releaseMajorRange ?? '')
109
+ packageEntry.independentRelease !== false ||
110
+ !semver.satisfies(migratorVersion, packageEntry.releaseMajorRange ?? '')
105
111
  ) {
106
112
  throw new Error(
107
113
  'Bundled compatibility manifest has stale migrator package metadata.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/components.migrator",
3
- "version": "4.14.1",
3
+ "version": "4.14.3",
4
4
  "description": "Migration tooling for updating @cratis/components consumers from Components 3 to Components 4.",
5
5
  "author": "Cratis",
6
6
  "license": "MIT",