Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@unicorns/data-table
Advanced tools
This is a vue2 datatable with support for sortable columns, filtering and searching. It is purely implemented with divs
(no tables) and is mobile-first.
npm install @unicorns/datatable --save
// In your vue component
<template>
<div>
<data-table :options="tableOptions" :dataset="dataset"></data-table>
</div>
</template>
<script>
import DataTable from '@unicorns/data-table'
export default {
components: {
DataTable
},
data(){
return {
tableOptions: {...},
dataset: [{...}, {...}, {...}, ...]
}
}
}
</script>
The component accepts only two props
options
- A configuration options object, described in details in the next sectiondataset
- An array of data items to be rendered. The data table expects each item in the array to be an object, with each key representing a table column. If your data set consists of simple values like strings and numbers, you can use a mapping function to convert them to objects.The options
prop is an object with the following props
fields
- an array of configs for each table column. Each config has the following properties
header
- Boolean. Determines if the column has a header or notfield
- The value key for this field in the data sets. Use dot syntax to denote nested propertiesname
- Table header labeltype
- Possible values are text
, currency
, number
, boolean
, component
, count
(count of array items), image
, datetime
, date
, time
or custom
. Additional options maybe required depending on the type selected hereimage
- Image url if type is image
no
- What to render if type
is boolean and field value is false
yes
- What to render if type
is boolean and field value is true
component
- component if type is component. It can be an object, a string or function that returns a component. The function is called with the data objectprops
- props for field type component. It is a function which receives the row data and returns an objectevents
- an object with event names and handlers. Only required if field type is componentsymbol
- Currency symbol if type is currencyvalue
- value if type is custom. Can be a function that returns a value or a literal valuesecondary
- boolean value determines if column is shown on small screens or notgrow
- flex grow css propertyconfig
- Has the following properties
search
- search configuration
enabled
- true or false. Disable or enable searchplaceholder
- Search box placeholderterm
- search v-modelfiltering
- Configuration for filtering
enabled
- Boolean, whether filtering is enabled or notfilters
- An array of filters
type
- Filter type. Can be tabbed
, checkbox
, or dropdown
tabs
- An array of tab filters. Only required if type
is tabbed
type
- Tabbed filter type. Can be date
or range
field
- Field to filtervalue
- Initial value of checkbox or dropdown filterplaceholder
- Dropdown filter placeholderoptions
- An array of options for dropdown filters. Can be strings or objects with label
and value
keyslinking
- Configuration for converting a whole table row into a link
enabled
- True or false to enable/disable linkinglink
- A function called with row data and returns a router-link :to
prop valuecontrols
- An array of configurations for call-to-actions for each row.
type
- Can be link
or component
href
- a callback function to return link configuration if type is link. Its called with the data for that rowlabel
- label if type is linkprops
- Either a callback function or object if type is component
events
- Events config if type is component dataset: [
{
id: 1,
name: 'Jon Doe',
date_of_birth: '01-01-1970',
role: 'admin',
active: true
},
{
id: 2,
name: 'Jane Doe',
date_of_birth: '01-01-1971',
role: 'editor',
active: false
},
{
id: 3,
name: 'Jane Doe',
date_of_birth: '01-01-1971',
role: 'manager',
active: true
},
],
options: {
fields: [
{
field: 'name',
name: 'Name',
type: 'text',
header: true
},
{
field: 'date_of_birth',
name: 'Birthday',
type: 'date',
header: true
},
{
field: 'role',
name: 'Role',
type: 'text',
header: true
},
{
field: 'active',
name: 'Status',
type: 'boolean',
header: true,
yes: 'Active',
no: 'Disabled'
}
],
config: {
filtering: {
enabled: true,
filters: [
{
type: 'dropdown',
field: 'role'
options: [
{label: 'Admin', value: 'admin'},
{label: 'Manager', value: 'manager'},
{label: 'Editor', value: 'editor'}
]
},
{
type: 'checkbox',
field: 'active',
value: true
},
{
type: 'tabbed',
tabs: [
{type: 'date'}
]
}
]
},
controls: [
{
type: 'link',
label: 'View',
href: (user) => {
return {name: 'ViewUserProfile', props: {userId: user.id}}
}
},
{
type: 'component',
component: 'DeleteUserDialog',
props: (user) => {
return {
userId: user.id,
name: user.name
}
},
events: {
success: () => {
//code to reload users list go here
},
error: () => {
//show an error message here
}
}
}
]
}
}
You can set a basic theme on the datatable.
It uses CSS modules and variables and a little bit of upfront processing to override the included defaults.
To pass in the theme you now need to Vue.use(DataTable)
You can also add custom assets for dropdowns, checkboxes, etc.
// In the host application
import DataTable from '@unicorns/datatable'
// This example will override these theme variables.
Vue.use(DataTable, {
theme: {
primary: '#DAB',
secondary: '#343',
padding: '1em',
gap: true, // adds a gap between the filtering and the table
rowHeight: '65px'
},
// you can also add custom assets
assets: {
dropdown: 'url(data:image/svg+xml;utf8,<svg><path stroke="#000" d="m2,2 15,15m0-15-15,15"/></svg>)'
}
})
v1.x is now deprecated and no longer supported.
v2.x is the latest version and is not backwards compatible with applications currently using v1.x.
Ensure you test your application sufficiently before updating the version from 1.x to 2.x
FAQs
Vue component for rendering data-tables
We found that @unicorns/data-table demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.