npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ag-grid-svelte5-extended

v0.0.13

Published

AG-Grid wrapper component for Svelte 5 (runes) with support for Svelte components as cell renderers, reactive data updates, and enhanced performance

Downloads

579

Readme

AG-Grid for Svelte 5

Demo page: https://bn-l.github.io/ag-grid-svelte5-extended. The cell with the thermometer icon is a svelte component.

This builds on JohnMaher1/ag-grid-svelte5 with some additional features.

To use to use ag-grid with a framework you need to create an adaptor that follows this interface: IFrameworkOverrides. Ag-grid give no documentation on building a framework integration. This is the adaptor code for svelte 5: src/lib/SvelteFrameworkOverrides.svelte.ts

Features

  • Fully svelte 5
  • Put any svelte component in a grid cell (see: cell renderers for context)
  • Reactive data updates (based on $state, just update the data prop supplied to the table)
  • Cell editing (nothing extra to do, will just work like updating the data).
  • Reactive grid options.

Note

Always provide a getRowId function in initialOptions for optimal performance

Installation

npm install ag-grid-svelte5-extended

AgGrid Component

| Prop | Type | Required | Description | |------|------|----------|-------------| | initialOptions | GridOptions<T> | Yes | Initial AG-Grid options | | updateOptions | Omit<GridOptions<T>, 'getRowId'> | No | Options to update after initialization | | rowData | T[] | No | Array of data to display | | modules | Module[] | No | AG-Grid modules to include | | gridClass | string | No | CSS class for grid (defaults to "ag-theme-quartz") | | quickFilterText | string | No | Text for quick filtering | | sizeColumnsToFit | boolean | No | Auto-size columns (default: true) | | theme | GridTheme | No | AG-Grid theme object |

Usage

(See demo page source for more extended example)

<script lang="ts" >
    import { AgGrid } from "ag-grid-svelte5-extended";
    import { ClientSideRowModelModule } from "@ag-grid-community/client-side-row-model";
    import { themeQuartz } from "@ag-grid-community/theming";

    interface Person {
        id: string;
        name: string;
        age: number;
    }

    let rowData = $state<Person[]>([
        { id: "1", name: "John", age: 25 },
        { id: "2", name: "Jane", age: 30 },
    ]);

    const initialOptions = {
        columnDefs: [
            { field: "name" },
            { field: "age" }
        ],
        getRowId: (params) => params.data.id,
        theme: themeQuartz
    };

    const modules = [ClientSideRowModelModule];
</script>


<AgGrid { initialOptions } { rowData } { modules } />

makeSvelteCellRenderer helper function

A utility function to create AG-Grid cell renderers from Svelte components. Takes a svelte component and optionally the class for the container div. It's given ICellRendererParams as props (with the cell's value as the value prop)

function makeSvelteCellRenderer(
    Component: Component<ICellRendererParams>,
    containerDivClass?: string
): ICellRenderer

Usage

(See demo page source for more extended example)

CustomBoldCell.svelte:

    <div class="font-bold" > { value } </div>

    < script lang = "ts" >
        import type { ICellRendererParams } from "@ag-grid-community/core";
        let { value }: ICellRendererParams = $props();
    </script>

+page.svelte:

<script lang="ts" >
    import { makeSvelteCellRenderer } from "ag-grid-svelte5-extended";
    import CustomCell from "./CustomCell.svelte";

    const initialOptions = {
        columnDefs: [
            {
                field: "name",
                cellRenderer: makeSvelteCellRenderer(CustomCell)
            }
        ]
    };

    // etc
</script>