WarUI

<war-grid> custom element

GRID-A02-F03P0baselineShippedexperimental

Use the grid as a standards-based custom element with attributes, properties and DOM events.

Live example

Expected behavior

Attribute changes apply live. Removing the element disposes the grid. Re-appending restores it with its last property state. Events show up in the log.

Source

import { defineWarGrid } from '@warlockcode/warui-core';
defineWarGrid();
const el = document.createElement('war-grid');
el.setAttribute('theme', 'dark');
el.setAttribute('row-height', '32');
el.rowData = [{ id: 1, name: 'Product 1' }];
el.addEventListener('war-cell-click', (e) => console.log(e.detail));
document.body.append(el);

API reference

GRID-A02-F03 API
KindNameTypeDescription
FunctiondefineWarGrid—Registers <war-grid>. Safe to call twice.
Attributerow-height, theme, selection-mode—Simple options, kept in sync with properties.
Propertyconfig, rowData, api—Complex data and the headless grid.
Eventwar-cell-click, war-selection-change—Bubbling, composed CustomEvents.

Acceptance criteria

  • Attribute and property for the same option stay in sync, and the property wins on conflict (met)
  • disconnectedCallback releases resources, and connectedCallback re-initializes them (met)
  • Events bubble and are composed so they cross shadow boundaries (met)
  • Registering the element twice does not throw (met)