@dloizides/ui-tables 1.12.0 → 1.14.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,100 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.14.0
4
+
5
+ **Campaign F2 — the private filter fields are now public, in `@dloizides/ui-forms`.**
6
+
7
+ This package contained a complete, themed, a11y-wired set of form controls inside its `Filters`
8
+ bar and exported NONE of them. Six portals could see them working and none could import them, so
9
+ the fleet reimplemented them: **6 select implementations, 5 date fields, 2 typeaheads**. Same
10
+ shape as `MultiTenancy.EntityFrameworkCore` shipping no EF Core. They now live in
11
+ `@dloizides/ui-forms` 1.8.0 as `SelectControl` / `TypeaheadControl` / `DateRangeControl` /
12
+ `AnchoredMenu` / `controlStyles`, and this package consumes them.
13
+
14
+ **No behaviour changed. All 258 pre-existing tests pass UNMODIFIED** — including
15
+ `Filters.test.tsx` (which drives every field kind through the bar), `selectAccessibleName.test.tsx`
16
+ (the i18n path) and `suggest.test.ts` (now running against the moved implementation). That is the
17
+ proof the move preserved behaviour rather than merely relocating it.
18
+
19
+ ### What moved, and what deliberately did not
20
+
21
+ The controls moved; the **schema** stayed. Each field was bound to this bar's `FilterField` types
22
+ (`field: SelectFilterField`, `barTestID`, `fieldTestID`), so moving them verbatim would have
23
+ dragged `FilterField`, `FilterFieldKind`, `FilterValues` and `FIELD_MIN_WIDTH` into `ui-forms` —
24
+ i.e. `ui-forms` would have come to own "what a filter bar's field schema is". Wrong direction.
25
+ The field files are now thin ADAPTERS mapping schema → plain props.
26
+
27
+ `TextField` and `BooleanField` stayed. `ui-forms` already ships two text inputs (`ThemedTextInput`,
28
+ `FormField`) and a switch row (`FormSwitch`); promoting a third of each would ADD duplicates to the
29
+ package this campaign is de-duplicating. Converging onto the existing ones is right but VISIBLE
30
+ (focus ring, hover border, `surfaceElevated` background, different switch-row metrics), so it
31
+ belongs in the visual-QA-gated wave. Both now use the shared `controlStyles` boxes, so no metric
32
+ is forked in the meantime.
33
+
34
+ ### `FieldShell` is deleted
35
+
36
+ The private label-wrapper fork existed only because `Field` hard-coded the 13/600 `field` label
37
+ voice. `Field` 1.7.0 named both contract voices, so the bar now asks for `labelVariant="control"`
38
+ — the 11/700/uppercase metrics `FieldShell` carried, verbatim. This ends the label-metric split
39
+ between `Field` and `FieldShell` that caused several defects this campaign.
40
+
41
+ The swap replaces the label implementation under six live portals, so it is guarded by a dedicated
42
+ test (`fieldShellRetirement.test.tsx`) asserting the voice, the absence of `Field`'s 16px form
43
+ rhythm, the per-kind reflow rules and the caller-override precedence. Removing `labelVariant`
44
+ fails two of its five assertions — verified, not assumed.
45
+
46
+ ### i18n manifests are untouched
47
+
48
+ `FILTERS_I18N` and `TABLE_I18N` are unchanged, and every portal guard that binds to them keeps
49
+ working. `ui-forms` never calls `t`, so the one field that resolved an i18n key —
50
+ `SelectField`'s `FILTERS_I18N.selectTriggerLabel` accessible name — composes that string HERE, in
51
+ the adapter, and passes the finished value down as `accessibilityLabel`. The i18n stayed with the
52
+ package that owns the keys.
53
+
54
+ ### Notes
55
+
56
+ - New peer dependency: `@dloizides/ui-forms >= 1.8.0`, plus `@dloizides/ui-buttons >= 1.4.0`
57
+ inherited through it (`ui-forms` bundles `FormActions`). All five portals consuming `ui-tables`
58
+ already declare `ui-buttons ^1.4.0`, so this is a declaration of existing reality, not a new
59
+ requirement.
60
+ - `FilterOption` and `DateRangeValue` are now ALIASES of `ui-forms`' `ControlOption` /
61
+ `DateRangeValue`. Public names unchanged; one definition instead of two structurally-identical
62
+ twins free to drift.
63
+ - `DEFAULT_TYPEAHEAD_MIN_CHARS` / `DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS` and `suggestOptions` /
64
+ `isUnmatched` are re-exported from `ui-forms`. Public API unchanged.
65
+ - Inherits the `AnchoredMenu` WCAG fix from `ui-forms` 1.8.0: the selected option now carries
66
+ `aria-selected`. `accessibilityState` is native-only and react-native-web ignores it, so on web
67
+ the current option had been conveyed by colour and font-weight alone (WCAG 1.4.1).
68
+ - `AnchoredMenu` remains one of three near-identical anchored-menu implementations, with
69
+ `ui-layout`'s `InlineMenu` and this package's `SizeDropdown`. Collapsing them was out of scope.
70
+ The move makes it EASIER: two of the three now sit in packages that may depend on `ui-forms`, so
71
+ a future collapse has an obvious home rather than needing a new shared package first.
72
+
73
+ ## 1.13.0
74
+
75
+ De-fork wave W1.1: pagination logic promoted from the byte-identical `PaginatedList`
76
+ twins in erevna-web and katalogos-web.
77
+
78
+ ### Added
79
+
80
+ - `usePagedRows(rows, { pageSize })` — client-side pagination state for an already
81
+ in-memory array. Returns `pageRows`, `currentPage`, `totalPages`, `setPage`,
82
+ `hasPages`, `pageSize`. No new translation keys; no action required.
83
+
84
+ Promoted as a **hook, not a component**, deliberately: the app-side `PaginatedList`
85
+ hard-bound a `FlatList` plus app-specific empty and loading states. Only the paging
86
+ maths is genuinely shared, so only that moved — callers keep their own list renderer.
87
+ For server-side paging keep using `DataTable`'s pager.
88
+
89
+ ### Fixed (behaviour differs from the app-side original)
90
+
91
+ - The original only clamped the page index when `totalPages > 0`, so emptying the list
92
+ left a stale non-zero page behind and the next non-empty render started on the wrong
93
+ page. `usePagedRows` clamps to 0 in that case.
94
+ - A `pageSize` of 0 divided by zero (`Math.ceil(n / 0)` → `Infinity` pages). Now floored
95
+ to 1.
96
+ - `setPage` clamps out-of-range input; the original trusted the caller.
97
+
3
98
  ## 1.12.0
