@mittwald/flow-react-components 1.2.0-next.32 → 1.2.0-next.34

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/MIGRATION.md CHANGED
@@ -571,7 +571,7 @@ case.
571
571
 
572
572
  ## TableColumn: `maxWidth` removed, `width` and `minWidth` retyped
573
573
 
574
- **Since `0.2.0-alpha.956`** · migration · manual change · also applies to
574
+ **Since `0.2.0-alpha.956`** · migration · codemod available · also applies to
575
575
  `@mittwald/flow-remote-react-components`
576
576
 
577
577
  `maxWidth` has been removed. `width` and `minWidth` are now typed as
@@ -588,9 +588,24 @@ Percentage, pixel and `fr` values keep working as strings or numbers
588
588
  (`width="50%"`, `width="200fr"`, `width={300}`). Where you passed `null` to mean
589
589
  "no explicit width", omit the prop instead.
590
590
 
591
+ A codemod removes `maxWidth` — the prop is gone from the type, so an explicit
592
+ attribute is wrong at any value, an expression included — and removes a `width`
593
+ or `minWidth` written as the literal `null`.
594
+
595
+ It declines what it cannot decide from the source: `width={maybeNull}` could be
596
+ anything at runtime, and a spread's contents are invisible. Both keep their
597
+ props and need a look by hand.
598
+
591
599
  **Apply:** Remove `maxWidth` from every `TableColumn`. Where `width` or
592
600
  `minWidth` was `null`, omit the prop instead — the type no longer accepts
593
- `null`, only `number | string`.
601
+ `null`, only `number | string`. A codemod does both for the cases it can decide
602
+ from the source. Two it declines: a `width`/`minWidth` whose value is an
603
+ expression (`width={maybeNull}`), and a spread that might carry `maxWidth`
604
+ (`<TableColumn {...props} />`). Check those by hand.
605
+
606
+ ```shell
607
+ npx @mittwald/flow-codemods@latest table-column-width-props src
608
+ ```
594
609
 
595
610
  ---
596
611
 
@@ -1011,18 +1026,39 @@ Only function **references** are affected. An inline arrow
1011
1026
  (`onAction={() => …}`), a zero-parameter function, and anything already
1012
1027
  accepting `unknown` are all fine.
1013
1028
 
1014
- A codemod renames the prop. It deliberately does not wrap: whether the
1015
- referenced function declares a parameter cannot be decided from the source —
1016
- that needs type information and wrapping everything would silently drop the
1017
- arguments `Action` passes to handlers that do accept them.
1029
+ A codemod renames the prop and wraps the reference.
1030
+
1031
+ Whether a reference _needs_ wrapping is not decidable from the source — that
1032
+ needs type information. Performing the wrap does not need it: `() => fn()` calls
1033
+ what `Action` would have called, and `onAction` takes no arguments. So the wrap
1034
+ fixes the reference that needed it and changes nothing for the rest, which makes
1035
+ the decision unnecessary.
1036
+
1037
+ Wrapped: a plain identifier and a member expression (`close`,
1038
+ `controller.close`, `this.handleSave`). Left alone: an arrow function and a
1039
+ function expression, which already are the handler; a call (`makeHandler()`,
1040
+ `close.bind(controller)`), which produces it; and anything that is not one
1041
+ reference (`isOpen ? close : open`, `onClose ?? noop`, `controller?.close`).
1042
+
1043
+ Two wraps are worth a look afterwards. A handler that read the event `Action`
1044
+ forwards — undocumented, but it does forward the trigger's event — stops
1045
+ receiving it. And `onAction={props.onAction}`, where the reference may be
1046
+ `undefined`: passing it was fine, calling it is not, so TypeScript now reports
1047
+ the call and wants a guard.
1018
1048
 
1019
1049
  **Apply:** Rename the `action` prop on `Action` to `onAction`. Not only a
1020
1050
  rename: the new prop is typed `ActionFn` (`(...args: unknown[]) => unknown`), so
1021
1051
  a function _reference_ that declares a parameter no longer type-checks and needs
1022
1052
  wrapping — `onAction={() => controller.close()}` rather than
1023
- `onAction={controller.close}`. Check every site where you passed a reference
1024
- rather than an inline arrow; the codemod renames the prop but cannot decide this
1025
- one from the source.
1053
+ `onAction={controller.close}`. A codemod does both. It wraps every bare
1054
+ reference (`close`, `controller.close`), because the wrap is a no-op for a
1055
+ reference that did not need it. It leaves a value that already is the handler or
1056
+ produces one — an arrow function, a function expression, a call like
1057
+ `makeHandler()` or `close.bind(controller)` — and anything that is not one
1058
+ reference, such as `isOpen ? close : open` or `controller?.close`. Two wraps to
1059
+ look at afterwards: a handler that read the event `Action` forwards stops
1060
+ receiving it, and a possibly-undefined reference (`onAction={props.onAction}`)
1061
+ becomes a call TypeScript rejects — add the guard it asks for.
1026
1062
 
1027
1063
  ```shell
1028
1064
  npx @mittwald/flow-codemods@latest action-prop-to-on-action src
@@ -1132,7 +1168,7 @@ npx @mittwald/flow-codemods@latest imports-to-package-root src
1132
1168
 
1133
1169
  ## Renamed CSS export
1134
1170
 
1135
- **Since `0.1.0-alpha.292`** · migration · manual change
1171
+ **Since `0.1.0-alpha.292`** · migration · codemod available
1136
1172
 
1137
1173
  The CSS export `@mittwald/flow-react-components/styles` has renamed to the more
1138
1174
  precise name `@mittwald/flow-react-components/all.css`, because the file
@@ -1145,5 +1181,15 @@ as well. A documentation on how to use them is planned.
1145
1181
  + import "@mittwald/flow-react-components/all.css";
1146
1182
  ```
1147
1183
 
1184
+ A codemod rewrites the specifier in every JavaScript and TypeScript form that
1185
+ names a module. It cannot reach a `.css` or `.scss` file, so an `@import` of the
1186
+ old path there needs a manual search.
1187
+
1148
1188
  **Apply:** Replace the import `@mittwald/flow-react-components/styles` with
1149
- `@mittwald/flow-react-components/all.css`.
1189
+ `@mittwald/flow-react-components/all.css`. A codemod does this for JavaScript
1190
+ and TypeScript files. An `@import` of the old path inside a `.css` or `.scss`
1191
+ file is not covered — search for it by hand.
1192
+
1193
+ ```shell
1194
+ npx @mittwald/flow-codemods@latest renamed-css-export src
1195
+ ```