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
Menu
was removed. - The prop
hideOnClick
was removed. The menu is closed on item click. MenuList
was renamed toMenu
.- The state needs to be passed to
Menu
andMenuButton
. MenuButton
has now alabel
prop to set its text.MenuButton
hasIconDotsThreeVertical
as the default icon, but if you pass a customlabel
the icon changes toIconCaretDown/Up
.MenuButton
has thelabelHidden
prop to hide its own label. In this case the icon is alwaysIconDotsThreeVertical
.MenuItem
has now alabel
property to set its text.MenuItem
has now aboolean
prop calledcritical
to 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
DataGrid
and all its references was renamed toTable
. - Remove the
density
prop from table. Now, the minimum row height is44px
and it grows depending on the content of its cells.
New Features
Create a
text
resolver to render a text and an optional description just below it. You can read more about it in the resolver section under theCode
tab.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
icon
andhandleDelete
properties were removed. - The
size
property now acceptsnormal
andlarge
, instead ofsmall
andregular
.
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
, andsticky
properties were removed. - The
fluid
behavior was incorporated as default for it. - Each variant has its own default icon now.
- The
tone
prop 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
tone
andcriticalText
, and now we useerror
anderrorText
. helperText
now ishelpText
- The placeholder is internationalized and it always shows
Select...
. tone
andcriticalText
doesn'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 π¨
PageAction
is nowPageHeaderAction
PageTitle
is nowPageHeaderTitle
π New Features π
PageHeaderTop
compositePageHeaderBottom
compositePageHeaderButton
composite that should be used in place of theButton
component within thePageHeaderActions
PageHeaderMenuButton
composite that should be used in place of theMenuButton
component within thePageHeaderActions
PageHeaderTags
wrapper that should be used within thePageHeaderTitle
componentPageHeaderTag
composite that should be used within thePageHeaderTags
component
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 π
FilterSearch
a filter with option searching. You can check the usage details on the documentation.FilterMultipleSearch
a 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
label
props 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 π¨
helperText
prop is nowhelpText
charLimit
is nowmaxLength
criticalText
is nowerrorText
tone
has been removed and you can use the booleanerror
to 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
/>
)
}