diff --git a/.storybook-s2/docs/Migrating.jsx b/.storybook-s2/docs/Migrating.jsx
index a695e930146..8e0fdfda1e6 100644
--- a/.storybook-s2/docs/Migrating.jsx
+++ b/.storybook-s2/docs/Migrating.jsx
@@ -12,6 +12,18 @@ export function Migrating() {
An automated upgrade assistant is available by running the following command in the project you want to upgrade:
npx @react-spectrum/codemods s1-to-s2
+ To only upgrade specific components, provide a --components
argument with a comma-separated list of components to upgrade:
+
+ npx @react-spectrum/codemods s1-to-s2 --components=Button,TextField
+
+ The following arguments are also available:
+
+
+ --path
- Path to apply the upgrade changes to. Defaults to the current directory (.
)
+ --dry
- Runs the upgrade assistant without making changes to components
+ --ignore-pattern
- Ignore files that match the provided glob expression. Defaults to '**/node_modules/**'
+
+
For cases that the upgrade assistant doesn't handle automatically or where you'd rather upgrade some components manually, use the guide below.
Note that [PENDING] indicates that future changes will occur before the final release, and the current solution should be considered temporary.
@@ -33,10 +45,13 @@ export function Migrating() {
Update Item
to be a MenuItem
+ AlertDialog
+ No updates needed.
+
Avatar
- [PENDING] Comment out
isDisabled
(it has not been implemented yet)
- - Remove
size
and instead provide a size via the style macro (i.e. {`styles={style({size: 20})}`}
)
+ - Update
size
to be a pixel value if it currently matches 'avatar-size-*'
Breadcrumbs
@@ -50,8 +65,8 @@ export function Migrating() {
Button
- - Change
variant=“cta”
to variant="accent"
- - Change
variant=“overBackground”
to variant=“primary” staticColor=“white”
+ - Change
variant="cta"
to variant="accent"
+ - Change
variant="overBackground"
to variant="primary" staticColor="white"
- Change
style
to fillStyle
- [PENDING] Comment out
isPending
(it has not been implemented yet)
- Remove
isQuiet
(it is no longer supported in Spectrum 2)
@@ -79,8 +94,8 @@ export function Migrating() {
- Remove
isQuiet
(it is no longer supported in Spectrum 2)
- Remove
placeholder
(it has been removed due to accessibility issues)
- - Change
validationState=“invalid”
to isInvalid
- - Remove
validationState=“valid”
(it is no longer supported in Spectrum 2)
+ - Change
validationState="invalid"
to isInvalid
+ - Remove
validationState="valid"
(it is no longer supported in Spectrum 2)
ColorSlider
@@ -102,8 +117,8 @@ export function Migrating() {
- Remove
isQuiet
(it is no longer supported in Spectrum 2)
- [PENDING] Comment out
loadingState
(it has not been implemented yet)
- Remove
placeholder
(it is no longer supported in Spectrum 2)
- - Change
validationState=“invalid”
to isInvalid
- - Remove
validationState=“valid”
(it is no longer supported in Spectrum 2)
+ - Change
validationState="invalid"
to isInvalid
+ - Remove
validationState="valid"
(it is no longer supported in Spectrum 2)
- [PENDING] Comment out
onLoadMore
(it has not been implemented yet)
- Update
Item
to be a ComboBoxItem
@@ -116,8 +131,8 @@ export function Migrating() {
DialogTrigger
- - [PENDING] Comment out
type=“tray”
(Tray
has not been implemented yet)
- - [PENDING] Comment out
mobileType=“tray”
(Tray
has not been implemented yet)
+ - [PENDING] Comment out
type="tray"
(Tray
has not been implemented yet)
+ - [PENDING] Comment out
mobileType="tray"
(Tray
has not been implemented yet)
- Remove
targetRef
(it is no longer supported in Spectrum 2)
- Update
children
to remove render props usage, and note that the close
function was moved from DialogTrigger
to Dialog
@@ -146,11 +161,13 @@ export function Migrating() {
IllustratedMessage
- No updates needed.
+
+ - Update illustrations to be from
@react-spectrum/s2/illustrations
. See Illustrations
+
InlineAlert
- - Change
variant=“info”
to variant=“informative”
+ - Change
variant="info"
to variant="informative"
Item
@@ -169,7 +186,7 @@ export function Migrating() {
Link
- - Change
variant=“overBackground”
to staticColor=“white”
+ - Change
variant="overBackground"
to staticColor="white"
ListBox
@@ -187,12 +204,20 @@ export function Migrating() {
[PENDING] Comment out closeOnSelect
(it has not been implemented yet)
+ NumberField
+
+ - Remove
isQuiet
(it is no longer supported in Spectrum 2)
+ - Change
validationState="invalid"
to isInvalid
+ - Remove
validationState="valid"
(it is no longer supported in Spectrum 2)
+ - [PENDING] Comment out
hideStepper
(it has not been implemented yet)
+
+
Picker
- Change
menuWidth
value from a DimensionValue
to a pixel value
- Remove
isQuiet
(it is no longer supported in Spectrum 2)
- - Change
validationState=“invalid”
to isInvalid
- - Remove
validationState=“valid”
(it is no longer supported in Spectrum 2)
+ - Change
validationState="invalid"
to isInvalid
+ - Remove
validationState="valid"
(it is no longer supported in Spectrum 2)
- [PENDING] Comment out
isLoading
(it has not been implemented yet)
- [PENDING] Comment out
onLoadMore
(it has not been implemented yet)
- Update
Item
to be a PickerItem
@@ -200,14 +225,14 @@ export function Migrating() {
ProgressBar
- - Change
variant=“overBackground”
to staticColor=“white”
+ - Change
variant="overBackground"
to staticColor="white"
- [PENDING] Comment out
labelPosition
(it has not been implemented yet)
- [PENDING] Comment out
showValueLabel
(it has not been implemented yet)
ProgressCircle
- - Change
variant=“overBackground”
to staticColor=“white”
+ - Change
variant="overBackground"
to staticColor="white"
Radio
@@ -215,8 +240,8 @@ export function Migrating() {
RadioGroup
- - Change
validationState=“invalid”
to isInvalid
- - Remove
validationState=“valid”
(it is no longer supported in Spectrum 2)
+ - Change
validationState="invalid"
to isInvalid
+ - Remove
validationState="valid"
(it is no longer supported in Spectrum 2)
- Remove
showErrorIcon
(it has been removed due to accessibility issues)
@@ -232,8 +257,8 @@ export function Migrating() {
- Remove
placeholder
(it has been removed due to accessibility issues)
- [PENDING] Comment out icon (it has not been implemented yet)
- Remove
isQuiet
(it is no longer supported in Spectrum 2)
- - Change
validationState=“invalid”
to isInvalid
- - Remove
validationState=“valid”
(it is no longer supported in Spectrum 2)
+ - Change
validationState="invalid"
to isInvalid
+ - Remove
validationState="valid"
(it is no longer supported in Spectrum 2)
Section
@@ -254,7 +279,7 @@ export function Migrating() {
StatusLight
- Remove
isDisabled
(it is no longer supported in Spectrum 2)
- - Change
variant=“info”
to variant="informative"
+ - Change
variant="info"
to variant="informative"
SubmenuTrigger
@@ -271,12 +296,9 @@ export function Migrating() {
TagGroup
- - [PENDING] Comment out
actionLabel
(it has not been implemented yet)
- - [PENDING] Comment out
onAction
(it has not been implemented yet)
- - [PENDING] Comment out
maxRows
(it has not been implemented yet)
- - [PENDING] Comment out
errorMessage
(it has not been implemented yet)
- - [PENDING] Comment out
isInvalid
(it has not been implemented yet)
- - [PENDING] Comment out
validationState
(isInvalid
should be used when it becomes available)
+ - Rename
actionLabel
to groupActionLabel
+ - Rename
onAction
to onGroupAction
+ - Change
validationState="invalid"
to isInvalid
- Update
Item
to be Tag
@@ -285,8 +307,8 @@ export function Migrating() {
[PENDING] Comment out icon
(it has not been implemented yet)
Remove isQuiet
(it is no longer supported in Spectrum 2)
Remove placeholder
(it has been removed due to accessibility issues)
- Change validationState=“invalid”
to isInvalid
- Remove validationState=“valid”
(it is no longer supported in Spectrum 2)
+ Change validationState="invalid"
to isInvalid
+ Remove validationState="valid"
(it is no longer supported in Spectrum 2)
TextField
@@ -294,8 +316,8 @@ export function Migrating() {
[PENDING] Comment out icon
(it has not been implemented yet)
Remove isQuiet
(it is no longer supported in Spectrum 2)
Remove placeholder
(it has been removed due to accessibility issues)
- Change validationState=“invalid”
to isInvalid
- Remove validationState=“valid”
(it is no longer supported in Spectrum 2)
+ Change validationState="invalid"
to isInvalid
+ Remove validationState="valid"
(it is no longer supported in Spectrum 2)
ToggleButton
@@ -311,7 +333,7 @@ export function Migrating() {
TooltipTrigger
- - Update placement prop to be have one value (i.e. Update
placement="bottom left"
to be placement=“bottom”
)
+ - Update placement prop to be have one value (i.e. Update
placement="bottom left"
to be placement="bottom"
)
View
diff --git a/packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/numberfield.test.ts.snap b/packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/numberfield.test.ts.snap
new file mode 100644
index 00000000000..682d470e152
--- /dev/null
+++ b/packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/numberfield.test.ts.snap
@@ -0,0 +1,41 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Comments out hideStepper 1`] = `
+"import { NumberField } from "@react-spectrum/s2";
+
+
+ // TODO(S2-upgrade): hideStepper has not been implemented yet.
+
+ // TODO(S2-upgrade): hideStepper has not been implemented yet.
+
+
"
+`;
+
+exports[`Removes isQuiet 1`] = `
+"import { NumberField } from "@react-spectrum/s2";
+let isQuiet = true;
+let props = {isQuiet: true};
+
+
+
+
+
+
+
+
"
+`;
+
+exports[`changes validationState to isInvalid or nothing 1`] = `
+"import { NumberField } from "@react-spectrum/s2";
+let validationState = 'invalid';
+let props = {validationState: 'invalid'};
+
+
+
+
+
+
"
+`;
diff --git a/packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/taggroup.test.ts.snap b/packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/taggroup.test.ts.snap
index fdfcd729d6c..cb28f5c4531 100644
--- a/packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/taggroup.test.ts.snap
+++ b/packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/taggroup.test.ts.snap
@@ -76,20 +76,23 @@ import { Item } from '@adobe/react-spectrum';
let validationState = 'invalid';
let props = {validationState: 'invalid'};
- // TODO(S2-upgrade): validationState has not been implemented yet.
-
+
News
- // TODO(S2-upgrade): validationState has not been implemented yet.
News
- // TODO(S2-upgrade): validationState has not been implemented yet.
-
+
News
- // TODO(S2-upgrade): validationState has not been implemented yet.
-
+
News
{
+ defineSnapshotTest(transform, {}, input, name);
+};
+
+test('Removes isQuiet', `
+import {NumberField} from '@adobe/react-spectrum';
+let isQuiet = true;
+let props = {isQuiet: true};
+
+
+
+
+
+
+
+
+`);
+
+test('changes validationState to isInvalid or nothing', `
+import {NumberField} from '@adobe/react-spectrum';
+let validationState = 'invalid';
+let props = {validationState: 'invalid'};
+
+
+
+
+
+
+`);
+
+test('Comments out hideStepper', `
+import {NumberField} from '@adobe/react-spectrum';
+
+
+
+
+
+`);
diff --git a/packages/dev/codemods/src/s1-to-s2/src/codemods/changes.ts b/packages/dev/codemods/src/s1-to-s2/src/codemods/changes.ts
index b10ee2313fd..f4cc810b1c8 100644
--- a/packages/dev/codemods/src/s1-to-s2/src/codemods/changes.ts
+++ b/packages/dev/codemods/src/s1-to-s2/src/codemods/changes.ts
@@ -639,6 +639,44 @@ export const changes: ChangesJSON = {
}
]
},
+ NumberField: {
+ changes: [
+ {
+ description: 'Remove isQuiet',
+ reason: 'It is no longer supported',
+ function: {name: 'removeProp', args: {propToRemove: 'isQuiet'}}
+ },
+ {
+ description: "Change validationState='invalid' to isInvalid",
+ reason: 'Updated API',
+ function: {
+ name: 'updatePropNameAndValue',
+ args: {
+ oldProp: 'validationState',
+ oldValue: 'invalid',
+ newProp: 'isInvalid',
+ newValue: true
+ }
+ }
+ },
+ {
+ description: "Remove validationState='valid'",
+ reason: 'It is no longer supported',
+ function: {
+ name: 'removeProp',
+ args: {propToRemove: 'validationState', propValue: 'valid'}
+ }
+ },
+ {
+ description: 'Comment out hideStepper',
+ reason: 'It has not been implemented yet',
+ function: {
+ name: 'commentOutProp',
+ args: {propToComment: 'hideStepper'}
+ }
+ }
+ ]
+ },
Picker: {
changes: [
{
@@ -953,51 +991,40 @@ export const changes: ChangesJSON = {
TagGroup: {
changes: [
{
- description: 'Comment out actionLabel',
- reason: 'It has not been implemented yet',
+ description: 'Change actionLabel to groupActionLabel',
+ reason: 'To match new onGroupAction prop',
function: {
- name: 'commentOutProp',
- args: {propToComment: 'actionLabel'}
- }
- },
- {
- description: 'Comment out onAction',
- reason: 'It has not been implemented yet',
- function: {
- name: 'commentOutProp',
- args: {propToComment: 'onAction'}
- }
- },
- {
- description: 'Comment out maxRows',
- reason: 'It has not been implemented yet',
- function: {
- name: 'commentOutProp',
- args: {propToComment: 'maxRows'}
+ name: 'updatePropName',
+ args: {oldProp: 'actionLabel', newProp: 'groupActionLabel'}
}
},
{
- description: 'Comment out errorMessage',
- reason: 'It has not been implemented yet',
+ description: 'Change onAction to onGroupAction',
+ reason: 'To avoid confusion with existing onAction prop on other collection components',
function: {
- name: 'commentOutProp',
- args: {propToComment: 'errorMessage'}
+ name: 'updatePropName',
+ args: {oldProp: 'onAction', newProp: 'onGroupAction'}
}
},
{
- description: 'Comment out isInvalid',
- reason: 'It has not been implemented yet',
+ description: "Change validationState='invalid' to isInvalid",
+ reason: 'Updated API',
function: {
- name: 'commentOutProp',
- args: {propToComment: 'isInvalid'}
+ name: 'updatePropNameAndValue',
+ args: {
+ oldProp: 'validationState',
+ oldValue: 'invalid',
+ newProp: 'isInvalid',
+ newValue: true
+ }
}
},
{
- description: 'Comment out validationState',
- reason: 'isInvalid should be used when it becomes available',
+ description: "Remove validationState='valid'",
+ reason: 'It is no longer supported',
function: {
- name: 'commentOutProp',
- args: {propToComment: 'validationState'}
+ name: 'removeProp',
+ args: {propToRemove: 'validationState', propValue: 'valid'}
}
}
]