Codemods

The American Express Design System provides a unified language for designing American Express websites and experiences. The design system provides design resources that match our coded components and are aligned with the American Express brand. Included are colors, components, icons and glyphs, type styles, and graphic assets to get you up and running quickly.

Back to All Codemods

DatePicker Transform

Converts a v6 DatePicker component to a v7 DatePicker component.

Automatic Changes

  • Renames the date prop to value.
  • Renames the onDateChange prop to onChange. See manual changes below.
  • Renames the locale prop to lang.
  • Renames the errorMessage prop to statusMessage.
  • Renames the describedBy prop to aria-describedby.
  • Renames the datesDescribedBy prop to aria-labelledby.
  • If the placeholder prop exists, updates to showPlaceholder={true}. To customize the placeholder text, update the lang prop.
  • If the accessibleHint prop exists, updates to hint and adds isHintVisuallyHidden={true}.
  • Renames the primaryDate prop to circleDate.dateString. Use the circleDate.label prop to customize the label.
  • Renames the secondaryDate prop to squareDate.dateString. Use the squareDate.label prop to customize the label.
  • Renames the buttonLabels.previousMonth prop to labelOverrides.previousMonthButtonScreenReaderLabel.
  • Renames the buttonLabels.nextMonth prop to labelOverrides.nextMonthButtonScreenReaderLabel.
  • Deletes the buttonLabels.openCalendar prop. Use the labelOverrides.getCalendarButtonScreenReaderLabel prop instead.
  • Deletes the buttonLabels.closeCalendar prop. Use the labelOverrides.getCalendarButtonScreenReaderLabel prop instead.
  • Deletes the buttonLabels.getCalendarButtonScreenReaderLabel prop. Use the labelOverrides.getCalendarDayScreenReaderLabel prop instead.
  • Deletes the showLegend prop. If the circleDate or squareDate props are provided, then the legend will be shown.
  • Deletes the dateLabels.getPrimaryLabel prop. Use the circleDate.label prop instead.
  • Deletes the dateLabels.getSecondaryLabel prop. Use the squareDate.label prop instead.
  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.

For example:

import { DatePicker } from '@americanexpress/dls-react6';

export default function Page() {

return (

<DatePicker

id="date-picker-id"

date={date}

onDateChange={() => {}}

onBlur={() => {}}

locale="en-US"

errorMessage="Message."

describedBy="some-id"

datesDescribedBy="other-id"

placeholder="MM/DD/YYYY"

accessibleHint="Please select a date."

primaryDate={primaryDate}

secondaryDate={secondaryDate}

buttonLabels={{

previousMonth: 'Previous month',

nextMonth: 'Next month',

openCalendar: 'Open calendar',

closeCalendar: 'Close calendar',

selectedDate: 'Selected date',

}}

showLegend={true}

dateLabels={{ getPrimaryLabel, getSecondaryLabel }}

weekdays={weekdays}

format={format}

startDayOffset={startDayOffset}

theme={{ color: 'red' }}

{...otherProps}

/>

);

}

Transforms into:

import { DatePicker } from '@americanexpress/dls-react';

export default function Page() {

return (

<DatePicker

id="date-picker-id"

value={date}

onChange={() => {}}

onBlur={() => {}}

lang="en-US"

statusMessage="Message."

aria-describedby="some-id"

aria-labelledby="other-id"

showPlaceholder={true}

circleDate={{

dateString: primaryDate,

label: 'Primary Date',

}}

squareDate={{

dateString: secondaryDate,

label: 'Secondary Date',

}}

labelOverrides={{

previousMonthButtonScreenReaderLabel: 'Previous month',

nextMonthButtonScreenReaderLabel: 'Next month',

}}

weekdays={weekdays}

format={format}

startDayOffset={startDayOffset}

hint="Please select a date."

isHintVisuallyHidden={true}

{...otherProps}

/>

);

}

Manual Changes

Updated Date Format for
dateString

The expected format of the dateString (applicable to the new value, onChange, and onBlur props) across the board is now expected to always be in the format YYYY-MM-DD. If you were previously providing dateStrings to the component in a different format, please update your code to always provide and receive any dateStrings in the format YYYY-MM-DD.

Function signature changes

The onDateChange prop has been renamed to onChange and the function signature has been updated. The second parameter is an object whose key invalid has been renamed to isInvalid.

The onBlur function signature has been updated. The second parameter is an object whose key invalid has been renamed to isInvalid.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.