ember-headless-table@1.2.0
Minor Changes
-
#58
f885ebbThanks @NullVoxPopuli! - New Metadata plugin, for allowing arbitrary data to be stored for each column as well as the whole table.
This can be useful eliminating prop-drilling in a UI Table implementation consuming the
headlessTable.For example, setting up the table can be done like:
import { headlessTable } from 'ember-headless-table'; class Example { /* ... */ table = headlessTable(this, { columns: () => [ { name: 'A', key: 'A' }, { name: 'B', key: 'B', pluginOptions: [ Metadata.forColumn(() => ({ isBulkSelectable: false, })), ], }, { name: 'D', key: 'D', pluginOptions: [Metadata.forColumn(() => ({ isRad: this.dRed }))], }, ], data: () => DATA, plugins: [ Metadata.with(() => ({ onBulkSelectionChange: (...args) => this.doSomething(...args), })), ], }); }
To allow "bulk selection" behaviors to be integrated into how the Table is rendered --
which for fancier tables, my span multiple components.For example: rows may be their own component
// Two helpers are provided for accessing your Metadata import { forColumn /*, forTable */ } from 'ember-headless-table/plugins/metadata'; const isBulkSelectable = (column) => forColumn(column, 'isBulkSelectable'); export const Row = <template> <tr> {{#each @table.columns as |column|}} {{#if (isBulkSelectable column)}} ... render some checkbox UI ... {{else}} <td> {{column.getValueForRow @datum}} </td> {{/if}} {{/each}} </tr> </template>;
-
#66
3075a5cThanks @NullVoxPopuli! - Add a new API for the column-reordering plugin that allows for
managing column order independently of the table's column order,
for example, in a configuration UI / preview, one may want to
see how their changes will look before applying them to the table.To use this new API, there are two relevant imports:
import { ColumnOrder, setColumnOrder, } from 'ember-headless-table/plugins/column-reordering';
To manage the "preview column order",
you'll want to instantiate theColumnOrderclass,
and then once your changes are done, callsetColumnOrderand pass
both the table and theColumnOrderinstance:class Demo { @tracked pendingColumnOrder; changeColumnOrder = () => { this.pendingColumnOrder = new ColumnOrder({ columns: () => this.columns, }); }; handleReconfigure = () => { setColumnOrder(this.table, this.pendingColumnOrder); this.pendingColumnOrder = null; }; }
In this example, when working with
this.pendingColumnOrder, you may use
familiar "moveLeft" and "moveRight" behaviors,
Patch Changes
-
#63
ecb68ffThanks @NullVoxPopuli! - Previously, ember-headless-table's releases were managed by semantic-release.
Now, they are managed by changesets, which is a bit more manual, but has far better
monorepo support and allows catering to humans when it comes to changelogs. -
#61
0356997Thanks @NullVoxPopuli! - Fixes the issue reported in #60
Where the column reordering and visibility plugins were not integrating well together.
In short, moving column, then hiding that same column, then moving a column "over the gap"
between the columns resulted in all column reordering no longer working.
Using both of the plugins together should now work as intuitively expected.
Features
- plugin, resizing: add helper for knowing if a column has a resize handle (f525f50)