Permalink
Browse files

fix(Table) allow empty labels

  • Loading branch information...
mosinve authored and pi0 committed Feb 4, 2018
1 parent 9c57015 commit 5ee0923501e01d63881c2e0dfe3df4b7b3513123
Showing with 3 additions and 4 deletions.
  1. +1 −1 src/components/table/README.md
  2. +2 −3 src/components/table/table.js
@@ -264,7 +264,7 @@ The following field properties are recognized:
| Property | Type | Description
| ---------| ---- | -----------
| `key` | String | The key for selecting data from the record in the items array. Required when passing the props `fields` an array of objects.
| `label` | String | Appears in the columns table header (and footer if `foot-clone` is set). Defaults to the field's key (in humanized format) if not provided.
| `label` | String | Appears in the columns table header (and footer if `foot-clone` is set). Defaults to the field's key (in humanized format) if not provided. It's possible to use empty labels by assigning an empty string `""`
| `class` | String or Array | Class name (or array of class names) to add to `<th>` **and** `<td>` in the column.
| `formatter` | String or Function | A formatter callback function, can be used instead of (or in conjunction with) slots for real table fields (i.e. fields, that have corresponding data at items array). Refer to [**Custom Data Rendering**](#custom-data-rendering) for more details.
| `sortable` | Boolean | Enable sorting on this column. Refer to the [**Sorting**](#sorting) Section for more details.
@@ -1,5 +1,4 @@
import startCase from 'lodash.startcase'
import looseEqual from '../../utils/loose-equal'
import stableSort from '../../utils/stable-sort'
import KeyCodes from '../../utils/key-codes'
@@ -763,12 +762,12 @@ export default {
fields.push({ key: k, label: startCase(k) })
})
}
// Ensure we have a unique array of fields and that they have labels
// Ensure we have a unique array of fields and that they have String labels
const memo = {}
return fields.filter(f => {
if (!memo[f.key]) {
memo[f.key] = true
f.label = f.label || startCase(f.key)
f.label = typeof f.label === 'string' ? f.label : startCase(f.key)
return true
}
return false

0 comments on commit 5ee0923

Please sign in to comment.