Bug Fixesβ
- Inline: margin styles were being applied not only to direct children but for all nested children
- Combobox: empty state only appeared when 2 or more letters were entered, causing a confusing delay
Featuresβ
Menuβ
π¨ Breaking Changes π¨
The way of using the Menu component is a little bit different. Below you can see what are the breaking changes in this version, but you should also check the documentation to look for new features.
- The Wrapper component named
Menuwas removed. - The prop
hideOnClickwas removed. The menu is closed on item click. MenuListwas renamed toMenu.- The state needs to be passed to
MenuandMenuButton. MenuButtonhas now alabelprop to set its text.MenuButtonhasIconDotsThreeVerticalas the default icon, but if you pass a customlabelthe icon changes toIconCaretDown/Up.MenuButtonhas thelabelHiddenprop to hide its own label. In this case the icon is alwaysIconDotsThreeVertical.MenuItemhas now alabelproperty to set its text.MenuItemhas now abooleanprop calledcriticalto set it to critical tone.
Before
import {
useMenuState,
MenuList,
MenuButton,
MenuItem,
MenuSeparator,
} from '@vtex/admin-ui'
function Example() {
const state = useMenuState()
return (
<Menu state={state} hideOnClick>
<MenuButton display="menu" />
<MenuList aria-label="Menu">
<MenuItem icon={<IconPlus />}>Create</MenuItem>
<MenuItem icon={<IconPencil />}>Edit</MenuItem>
<MenuItem icon={<IconArrowLineDown />}>Download</MenuItem>
<MenuSeparator />
<MenuItem icon={<IconTrash />} tone="critical">
Delete
</MenuItem>
</MenuList>
</Menu>
}
After
import {
MenuButton,
Menu,
MenuItem,
MenuDivider,
useMenuState
} from '@vtex/admin-ui'
function Example() {
const state = useMenuState()
return (
<>
<MenuButton state={state} />
<Menu state={state} aria-label="Menu">
<MenuItem label="Create" icon={<IconPlus />} />
<MenuItem label="Edit" icon={<IconPencil />} />
<MenuItem label="Download" icon={<IconArrowLineDown />} />
<MenuDivider />
<MenuItem label="Delete" icon={<IconTrash />} critical />
</Menu>
</>
)
DataGridβ
π¨ Breaking Changes π¨
Below you can see what are the breaking changes in this version, but you should also check the documentation to look for new features.
- The
DataGridand all its references was renamed toTable. - Remove the
densityprop from table. Now, the minimum row height is44pxand it grows depending on the content of its cells.
New Features
Create a
textresolver to render a text and an optional description just below it. You can read more about it in the resolver section under theCodetab.Usage
const state = useTableState({
columns: [
{
id: 'name',
header: 'Name',
resolver: {
type: 'text', // Resolver name
columnType: 'name',
mapText: (item) => item.name,
mapDescription: (item) => item.description, // Optional text description
},
// Other table columns...
]
})
NumberInputβ
π¨ Breaking Changes π¨
The NumericStepper component does not exist anymore, it has been replaced by the NumberInput component. Below you can see what are the breaking changes in this version, but you should also check the documentation to look for new features.
Before
import { NumericStepper } from '@vtex/admin-ui'
function Example() {
const [value, setValue] = React.useState(0)
return (
<NumericStepper
value={value}
helperText="Helper Text"
label="numeric-stepper"
onChange={(event) => setValue(event.value)}
/>
)
}
After
import { NumberInput } from '@vtex/admin-ui'
function Example() {
const [value, setValue] = useState('')
return (
<NumberInput
value={value}
label="Label"
helpText="Help text"
onChange={(newValue) => setValue(newValue)}
/>
)
}
Tagβ
π¨ Breaking Changes π¨
- The
iconandhandleDeleteproperties were removed. - The
sizeproperty now acceptsnormalandlarge, instead ofsmallandregular.
You can use our codemod cli to update the tag's properties for you. See its README for more information on how to execute the codemod.
Before
import { Tag } from '@vtex/admin-ui'
function Example() {
return (
<Tag
icon={<IconHeart />}
label="Here goes the label!"
size="small"
handleDelete={() => window.alert('Tag deleted')}
/>
)
}
After
import { Tag } from '@vtex/admin-ui'
function Example() {
return <Tag label="Short text" size="normal" />
}
Alertβ
π¨ Breaking Changes π¨
- The
icon,fluid,visible, andstickyproperties were removed. - The
fluidbehavior was incorporated as default for it. - Each variant has its own default icon now.
- The
toneprop was renamed tovariant.
You can use our codemod cli to update the alert's properties for you. See its README for more information on how to execute the codemod.
Beforeβ
import { Alert } from '@vtex/admin-ui'
function Example() {
return (
<Alert icon={<IconHeart />} fluid sticky visible>
Hello world
</Alert>
)
}
Afterβ
import { Alert } from '@vtex/admin-ui'
function Example() {
return <Alert visible>Hello world</Alert>
}
Selectβ
π¨ Breaking Changes π¨
- The way of handling errors is different now. Before we used a combination of
toneandcriticalText, and now we useerroranderrorText. helperTextnow ishelpText- The placeholder is internationalized and it always shows
Select.... toneandcriticalTextdoesn't exist anymore.
Before
<Select
label="Disabled"
helperText="Helpful text"
criticalText="Critical message"
value={value}
tone="critical"
onChange={(e) => setValue(e.target.value)}
disabled
>
<option value="yesterday">Yesterday</option>
<option value="today">Today</option>
</Select>
After
<Select
label="Disabled"
helpText="Helpful text"
errorText="Critical message"
error
value={value}
onChange={(e) => setValue(e.target.value)}
disabled
>
<option value="yesterday">Yesterday</option>
<option value="today">Today</option>
</Select>
Pageβ
π¨ Breaking Changes π¨
PageActionis nowPageHeaderActionPageTitleis nowPageHeaderTitle
π New Features π
PageHeaderTopcompositePageHeaderBottomcompositePageHeaderButtoncomposite that should be used in place of theButtoncomponent within thePageHeaderActionsPageHeaderMenuButtoncomposite that should be used in place of theMenuButtoncomponent within thePageHeaderActionsPageHeaderTagswrapper that should be used within thePageHeaderTitlecomponentPageHeaderTagcomposite that should be used within thePageHeaderTagscomponent
Beforeβ
import {
Page,
PageHeader,
PageTitle,
PageActions,
PageContent,
} from '@vtex/admin-ui'
function WithSearch() {
const view = useDataViewState()
const search = useSearchState()
const searchedItems = searchLogic()
const grid = gridState()
return (
<Page>
<PageHeader onPopNavigation={() => alert('should go back')}>
<PageTitle>Page Title</PageTitle>
<PageActions>
<Button variant="tertiary">Tertiary Action</Button>
<Button variant="secondary">Secondary Action</Button>
<Button>Primary Action</Button>
</PageActions>
</PageHeader>
<PageContent>
<DataView state={view}>
<DataViewControls>
<Search id="search" placeholder="Search" state={search} />
</DataViewControls>
<DataGrid state={grid} />
</DataView>
</PageContent>
</Page>
)
}
Afterβ
import {
Page,
PageHeader,
PageHeaderTop,
PageHeaderTitle,
PageHeaderTags,
PageHeaderTag,
PageHeaderActions,
PageHeaderButton,
PageHeaderMenuButton,
PageHeaderBottom,
PageContent,
} from '@vtex/admin-ui'
function Example() {
const view = useDataViewState()
const search = useSearchState()
const tabs = useTabState()
const state = useMenuState()
const searchedItems = searchLogic()
const table = tableData()
return (
<Page>
<PageHeader onPopNavigation={() => alert('should go back')}>
<PageHeaderTop>
<PageHeaderTitle>
Product #123{' '}
<PageHeaderTags>
<PageHeaderTag label="Short text" />
</PageHeaderTags>
</PageHeaderTitle>
<PageHeaderActions>
<PageHeaderButton>Create</PageHeaderButton>
<PageHeaderMenuButton state={state} />
<Menu state={state} aria-label="actions">
<MenuItem label="Create" icon={<IconPlus />} />
<MenuItem label="Edit" icon={<IconPencil />} />
</Menu>
</PageHeaderActions>
</PageHeaderTop>
<PageHeaderBottom>
<TabList state={tabs}>
<Tab id="1">Label</Tab>
<Tab id="2">Label</Tab>
<Tab id="3">Label</Tab>
</TabList>
</PageHeaderBottom>
</PageHeader>
<PageContent>
<DataView state={view}>
<DataViewControls>
<Search id="search" placeholder="Search" state={search} />
</DataViewControls>
<Table state={table} />
</DataView>
</PageContent>
</Page>
)
}
Replace Emotion with Stitchesβ
π¨ Breaking Changes π¨
The createSystem function doesn't receive the key and experimentalEmotionOptions properties anymore.
Before
const [SystemProvider, emotion] = createSystem({ key: 'app-key' })
After
const [SystemProvider] = createSystem()
Filtersβ
β οΈ All filter components are still experimental. Check the guidelines for experimental components.
π New components π
FilterSearcha filter with option searching. You can check the usage details on the documentation.FilterMultipleSearcha filter with option searching that allows selection of more than one item. You can check the usage details on the documentation.
Deprecate admin-ui-formikβ
The admin-ui-formik library is deprecated and soon will no longer be maintained by the admin-ui team. However, weβve implemented a solution on top of React Hook Form that you can use to replace the approach using Formik. For detailed info, you can visit this link: Form | Admin UI
Motivationβ
- We received reports about the Formik lib having performance issues
- Evolving the Formik components was difficult because it uses a different approach from admin-ui to handle the states.
- The new solution is easier to maintain and evolve since itβs a hook-based library
Tooltipβ
π¨ Breaking Changes π¨
Below you can see what are the breaking changes in this version, but you should also check the documentation to look for new features.
- The
labelprops was renamed totext.
New Features
- The Tooltip component can be used standalone.
- Added bleedX and bleedY props to trespass the parent element padding.
before
import { Tooltip } from '@vtex/admin-ui'
function Example() {
return (
<Tooltip label="Tooltip Label" placement="right">
<Button icon={<IconCopySimple />} aria-label="Example button" />
</Tooltip>
)
}
after
import { Tooltip } from '@vtex/admin-ui'
function Example() {
return <Tooltip text="Tooltip text" />
// Or
return (
<Tooltip text="Copy files">
<Button icon={<IconCopySimple />} variant="tertiary" />
</Tooltip>
)
}
TextAreaβ
π¨ Breaking Changes π¨
helperTextprop is nowhelpTextcharLimitis nowmaxLengthcriticalTextis nowerrorTexttonehas been removed and you can use the booleanerrorto indicate an error state
Before
import { TextArea } from '@vtex/admin-ui'
function Example() {
return (
<TextArea
label="With Error, help and counter"
tone={'critical'}
helperText="help text"
criticalText="Error text"
charLimit={120}
/>
)
}
After
import { TextArea } from '@vtex/admin-ui'
function Example() {
return (
<TextArea
label="With Error, help and counter"
errorText="Error text"
helpText="help text"
maxLength={120}
error
/>
)
}
