Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@react-md/list
Advanced tools
Create lists of content that can have optional supplementary icons, avatars, or images placed with the text.
npm install --save @react-md/list
It is also recommended to install the following packages as they normally work together well with lists:
npm install --save @react-md/theme \
@react-md/typography \
@react-md/divider \
@react-md/avatar \
@react-md/icon \
@react-md/media
You should check out the full documentation for live examples and more customization information, but an example usage is shown below.
import { render } from "react-dom";
import { Divider } from "@react-md/divider";
import { List, ListItem } from "@react-md/list";
import { FontIcon } from "@react-md/icon";
const App = () => (
<List>
<ListItem id="item-1">Item 1</ListItem>
<ListItem id="item-2" secondaryText="This is secondary text">
Item 2 Primary Text
</ListItem>
<ListItem id="item-3" disabled>
Item 3 Disabled
</ListItem>
<Divider />
<ListSubheader>Sub actions</ListSubheader>
<ListItem id="item-4" leftAddon={<FontIcon>close</FontIcon>}>
Close
</ListItem>
<ListItem
id="item-5"
leftAddon={
<Avatar
src="https://picsum.photos/40?random"
alt="A random image from https://picsum.photos"
/>
}
leftAddonType="avatar"
>
With Avatar
</ListItem>
</List>
);
render(<App />, document.getElementById("root"));
5.0.0 (2022-01-31)
Check out the v4 to v5 Migration Guide for more information around updating code to this major version.
This release focused on creating a new Menu
API that should hopefully make menus easier to use along with some other new features. The main difference is that the DropdownMenu
no longer accepts a list of items
that get converted to MenuItem
s behind the scenes. Instead, the children
of the DropdownMenu
should be all the MenuItem
components that should be used inside the menu. The main reason for this change is to make it easier to create reusable components for different actions within your app and no longer needed to disable the React eslint
rule around missing key
s.
Another notable change is that nested dropdown menus no longer require the DropdownMenuItem
component and instead the DropdownMenu
automatically renders as a <li>
if it appears as a child of another Menu
component.
Here's a quick example of migrating to the new DropdownMenu
API:
import type { ReactElement } from "react";
-import { DropdownMenu, DropdownMenuItem } from "@react-md/menu";
+import { DropdownMenu, MenuItem } from "@react-md/menu";
export default function Example(): ReactElement (
- <DropdownMenu
- id="example-dropdown-menu"
- items={[
- { onClick: () => console.log("Clicked Item 1"), children: "Item 1" },
- { onClick: () => console.log("Clicked Item 2"), children: "Item 2" },
- { onClick: () => console.log("Clicked Item 3"), children: "Item 3" },
- <DropdownMenuItem
- id="nested-dropdown-menu"
- items={["Subitem 1", "Subitem 2", "Subitem 3"]}
- >
- Submenu
- </DropdownMenuItem>,
- ]}
- >
- Dropdown
+ <DropdownMenu id="example-dropdown-menu" buttonChildren="Dropdown">
+ <MenuItem onClick={() => console.log("Clicked Item 1")}>Item 1</MenuItem>
+ <MenuItem onClick={() => console.log("Clicked Item 2")}>Item 2</MenuItem>
+ <MenuItem onClick={() => console.log("Clicked Item 3")}>Item 3</MenuItem>
+ <DropdownMenu
+ id="nested-dropdown-menu"
+ buttonChildren="Submenu"
+ >
+ <MenuItem>Subitem 1</MenuItem>
+ <MenuItem>Subitem 2</MenuItem>
+ <MenuItem>Subitem 3</MenuItem>
+ </DropdownMenu>
</DropdownMenu>
);
On top of the new API, two major new features have been integrated into this release:
Menus can now act like a browser's bookmark folder behavior where the user must click one of the dropdowns before all other menus become immediately visible on hover by using the new MenuBar
component. This also implements some new keyboard movement behavior matching the menubar spec.
If the first-click behavior is undesired, the MenuBar
also accepts a hoverTimeout
prop which can be set to 0
to make the menus appear immediately on hover or another time in milliseconds to wait before the "hover mode" behavior should begin.
Check out the Hoverable Menus demo for more information.
Since menus aren't always ideal for small viewports, the DropdownMenu
has been updated to conditionally rendering the Menu
within a Sheet
instead of being positioned relative to the Button
element. This feature is opt-in by either:
menuConfiguration={{ renderAsSheet: "phone" }}
on the Configuration
component from @react-md/layout
DropdownMenu
in the MenuConfigurationProvider
and adding a prop renderAsSheet="phone"
DropdownMenu
with the renderAsSheet="phone"
propThe Sheet
will default to rendering at the bottom of the viewport and have a max height that should allow the user to close the menu by clicking the overlay behind the sheet. These defaults can be configured with the sheetPosition
and sheetVerticalSize
props.
The Sheet
can also be configured to have an optional header and footer using the sheetHeader
and sheetFooter
props. If all else fails, the DropdownMenu
accepts sheetProps
which will be passed to the Sheet
component.
Check out the Mobile Action Sheets demo for more information.
TextArea
applies custom height style when resize="none"
(e77d939)disableEnterClick
in ListItem
(b5e8b69)useRefCache
returns non-mutable object (b696b72)overlayProps
to configure the dialog's overlay (cfc30f0)useVerticalDividerHeight
to support any HTMLElement (edd9287)TextFieldContainer
to optionally fill all space in flex containers (2c8e68c)FileInput
snapshots for new icon (f5e43fe)MenuBar
visibility for touch devices (1288be7)enableScrollLock
and disableScrollLock
utils (6a95734)next
from 12.0.7 to 12.0.9 (04749c6)create-react-app
examples to use v5.0.0 (f7850b8)react-md
major versions (78b7396)TextArea
(5361825)DEFAULT_HOVER_MODE_STICKY_EXIT_TIME
has been renamed to DEFAULT_HOVER_MODE_EXIT_TIME
.ArrowUp
or ArrowDown
keys.DropdownMenu
component no longer accepts a list of items
and instead the children
should be the MenuItem
components.DropdownMenu
component no longer supports the menuRenderer
and itemRenderer
props. Instead, there is built-in support for conditionally rendering as a Sheet
component using the renderAsSheet
prop.DropdownMenu
component now requires a parent AppSizeListener
because of the conditional Sheet
rendering functionality. This might require updating your tests to either use the Configuration
component from @react-md/layout
(recommended) or adding the AppSizeListener
to tests that include DropdownMenu
s.DropdownMenuItem
component is no longer required for nested dropdown menus and is an "internal" component instead that shouldn't really be used.exitVisibilityDelay
always defaults to DEFAULT_HOVER_MODE_EXIT_TIME
.MenuItemSeparator
now renders as an <li>
instead of an <hr>
or <div>
.useContextMenu
now returns an object instead of an ordered list.useHoverMode
hook no longer accepts an HTMLElement
generic and instead the event handlers will automatically infer the HTMLElement
based on usage.useHoverMode
hook no longer returns stickyHandlers
and instead returns hoverHandlers
that only include onMouseEnter
and onMouseLeave
. The handlers
that are returned now include onClick
, onMouseEnter
, and onMouseLeave
. This was kind of what the stickyHandlers
was before. In addition, clicking an element no longer disabled the hover mode behavior.HoverModeOnlyOptions
, HoverModeOnlyReturnValue
MenuItem
components requires the <MenuKeyboardFocusProvider>
to be mounted as a parent component which might affect tests. This will not break anything if you are using the DropdownMenu
or Menu
components.FAQs
This package is used to create lists with the material design specs.
The npm package @react-md/list receives a total of 955 weekly downloads. As such, @react-md/list popularity was classified as not popular.
We found that @react-md/list demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.