@getaster/elements
v0.5.3
Published
Browser-native grids, forms and workspace controls backed by shared Aster data models.
Maintainers
Readme
@getaster/elements
Browser-native controls for metadata-driven enterprise applications: grids,
forms, pickers, filters, dashboards and workspaces. Controls share records and
edit state through @getaster/data and use CSS for layout and theming.
Preview controls are published separately in @getaster/elements-preview.
Install
npm install @getaster/data @getaster/elementsUse a modern browser with custom elements and ES modules, plus a bundler that
resolves npm modules and CSS imports. The package ships TypeScript declarations.
Its main entry registers browser elements and requires a DOM; use
@getaster/data for headless work. Package tooling requires Node 22 or later.
@getaster/elements/styles/theme-lamplight.css and
@getaster/elements/styles/theme-harbour.css each compose the base primitives,
element styles and one identity. Lamplight's entry also loads the packaged
Bricolage Grotesque and Fraunces Latin faces, with metric-matched local
fallbacks, from @getaster/elements/styles/fonts.css. Import one composed
entry, not the parts.
Connect a grid
With an OData service exposing a Projects entity set and JSON CSDL metadata:
import { DataContext, fetchTransport } from '@getaster/data';
import { Grid } from '@getaster/elements';
import '@getaster/elements/styles/aster-ui.css';
const ctx = await DataContext.connect(
fetchTransport('https://your-service.example/odata/')
);
const grid = new Grid();
grid.ctx = ctx;
grid.set = 'Projects';
grid.label = 'Projects';
grid.style.height = '24rem';
document.body.append(grid);Replace the endpoint and entity set with your own. Give a virtualized grid a bounded height, and supply your application's theme tokens as described in the theming guide. When the view closes, remove the element; separately owned data models remain the host's responsibility.
Compose an application
Use a shared data context to connect a grid, form and selection. JavaScript and YAML composition support reusable workspace definitions. Controls provide keyboard interaction and semantic markup; application labels, focus flow and accessibility still need testing in the completed application.
The package depends on Aster's data core, Lit HTML and Preact signals. Keep one
compatible copy of each shared runtime in your build. The YAML compiler is a
separate subpath, @getaster/elements/yaml, and is the only entry that loads
the yaml parser; a browser that imports a compiled definition never loads it.
The optional ECharts adapter accepts an application-supplied runtime; ECharts,
showcase data and the mock service are not bundled into this package. The
Lamplight font files and their SIL Open Font License texts are included under
styles/fonts/. There are no install scripts.
Documentation and support
License
Apache-2.0. See the included LICENSE and package-specific NOTICE.
Separately installed dependencies retain their own licenses.
Named model displays
bindFieldPresentations(ctx, model, set, registry, overrides?) binds separately
registered fieldPresentation renderers to model display: { renderer }
references. Give the returned presentation to Grid or Form and call dispose()
when the view closes. Registrations declare scalar dependencies through
defineCompositeRenderer(properties, callback, { dependencies }).
Compact related displays read their own permitted record through batched data
lookups. A missing dependency uses the model's plain displayField label or
“Unavailable”. Field and custom scalar type references use the existing field
callback context. Metadata never supplies executable code. See the formatted
values guide and the named displays showcase for complete examples.
