How glromeo/sleek-grid works
1. Project shape
This is a browser-first, dependency-free JavaScript grid library. The core library lives under lib/ and is packaged as ESM plus an IIFE build for direct browser use. The rest of the repo is supporting material: demos, docs, benchmarks, and browser-based specs.
2. Primary entry points
lib/index.mjs and lib/sleek-grid.mjs are the main library entry points. lib/sleek-grid.d.ts provides the TypeScript surface area. The iife/ bundle is the distributable format for <script>-style consumption.
3. Core architecture
The grid is split into a small set of controllers and renderable components:
- row-controller.mjs manages row state and row lifecycle.
- column-controller.mjs manages column definitions, sizing, and ordering.
- components/ contains the DOM-facing pieces: root, grid-area, header-row, and grid-row.
This separation suggests the controllers own state and the components focus on rendering and interaction.
4. Rendering model
The library is explicitly virtualized, so it does not render all rows at once. The grid-area and grid-row components likely form the scrollable viewport and row renderer, while header-row handles column headers. This is the central performance boundary: data can be large, but DOM work stays bounded by visible content.
5. Feature layer
lib/features/ contains interaction behaviors that sit on top of the core rendering model:
- column-dnd.mjs and row-dnd.mjs for drag-and-drop reordering.
- column-resize.mjs, row-resize.mjs, and header-resize.mjs for resizing.
- highlight.mjs for selection/focus/hover-style feedback.
These look like modular add-ons rather than baked-in logic, which makes the interaction layer a distinct subsystem.
6. API and utilities boundary
lib/utils/grid-api.mjs is likely the imperative/public API boundary used by consumers and internal modules to manipulate grid state. lib/utils/nano-memoize.mjs and lib/utils/index.mjs support internal performance and helper logic. This is where programmatic access meets the render/controller layer.
7. Styling and iconography
lib/styles/sleek.mjs and lib/styles/static.mjs separate dynamic grid styling from more static presentation rules. lib/icons.mjs indicates the grid ships its own UI affordances rather than depending on external icon sets. The presence of construct-style-sheets-polyfill.js in demo/public files suggests the library may use constructable stylesheets when available, with a fallback for older browsers.
8. Consumer-facing samples
public/ contains runnable examples such as index.html, vanilla.html, and react.html, plus mock-data.json. docs/demo.html and the docs/demo/ assets mirror the demo experience for published documentation. This repo is not only the source of the library, but also its integration showcase.
9. Documentation and publishing
docs/ appears to be GitHub Pages / static docs content, driven by _config.yml and index.md. .github/workflows/npm-publish.yml indicates automated packaging/publishing to npm. So the release flow is: source in lib/ → bundle outputs in iife/ and probably npm package artifacts → docs/demo published separately.
10. Testing architecture
spec/ contains browser-based Jasmine tests (spec/support/jasmine-browser.json, spec/runner.html) plus a small local test harness in spec/lib/. The tests run in the browser, which fits a DOM-heavy library where interaction and layout behavior matter more than pure unit execution.
11. Benchmarking and performance validation
benchmark/ includes comparison pages such as ag-grid.html and scripts like benchmark.js. This indicates performance is a first-class concern, and the benchmark layer is used to validate the virtualization and rendering strategy against alternative approaches.
12. Likely runtime boundary
The grid runs in the browser DOM, not on a server. External dependencies are intentionally absent, so all state management, rendering, and interactions are implemented in-repo. The main architectural boundary is between consumer-provided data/configuration and internal DOM virtualization/rendering.
13. How to draw the diagram
A good architecture diagram should center on:
- Consumer app / demo pages on the outside
- Public grid API and entry module
- Controllers for rows and columns
- Virtualized root/grid-area/grid-row/header-row rendering components
- Feature modules layered onto the core
- Styles and icons as supporting assets
- Separate docs, tests, and benchmark pipelines around the core library
14. Overall picture
In short, this is a modular, high-performance grid engine for the browser: a thin public API feeds state into row/column controllers, which drive a virtualized DOM component tree, with interaction features attached as separate modules and browser demos/tests/benchmarks validating the result.
Main entry points: index.mjs Entry · column-controller.mjs Columns · grid-area.mjs Grid area · row-controller.mjs Rows
Components 23
Core library
Main ESM grid engine, rendering components, features, and styling.
- Entry · Primary library entry module.
lib/index.mjs - Bundle · Main distributable module surface.
lib/sleek-grid.mjs - Types · TypeScript declarations for consumers.
lib/sleek-grid.d.ts - Rows · Owns row state, lifecycle, and virtualization-driven row management.
lib/row-controller.mjs - Columns · Manages column definitions, sizing, and ordering.
lib/column-controller.mjs - Root · Top-level DOM shell for the grid.
lib/components/root.mjs - Grid area · Scrollable viewport and virtualization boundary.
lib/components/grid-area.mjs - Header row · Renders column headers and header interactions.
lib/components/header-row.mjs - Grid row · Renderable row view for visible data.
lib/components/grid-row.mjs - Col resize · Column drag handles and width changes.
lib/features/column-resize.mjs - Row resize · Row resizing interactions.
lib/features/row-resize.mjs - Header resize · Header-specific resize behavior.
lib/features/header-resize.mjs - Col drag · Column reorder by drag-and-drop.
lib/features/column-dnd.mjs - Row drag · Row reorder by drag-and-drop.
lib/features/row-dnd.mjs - Highlight · Selection, focus, and hover feedback.
lib/features/highlight.mjs - Grid API · Imperative boundary for consumers and internal modules.
lib/utils/grid-api.mjs - Styles · Dynamic and static grid styling.
lib/styles/sleek.mjs - Icons · Built-in iconography for grid affordances.
lib/icons.mjs
Delivery
Browser package outputs and publishable bundles.
- IIFE build · Script-tag distributable build.
iife/sleek-grid.js
Examples
Runnable demos, docs, and browser-facing sample pages.
Validation
Browser specs and performance benchmarks.
- Browser specs · Browser-based behavioral tests and runner.
spec/runner.html - Benchmarks · Performance comparison and workload validation pages.
benchmark/index.html
Connections 26
- Entry → Bundle: re-exports · Primary module surface is exposed through the packaged bundle.
- Entry → Rows: uses · Entry wiring connects row state management into the grid.
- Entry → Columns: uses · Entry wiring connects column state management into the grid.
- Entry → Root: mounts · Creates the top-level shell component.
- Root → Grid area: contains · Root composes the scrollable viewport.
- Grid area → Header row: positions · Viewport coordinates header rendering with visible content.
- Grid area → Grid row: renders · Viewport renders only visible rows.
- Rows → Grid row: drives · Row controller feeds visible row state to row components.
- Columns → Header row: drives · Column state determines header structure and ordering.
- Columns → Grid row: sizes · Column sizing affects row cell layout.
- Header row → Col resize: enables · Header wires column resize behavior.
- Header row → Header resize: enables · Header-specific resizing behavior sits on the header layer.
- Grid row → Row resize: enables · Row rendering layer supports resizing interactions.
- Columns → Col drag: supports · Column ordering changes are handled as a feature on top of column state.
- Rows → Row drag: supports · Row ordering changes are handled as a feature on top of row state.
- Grid area → Highlight: overlays · Highlight feedback is layered onto the virtualized viewport.
- Entry → Grid API: exposes · Public imperative API boundary.
- Grid API → Rows: controls · API operations manipulate row state.
- Grid API → Columns: controls · API operations manipulate column state.
- Entry → Styles: applies · Core library attaches grid styling.
- Entry → Icons: uses · Core library ships internal icon assets.
- IIFE build → Entry: packages · Browser bundle packages the main library surface.
- Docs site → IIFE build: consumes · Documentation demo loads the distributable build.
- Demo app → Entry: consumes · Sample pages exercise the library in the browser.
- Browser specs → Entry: verifies · Browser specs exercise the library entry surface.
- Benchmarks → Grid area: measures · Benchmarks stress the virtualization and rendering boundary.