4
99
 
5
100
  Accessibility fix: controls that announced a **bare number** now say what they are. Confirmed in
package/README.md CHANGED
@@ -39,6 +39,13 @@ behaviour everywhere — only the theme changes. Field kinds: `select`, `text`,
39
39
  Every user-facing string is **pre-localized** and passed in (labels, option labels, placeholders,
40
40
  errors) — the package never calls FM/i18n for content, touches a router, or reads a store.
41
41
 
42
+ > **Since 1.14.0 the controls themselves live in [`@dloizides/ui-forms`](https://www.npmjs.com/package/@dloizides/ui-forms)**
43
+ > as `SelectControl`, `TypeaheadControl` and `DateRangeControl`. They used to be private to this
44
+ > bar, which is why the fleet grew 6 selects, 5 date fields and 2 typeaheads — apps could see them
45
+ > working and could not import them. **If you need a select or a date range OUTSIDE a filter bar,
46
+ > import it from `ui-forms` — do not rebuild it, and do not reach into this package.** `Filters`
47
+ > is unchanged and still the right thing for a filter bar; it now composes the shared controls.
48
+
42
49
  ```tsx
43
50
  import { Filters, useFilterDraft, type FilterField, type FilterValues } from '@dloizides/ui-tables';
44
51
 
@@ -262,10 +269,12 @@ required.forEach((key) => expect(en).toHaveProperty(key));
262
269
  ## Install
263
270
 
264
271
  ```bash
265
- npm install @dloizides/ui-tables @dloizides/ui-feedback
272
+ npm install @dloizides/ui-tables @dloizides/ui-feedback @dloizides/ui-forms @dloizides/ui-buttons
266
273
  ```
267
274
 
268
- Peer dependencies: `@dloizides/ui-feedback >= 1.1.0`, `react >= 18`, `react-native >= 0.74`.
275
+ Peer dependencies: `@dloizides/ui-feedback >= 1.1.0`, `@dloizides/ui-forms >= 1.8.0`,
276
+ `@dloizides/ui-buttons >= 1.4.0` (inherited through `ui-forms`), `react >= 18`,
277
+ `react-native >= 0.74`.
269
278
 
270
279
  ## Usage
271
280
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
+ import { DateRangeValue, ControlOption } from '@dloizides/ui-forms';
4
+ export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeValue, isUnmatched, suggestOptions } from '@dloizides/ui-forms';
3
5
 
4
6
  /**
5
7
  * StatCard — a single labelled metric tile (label + formatted numeric value).
@@ -486,16 +488,16 @@ declare const TABLE_I18N: {
486
488
 
487
489
  /** The kinds of field the declarative bar can render. */
488
490
  type FilterFieldKind = 'select' | 'text' | 'number' | 'dateRange' | 'typeahead' | 'boolean';
489
- /** A single choice for a `select` / `typeahead` field. Label is pre-localized. */
490
- interface FilterOption {
491
- readonly label: string;
492
- readonly value: string;
493
- }
494
- /** The inclusive from/to value of a `dateRange` field (each an ISO `YYYY-MM-DD` string, or ''). */
495
- interface DateRangeValue {
496
- readonly from: string;
497
- readonly to: string;
498
- }
491
+ /**
492
+ * A single choice for a `select` / `typeahead` field. Label is pre-localized.
493
+ *
494
+ * F2: an ALIAS of `@dloizides/ui-forms`' `ControlOption`, not a second declaration. The two were
495
+ * structurally identical, which is precisely the shape that drifts silently — a field added to
496
+ * one would type-check against the other until the day it didn't. The public name is unchanged,
497
+ * so this is not a breaking change for any consumer.
498
+ */
499
+ type FilterOption = ControlOption;
500
+
499
501
  /** The runtime value a field holds, by kind. */
500
502
  type FilterValue = string | boolean | DateRangeValue;
501
503
  /** The applied/draft value map, keyed by each field's `key`. */
@@ -566,7 +568,13 @@ type FilterField = SelectFilterField | TextFilterField | NumberFilterField | Dat
566
568
  * FilterFieldView — dispatches one {@link FilterField} to its renderer, wired to the value map.
567
569
  * Reads the field's typed value out of {@link FilterValues} (coercing a missing/mismatched
568
570
  * entry to that kind's empty value) and writes edits back via `setField`. `boolean` renders its
569
- * own inline switch-row; every other kind is wrapped in the label-over-control {@link FieldShell}.
571
+ * own inline switch-row; every other kind is wrapped in `@dloizides/ui-forms`' `Field`.
572
+ *
573
+ * F2: the label wrapper used to be a PRIVATE `FieldShell` fork, which existed only because
574
+ * `Field` hard-coded the 13/600 `field` label voice and offered no way out. `Field` now names
575
+ * both contract voices, so the fork is deleted and the bar asks for `labelVariant="control"`
576
+ * (11/700/uppercase) — the exact metrics `FieldShell` carried. One label implementation, and the
577
+ * label-metric split that caused several defects this campaign is gone.
570
578
  */
571
579
 
572
580
  /** Resolved, pre-localized strings the bar passes down to every field. */
@@ -580,7 +588,7 @@ interface FieldStrings {
580
588
  /**
581
589
  * Args for a custom select renderer — the injection point apps use to swap the built-in
582
590
  * in-tree dropdown for `@dloizides/ui-layout`'s responsive ModalDropdown (modal on mobile /
583
- * native, inline menu on desktop). The label wrapper (FieldShell) is still supplied by the bar.
591
+ * native, inline menu on desktop). The label wrapper is still supplied by the bar.
584
592
  */
585
593
  interface RenderSelectArgs {
586
594
  field: SelectFilterField;
@@ -673,21 +681,6 @@ interface FilterDraft<V extends FilterValues> {
673
681
  }
674
682
  declare function useFilterDraft<V extends FilterValues>({ initial, onApply, onReset }: UseFilterDraftOptions<V>): FilterDraft<V>;
675
683
 
676
- /**
677
- * suggestOptions — the ranked substring matcher behind the `typeahead` field, generalized
678
- * from aml-v2's `suggestCountries`. Ranks: value exact (0) > value prefix (1) > label prefix
679
- * (2) > label contains (3); ties broken by `label.localeCompare`. Empty/short queries return
680
- * `[]` (nothing surfaces until `minChars` is typed, mirroring a native `<datalist>`).
681
- */
682
-
683
- /**
684
- * Rank + cap the options matching `query`. Returns `[]` until `query` (trimmed) is at least
685
- * `minChars` long, then the best `limit` matches, ranked as documented above.
686
- */
687
- declare function suggestOptions(options: readonly FilterOption[], query: string, minChars: number, limit: number): readonly FilterOption[];
688
- /** True when `text` is non-empty yet matches no option's value or label exactly (case-insensitive). */
689
- declare function isUnmatched(options: readonly FilterOption[], text: string): boolean;
690
-
691
684
  /**
692
685
  * Constants for the declarative Filters bar — every test id, i18n key and layout number in
693
686
  * one place so the components carry no magic numbers and no ad-hoc strings.
@@ -697,10 +690,7 @@ declare function isUnmatched(options: readonly FilterOption[], text: string): bo
697
690
  declare const FILTERS_TEST_ID = "ui-filters-declarative";
698
691
  /** Default minimum widths (px) per field kind before it wraps. */
699
692
  declare const FIELD_MIN_WIDTH: Record<FilterFieldKind, number>;
700
- /** Default min characters before a typeahead surfaces suggestions. */
701
- declare const DEFAULT_TYPEAHEAD_MIN_CHARS = 1;
702
- /** Default cap on typeahead suggestions rendered. */
703
- declare const DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS = 8;
693
+
704
694
  /** Derived testIDs for the declarative bar. */
705
695
  declare const fieldTestID: (barTestID: string, key: string) => string;
706
696
  declare const applyTestID: (barTestID: string) => string;
@@ -729,4 +719,33 @@ declare const FILTERS_I18N: {
729
719
  readonly to: "uiTables.filters.to";
730
720
  };
731
721
 
732
- export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, type DateRangeValue, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type NumberFilterField, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, applyTestID, clearTestID, fieldTestID, isUnmatched, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, suggestOptions, useFilterDraft };
722
+ /** Rows to show per page when the caller does not specify. */
723
+ declare const DEFAULT_PAGE_SIZE = 10;
724
+ interface UsePagedRowsOptions {
725
+ /** Rows per page. Values < 1 are treated as 1 — a 0 page size would divide by zero. */
726
+ pageSize?: number;
727
+ }
728
+ interface PagedRows<T> {
729
+ /** The slice of `rows` belonging to the current page. */
730
+ pageRows: T[];
731
+ /** Zero-based index of the current page. */
732
+ currentPage: number;
733
+ /** Total number of pages; 0 when there are no rows. */
734
+ totalPages: number;
735
+ /** Jump to a page. Out-of-range values are clamped into `[0, totalPages - 1]`. */
736
+ setPage: (page: number) => void;
737
+ /** Whether a pager is worth rendering at all (more than one page exists). */
738
+ hasPages: boolean;
739
+ /** Effective page size after the `< 1` guard. */
740
+ pageSize: number;
741
+ }
742
+ /**
743
+ * Slice `rows` into pages and track the current one.
744
+ *
745
+ * The current page is kept valid as `rows` changes: if rows are removed while the
746
+ * user is on the last page, the page index clamps down rather than leaving the
747
+ * caller rendering an empty slice of a non-empty list.
748
+ */
749
+ declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
750
+
751
+ export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle, TextStyle } from 'react-native';
3
+ import { DateRangeValue, ControlOption } from '@dloizides/ui-forms';
4
+ export { DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeValue, isUnmatched, suggestOptions } from '@dloizides/ui-forms';
3
5
 
4
6
  /**
5
7
  * StatCard — a single labelled metric tile (label + formatted numeric value).
@@ -486,16 +488,16 @@ declare const TABLE_I18N: {
486
488
 
487
489
  /** The kinds of field the declarative bar can render. */
488
490
  type FilterFieldKind = 'select' | 'text' | 'number' | 'dateRange' | 'typeahead' | 'boolean';
489
- /** A single choice for a `select` / `typeahead` field. Label is pre-localized. */
490
- interface FilterOption {
491
- readonly label: string;
492
- readonly value: string;
493
- }
494
- /** The inclusive from/to value of a `dateRange` field (each an ISO `YYYY-MM-DD` string, or ''). */
495
- interface DateRangeValue {
496
- readonly from: string;
497
- readonly to: string;
498
- }
491
+ /**
492
+ * A single choice for a `select` / `typeahead` field. Label is pre-localized.
493
+ *
494
+ * F2: an ALIAS of `@dloizides/ui-forms`' `ControlOption`, not a second declaration. The two were
495
+ * structurally identical, which is precisely the shape that drifts silently — a field added to
496
+ * one would type-check against the other until the day it didn't. The public name is unchanged,
497
+ * so this is not a breaking change for any consumer.
498
+ */
499
+ type FilterOption = ControlOption;
500
+
499
501
  /** The runtime value a field holds, by kind. */
500
502
  type FilterValue = string | boolean | DateRangeValue;
501
503
  /** The applied/draft value map, keyed by each field's `key`. */
@@ -566,7 +568,13 @@ type FilterField = SelectFilterField | TextFilterField | NumberFilterField | Dat
566
568
  * FilterFieldView — dispatches one {@link FilterField} to its renderer, wired to the value map.
567
569
  * Reads the field's typed value out of {@link FilterValues} (coercing a missing/mismatched
568
570
  * entry to that kind's empty value) and writes edits back via `setField`. `boolean` renders its
569
- * own inline switch-row; every other kind is wrapped in the label-over-control {@link FieldShell}.
571
+ * own inline switch-row; every other kind is wrapped in `@dloizides/ui-forms`' `Field`.
572
+ *
573
+ * F2: the label wrapper used to be a PRIVATE `FieldShell` fork, which existed only because
574
+ * `Field` hard-coded the 13/600 `field` label voice and offered no way out. `Field` now names
575
+ * both contract voices, so the fork is deleted and the bar asks for `labelVariant="control"`
576
+ * (11/700/uppercase) — the exact metrics `FieldShell` carried. One label implementation, and the
577
+ * label-metric split that caused several defects this campaign is gone.
570
578
  */
571
579
 
572
580
  /** Resolved, pre-localized strings the bar passes down to every field. */
@@ -580,7 +588,7 @@ interface FieldStrings {
580
588
  /**
581
589
  * Args for a custom select renderer — the injection point apps use to swap the built-in
582
590
  * in-tree dropdown for `@dloizides/ui-layout`'s responsive ModalDropdown (modal on mobile /
583
- * native, inline menu on desktop). The label wrapper (FieldShell) is still supplied by the bar.
591
+ * native, inline menu on desktop). The label wrapper is still supplied by the bar.
584
592
  */
585
593
  interface RenderSelectArgs {
586
594
  field: SelectFilterField;
@@ -673,21 +681,6 @@ interface FilterDraft<V extends FilterValues> {
673
681
  }
674
682
  declare function useFilterDraft<V extends FilterValues>({ initial, onApply, onReset }: UseFilterDraftOptions<V>): FilterDraft<V>;
675
683
 
676
- /**
677
- * suggestOptions — the ranked substring matcher behind the `typeahead` field, generalized
678
- * from aml-v2's `suggestCountries`. Ranks: value exact (0) > value prefix (1) > label prefix
679
- * (2) > label contains (3); ties broken by `label.localeCompare`. Empty/short queries return
680
- * `[]` (nothing surfaces until `minChars` is typed, mirroring a native `<datalist>`).
681
- */
682
-
683
- /**
684
- * Rank + cap the options matching `query`. Returns `[]` until `query` (trimmed) is at least
685
- * `minChars` long, then the best `limit` matches, ranked as documented above.
686
- */
687
- declare function suggestOptions(options: readonly FilterOption[], query: string, minChars: number, limit: number): readonly FilterOption[];
688
- /** True when `text` is non-empty yet matches no option's value or label exactly (case-insensitive). */
689
- declare function isUnmatched(options: readonly FilterOption[], text: string): boolean;
690
-
691
684
  /**
692
685
  * Constants for the declarative Filters bar — every test id, i18n key and layout number in
693
686
  * one place so the components carry no magic numbers and no ad-hoc strings.
@@ -697,10 +690,7 @@ declare function isUnmatched(options: readonly FilterOption[], text: string): bo
697
690
  declare const FILTERS_TEST_ID = "ui-filters-declarative";
698
691
  /** Default minimum widths (px) per field kind before it wraps. */
699
692
  declare const FIELD_MIN_WIDTH: Record<FilterFieldKind, number>;
700
- /** Default min characters before a typeahead surfaces suggestions. */
701
- declare const DEFAULT_TYPEAHEAD_MIN_CHARS = 1;
702
- /** Default cap on typeahead suggestions rendered. */
703
- declare const DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS = 8;
693
+
704
694
  /** Derived testIDs for the declarative bar. */
705
695
  declare const fieldTestID: (barTestID: string, key: string) => string;
706
696
  declare const applyTestID: (barTestID: string) => string;
@@ -729,4 +719,33 @@ declare const FILTERS_I18N: {
729
719
  readonly to: "uiTables.filters.to";
730
720
  };
731
721
 
732
- export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE_OPTIONS, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, type DateRangeValue, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type NumberFilterField, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, applyTestID, clearTestID, fieldTestID, isUnmatched, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, suggestOptions, useFilterDraft };
722
+ /** Rows to show per page when the caller does not specify. */
723
+ declare const DEFAULT_PAGE_SIZE = 10;
724
+ interface UsePagedRowsOptions {
725
+ /** Rows per page. Values < 1 are treated as 1 — a 0 page size would divide by zero. */
726
+ pageSize?: number;
727
+ }
728
+ interface PagedRows<T> {
729
+ /** The slice of `rows` belonging to the current page. */
730
+ pageRows: T[];
731
+ /** Zero-based index of the current page. */
732
+ currentPage: number;
733
+ /** Total number of pages; 0 when there are no rows. */
734
+ totalPages: number;
735
+ /** Jump to a page. Out-of-range values are clamped into `[0, totalPages - 1]`. */
736
+ setPage: (page: number) => void;
737
+ /** Whether a pager is worth rendering at all (more than one page exists). */
738
+ hasPages: boolean;
739
+ /** Effective page size after the `< 1` guard. */
740
+ pageSize: number;
741
+ }
742
+ /**
743
+ * Slice `rows` into pages and track the current one.
744
+ *
745
+ * The current page is kept valid as `rows` changes: if rows are removed while the
746
+ * user is on the last page, the page index clamps down rather than leaving the
747
+ * caller rendering an empty slice of a non-empty list.
748
+ */
749
+ declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
750
+
751
+ export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, type DateRangeFilterField, FIELD_MIN_WIDTH, FILTERS_I18N, FILTERS_TEST_ID, type FieldStrings, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, type FilterDraft, type FilterField, type FilterFieldKind, type FilterOption, type FilterValue, type FilterValues, Filters, type FiltersProps, type NumberFilterField, type PagedRows, Pager, type PagerProps, type PagerStyleOverrides, type RenderSelectArgs, type SelectFilterField, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, type TextFilterField, type TypeaheadFilterField, type UseFilterDraftOptions, type UsePagedRowsOptions, applyTestID, clearTestID, fieldTestID, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, useFilterDraft, usePagedRows };