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

MultiSelect Transform

Converts a v6 MultiSelect component to a v7 MultiSelect component.

Automatic Changes

  • Attempts to transform the deprecated theme prop to the className prop. If it cannot, deletes the theme prop.
  • Renames the disabled prop to aria-disabled.
  • Rename ariaLabel prop to aria-label.
  • Rename onChange prop to onSelectedValuesChange.
  • Delete the fluid prop.
  • Delete the getSelectedCount prop. Previously, the number of selected items would be announced via the screen reader after ever selection. In v7, we’ve removed this and instead announce the total selected options once the user is finished selecting and closes the Popover. When the focus is back on the MultiSelect, the total selected options will be announced.
  • Delete the showSelectedCount prop. Previously, this was used in conjunction with getSelectedCount. Since we’ve removed getSelectedCount, this prop is no longer needed.
  • Replace success with default for the status prop, since MultiSelect does not support the success status.

For example:

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

export default function Page() {

return (

<MultiSelect

disabled={isDisabled}

ariaLabel="label"

onChange={(selectedId, isSelected) => {}}

onOptionsToggle={(isHidden) => {}}

fluid={true}

getSelectedCount={getSelectedCount}

showSelectedCount={true}

status="success"

theme={{ color: 'red' }}

{...otherProps}

>

{/** Children */}

</MultiSelect>

);

}

Transforms into:

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

export default function Page() {

return (

<MultiSelect

aria-disabled={isDisabled}

aria-label="label"

onChange={(selectedValue, isSelected) => {}}

onIsOpenChange={(isOpen) => {}}

{...otherProps}

>

{/** Children */}

</MultiSelect>

);

}

Manual Changes

fluid has been deprecated

MultiSelect is now fluid by default. To prevent the component from occupying the full width of the container it is in, we recommend applying a utility class (like col-md-6) to the component or limiting the width of the container it is in.

onOptionsToggle has been renamed to onIsOpenChange with a different signature

We’ve renamed the onOptionsToggle prop to onIsOpenChange and inverted the boolean argument in the function signature (i.e onOptionsToggle={isHidden => {}} is converted to onIsOpenChange={isOpen => {}}).

onSelectedValuesChange has a different signature than onChange

Previously, the first parameter, selectedId, of the onChange function was the id of the selected value, and the second parameter, isSelected, was a boolean indicating if the selectedId was selected or deselected. In v7, the first parameter, selectedValue, of the onSelectedValuesChange function is the value instead of the id. This value is the same as the value prop of the <MultiSelectOption> component. The second parameter is unchanged and is a boolean indicating if the selectedValue was selected or deselected.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.