@svgrid/grid 1.0.2 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +137 -39
- package/dist/GridFooter.svelte +164 -0
- package/dist/GridFooter.svelte.d.ts +29 -0
- package/dist/GridMenus.svelte +648 -0
- package/dist/GridMenus.svelte.d.ts +31 -0
- package/dist/SvGrid.controller.svelte.d.ts +472 -0
- package/dist/SvGrid.controller.svelte.js +1917 -0
- package/dist/SvGrid.css +2012 -0
- package/dist/SvGrid.helpers.d.ts +35 -0
- package/dist/SvGrid.helpers.js +160 -0
- package/dist/SvGrid.helpers.test.d.ts +1 -0
- package/dist/SvGrid.helpers.test.js +298 -0
- package/dist/SvGrid.svelte +2346 -8742
- package/dist/SvGrid.svelte.d.ts +4 -357
- package/dist/SvGrid.types.d.ts +523 -0
- package/dist/SvGrid.types.js +1 -0
- package/dist/SvGridChart.svelte +1060 -23
- package/dist/SvGridChart.svelte.d.ts +17 -0
- package/dist/aligned-grids.d.ts +6 -0
- package/dist/aligned-grids.js +84 -0
- package/dist/aligned-grids.test.d.ts +1 -0
- package/dist/aligned-grids.test.js +75 -0
- package/dist/build-api.coverage.test.d.ts +20 -0
- package/dist/build-api.coverage.test.js +505 -0
- package/dist/build-api.d.ts +5 -0
- package/dist/build-api.js +557 -0
- package/dist/cell-render.d.ts +15 -0
- package/dist/cell-render.js +246 -0
- package/dist/cell-render.test.d.ts +1 -0
- package/dist/cell-render.test.js +338 -0
- package/dist/cell-values.d.ts +28 -0
- package/dist/cell-values.js +89 -0
- package/dist/chart-export.test.d.ts +1 -0
- package/dist/chart-export.test.js +302 -0
- package/dist/chart.coverage.test.d.ts +1 -0
- package/dist/chart.coverage.test.js +748 -0
- package/dist/chart.d.ts +370 -3
- package/dist/chart.js +1135 -42
- package/dist/clipboard.d.ts +15 -0
- package/dist/clipboard.js +420 -0
- package/dist/clipboard.test.d.ts +1 -0
- package/dist/clipboard.test.js +700 -0
- package/dist/collaboration.coverage.test.d.ts +1 -0
- package/dist/collaboration.coverage.test.js +200 -0
- package/dist/column-groups.d.ts +19 -0
- package/dist/column-groups.js +62 -0
- package/dist/column-groups.test.d.ts +1 -0
- package/dist/column-groups.test.js +56 -0
- package/dist/column-types.d.ts +10 -0
- package/dist/column-types.js +63 -0
- package/dist/column-types.test.d.ts +1 -0
- package/dist/column-types.test.js +62 -0
- package/dist/columns.d.ts +30 -0
- package/dist/columns.js +277 -0
- package/dist/columns.test.d.ts +1 -0
- package/dist/columns.test.js +625 -0
- package/dist/core.d.ts +86 -1
- package/dist/css.d.ts +3 -0
- package/dist/editing.d.ts +31 -0
- package/dist/editing.js +529 -0
- package/dist/editing.test.d.ts +1 -0
- package/dist/editing.test.js +732 -0
- package/dist/editors/cell-editors.coverage.test.d.ts +1 -0
- package/dist/editors/cell-editors.coverage.test.js +139 -0
- package/dist/editors/cell-editors.d.ts +1 -1
- package/dist/facet-buckets.d.ts +13 -0
- package/dist/facet-buckets.js +54 -0
- package/dist/facet-buckets.test.d.ts +1 -0
- package/dist/facet-buckets.test.js +296 -0
- package/dist/features.d.ts +5 -0
- package/dist/features.js +30 -0
- package/dist/filter-operators.d.ts +16 -0
- package/dist/filter-operators.js +69 -0
- package/dist/filter-operators.test.d.ts +1 -0
- package/dist/filter-operators.test.js +135 -0
- package/dist/hyperformula-adapter.d.ts +82 -0
- package/dist/hyperformula-adapter.js +73 -0
- package/dist/hyperformula-adapter.test.d.ts +1 -0
- package/dist/hyperformula-adapter.test.js +205 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.js +8 -2
- package/dist/keyboard-handlers.coverage.test.d.ts +1 -0
- package/dist/keyboard-handlers.coverage.test.js +495 -0
- package/dist/keyboard-handlers.d.ts +7 -0
- package/dist/keyboard-handlers.js +202 -0
- package/dist/menus.d.ts +40 -0
- package/dist/menus.js +390 -0
- package/dist/menus.test.d.ts +1 -0
- package/dist/menus.test.js +560 -0
- package/dist/named-views.coverage.test.d.ts +1 -0
- package/dist/named-views.coverage.test.js +180 -0
- package/dist/named-views.d.ts +27 -0
- package/dist/named-views.js +39 -0
- package/dist/row-drag.d.ts +49 -0
- package/dist/row-drag.js +221 -0
- package/dist/row-drag.test.d.ts +1 -0
- package/dist/row-drag.test.js +142 -0
- package/dist/row-resize.d.ts +43 -0
- package/dist/row-resize.js +158 -0
- package/dist/row-resize.test.d.ts +1 -0
- package/dist/row-resize.test.js +329 -0
- package/dist/scroll-sync.d.ts +9 -0
- package/dist/scroll-sync.js +89 -0
- package/dist/scroll-sync.test.d.ts +1 -0
- package/dist/scroll-sync.test.js +290 -0
- package/dist/selection.d.ts +32 -0
- package/dist/selection.js +427 -0
- package/dist/selection.multi-range.test.d.ts +1 -0
- package/dist/selection.multi-range.test.js +55 -0
- package/dist/selection.test.d.ts +1 -0
- package/dist/selection.test.js +647 -0
- package/dist/server-data-source.coverage.test.d.ts +1 -0
- package/dist/server-data-source.coverage.test.js +154 -0
- package/dist/spreadsheet.d.ts +110 -0
- package/dist/spreadsheet.js +242 -0
- package/dist/spreadsheet.test.d.ts +1 -0
- package/dist/spreadsheet.test.js +446 -0
- package/dist/summaries.d.ts +12 -0
- package/dist/summaries.js +65 -0
- package/dist/sv-grid-scrollbar.js +13 -1
- package/dist/svgrid-wrapper.types.d.ts +31 -1
- package/dist/svgrid.behavior.test.js +20 -0
- package/dist/svgrid.comments-autocomplete.test.d.ts +1 -0
- package/dist/svgrid.comments-autocomplete.test.js +96 -0
- package/dist/svgrid.context-menu.test.d.ts +1 -0
- package/dist/svgrid.context-menu.test.js +102 -0
- package/dist/svgrid.interaction.test.js +31 -0
- package/dist/svgrid.new-features.wrapper.test.js +64 -6
- package/dist/svgrid.wrapper.test.js +27 -1
- package/dist/test-setup.js +9 -3
- package/dist/virtualization/column-virtualizer.d.ts +2 -0
- package/dist/virtualization/scroll-scaling.d.ts +45 -0
- package/dist/virtualization/scroll-scaling.js +99 -0
- package/dist/virtualization/scroll-scaling.test.d.ts +1 -0
- package/dist/virtualization/scroll-scaling.test.js +127 -0
- package/dist/virtualization/svelte-virtualizer.svelte.d.ts +2 -0
- package/dist/virtualization/svelte-virtualizer.svelte.js +2 -0
- package/dist/virtualization/virtualizer.d.ts +7 -0
- package/dist/virtualization/virtualizer.js +30 -0
- package/package.json +2 -1
- package/src/GridFooter.svelte +164 -0
- package/src/GridMenus.svelte +648 -0
- package/src/SvGrid.controller.svelte.ts +2352 -0
- package/src/SvGrid.css +2012 -0
- package/src/SvGrid.helpers.test.ts +415 -0
- package/src/SvGrid.helpers.ts +185 -0
- package/src/SvGrid.svelte +2346 -8742
- package/src/SvGrid.types.ts +537 -0
- package/src/SvGridChart.svelte +1060 -23
- package/src/aligned-grids.test.ts +80 -0
- package/src/aligned-grids.ts +87 -0
- package/src/build-api.coverage.test.ts +532 -0
- package/src/build-api.ts +683 -0
- package/src/cell-render.test.ts +451 -0
- package/src/cell-render.ts +426 -0
- package/src/cell-values.ts +114 -0
- package/src/chart-export.test.ts +370 -0
- package/src/chart.coverage.test.ts +814 -0
- package/src/chart.ts +1352 -47
- package/src/clipboard.test.ts +780 -0
- package/src/clipboard.ts +552 -0
- package/src/collaboration.coverage.test.ts +220 -0
- package/src/column-groups.test.ts +59 -0
- package/src/column-groups.ts +80 -0
- package/src/column-types.test.ts +68 -0
- package/src/column-types.ts +82 -0
- package/src/columns.test.ts +702 -0
- package/src/columns.ts +419 -0
- package/src/core.ts +86 -0
- package/src/css.d.ts +3 -0
- package/src/editing.test.ts +837 -0
- package/src/editing.ts +669 -0
- package/src/editors/cell-editors.coverage.test.ts +156 -0
- package/src/editors/cell-editors.ts +1 -0
- package/src/facet-buckets.test.ts +353 -0
- package/src/facet-buckets.ts +67 -0
- package/src/features.ts +128 -0
- package/src/filter-operators.test.ts +174 -0
- package/src/filter-operators.ts +87 -0
- package/src/hyperformula-adapter.test.ts +256 -0
- package/src/hyperformula-adapter.ts +124 -0
- package/src/index.ts +49 -0
- package/src/keyboard-handlers.coverage.test.ts +560 -0
- package/src/keyboard-handlers.ts +353 -0
- package/src/keyboard.ts +97 -97
- package/src/menus.test.ts +620 -0
- package/src/menus.ts +555 -0
- package/src/named-views.coverage.test.ts +210 -0
- package/src/named-views.ts +48 -0
- package/src/row-drag.test.ts +168 -0
- package/src/row-drag.ts +255 -0
- package/src/row-resize.test.ts +369 -0
- package/src/row-resize.ts +171 -0
- package/src/scroll-sync.test.ts +330 -0
- package/src/scroll-sync.ts +218 -0
- package/src/selection.multi-range.test.ts +61 -0
- package/src/selection.test.ts +722 -0
- package/src/selection.ts +579 -0
- package/src/server-data-source.coverage.test.ts +180 -0
- package/src/spreadsheet.test.ts +489 -0
- package/src/spreadsheet.ts +304 -0
- package/src/summaries.ts +204 -0
- package/src/sv-grid-scrollbar.ts +13 -1
- package/src/svgrid-wrapper.types.ts +31 -1
- package/src/svgrid.behavior.test.ts +22 -0
- package/src/svgrid.comments-autocomplete.test.ts +112 -0
- package/src/svgrid.context-menu.test.ts +126 -0
- package/src/svgrid.interaction.test.ts +30 -0
- package/src/svgrid.new-features.wrapper.test.ts +67 -6
- package/src/svgrid.wrapper.test.ts +27 -1
- package/src/test-setup.ts +9 -6
- package/src/virtualization/scroll-scaling.test.ts +148 -0
- package/src/virtualization/scroll-scaling.ts +121 -0
- package/src/virtualization/svelte-virtualizer.svelte.ts +2 -0
- package/src/virtualization/virtualizer.ts +26 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,39 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://svgrid.com/brand/svgrid-logo-icon-1200.png" alt="SvGrid" width="100" height="100" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">@svgrid/grid</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><strong>The Svelte 5 native data grid. Headless-first. Render-ready.</strong></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/@svgrid/grid"><img src="https://img.shields.io/npm/v/%40svgrid%2Fgrid.svg?label=%40svgrid%2Fgrid" alt="npm version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/@svgrid/grid"><img src="https://img.shields.io/npm/dm/%40svgrid%2Fgrid.svg" alt="npm downloads" /></a>
|
|
12
|
+
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License" /></a>
|
|
13
|
+
<a href="./dist"><img src="https://img.shields.io/badge/types-included-blue.svg" alt="TypeScript" /></a>
|
|
14
|
+
<a href="https://svelte.dev"><img src="https://img.shields.io/badge/svelte-5-ff3e00.svg" alt="Svelte 5" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://svgrid.com">Website</a> ·
|
|
19
|
+
<a href="https://svgrid.com/docs">Docs</a> ·
|
|
20
|
+
<a href="https://svgrid.com/demos">150+ Demos</a> ·
|
|
21
|
+
<a href="https://svgrid.com/pricing">Pricing</a> ·
|
|
22
|
+
<a href="https://svgrid.com/roadmap">Roadmap</a>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
A production-grade data grid built from the first line for **Svelte 5 runes** - not a React grid wrapped in a Svelte shim. Compose the headless engine yourself, or drop in the full `<SvGrid />` render component and ship. The MIT core has **zero feature gating**: no license key, no watermark, no row-count cap.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
Scaffold a working Vite + Svelte 5 app with SvGrid wired up:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm create @svgrid@latest
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or add it to an existing app:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @svgrid/grid
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
```svelte
|
|
46
|
+
<script lang="ts">
|
|
47
|
+
import { SvGrid, type ColumnDef } from '@svgrid/grid'
|
|
48
|
+
|
|
49
|
+
const rows = [
|
|
50
|
+
{ firstName: 'Ada', age: 36, status: 'active' },
|
|
51
|
+
{ firstName: 'Linus', age: 54, status: 'active' },
|
|
52
|
+
{ firstName: 'Grace', age: 85, status: 'inactive' },
|
|
53
|
+
]
|
|
54
|
+
const columns: ColumnDef<{}, (typeof rows)[number]>[] = [
|
|
55
|
+
{ field: 'firstName', header: 'First name' },
|
|
56
|
+
{ field: 'age', header: 'Age' },
|
|
57
|
+
{ field: 'status', header: 'Status' },
|
|
58
|
+
]
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<SvGrid data={rows} columns={columns} />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
That is a real, accessible grid. Sorting, filtering, virtualization, cell selection, and inline editing all wire up the moment you turn on the matching prop.
|
|
65
|
+
|
|
66
|
+
## Capabilities
|
|
67
|
+
|
|
68
|
+
- **Virtualization** - row + column windowing; 100k x 100 stays smooth, with a 1M-row demo.
|
|
69
|
+
- **Filtering** - Excel-style filter menu, inline filter row, set / value-list filter, locale-aware matching, between operators.
|
|
70
|
+
- **Editing** - 14 built-in `editorType`s (text, number, date, datetime, time, select, rich-select with typeahead, textarea, color, checkbox, list, chips, rating, password) plus a `cellEditor` snippet slot for anything custom.
|
|
71
|
+
- **Selection** - cell-range click+drag and Shift+arrows, copy/paste as TSV, Excel-style fill handle, row selection.
|
|
72
|
+
- **Hierarchy** - row grouping with aggregation, tree data, master/detail, full-width detail rows.
|
|
73
|
+
- **Layout** - row + column pinning, sticky header + first column, header drag-to-reorder, autosize, column sizing API, zebra rows.
|
|
74
|
+
- **Data operations** - find in grid (Ctrl+F), undo / redo, transaction API, optimistic updates, server-side row model with sort / filter / group pushdown.
|
|
75
|
+
- **Accessibility** - WAI-ARIA grid roles, full keyboard navigation, RTL, high-contrast theme.
|
|
76
|
+
- **Engineered for production** - first-class TypeScript types, CSP / Trusted-Types safe rendering, SSR-friendly, themeable via `--sg-*` CSS tokens.
|
|
77
|
+
- **Lean** - ~7.5 KB gzipped headless core, ~42 KB gzipped full render component; Svelte stays a peer dependency.
|
|
78
|
+
|
|
79
|
+
## Headless or render-ready
|
|
80
|
+
|
|
81
|
+
SvGrid ships two layers from one package, so you can choose how much control you want:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import {
|
|
85
|
+
// Drop-in render component
|
|
86
|
+
SvGrid,
|
|
87
|
+
// Headless engine + row-model factories
|
|
88
|
+
createSvGrid,
|
|
89
|
+
createCoreRowModel,
|
|
90
|
+
createFilteredRowModel,
|
|
91
|
+
createSortedRowModel,
|
|
92
|
+
createGroupedRowModel,
|
|
93
|
+
createExpandedRowModel,
|
|
94
|
+
createPaginatedRowModel,
|
|
95
|
+
// Feature modules
|
|
96
|
+
tableFeatures,
|
|
97
|
+
rowSortingFeature,
|
|
98
|
+
columnFilteringFeature,
|
|
99
|
+
columnGroupingFeature,
|
|
100
|
+
rowExpandingFeature,
|
|
101
|
+
rowPaginationFeature,
|
|
102
|
+
rowSelectionFeature,
|
|
103
|
+
// Cell renderers
|
|
104
|
+
renderSnippet,
|
|
105
|
+
renderComponent,
|
|
106
|
+
type ColumnDef,
|
|
107
|
+
type SvGridApi,
|
|
108
|
+
} from '@svgrid/grid'
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- **Headless** - drive `createSvGrid` and the row-model factories, render your own markup. `getGrid*A11yProps` helpers keep custom markup accessible.
|
|
112
|
+
- **Render-ready** - `<SvGrid />` is a complete, accessible, themeable grid you configure with props.
|
|
113
|
+
|
|
114
|
+
Compatibility aliases are provided for the framework-neutral names: `createGrid`, `createGridState`, `subscribeGrid`.
|
|
115
|
+
|
|
116
|
+
## AI-native
|
|
117
|
+
|
|
118
|
+
SvGrid publishes an [MCP server](https://www.npmjs.com/package/@svgrid/mcp) and `llms.txt` / `llms-full.txt`, so Claude, Cursor, and Zed answer with accurate, version-pinned APIs and all 150+ demo sources as context - not hallucinated methods.
|
|
119
|
+
|
|
120
|
+
## Enterprise
|
|
121
|
+
|
|
122
|
+
The MIT core is free for any use, including commercial. The optional [`@svgrid/enterprise`](https://www.npmjs.com/package/@svgrid/enterprise) pack adds Excel / PDF / CSV / TSV / HTML export, paginated print, pivot tables with a drag-and-drop Designer, and AI helpers. OSS projects receive an Enterprise key free. See [Pricing](https://svgrid.com/pricing).
|
|
123
|
+
|
|
124
|
+
## Documentation
|
|
125
|
+
|
|
126
|
+
- [Getting started](https://svgrid.com/docs) - end-to-end walkthrough.
|
|
127
|
+
- [150+ live demos](https://svgrid.com/demos) - copy-paste recipes for every feature.
|
|
128
|
+
- [Why headless?](https://svgrid.com/docs) - when to compose vs. drop in.
|
|
129
|
+
- [Theming](https://svgrid.com/docs) - re-skin via `--sg-*` tokens and dark mode.
|
|
130
|
+
|
|
131
|
+
## Who's behind it
|
|
132
|
+
|
|
133
|
+
SvGrid is built by [jQWidgets](https://www.jqwidgets.com), shipping UI components since 2011 to 5,000+ companies including Samsung, Boeing, NVIDIA, Microsoft, Nokia, and Intel. SvGrid is our Svelte 5 native effort.
|
|
134
|
+
|
|
135
|
+
## License & trademark
|
|
136
|
+
|
|
137
|
+
The source code is **MIT-licensed** - see [LICENSE](./LICENSE). It is free for commercial use. SvGrid™ and sv-grid™ are trademarks of jQWidgets Ltd; the license covers the code only, not the name or logo.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<script lang="ts" generics="TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData">
|
|
2
|
+
import {
|
|
3
|
+
getGridCellA11yProps,
|
|
4
|
+
getGridCellDomId,
|
|
5
|
+
getGridHeaderA11yProps,
|
|
6
|
+
getGridRootA11yProps,
|
|
7
|
+
getGridRowA11yProps,
|
|
8
|
+
type EditorContext,
|
|
9
|
+
type CellEditorOption,
|
|
10
|
+
type Column,
|
|
11
|
+
type Row,
|
|
12
|
+
type RowData,
|
|
13
|
+
type TableFeatures,
|
|
14
|
+
} from "./index";
|
|
15
|
+
import "./sv-grid-scrollbar";
|
|
16
|
+
import type { Snippet } from "svelte";
|
|
17
|
+
import {
|
|
18
|
+
RenderSnippetConfig,
|
|
19
|
+
RenderComponentConfig,
|
|
20
|
+
} from "./render-component";
|
|
21
|
+
import {
|
|
22
|
+
buildSparkline,
|
|
23
|
+
toSparklineValues,
|
|
24
|
+
} from "./sparkline";
|
|
25
|
+
import SvGridDropdown from "./SvGridDropdown.svelte";
|
|
26
|
+
import type {
|
|
27
|
+
Props,
|
|
28
|
+
SelectionPoint,
|
|
29
|
+
SelectionRange,
|
|
30
|
+
CellEditState,
|
|
31
|
+
FilterOperator,
|
|
32
|
+
FilterOption,
|
|
33
|
+
MenuPosition,
|
|
34
|
+
} from "./SvGrid.types";
|
|
35
|
+
import {
|
|
36
|
+
cfTextStyle,
|
|
37
|
+
fmtStat,
|
|
38
|
+
getEditableInputValue,
|
|
39
|
+
getEditorInputType,
|
|
40
|
+
toValueArray,
|
|
41
|
+
getOptionLabel,
|
|
42
|
+
getOptionColor,
|
|
43
|
+
colorfulChipStyle,
|
|
44
|
+
getEditorClass,
|
|
45
|
+
} from "./SvGrid.helpers";
|
|
46
|
+
import {
|
|
47
|
+
} from "./SvGrid.controller.svelte";
|
|
48
|
+
import type { SvGridController } from "./SvGrid.controller.svelte";
|
|
49
|
+
|
|
50
|
+
let { ctrl }: { ctrl: SvGridController<TFeatures, TData> } = $props();
|
|
51
|
+
|
|
52
|
+
// View facade: re-bind the controller's reactive members so the markup
|
|
53
|
+
// (moved verbatim from SvGrid.svelte) stays identical.
|
|
54
|
+
const paginationEnabled = $derived(ctrl.paginationEnabled);
|
|
55
|
+
const grid = $derived(ctrl.grid);
|
|
56
|
+
const paginationState = $derived(ctrl.paginationState);
|
|
57
|
+
const allRowsBeforePagination = $derived(ctrl.allRowsBeforePagination);
|
|
58
|
+
const statusBarEnabled = $derived(ctrl.statusBarEnabled);
|
|
59
|
+
const statusBarAggregates = $derived(ctrl.statusBarAggregates);
|
|
60
|
+
const statusBarStats = $derived(ctrl.statusBarStats);
|
|
61
|
+
const changePage = $derived(ctrl.changePage);
|
|
62
|
+
const goToPage = $derived(ctrl.goToPage);
|
|
63
|
+
const setPageSize = $derived(ctrl.setPageSize);
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
{#if statusBarEnabled && statusBarStats}
|
|
67
|
+
{@const s = statusBarStats}
|
|
68
|
+
<div class="sv-grid-status-bar" role="status" aria-live="polite">
|
|
69
|
+
{#each statusBarAggregates as agg (agg)}
|
|
70
|
+
{#if agg === "count"}
|
|
71
|
+
<span class="sv-grid-status-item"
|
|
72
|
+
><span class="sv-grid-status-label">Count</span>{fmtStat(s.count)}</span
|
|
73
|
+
>
|
|
74
|
+
{:else if agg === "numericCount"}
|
|
75
|
+
<span class="sv-grid-status-item"
|
|
76
|
+
><span class="sv-grid-status-label">Numeric</span>{fmtStat(s.numericCount)}</span
|
|
77
|
+
>
|
|
78
|
+
{:else if s.numericCount > 0 && agg === "sum"}
|
|
79
|
+
<span class="sv-grid-status-item"
|
|
80
|
+
><span class="sv-grid-status-label">Sum</span>{fmtStat(s.sum)}</span
|
|
81
|
+
>
|
|
82
|
+
{:else if s.numericCount > 0 && agg === "avg"}
|
|
83
|
+
<span class="sv-grid-status-item"
|
|
84
|
+
><span class="sv-grid-status-label">Avg</span>{fmtStat(s.avg)}</span
|
|
85
|
+
>
|
|
86
|
+
{:else if s.numericCount > 0 && agg === "min"}
|
|
87
|
+
<span class="sv-grid-status-item"
|
|
88
|
+
><span class="sv-grid-status-label">Min</span>{fmtStat(s.min)}</span
|
|
89
|
+
>
|
|
90
|
+
{:else if s.numericCount > 0 && agg === "max"}
|
|
91
|
+
<span class="sv-grid-status-item"
|
|
92
|
+
><span class="sv-grid-status-label">Max</span>{fmtStat(s.max)}</span
|
|
93
|
+
>
|
|
94
|
+
{/if}
|
|
95
|
+
{/each}
|
|
96
|
+
</div>
|
|
97
|
+
{/if}
|
|
98
|
+
|
|
99
|
+
{#if paginationEnabled}
|
|
100
|
+
{@const totalRows = allRowsBeforePagination.length}
|
|
101
|
+
{@const pageSize = paginationState.pageSize}
|
|
102
|
+
{@const pageCount = Math.max(1, Math.ceil(totalRows / pageSize))}
|
|
103
|
+
{@const currentPage = Math.min(paginationState.pageIndex + 1, pageCount)}
|
|
104
|
+
{@const rangeStart =
|
|
105
|
+
totalRows === 0 ? 0 : (currentPage - 1) * pageSize + 1}
|
|
106
|
+
{@const rangeEnd = Math.min(totalRows, currentPage * pageSize)}
|
|
107
|
+
{@const onFirst = currentPage <= 1}
|
|
108
|
+
{@const onLast = currentPage >= pageCount}
|
|
109
|
+
<div class="sv-grid-pagination" role="navigation" aria-label="Pagination">
|
|
110
|
+
<label class="sv-grid-pagination-pagesize">
|
|
111
|
+
<span>Page Size:</span>
|
|
112
|
+
<select
|
|
113
|
+
onchange={(event) =>
|
|
114
|
+
setPageSize(
|
|
115
|
+
parseInt((event.currentTarget as HTMLSelectElement).value, 10),
|
|
116
|
+
)}
|
|
117
|
+
>
|
|
118
|
+
<option value="10" selected={pageSize === 10}>10</option>
|
|
119
|
+
<option value="25" selected={pageSize === 25}>25</option>
|
|
120
|
+
<option value="50" selected={pageSize === 50}>50</option>
|
|
121
|
+
<option value="100" selected={pageSize === 100}>100</option>
|
|
122
|
+
</select>
|
|
123
|
+
</label>
|
|
124
|
+
<span class="sv-grid-pagination-range">
|
|
125
|
+
<strong>{rangeStart.toLocaleString()}</strong> to
|
|
126
|
+
<strong>{rangeEnd.toLocaleString()}</strong> of
|
|
127
|
+
<strong>{totalRows.toLocaleString()}</strong>
|
|
128
|
+
</span>
|
|
129
|
+
<div class="sv-grid-pagination-nav">
|
|
130
|
+
<button
|
|
131
|
+
type="button"
|
|
132
|
+
class="sv-grid-pagination-btn"
|
|
133
|
+
disabled={onFirst}
|
|
134
|
+
onclick={() => goToPage(0)}
|
|
135
|
+
aria-label="First page">⇤</button
|
|
136
|
+
>
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
class="sv-grid-pagination-btn"
|
|
140
|
+
disabled={onFirst}
|
|
141
|
+
onclick={() => changePage(-1)}
|
|
142
|
+
aria-label="Previous page">‹</button
|
|
143
|
+
>
|
|
144
|
+
<span class="sv-grid-pagination-label">
|
|
145
|
+
Page <strong>{currentPage.toLocaleString()}</strong> of
|
|
146
|
+
<strong>{pageCount.toLocaleString()}</strong>
|
|
147
|
+
</span>
|
|
148
|
+
<button
|
|
149
|
+
type="button"
|
|
150
|
+
class="sv-grid-pagination-btn"
|
|
151
|
+
disabled={onLast}
|
|
152
|
+
onclick={() => changePage(1)}
|
|
153
|
+
aria-label="Next page">›</button
|
|
154
|
+
>
|
|
155
|
+
<button
|
|
156
|
+
type="button"
|
|
157
|
+
class="sv-grid-pagination-btn"
|
|
158
|
+
disabled={onLast}
|
|
159
|
+
onclick={() => goToPage(pageCount - 1)}
|
|
160
|
+
aria-label="Last page">⇥</button
|
|
161
|
+
>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
{/if}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type RowData, type TableFeatures } from "./index";
|
|
2
|
+
import "./sv-grid-scrollbar";
|
|
3
|
+
import type { SvGridController } from "./SvGrid.controller.svelte";
|
|
4
|
+
declare function $$render<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData>(): {
|
|
5
|
+
props: {
|
|
6
|
+
ctrl: SvGridController<TFeatures, TData>;
|
|
7
|
+
};
|
|
8
|
+
exports: {};
|
|
9
|
+
bindings: "";
|
|
10
|
+
slots: {};
|
|
11
|
+
events: {};
|
|
12
|
+
};
|
|
13
|
+
declare class __sveltets_Render<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> {
|
|
14
|
+
props(): ReturnType<typeof $$render<TFeatures, TData>>['props'];
|
|
15
|
+
events(): ReturnType<typeof $$render<TFeatures, TData>>['events'];
|
|
16
|
+
slots(): ReturnType<typeof $$render<TFeatures, TData>>['slots'];
|
|
17
|
+
bindings(): "";
|
|
18
|
+
exports(): {};
|
|
19
|
+
}
|
|
20
|
+
interface $$IsomorphicComponent {
|
|
21
|
+
new <TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TFeatures, TData>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TFeatures, TData>['props']>, ReturnType<__sveltets_Render<TFeatures, TData>['events']>, ReturnType<__sveltets_Render<TFeatures, TData>['slots']>> & {
|
|
22
|
+
$$bindings?: ReturnType<__sveltets_Render<TFeatures, TData>['bindings']>;
|
|
23
|
+
} & ReturnType<__sveltets_Render<TFeatures, TData>['exports']>;
|
|
24
|
+
<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData>(internal: unknown, props: ReturnType<__sveltets_Render<TFeatures, TData>['props']> & {}): ReturnType<__sveltets_Render<TFeatures, TData>['exports']>;
|
|
25
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
26
|
+
}
|
|
27
|
+
declare const GridFooter: $$IsomorphicComponent;
|
|
28
|
+
type GridFooter<TFeatures extends TableFeatures = TableFeatures, TData extends RowData = RowData> = InstanceType<typeof GridFooter<TFeatures, TData>>;
|
|
29
|
+
export default GridFooter;
|