Active Table
website·Indexed 31 days ago
https://activetable.io/A framework-agnostic web component designed for an editable data table experience. It features a variety of column types, programmatic updates, and support for importing and exporting files in csv, xls, xlsx, ods, and txt formats. The API includes properties for table styling, pagination, filtering, and custom event handling.
What's inside Active Table
- Active Table is a cross-framework web component designed for creating highly customizable editable tables. It provides a comprehensive API to handle various data requirements, including categorical, numerical, and partial augmentation of data, allowing developers to implement complex editable data features quickly across different frameworks.
Overview of Active Table features
Active Table is a framework-agnostic table component designed for editable data experiences. Key capabilities include:
- Customizable Columns: Support for various column types with an API to create custom ones including custom sorting, validation, and selection options.
- Programmatic Updates: Ability to stream data and update cells programmatically without manual user input.
- Reactive Styling: Preconfigurable styling that reacts to text changes to improve user experience.
- Responsive Design: Built-in support for responsive layouts and style management.
Programmatically update cells in ActiveTable
ActiveTable allows developers to stream data and update cells programmatically, enabling the table to reflect real-time data changes without manual user input. This can be combined with reactive on-text change styling to enhance the user experience when values are updated via API or stream.Customize Active Table column types and behavior
Active Table provides a variety of built-in column types and an API that allows developers to create custom columns. Custom columns can include specialized logic for sorting, data validation, and selection options.Programmatically update cells and apply reactive styling
Active Table supports streaming data and updating cells programmatically to eliminate manual input. It also allows for the preconfiguration of reactive styling that triggers automatically when text changes occur.Use ActiveTable with Vanilla JavaScript
ActiveTable can be imported via CDN for Vanilla JS projects. It is recommended to set values via properties; attributes should be used as a fallback approach.Integrate ActiveTable with Next.js
For Next.js integrations, use theactive-table-reactpackage. Because the component relies on browser APIs, it must be lazy-loaded using Next'sdynamicextension to disable server-side rendering for that component.General ActiveTable event usage guidelines
ActiveTable events can be observed in two ways: by assigning a callback function to the element's property (e.g.,
tableElementRef.onRender = ...) or by listening for the corresponding custom DOM event fired from the element.Caveat: To avoid performance issues or infinite loops, avoid re-rendering the component when using event information to update the parent state.
Enable file import and export for Excel and ODS formats
Active Table supports importing and exporting files incsv,xls,xlsx,ods, andtxtformats. Whilecsvis supported natively, all other formats require thexlsxmodule to be available on the globalwindow.XLSXobject.Configure the xlsx module for Active Table
To enable support forxls,xlsx,ods, andtxtfiles, you must assign thexlsxmodule towindow.XLSX. Depending on your project setup, use one of the following methods:// 1. Standard import via npm import * as xlsx from "xlsx"; window.XLSX = xlsx; // 2. Dynamic import via npm import("xlsx").then((module) => { window.XLSX = module; }); // 3. Dynamic import from CDN import("https://cdn.sheetjs.com/xlsx-0.19.3/package/dist/xlsx.full.min.js").then((module) => { window.XLSX = module; }); // 4. Script tag (HTML) <script src="https://cdn.sheetjs.com/xlsx-0.19.3/package/dist/xlsx.full.min.js"></script> // 5. Programmatic script injection const script = document.createElement("script"); script.src = "https://cdn.sheetjs.com/xlsx-0.19.3/package/dist/xlsx.full.min.js"; document.body.appendChild(script);Install Active Table via npm
Install the standard Active Table component using the npm package manager.npm install active-tableDefine custom column sorting
Custom sorting is implemented via thesortingproperty in aColumnType. ProvideascendingFuncanddescendingFuncwhich follow the standard JavaScriptArray.sortcontract: return < 0 if the first element is smaller, 0 if equal, and > 0 if larger.<active-table customColumnTypes='[ { "name": "Custom type", "sorting": { "ascendingFunc": "(cellText1, cellText2) => Number(cellText1) - Number(cellText2)", "descendingFunc": "(cellText1, cellText2) => Number(cellText2) - Number(cellText1)" } }]' ></active-table>