@geovi/the-datagrid 0.0.12 → 0.0.13
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/README.md +195 -40
- package/dist/base.css +1 -1
- package/dist/components.js +23 -23
- package/dist/grid/ReactDataGrid.d.ts.map +1 -1
- package/dist/grid/hooks/useGridColumnApi.d.ts +0 -5
- package/dist/grid/hooks/useGridColumnApi.d.ts.map +1 -1
- package/dist/grid/hooks/useGridToolbarBridge.d.ts +28 -0
- package/dist/grid/hooks/useGridToolbarBridge.d.ts.map +1 -0
- package/dist/grid/internalProps.d.ts +12 -5
- package/dist/grid/internalProps.d.ts.map +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.css +1 -1
- package/dist/index.js +6061 -5994
- package/dist/optional-target.d.ts +1 -1
- package/dist/optional-target.d.ts.map +1 -1
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/search/RDGSearchTarget.d.ts.map +1 -1
- package/dist/search.js +70 -70
- package/dist/style/theme/amber-dark/index.css +1 -1
- package/dist/style/theme/amber-light/index.css +1 -1
- package/dist/style/theme/blue-dark/index.css +1 -1
- package/dist/style/theme/blue-light/index.css +1 -1
- package/dist/style/theme/default-dark/index.css +1 -1
- package/dist/style/theme/default-light/index.css +1 -1
- package/dist/style/theme/green-dark/index.css +1 -1
- package/dist/style/theme/green-light/index.css +1 -1
- package/dist/style/theme/pink-dark/index.css +1 -1
- package/dist/style/theme/pink-light/index.css +1 -1
- package/dist/toolbar/RDGToolbar.d.ts +88 -0
- package/dist/toolbar/RDGToolbar.d.ts.map +1 -0
- package/dist/toolbar/RDGToolbarProvider.d.ts +6 -0
- package/dist/toolbar/RDGToolbarProvider.d.ts.map +1 -0
- package/dist/toolbar/RDGToolbarTarget.d.ts +7 -0
- package/dist/toolbar/RDGToolbarTarget.d.ts.map +1 -0
- package/dist/toolbar/controller.d.ts +29 -0
- package/dist/toolbar/controller.d.ts.map +1 -0
- package/dist/toolbar/export.d.ts +70 -0
- package/dist/toolbar/export.d.ts.map +1 -0
- package/dist/toolbar/icons.d.ts +22 -0
- package/dist/toolbar/icons.d.ts.map +1 -0
- package/dist/toolbar/index.d.ts +8 -0
- package/dist/toolbar/index.d.ts.map +1 -0
- package/dist/toolbar/runtime.d.ts.map +1 -0
- package/dist/toolbar/store.d.ts +20 -0
- package/dist/toolbar/store.d.ts.map +1 -0
- package/dist/toolbar/xlsx.d.ts +35 -0
- package/dist/toolbar/xlsx.d.ts.map +1 -0
- package/dist/toolbar.css +1 -0
- package/dist/toolbar.js +797 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +29 -11
- package/dist/column-visibility/RDGColumnVisibilityProvider.d.ts +0 -6
- package/dist/column-visibility/RDGColumnVisibilityProvider.d.ts.map +0 -1
- package/dist/column-visibility/RDGColumnVisibilityTarget.d.ts +0 -7
- package/dist/column-visibility/RDGColumnVisibilityTarget.d.ts.map +0 -1
- package/dist/column-visibility/RDGColumnVisibilityToolbar.d.ts +0 -9
- package/dist/column-visibility/RDGColumnVisibilityToolbar.d.ts.map +0 -1
- package/dist/column-visibility/controller.d.ts +0 -13
- package/dist/column-visibility/controller.d.ts.map +0 -1
- package/dist/column-visibility/index.d.ts +0 -7
- package/dist/column-visibility/index.d.ts.map +0 -1
- package/dist/column-visibility/runtime.d.ts.map +0 -1
- package/dist/column-visibility/store.d.ts +0 -20
- package/dist/column-visibility/store.d.ts.map +0 -1
- package/dist/column-visibility.css +0 -1
- package/dist/column-visibility.js +0 -426
- /package/dist/{column-visibility → toolbar}/runtime.d.ts +0 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Documentation and live examples: https://geo-vi.github.io/the-datagrid/
|
|
|
10
10
|
- Sorting (single + multi-column)
|
|
11
11
|
- Filtering with a built-in filter row and operators
|
|
12
12
|
- Opt-in global table search through a separate, tree-shakeable entry
|
|
13
|
-
- Opt-in
|
|
13
|
+
- Opt-in grid toolbar: column toggles, export, filter-row and clear-filter actions
|
|
14
14
|
- Column management (reorder, resize, auto-size)
|
|
15
15
|
- Stacked and nested column headers with split/rejoin and group resizing
|
|
16
16
|
- Pagination (local + remote)
|
|
@@ -154,7 +154,7 @@ method allowlists.
|
|
|
154
154
|
entry, normalized AND matching, column-scoped queries and aliases, nested or
|
|
155
155
|
derived search values, hidden-column search, a lazy cached local index, static
|
|
156
156
|
Promise search, and `searchValue` forwarding for remote functions.
|
|
157
|
-
- **Optional
|
|
157
|
+
- **Optional toolbar:** a separate provider/toolbar/target entry that
|
|
158
158
|
follows live grid order and visibility, honors non-hideable columns, protects
|
|
159
159
|
the final visible column, and accepts application actions on the right.
|
|
160
160
|
- **Themes and UI:** packaged CSS, shadcn-aligned controls, fixed
|
|
@@ -237,15 +237,15 @@ light/dark theme path, and `@geovi/the-datagrid/search/style.css`.
|
|
|
237
237
|
|
|
238
238
|
The optional `@geovi/the-datagrid/components` entry is the one-import choice for
|
|
239
239
|
mixed contextual controls. It exports `RDGProvider`, `RDGTarget`,
|
|
240
|
-
`RDGSearchBar`, `
|
|
240
|
+
`RDGSearchBar`, `RDGToolbar`, all four stable feature-specific
|
|
241
241
|
provider/target APIs, and their prop types. It reuses the existing search and
|
|
242
|
-
|
|
242
|
+
toolbar singleton contexts and automatically loads both isolated
|
|
243
243
|
stylesheets; there is intentionally no duplicate `components/style.css`.
|
|
244
244
|
|
|
245
|
-
The optional `@geovi/the-datagrid/
|
|
246
|
-
`
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
The optional `@geovi/the-datagrid/toolbar` entry exports
|
|
246
|
+
`RDGToolbarProvider`, `RDGToolbar`, `RDGToolbarTarget`, and their prop types.
|
|
247
|
+
Its explicit stylesheet fallback is
|
|
248
|
+
`@geovi/the-datagrid/toolbar/style.css`.
|
|
249
249
|
|
|
250
250
|
The Inovua-compatible standalone input remains a default class export at
|
|
251
251
|
`@geovi/the-datagrid/packages/TextInput`. That deep entry loads the packaged
|
|
@@ -457,24 +457,20 @@ export default function App() {
|
|
|
457
457
|
|
|
458
458
|
## Combined contextual controls
|
|
459
459
|
|
|
460
|
-
Use one `RDGProvider` when search and
|
|
460
|
+
Use one `RDGProvider` when search and the toolbar control the same grid.
|
|
461
461
|
A direct grid child connects automatically:
|
|
462
462
|
|
|
463
463
|
```tsx
|
|
464
464
|
import ReactDataGrid from "@geovi/the-datagrid";
|
|
465
465
|
import {
|
|
466
|
-
|
|
466
|
+
RDGToolbar,
|
|
467
467
|
RDGProvider,
|
|
468
468
|
RDGSearchBar,
|
|
469
469
|
} from "@geovi/the-datagrid/components";
|
|
470
470
|
|
|
471
471
|
<RDGProvider>
|
|
472
472
|
<RDGSearchBar />
|
|
473
|
-
<
|
|
474
|
-
<button type="button" onClick={exportRows}>
|
|
475
|
-
Export CSV
|
|
476
|
-
</button>
|
|
477
|
-
</RDGColumnVisibilityToolbar>
|
|
473
|
+
<RDGToolbar showExport showFilterToggle />
|
|
478
474
|
<ReactDataGrid idProperty="id" columns={columns} dataSource={rows} />
|
|
479
475
|
</RDGProvider>;
|
|
480
476
|
```
|
|
@@ -484,12 +480,12 @@ between the provider and grid, put one `RDGTarget` immediately around the grid.
|
|
|
484
480
|
`RDGProvider` and `RDGTarget` add no DOM elements and support one grid per
|
|
485
481
|
provider scope. Use `defaultSearchValue` when the shared search query needs a
|
|
486
482
|
non-empty initial value. Do not nest `RDGSearchTarget` and
|
|
487
|
-
`
|
|
483
|
+
`RDGToolbarTarget`; use the combined target instead.
|
|
488
484
|
|
|
489
485
|
Controls imported from `@geovi/the-datagrid/search` and
|
|
490
|
-
`@geovi/the-datagrid/
|
|
486
|
+
`@geovi/the-datagrid/toolbar` also work inside `RDGProvider`. The
|
|
491
487
|
existing `RDGSearchProvider`, `RDGSearchTarget`,
|
|
492
|
-
`
|
|
488
|
+
`RDGToolbarProvider`, and `RDGToolbarTarget` exports remain
|
|
493
489
|
supported and are not deprecated.
|
|
494
490
|
|
|
495
491
|
## Optional table search
|
|
@@ -625,32 +621,115 @@ remote page and present it as a server-wide result. If the backend does not yet
|
|
|
625
621
|
support global search, keep that search state application-owned until its
|
|
626
622
|
request contract is defined.
|
|
627
623
|
|
|
628
|
-
## Optional
|
|
624
|
+
## Optional grid toolbar
|
|
629
625
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
626
|
+
Grid toolbar controls are also an opt-in contextual entry. A direct grid child
|
|
627
|
+
connects automatically. Column toggles always render; export, filter-row and
|
|
628
|
+
clear-filter buttons are opt-in props, and toolbar children stay a separate
|
|
629
|
+
right-side action area for consumer-owned controls:
|
|
633
630
|
|
|
634
631
|
```tsx
|
|
635
632
|
import ReactDataGrid from "@geovi/the-datagrid";
|
|
636
|
-
import {
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
<RDGColumnVisibilityToolbar>
|
|
643
|
-
<button type="button" onClick={exportRows}>
|
|
644
|
-
Export CSV
|
|
645
|
-
</button>
|
|
646
|
-
<button type="button" onClick={toggleFilters}>
|
|
647
|
-
Show filters
|
|
633
|
+
import { RDGToolbarProvider, RDGToolbar } from "@geovi/the-datagrid/toolbar";
|
|
634
|
+
|
|
635
|
+
<RDGToolbarProvider>
|
|
636
|
+
<RDGToolbar showExport showFilterToggle showClearFilters>
|
|
637
|
+
<button type="button" onClick={reload}>
|
|
638
|
+
Reload
|
|
648
639
|
</button>
|
|
649
|
-
</
|
|
640
|
+
</RDGToolbar>
|
|
650
641
|
<ReactDataGrid idProperty="id" columns={columns} dataSource={rows} />
|
|
651
|
-
</
|
|
642
|
+
</RDGToolbarProvider>;
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
`showExport` writes the grid's current columns, in grid order, as CSV, JSON or
|
|
646
|
+
XLSX. Spreadsheet output needs the optional `xlsx` peer dependency:
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
npm install xlsx
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
It is left out of `exportFormats` by default, since its writer is many times the
|
|
653
|
+
size of the toolbar entry, and it is imported on demand the first time somebody
|
|
654
|
+
exports a workbook. Values keep their JavaScript type on the way into a
|
|
655
|
+
workbook, so numbers stay summable, `Date` values become date cells carrying
|
|
656
|
+
`exportDateFormat`, and booleans become `TRUE`/`FALSE`; text formats stringify
|
|
657
|
+
the same values and write dates as ISO-8601. `exportDateFormat` is an Excel
|
|
658
|
+
number format code rather than a date-library pattern, `exportSheetName` names
|
|
659
|
+
the worksheet, and the two callbacks report the outcome: `onExportSuccess`
|
|
660
|
+
receives the format, scope, row and column counts, file name and byte size,
|
|
661
|
+
which is enough for a confirmation toast, while `onExportError` reports a
|
|
662
|
+
failure such as a missing peer dependency.
|
|
663
|
+
|
|
664
|
+
`exportScope` selects the rows: `"view"` (default) exports the filtered,
|
|
665
|
+
searched and sorted rows, `"all"` the entire data source. Under local pagination
|
|
666
|
+
the grid holds a single page, so `"view"` exports that page. `exportFormats`,
|
|
667
|
+
`exportFileName` and `labels` cover the rest; with exactly one format the button
|
|
668
|
+
exports on click instead of opening a menu.
|
|
669
|
+
|
|
670
|
+
Every string the toolbar renders itself comes from `labels`, as a string or an
|
|
671
|
+
element, so a translation helper can supply all of them:
|
|
672
|
+
|
|
673
|
+
```tsx
|
|
674
|
+
<RDGToolbar
|
|
675
|
+
showExport
|
|
676
|
+
showFilterToggle
|
|
677
|
+
showClearFilters
|
|
678
|
+
labels={{
|
|
679
|
+
export: t("export"),
|
|
680
|
+
showFilters: t("show_filters"),
|
|
681
|
+
hideFilters: t("hide_filters"),
|
|
682
|
+
clearFilters: t("clear_filters"),
|
|
683
|
+
|
|
684
|
+
// Menu entry per format; an unnamed format keeps its own name.
|
|
685
|
+
exportFormats: { csv: t("csv"), xlsx: t("excel") },
|
|
686
|
+
|
|
687
|
+
// Whole button text when one format is offered. The default joins
|
|
688
|
+
// `export` and the format name in that order ("Export CSV"), which a
|
|
689
|
+
// translation file cannot reorder - set this for "CSV exportieren".
|
|
690
|
+
exportSingle: { csv: t("export_csv") },
|
|
691
|
+
}}
|
|
692
|
+
/>
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
`title`, `description` and `ariaLabel` are separate props and take the same
|
|
696
|
+
treatment; column toggles read each column's `header`. The export menu is named
|
|
697
|
+
after its own trigger, so a translated label needs no second string.
|
|
698
|
+
|
|
699
|
+
Export reads row values, never `render`, which returns React nodes. Columns
|
|
700
|
+
describe their own exported shape:
|
|
701
|
+
|
|
702
|
+
```tsx
|
|
703
|
+
const columns: TypeColumns = [
|
|
704
|
+
{ name: "id", header: "ID" },
|
|
705
|
+
|
|
706
|
+
// render returns a React node, so export needs its own value.
|
|
707
|
+
{
|
|
708
|
+
name: "active",
|
|
709
|
+
header: "Active",
|
|
710
|
+
render: ({ value }) => <StatusPill active={value} />,
|
|
711
|
+
exportValue: ({ value }) => (value ? "Yes" : "No"),
|
|
712
|
+
},
|
|
713
|
+
|
|
714
|
+
// Hidden in the grid, still written to the file.
|
|
715
|
+
{
|
|
716
|
+
name: "auditId",
|
|
717
|
+
header: "Audit ID",
|
|
718
|
+
defaultVisible: false,
|
|
719
|
+
exportWhenHidden: true,
|
|
720
|
+
},
|
|
721
|
+
|
|
722
|
+
// Row buttons have no exportable representation.
|
|
723
|
+
{ name: "actions", header: "Actions", exportable: false },
|
|
724
|
+
];
|
|
652
725
|
```
|
|
653
726
|
|
|
727
|
+
Only visible columns are exported unless a column sets `exportWhenHidden`, and
|
|
728
|
+
`exportable: false` always wins. `showFilterToggle` drives the grid's own
|
|
729
|
+
filter-row state, so it renders disabled while `enableFiltering` is passed as a
|
|
730
|
+
controlled prop; `showClearFilters` calls `clearAllFilters` and stays disabled
|
|
731
|
+
while nothing is filtered.
|
|
732
|
+
|
|
654
733
|
The toolbar renders columns in the grid's current order and reflects the live
|
|
655
734
|
visibility map. It uses string or numeric headers with stable `id`/`name`
|
|
656
735
|
fallbacks, omits columns with `hideable={false}`, and does not allow the final
|
|
@@ -670,19 +749,95 @@ toggle group keeps its `ariaLabel`, and the description is associated with both
|
|
|
670
749
|
through `aria-describedby`. Passing `title={null}` suppresses the heading while
|
|
671
750
|
preserving the group's accessible name.
|
|
672
751
|
|
|
673
|
-
|
|
752
|
+
### Styling the toolbar
|
|
753
|
+
|
|
754
|
+
The toolbar carries no utility classes: every visual decision is a
|
|
755
|
+
`--tdg-toolbar-*` custom property, so restyling means redeclaring tokens on
|
|
756
|
+
`.tdg-toolbar-root` or any ancestor.
|
|
757
|
+
|
|
758
|
+
```css
|
|
759
|
+
.tdg-toolbar-root {
|
|
760
|
+
--tdg-toolbar-padding: 0;
|
|
761
|
+
--tdg-toolbar-radius: 0;
|
|
762
|
+
--tdg-toolbar-border-width: 0;
|
|
763
|
+
--tdg-toolbar-shadow: none;
|
|
764
|
+
|
|
765
|
+
--tdg-toolbar-toggle-gap: 3px;
|
|
766
|
+
--tdg-toolbar-control-padding: 6px 8px;
|
|
767
|
+
--tdg-toolbar-control-radius: 4px;
|
|
768
|
+
--tdg-toolbar-control-height: auto;
|
|
769
|
+
--tdg-toolbar-control-cursor: pointer;
|
|
770
|
+
|
|
771
|
+
/* Export and clear-filters. */
|
|
772
|
+
--tdg-toolbar-action-fill: #eef1f5;
|
|
773
|
+
--tdg-toolbar-action-color: #12263f;
|
|
774
|
+
|
|
775
|
+
/* A released toggle, filled here rather than recessed. */
|
|
776
|
+
--tdg-toolbar-toggle-off-fill: #eef1f5;
|
|
777
|
+
--tdg-toolbar-toggle-off-color: #5b6b7f;
|
|
778
|
+
|
|
779
|
+
/* A pressed toggle, and export while its menu is open. */
|
|
780
|
+
--tdg-toolbar-toggle-on-fill: #1a73e8;
|
|
781
|
+
--tdg-toolbar-toggle-on-color: #ffffff;
|
|
782
|
+
}
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
The three appearances differ by one signal each: an action keeps its border, a
|
|
786
|
+
released toggle drops it and dims the label, a pressed toggle keeps it over an
|
|
787
|
+
opaque `card` fill. Hover only changes the fill, so it never reads as a state.
|
|
788
|
+
|
|
789
|
+
Colour tokens fall back through `--tdg-color-*` and then the shadcn variable of
|
|
790
|
+
the same name, so a themed application inherits sensible values without setting
|
|
791
|
+
anything. Bridging another design system - BaseUI, MUI, a styled-components
|
|
792
|
+
theme - means assigning its values to these tokens once, on a wrapper element.
|
|
793
|
+
|
|
794
|
+
A grid theme named `*-dark` or `*-light` is the exception: it states a mode, so
|
|
795
|
+
the toolbar skips the shadcn step, which tracks the page's mode rather than the
|
|
796
|
+
grid's. Reading it would paint a dark toolbar with the page's white `--card`. A
|
|
797
|
+
theme named `default` states no mode and keeps following the page.
|
|
798
|
+
|
|
799
|
+
Two caveats when you theme a toolbar that sits outside the grid. Theme
|
|
800
|
+
stylesheets scope their variables to the grid root, so a sibling toolbar never
|
|
801
|
+
sees them - declare `--tdg-color-*` on a common ancestor to share one palette.
|
|
802
|
+
And the mode rules above are selected by attribute, so they only ever move
|
|
803
|
+
private plumbing (`--tdg-toolbar-host-*`, `--tdg-toolbar-*-fallback`,
|
|
804
|
+
`--tdg-toolbar-surface-backdrop`); every token in the reference is declared once
|
|
805
|
+
at plain `.tdg-toolbar-root` specificity, so your override always wins.
|
|
806
|
+
|
|
807
|
+
Plain CSS overrides work too, and never need `!important`: every default rule is
|
|
808
|
+
written with exactly one unit of specificity, so any selector of yours that adds
|
|
809
|
+
a second part outranks it.
|
|
810
|
+
|
|
811
|
+
```css
|
|
812
|
+
.tdg-toolbar-root button[data-state="off"] {
|
|
813
|
+
background-color: var(--button-secondary-fill);
|
|
814
|
+
}
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
Elements expose stable `data-slot` names (`rdg-toolbar`, `rdg-column-toggle`,
|
|
818
|
+
`rdg-toolbar-actions`, `rdg-toolbar-export`, `rdg-toolbar-filter-toggle`, ...),
|
|
819
|
+
and toggles expose `data-state` as `on` or `off`. `RDGToolbar` also accepts
|
|
820
|
+
`className` for scoping overrides to a class of your own. The complete token
|
|
821
|
+
table lives in
|
|
822
|
+
[the toolbar styling reference](https://geo-vi.github.io/the-datagrid/docs/reference/toolbar#toolbar-styling).
|
|
823
|
+
|
|
824
|
+
Stacked, the toolbar places its actions above the column toggles, since a
|
|
825
|
+
wrapping toggle list would otherwise push export and the filter controls far
|
|
826
|
+
down the card; from `80rem` it becomes a row with toggles leading.
|
|
827
|
+
|
|
828
|
+
Use `RDGToolbarTarget` around the grid when layout markup separates it
|
|
674
829
|
from the provider. Keep one grid per provider so the column model is
|
|
675
830
|
unambiguous. The JavaScript entry loads its scoped stylesheet automatically; if
|
|
676
831
|
your environment requires manual CSS imports, add
|
|
677
|
-
`import "@geovi/the-datagrid/
|
|
832
|
+
`import "@geovi/the-datagrid/toolbar/style.css"`.
|
|
678
833
|
|
|
679
834
|
For the complete direct-child rules, nested layout examples, multiple-grid
|
|
680
835
|
scoping, and the stability contract for all feature-specific providers and
|
|
681
836
|
targets, see [Providers and targets](https://geo-vi.github.io/the-datagrid/docs/reference/providers-and-targets).
|
|
682
837
|
|
|
683
|
-
When search and
|
|
838
|
+
When search and the toolbar share a grid, prefer `RDGProvider`/`RDGTarget` from
|
|
684
839
|
`@geovi/the-datagrid/components`. The feature-specific provider and target
|
|
685
|
-
remain supported for
|
|
840
|
+
remain supported for toolbar-only screens and existing integrations.
|
|
686
841
|
|
|
687
842
|
## Advanced usage
|
|
688
843
|
|