
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
@swrve/sortable-table
Advanced tools
The sortable table component V2 is designed to allow for the easy display of data within a sortable table, with the maximum amount of flexibility in terms of styling and the choice of component you use to render the cell data. This is achieved with the use of render props with sensible defaults.
If you just need to display data with standard string sorting you just need to pass the data and a cols array, with determines the cols to display and the order they are displayed.
<SortableTable
cols={['name', 'age', 'createAt']}
rows={[
{ id: '1', name: 'a', age: '30', createAt: '2017-11-01T03:01:00.000-08:00' },
{ id: '2', name: 'd', age: '32', createAt: '2017-10-01T03:01:00.000-08:00' },
{ id: '3', name: 'g', age: '54', createAt: '2017-09-01T03:01:00.000-08:00' },
{ id: '4', name: 'j', age: '23', createAt: '2017-05-01T03:01:00.000-08:00' }
]}
/>
If you require controls, custom rendering and styling of the cells you can use the render props to achieve this.
Render Props
render prop | description |
---|---|
renderHeader(value, { sortBy, order }) | This customises all the Header cells |
renderCell(defaultSchemaRender(), { id, key } ) | This customises all the value cells. |
render(value, { id, key, sortBy, order })) | The schema object also supports a render prop for per col customising. |
Schema
The schema allows you to attach metadata to the individual cells in the table, the schema render Props is very useful for adding input components to a cells.
Schema props | description |
---|---|
label | The header label for a column |
sortType | How to sort, string, number, date, boolean |
render | A per cell render function |
<SortableTable
renderCell={value => <div className="text-red font-mono">{value}</div>}
cols={['name', 'age', 'createdAt', 'selected']}
rows={[
{ id: '1', name: 'a', age: '30', createAt: '2017-11-01T03:01:00.000-08:00' },
{ id: '2', name: 'd', age: '32', createAt: '2017-10-01T03:01:00.000-08:00' },
{ id: '3', name: 'g', age: '54', createAt: '2017-09-01T03:01:00.000-08:00' },
{ id: '4', name: 'j', age: '23', createAt: '2017-05-01T03:01:00.000-08:00' }
]}
schema={{
id: { label: 'id' },
name: { label: 'Name' },
age: {
label: 'Age',
sortType: 'number',
render: value => {
if (value < '32') {
return (
<div>
<Button theme="secondary">Save {`${value} years`}</Button>
</div>
)
}
return (
<div>
<Button theme="primary">Save {`${value} years`}</Button>
</div>
)
}
},
createdAt: {
label: 'Created',
sortType: 'date',
render: (value, id, key) => <DateRenderer value={value} />
},
selected: {
label: 'Selected',
sortType: 'boolean',
render: (value, id, key) => (
<input
type="checkbox"
checked={value}
onChange={e => console.log(value, id, key)}
name="name"
/>
)
}
}}
/>
If the props 'order' or 'sortBy' are passed in as props these props take precedent over the local state versions. This means that the sortable table can be used as a controlled or a uncontrolled component.
undocumented - Coming soon
FAQs
A complex sortable table component
The npm package @swrve/sortable-table receives a total of 184 weekly downloads. As such, @swrve/sortable-table popularity was classified as not popular.
We found that @swrve/sortable-table demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.