@dloizides/ui-tables 1.11.0 → 1.13.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 +80 -0
- package/README.md +36 -2
- package/dist/index.d.mts +57 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.js +130 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.13.0
|
|
4
|
+
|
|
5
|
+
De-fork wave W1.1: pagination logic promoted from the byte-identical `PaginatedList`
|
|
6
|
+
twins in erevna-web and katalogos-web.
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- `usePagedRows(rows, { pageSize })` — client-side pagination state for an already
|
|
11
|
+
in-memory array. Returns `pageRows`, `currentPage`, `totalPages`, `setPage`,
|
|
12
|
+
`hasPages`, `pageSize`. No new translation keys; no action required.
|
|
13
|
+
|
|
14
|
+
Promoted as a **hook, not a component**, deliberately: the app-side `PaginatedList`
|
|
15
|
+
hard-bound a `FlatList` plus app-specific empty and loading states. Only the paging
|
|
16
|
+
maths is genuinely shared, so only that moved — callers keep their own list renderer.
|
|
17
|
+
For server-side paging keep using `DataTable`'s pager.
|
|
18
|
+
|
|
19
|
+
### Fixed (behaviour differs from the app-side original)
|
|
20
|
+
|
|
21
|
+
- The original only clamped the page index when `totalPages > 0`, so emptying the list
|
|
22
|
+
left a stale non-zero page behind and the next non-empty render started on the wrong
|
|
23
|
+
page. `usePagedRows` clamps to 0 in that case.
|
|
24
|
+
- A `pageSize` of 0 divided by zero (`Math.ceil(n / 0)` → `Infinity` pages). Now floored
|
|
25
|
+
to 1.
|
|
26
|
+
- `setPage` clamps out-of-range input; the original trusted the caller.
|
|
27
|
+
|
|
28
|
+
## 1.12.0
|
|
29
|
+
|
|
30
|
+
Accessibility fix: controls that announced a **bare number** now say what they are. Confirmed in
|
|
31
|
+
a real browser, the rows-per-page trigger rendered `aria-label="50"` — a screen-reader user heard
|
|
32
|
+
the value and nothing about the control. Fixed across the whole package, plus two more instances
|
|
33
|
+
of the same defect class found while auditing.
|
|
34
|
+
|
|
35
|
+
### ⚠️ ACTION REQUIRED — add three translation keys
|
|
36
|
+
|
|
37
|
+
The new accessible names are user-facing strings, so they come from the host app's locale files.
|
|
38
|
+
**Every consuming app must add these three keys:**
|
|
39
|
+
|
|
40
|
+
| Key | Params | Suggested English |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `uiTables.pager.rowsTriggerLabel` | `{{p1}}` = current page size | `Rows per page, currently {{p1}}` |
|
|
43
|
+
| `uiTables.pager.rowsOptionLabel` | `{{p1}}` = that option's size | `Show {{p1}} rows per page` |
|
|
44
|
+
| `uiTables.filters.selectTriggerLabel` | `{{p1}}` = field label, `{{p2}}` = selection | `{{p1}}: {{p2}}` |
|
|
45
|
+
|
|
46
|
+
They are exported as `TABLE_I18N.pagerRowsTriggerLabel`, `TABLE_I18N.pagerRowsOptionLabel` and
|
|
47
|
+
`FILTERS_I18N.selectTriggerLabel`, so an app that derives its required-key list from those maps
|
|
48
|
+
(as zygos' guard test does) picks them up automatically.
|
|
49
|
+
|
|
50
|
+
**Upgrading without adding them is safe.** Unlike the usual kit contract — where an undefined key
|
|
51
|
+
renders as its literal dotted name, the failure that put 44 raw keys on screen in zygos — a
|
|
52
|
+
newly-introduced ACCESSIBLE-NAME key degrades to the value it replaced (the bare number, the field
|
|
53
|
+
label). An aria-label is invisible to sighted reviewers, so a raw key there would ship silently and
|
|
54
|
+
hurt only screen-reader users. Until you add the keys you simply keep the old, worse names.
|
|
55
|
+
|
|
56
|
+
### Fixed
|
|
57
|
+
|
|
58
|
+
- **`Pager` rows-per-page trigger** (`dropdown` variant) — was `aria-label="50"`, now
|
|
59
|
+
"Rows per page, currently 50".
|
|
60
|
+
- **`Pager` rows-per-page options** (`dropdown` variant) — was `aria-label="100"`, now
|
|
61
|
+
"Show 100 rows per page".
|
|
62
|
+
- **`Pager` rows-per-page pills** (the **DEFAULT** `pills` variant) — carried the identical
|
|
63
|
+
bare-number defect and was NOT in the original report, so it affected more consumers than the
|
|
64
|
+
dropdown did. Same fix, same key.
|
|
65
|
+
- **`Filters` select trigger** — `accessibilityLabel` replaces the trigger's visible text for a
|
|
66
|
+
screen reader, so labelling it `field.label` alone silently hid the current selection: sighted
|
|
67
|
+
users saw "Closed", screen-reader users heard only "Status". Now "Status: Closed".
|
|
68
|
+
- **`StatCard`** — its two translation keys were string literals inlined in the component rather
|
|
69
|
+
than members of an exported map, so an app deriving its required-key list from `TABLE_I18N`
|
|
70
|
+
could not see them and would render them raw. Now exported as `TABLE_I18N.statCardLabel` /
|
|
71
|
+
`TABLE_I18N.statHint`. **The key strings are unchanged** (`analytics.statCardLabel`,
|
|
72
|
+
`analytics.statHint`) — renaming them would have broken every app that already defines them.
|
|
73
|
+
|
|
74
|
+
### Added
|
|
75
|
+
|
|
76
|
+
- **`accessibleName(translated, key, fallback)`** — the internal degradation guard described
|
|
77
|
+
above. Not exported; the kit's fallback-free i18n contract is unchanged for visible copy.
|
|
78
|
+
|
|
79
|
+
Additive and backward compatible for consumers — no public prop changed, so a MINOR bump.
|
|
80
|
+
`SizeDropdown`'s props gained `triggerLabel` / `getOptionLabel`, but that component is internal
|
|
81
|
+
(never exported from the package root).
|
|
82
|
+
|
|
3
83
|
## 1.11.0
|
|
4
84
|
|
|
5
85
|
Additive: a **declarative `Filters` bar** + **Pager** enhancements. Every change is additive and
|
package/README.md
CHANGED
|
@@ -226,6 +226,39 @@ renders exactly as it always has.
|
|
|
226
226
|
|
|
227
227
|
Colours come entirely from `useUi().theme` (drive it with `@dloizides/design-tokens` via `tokensToUiTheme`), so the grid re-themes per tenant. Every component-authored string is routed through the UiProvider `t` — provide the `uiTables.*` keys (see `TABLE_I18N`) in your locale files; a caller may also pass already-translated `loadingLabel` / `emptyLabel` / `resultsLabel` directly.
|
|
228
228
|
|
|
229
|
+
## ⚠️ New in 1.12.0 — three translation keys every host app must add
|
|
230
|
+
|
|
231
|
+
1.12.0 gives three controls a real accessible name instead of a bare number. Those names are
|
|
232
|
+
user-facing strings, so they come from **your** locale files. **Add these three keys.**
|
|
233
|
+
|
|
234
|
+
| Key (constant) | Key (string) | Params | Suggested English |
|
|
235
|
+
|---|---|---|---|
|
|
236
|
+
| `TABLE_I18N.pagerRowsTriggerLabel` | `uiTables.pager.rowsTriggerLabel` | `{{p1}}` = current page size | `Rows per page, currently {{p1}}` |
|
|
237
|
+
| `TABLE_I18N.pagerRowsOptionLabel` | `uiTables.pager.rowsOptionLabel` | `{{p1}}` = that option's size | `Show {{p1}} rows per page` |
|
|
238
|
+
| `FILTERS_I18N.selectTriggerLabel` | `uiTables.filters.selectTriggerLabel` | `{{p1}}` = field label, `{{p2}}` = selected option | `{{p1}}: {{p2}}` |
|
|
239
|
+
|
|
240
|
+
Also newly **listed** in `TABLE_I18N` (not new keys — StatCard has always called them, they were
|
|
241
|
+
just inlined in the component where a key-coverage guard could not see them). If your app renders
|
|
242
|
+
`StatCard`, check you actually define them:
|
|
243
|
+
|
|
244
|
+
| Key (constant) | Key (string) | Params |
|
|
245
|
+
|---|---|---|
|
|
246
|
+
| `TABLE_I18N.statCardLabel` | `analytics.statCardLabel` | `{{p1}}` = label, `{{p2}}` = value |
|
|
247
|
+
| `TABLE_I18N.statHint` | `analytics.statHint` | `{{p1}}` = label |
|
|
248
|
+
|
|
249
|
+
**Your app will not visibly break if you skip this.** A key you have not defined degrades to the
|
|
250
|
+
value it replaced (the bare number, the field label alone) rather than to the raw dotted key —
|
|
251
|
+
so upgrading is safe, but until you add the keys your screen-reader users keep the old, worse
|
|
252
|
+
experience. Derive your required-key list from the exported maps rather than hand-maintaining it:
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
import { TABLE_I18N, FILTERS_I18N } from '@dloizides/ui-tables';
|
|
256
|
+
|
|
257
|
+
// Guard test: every key the kit can ask for must exist in your locale file.
|
|
258
|
+
const required = [...Object.values(TABLE_I18N), ...Object.values(FILTERS_I18N)];
|
|
259
|
+
required.forEach((key) => expect(en).toHaveProperty(key));
|
|
260
|
+
```
|
|
261
|
+
|
|
229
262
|
## Install
|
|
230
263
|
|
|
231
264
|
```bash
|
|
@@ -243,8 +276,9 @@ import { StatCard } from '@dloizides/ui-tables';
|
|
|
243
276
|
```
|
|
244
277
|
|
|
245
278
|
Mount a `FeedbackUiProvider` / `UiProvider` (from `@dloizides/ui-feedback`) at your app root so the
|
|
246
|
-
component picks up your theme + translations. The injected `t` is called with `
|
|
247
|
-
`analytics.statCardLabel` (provide these
|
|
279
|
+
component picks up your theme + translations. The injected `t` is called with `TABLE_I18N.statHint`
|
|
280
|
+
(`analytics.statHint`) and `TABLE_I18N.statCardLabel` (`analytics.statCardLabel`) — provide these
|
|
281
|
+
keys in your locale files.
|
|
248
282
|
|
|
249
283
|
## License
|
|
250
284
|
|
package/dist/index.d.mts
CHANGED
|
@@ -447,6 +447,26 @@ declare const TABLE_I18N: {
|
|
|
447
447
|
readonly pagerRowsOptionHint: "uiTables.pager.rowsOptionHint";
|
|
448
448
|
/** Accessible hint for the dropdown-variant rows-per-page trigger button. */
|
|
449
449
|
readonly pagerRowsTriggerHint: "uiTables.pager.rowsTriggerHint";
|
|
450
|
+
/**
|
|
451
|
+
* Accessible NAME of the rows-per-page control, e.g. "Rows per page, currently {{p1}}".
|
|
452
|
+
* Without it the control is announced as the bare number ("50"), which says nothing about
|
|
453
|
+
* what it does. Untranslated it degrades to that bare number — never to the raw key.
|
|
454
|
+
*/
|
|
455
|
+
readonly pagerRowsTriggerLabel: "uiTables.pager.rowsTriggerLabel";
|
|
456
|
+
/**
|
|
457
|
+
* Accessible NAME of ONE rows-per-page choice, e.g. "Show {{p1}} rows per page". Used by
|
|
458
|
+
* BOTH the `dropdown` options and the default `pills`. Untranslated it degrades to the
|
|
459
|
+
* bare number — never to the raw key.
|
|
460
|
+
*/
|
|
461
|
+
readonly pagerRowsOptionLabel: "uiTables.pager.rowsOptionLabel";
|
|
462
|
+
/**
|
|
463
|
+
* StatCard's accessible name, e.g. "{{p1}}: {{p2}}". Note the `analytics.` prefix: these
|
|
464
|
+
* two keys predate this map and were only ever inlined in StatCard.tsx, so apps deriving
|
|
465
|
+
* their required-key list from TABLE_I18N could not see them. Registered here UNCHANGED
|
|
466
|
+
* (renaming them would break every app that already defines them).
|
|
467
|
+
*/
|
|
468
|
+
readonly statCardLabel: "analytics.statCardLabel";
|
|
469
|
+
readonly statHint: "analytics.statHint";
|
|
450
470
|
};
|
|
451
471
|
|
|
452
472
|
/**
|
|
@@ -698,8 +718,44 @@ declare const FILTERS_I18N: {
|
|
|
698
718
|
readonly selectPlaceholder: "uiTables.filters.selectPlaceholder";
|
|
699
719
|
readonly dropdownHint: "uiTables.filters.dropdownHint";
|
|
700
720
|
readonly optionHint: "uiTables.filters.optionHint";
|
|
721
|
+
/**
|
|
722
|
+
* Accessible NAME of a select trigger, e.g. "{{p1}}: {{p2}}" → "Status: Active". The
|
|
723
|
+
* trigger's `accessibilityLabel` REPLACES its visible text for a screen reader, so labelling
|
|
724
|
+
* it with the field name alone silently hides the current selection. Untranslated it
|
|
725
|
+
* degrades to the field label alone (prior behaviour) — never to the raw key.
|
|
726
|
+
*/
|
|
727
|
+
readonly selectTriggerLabel: "uiTables.filters.selectTriggerLabel";
|
|
701
728
|
readonly from: "uiTables.filters.from";
|
|
702
729
|
readonly to: "uiTables.filters.to";
|
|
703
730
|
};
|
|
704
731
|
|
|
705
|
-
|
|
732
|
+
/** Rows to show per page when the caller does not specify. */
|
|
733
|
+
declare const DEFAULT_PAGE_SIZE = 10;
|
|
734
|
+
interface UsePagedRowsOptions {
|
|
735
|
+
/** Rows per page. Values < 1 are treated as 1 — a 0 page size would divide by zero. */
|
|
736
|
+
pageSize?: number;
|
|
737
|
+
}
|
|
738
|
+
interface PagedRows<T> {
|
|
739
|
+
/** The slice of `rows` belonging to the current page. */
|
|
740
|
+
pageRows: T[];
|
|
741
|
+
/** Zero-based index of the current page. */
|
|
742
|
+
currentPage: number;
|
|
743
|
+
/** Total number of pages; 0 when there are no rows. */
|
|
744
|
+
totalPages: number;
|
|
745
|
+
/** Jump to a page. Out-of-range values are clamped into `[0, totalPages - 1]`. */
|
|
746
|
+
setPage: (page: number) => void;
|
|
747
|
+
/** Whether a pager is worth rendering at all (more than one page exists). */
|
|
748
|
+
hasPages: boolean;
|
|
749
|
+
/** Effective page size after the `< 1` guard. */
|
|
750
|
+
pageSize: number;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Slice `rows` into pages and track the current one.
|
|
754
|
+
*
|
|
755
|
+
* The current page is kept valid as `rows` changes: if rows are removed while the
|
|
756
|
+
* user is on the last page, the page index clamps down rather than leaving the
|
|
757
|
+
* caller rendering an empty slice of a non-empty list.
|
|
758
|
+
*/
|
|
759
|
+
declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
|
|
760
|
+
|
|
761
|
+
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, 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, 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, isUnmatched, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, suggestOptions, useFilterDraft, usePagedRows };
|
package/dist/index.d.ts
CHANGED
|
@@ -447,6 +447,26 @@ declare const TABLE_I18N: {
|
|
|
447
447
|
readonly pagerRowsOptionHint: "uiTables.pager.rowsOptionHint";
|
|
448
448
|
/** Accessible hint for the dropdown-variant rows-per-page trigger button. */
|
|
449
449
|
readonly pagerRowsTriggerHint: "uiTables.pager.rowsTriggerHint";
|
|
450
|
+
/**
|
|
451
|
+
* Accessible NAME of the rows-per-page control, e.g. "Rows per page, currently {{p1}}".
|
|
452
|
+
* Without it the control is announced as the bare number ("50"), which says nothing about
|
|
453
|
+
* what it does. Untranslated it degrades to that bare number — never to the raw key.
|
|
454
|
+
*/
|
|
455
|
+
readonly pagerRowsTriggerLabel: "uiTables.pager.rowsTriggerLabel";
|
|
456
|
+
/**
|
|
457
|
+
* Accessible NAME of ONE rows-per-page choice, e.g. "Show {{p1}} rows per page". Used by
|
|
458
|
+
* BOTH the `dropdown` options and the default `pills`. Untranslated it degrades to the
|
|
459
|
+
* bare number — never to the raw key.
|
|
460
|
+
*/
|
|
461
|
+
readonly pagerRowsOptionLabel: "uiTables.pager.rowsOptionLabel";
|
|
462
|
+
/**
|
|
463
|
+
* StatCard's accessible name, e.g. "{{p1}}: {{p2}}". Note the `analytics.` prefix: these
|
|
464
|
+
* two keys predate this map and were only ever inlined in StatCard.tsx, so apps deriving
|
|
465
|
+
* their required-key list from TABLE_I18N could not see them. Registered here UNCHANGED
|
|
466
|
+
* (renaming them would break every app that already defines them).
|
|
467
|
+
*/
|
|
468
|
+
readonly statCardLabel: "analytics.statCardLabel";
|
|
469
|
+
readonly statHint: "analytics.statHint";
|
|
450
470
|
};
|
|
451
471
|
|
|
452
472
|
/**
|
|
@@ -698,8 +718,44 @@ declare const FILTERS_I18N: {
|
|
|
698
718
|
readonly selectPlaceholder: "uiTables.filters.selectPlaceholder";
|
|
699
719
|
readonly dropdownHint: "uiTables.filters.dropdownHint";
|
|
700
720
|
readonly optionHint: "uiTables.filters.optionHint";
|
|
721
|
+
/**
|
|
722
|
+
* Accessible NAME of a select trigger, e.g. "{{p1}}: {{p2}}" → "Status: Active". The
|
|
723
|
+
* trigger's `accessibilityLabel` REPLACES its visible text for a screen reader, so labelling
|
|
724
|
+
* it with the field name alone silently hides the current selection. Untranslated it
|
|
725
|
+
* degrades to the field label alone (prior behaviour) — never to the raw key.
|
|
726
|
+
*/
|
|
727
|
+
readonly selectTriggerLabel: "uiTables.filters.selectTriggerLabel";
|
|
701
728
|
readonly from: "uiTables.filters.from";
|
|
702
729
|
readonly to: "uiTables.filters.to";
|
|
703
730
|
};
|
|
704
731
|
|
|
705
|
-
|
|
732
|
+
/** Rows to show per page when the caller does not specify. */
|
|
733
|
+
declare const DEFAULT_PAGE_SIZE = 10;
|
|
734
|
+
interface UsePagedRowsOptions {
|
|
735
|
+
/** Rows per page. Values < 1 are treated as 1 — a 0 page size would divide by zero. */
|
|
736
|
+
pageSize?: number;
|
|
737
|
+
}
|
|
738
|
+
interface PagedRows<T> {
|
|
739
|
+
/** The slice of `rows` belonging to the current page. */
|
|
740
|
+
pageRows: T[];
|
|
741
|
+
/** Zero-based index of the current page. */
|
|
742
|
+
currentPage: number;
|
|
743
|
+
/** Total number of pages; 0 when there are no rows. */
|
|
744
|
+
totalPages: number;
|
|
745
|
+
/** Jump to a page. Out-of-range values are clamped into `[0, totalPages - 1]`. */
|
|
746
|
+
setPage: (page: number) => void;
|
|
747
|
+
/** Whether a pager is worth rendering at all (more than one page exists). */
|
|
748
|
+
hasPages: boolean;
|
|
749
|
+
/** Effective page size after the `< 1` guard. */
|
|
750
|
+
pageSize: number;
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Slice `rows` into pages and track the current one.
|
|
754
|
+
*
|
|
755
|
+
* The current page is kept valid as `rows` changes: if rows are removed while the
|
|
756
|
+
* user is on the last page, the page index clamps down rather than leaving the
|
|
757
|
+
* caller rendering an empty slice of a non-empty list.
|
|
758
|
+
*/
|
|
759
|
+
declare function usePagedRows<T>(rows: readonly T[], options?: UsePagedRowsOptions): PagedRows<T>;
|
|
760
|
+
|
|
761
|
+
export { type BooleanFilterField, CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE, 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, 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, isUnmatched, rowDetailTestID, rowSelectTestID, rowTestID, selectAllTestID, suggestOptions, useFilterDraft, usePagedRows };
|
package/dist/index.js
CHANGED
|
@@ -11,48 +11,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
11
11
|
var React4__default = /*#__PURE__*/_interopDefault(React4);
|
|
12
12
|
|
|
13
13
|
// src/StatCard/StatCard.tsx
|
|
14
|
-
var CARD_PADDING = 16;
|
|
15
|
-
var CARD_BORDER_RADIUS = 12;
|
|
16
|
-
var CARD_BORDER_WIDTH = 1;
|
|
17
|
-
var LABEL_FONT_SIZE = 14;
|
|
18
|
-
var VALUE_FONT_SIZE = 28;
|
|
19
|
-
var VALUE_LINE_HEIGHT = 36;
|
|
20
|
-
var styles = reactNative.StyleSheet.create({
|
|
21
|
-
card: {
|
|
22
|
-
padding: CARD_PADDING,
|
|
23
|
-
borderRadius: CARD_BORDER_RADIUS,
|
|
24
|
-
borderWidth: CARD_BORDER_WIDTH
|
|
25
|
-
},
|
|
26
|
-
label: {
|
|
27
|
-
fontSize: LABEL_FONT_SIZE,
|
|
28
|
-
fontWeight: "500"
|
|
29
|
-
},
|
|
30
|
-
value: {
|
|
31
|
-
fontSize: VALUE_FONT_SIZE,
|
|
32
|
-
fontWeight: "700",
|
|
33
|
-
lineHeight: VALUE_LINE_HEIGHT
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
var StatCard = React4.memo(({ label, value, testID }) => {
|
|
37
|
-
const { theme, t } = uiFeedback.useUi();
|
|
38
|
-
const { colors } = theme;
|
|
39
|
-
const formattedValue = value.toLocaleString();
|
|
40
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
41
|
-
reactNative.View,
|
|
42
|
-
{
|
|
43
|
-
accessibilityHint: t("analytics.statHint", label),
|
|
44
|
-
accessibilityLabel: t("analytics.statCardLabel", label, formattedValue),
|
|
45
|
-
accessibilityRole: "text",
|
|
46
|
-
style: [styles.card, { backgroundColor: colors.surface, borderColor: colors.border }],
|
|
47
|
-
testID,
|
|
48
|
-
children: [
|
|
49
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.label, { color: colors.textSecondary }], children: label }),
|
|
50
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.value, { color: colors.text }], children: formattedValue })
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
StatCard.displayName = "StatCard";
|
|
56
14
|
|
|
57
15
|
// src/DataTable/constants.ts
|
|
58
16
|
var CARD_STACK_BREAKPOINT = 640;
|
|
@@ -121,8 +79,70 @@ var TABLE_I18N = {
|
|
|
121
79
|
pagerRows: "uiTables.pager.rows",
|
|
122
80
|
pagerRowsOptionHint: "uiTables.pager.rowsOptionHint",
|
|
123
81
|
/** Accessible hint for the dropdown-variant rows-per-page trigger button. */
|
|
124
|
-
pagerRowsTriggerHint: "uiTables.pager.rowsTriggerHint"
|
|
82
|
+
pagerRowsTriggerHint: "uiTables.pager.rowsTriggerHint",
|
|
83
|
+
/**
|
|
84
|
+
* Accessible NAME of the rows-per-page control, e.g. "Rows per page, currently {{p1}}".
|
|
85
|
+
* Without it the control is announced as the bare number ("50"), which says nothing about
|
|
86
|
+
* what it does. Untranslated it degrades to that bare number — never to the raw key.
|
|
87
|
+
*/
|
|
88
|
+
pagerRowsTriggerLabel: "uiTables.pager.rowsTriggerLabel",
|
|
89
|
+
/**
|
|
90
|
+
* Accessible NAME of ONE rows-per-page choice, e.g. "Show {{p1}} rows per page". Used by
|
|
91
|
+
* BOTH the `dropdown` options and the default `pills`. Untranslated it degrades to the
|
|
92
|
+
* bare number — never to the raw key.
|
|
93
|
+
*/
|
|
94
|
+
pagerRowsOptionLabel: "uiTables.pager.rowsOptionLabel",
|
|
95
|
+
/**
|
|
96
|
+
* StatCard's accessible name, e.g. "{{p1}}: {{p2}}". Note the `analytics.` prefix: these
|
|
97
|
+
* two keys predate this map and were only ever inlined in StatCard.tsx, so apps deriving
|
|
98
|
+
* their required-key list from TABLE_I18N could not see them. Registered here UNCHANGED
|
|
99
|
+
* (renaming them would break every app that already defines them).
|
|
100
|
+
*/
|
|
101
|
+
statCardLabel: "analytics.statCardLabel",
|
|
102
|
+
statHint: "analytics.statHint"
|
|
125
103
|
};
|
|
104
|
+
var CARD_PADDING = 16;
|
|
105
|
+
var CARD_BORDER_RADIUS = 12;
|
|
106
|
+
var CARD_BORDER_WIDTH = 1;
|
|
107
|
+
var LABEL_FONT_SIZE = 14;
|
|
108
|
+
var VALUE_FONT_SIZE = 28;
|
|
109
|
+
var VALUE_LINE_HEIGHT = 36;
|
|
110
|
+
var styles = reactNative.StyleSheet.create({
|
|
111
|
+
card: {
|
|
112
|
+
padding: CARD_PADDING,
|
|
113
|
+
borderRadius: CARD_BORDER_RADIUS,
|
|
114
|
+
borderWidth: CARD_BORDER_WIDTH
|
|
115
|
+
},
|
|
116
|
+
label: {
|
|
117
|
+
fontSize: LABEL_FONT_SIZE,
|
|
118
|
+
fontWeight: "500"
|
|
119
|
+
},
|
|
120
|
+
value: {
|
|
121
|
+
fontSize: VALUE_FONT_SIZE,
|
|
122
|
+
fontWeight: "700",
|
|
123
|
+
lineHeight: VALUE_LINE_HEIGHT
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
var StatCard = React4.memo(({ label, value, testID }) => {
|
|
127
|
+
const { theme, t } = uiFeedback.useUi();
|
|
128
|
+
const { colors } = theme;
|
|
129
|
+
const formattedValue = value.toLocaleString();
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
131
|
+
reactNative.View,
|
|
132
|
+
{
|
|
133
|
+
accessibilityHint: t(TABLE_I18N.statHint, label),
|
|
134
|
+
accessibilityLabel: t(TABLE_I18N.statCardLabel, label, formattedValue),
|
|
135
|
+
accessibilityRole: "text",
|
|
136
|
+
style: [styles.card, { backgroundColor: colors.surface, borderColor: colors.border }],
|
|
137
|
+
testID,
|
|
138
|
+
children: [
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.label, { color: colors.textSecondary }], children: label }),
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles.value, { color: colors.text }], children: formattedValue })
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
});
|
|
145
|
+
StatCard.displayName = "StatCard";
|
|
126
146
|
var BORDER_WIDTH = 1;
|
|
127
147
|
var BORDER_RADIUS = 12;
|
|
128
148
|
var COLUMN_GAP = 16;
|
|
@@ -957,6 +977,12 @@ function FilterBar({
|
|
|
957
977
|
!!actions && /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chromeStyles.filtersActions, o?.filtersActions], children: actions })
|
|
958
978
|
] });
|
|
959
979
|
}
|
|
980
|
+
|
|
981
|
+
// src/accessibleName.ts
|
|
982
|
+
function accessibleName(translated, key, fallback) {
|
|
983
|
+
const isUntranslated = translated === key || translated === "";
|
|
984
|
+
return isUntranslated ? fallback : translated;
|
|
985
|
+
}
|
|
960
986
|
var CHEVRON_DOWN = "\u25BE";
|
|
961
987
|
var CHEVRON_UP = "\u25B4";
|
|
962
988
|
var IS_WEB2 = reactNative.Platform.OS === "web";
|
|
@@ -1022,6 +1048,8 @@ function SizeDropdown({
|
|
|
1022
1048
|
pageSizeOptions,
|
|
1023
1049
|
onPageSizeChange,
|
|
1024
1050
|
testID,
|
|
1051
|
+
triggerLabel,
|
|
1052
|
+
getOptionLabel,
|
|
1025
1053
|
triggerHint,
|
|
1026
1054
|
optionHint,
|
|
1027
1055
|
textColor,
|
|
@@ -1065,7 +1093,7 @@ function SizeDropdown({
|
|
|
1065
1093
|
{
|
|
1066
1094
|
testID: `${testID}-size-${size}`,
|
|
1067
1095
|
accessibilityRole: "menuitem",
|
|
1068
|
-
accessibilityLabel:
|
|
1096
|
+
accessibilityLabel: getOptionLabel(size),
|
|
1069
1097
|
accessibilityHint: optionHint,
|
|
1070
1098
|
accessibilityState: { selected: active },
|
|
1071
1099
|
onPress: () => select(size),
|
|
@@ -1083,7 +1111,7 @@ function SizeDropdown({
|
|
|
1083
1111
|
{
|
|
1084
1112
|
testID: `${testID}-size-trigger`,
|
|
1085
1113
|
accessibilityRole: "button",
|
|
1086
|
-
accessibilityLabel:
|
|
1114
|
+
accessibilityLabel: triggerLabel,
|
|
1087
1115
|
accessibilityHint: triggerHint,
|
|
1088
1116
|
accessibilityState: { expanded: isOpen },
|
|
1089
1117
|
"aria-expanded": isOpen,
|
|
@@ -1120,6 +1148,14 @@ function NavButton({ label, hint, disabled, onPress, color, border, testID, styl
|
|
|
1120
1148
|
}
|
|
1121
1149
|
);
|
|
1122
1150
|
}
|
|
1151
|
+
function rowsTriggerLabel(t, pageSize) {
|
|
1152
|
+
const size = String(pageSize);
|
|
1153
|
+
return accessibleName(t(TABLE_I18N.pagerRowsTriggerLabel, size), TABLE_I18N.pagerRowsTriggerLabel, size);
|
|
1154
|
+
}
|
|
1155
|
+
function rowsOptionLabel(t, optionSize) {
|
|
1156
|
+
const size = String(optionSize);
|
|
1157
|
+
return accessibleName(t(TABLE_I18N.pagerRowsOptionLabel, size), TABLE_I18N.pagerRowsOptionLabel, size);
|
|
1158
|
+
}
|
|
1123
1159
|
function RowsControl({ pageSize, pageSizeOptions, onPageSizeChange, isDropdown, testID, styleOverrides: o }) {
|
|
1124
1160
|
const { theme, t } = uiFeedback.useUi();
|
|
1125
1161
|
const { colors, palette } = theme;
|
|
@@ -1133,6 +1169,8 @@ function RowsControl({ pageSize, pageSizeOptions, onPageSizeChange, isDropdown,
|
|
|
1133
1169
|
pageSizeOptions,
|
|
1134
1170
|
onPageSizeChange,
|
|
1135
1171
|
testID,
|
|
1172
|
+
triggerLabel: rowsTriggerLabel(t, pageSize),
|
|
1173
|
+
getOptionLabel: (size) => rowsOptionLabel(t, size),
|
|
1136
1174
|
triggerHint: t(TABLE_I18N.pagerRowsTriggerHint),
|
|
1137
1175
|
optionHint: t(TABLE_I18N.pagerRowsOptionHint),
|
|
1138
1176
|
textColor: colors.text,
|
|
@@ -1150,7 +1188,7 @@ function RowsControl({ pageSize, pageSizeOptions, onPageSizeChange, isDropdown,
|
|
|
1150
1188
|
{
|
|
1151
1189
|
testID: `${testID}-size-${size}`,
|
|
1152
1190
|
accessibilityRole: "button",
|
|
1153
|
-
accessibilityLabel:
|
|
1191
|
+
accessibilityLabel: rowsOptionLabel(t, size),
|
|
1154
1192
|
accessibilityHint: t(TABLE_I18N.pagerRowsOptionHint),
|
|
1155
1193
|
accessibilityState: { selected: active },
|
|
1156
1194
|
hitSlop: PAGER_HIT_SLOP,
|
|
@@ -1447,6 +1485,13 @@ var FILTERS_I18N = {
|
|
|
1447
1485
|
selectPlaceholder: "uiTables.filters.selectPlaceholder",
|
|
1448
1486
|
dropdownHint: "uiTables.filters.dropdownHint",
|
|
1449
1487
|
optionHint: "uiTables.filters.optionHint",
|
|
1488
|
+
/**
|
|
1489
|
+
* Accessible NAME of a select trigger, e.g. "{{p1}}: {{p2}}" → "Status: Active". The
|
|
1490
|
+
* trigger's `accessibilityLabel` REPLACES its visible text for a screen reader, so labelling
|
|
1491
|
+
* it with the field name alone silently hides the current selection. Untranslated it
|
|
1492
|
+
* degrades to the field label alone (prior behaviour) — never to the raw key.
|
|
1493
|
+
*/
|
|
1494
|
+
selectTriggerLabel: "uiTables.filters.selectTriggerLabel",
|
|
1450
1495
|
from: "uiTables.filters.from",
|
|
1451
1496
|
to: "uiTables.filters.to"
|
|
1452
1497
|
};
|
|
@@ -1619,7 +1664,7 @@ function AnchoredMenu({
|
|
|
1619
1664
|
var CHEVRON_DOWN2 = "\u25BE";
|
|
1620
1665
|
var CHEVRON_UP2 = "\u25B4";
|
|
1621
1666
|
function SelectField({ field, barTestID, value, onChange, placeholder, dropdownHint, optionHint }) {
|
|
1622
|
-
const { theme } = uiFeedback.useUi();
|
|
1667
|
+
const { theme, t } = uiFeedback.useUi();
|
|
1623
1668
|
const { colors, palette } = theme;
|
|
1624
1669
|
const anchorRef = React4.useRef(null);
|
|
1625
1670
|
const [isOpen, setIsOpen] = React4.useState(false);
|
|
@@ -1628,6 +1673,11 @@ function SelectField({ field, barTestID, value, onChange, placeholder, dropdownH
|
|
|
1628
1673
|
const found = field.options.find((o) => o.value === value);
|
|
1629
1674
|
return found?.label ?? field.placeholder ?? placeholder;
|
|
1630
1675
|
}, [field.options, field.placeholder, placeholder, value]);
|
|
1676
|
+
const triggerLabel = accessibleName(
|
|
1677
|
+
t(FILTERS_I18N.selectTriggerLabel, field.label, selectedLabel),
|
|
1678
|
+
FILTERS_I18N.selectTriggerLabel,
|
|
1679
|
+
field.label
|
|
1680
|
+
);
|
|
1631
1681
|
const close = React4.useCallback(() => {
|
|
1632
1682
|
setIsOpen(false);
|
|
1633
1683
|
}, []);
|
|
@@ -1646,7 +1696,7 @@ function SelectField({ field, barTestID, value, onChange, placeholder, dropdownH
|
|
|
1646
1696
|
reactNative.Pressable,
|
|
1647
1697
|
{
|
|
1648
1698
|
accessibilityRole: "button",
|
|
1649
|
-
accessibilityLabel:
|
|
1699
|
+
accessibilityLabel: triggerLabel,
|
|
1650
1700
|
accessibilityHint: field.accessibilityHint ?? dropdownHint,
|
|
1651
1701
|
accessibilityState: { expanded: isOpen },
|
|
1652
1702
|
"aria-expanded": isOpen,
|
|
@@ -1993,8 +2043,39 @@ function useFilterDraft({ initial, onApply, onReset }) {
|
|
|
1993
2043
|
const dirty = React4.useMemo(() => !shallowEqual(draft, committed), [draft, committed]);
|
|
1994
2044
|
return { draft, committed, setField, setDraft, apply, reset, dirty };
|
|
1995
2045
|
}
|
|
2046
|
+
var DEFAULT_PAGE_SIZE = 10;
|
|
2047
|
+
function usePagedRows(rows, options = {}) {
|
|
2048
|
+
const pageSize = Math.max(1, options.pageSize ?? DEFAULT_PAGE_SIZE);
|
|
2049
|
+
const [currentPage, setCurrentPage] = React4.useState(0);
|
|
2050
|
+
const totalPages = Math.ceil(rows.length / pageSize);
|
|
2051
|
+
React4.useEffect(() => {
|
|
2052
|
+
const lastValidPage = totalPages > 0 ? totalPages - 1 : 0;
|
|
2053
|
+
if (currentPage > lastValidPage) setCurrentPage(lastValidPage);
|
|
2054
|
+
}, [currentPage, totalPages]);
|
|
2055
|
+
const pageRows = React4.useMemo(() => {
|
|
2056
|
+
const start = currentPage * pageSize;
|
|
2057
|
+
return rows.slice(start, start + pageSize);
|
|
2058
|
+
}, [rows, currentPage, pageSize]);
|
|
2059
|
+
const setPage = React4.useCallback(
|
|
2060
|
+
(page) => {
|
|
2061
|
+
const lastValidPage = totalPages > 0 ? totalPages - 1 : 0;
|
|
2062
|
+
const clamped = Math.min(Math.max(0, page), lastValidPage);
|
|
2063
|
+
setCurrentPage(clamped);
|
|
2064
|
+
},
|
|
2065
|
+
[totalPages]
|
|
2066
|
+
);
|
|
2067
|
+
return {
|
|
2068
|
+
pageRows,
|
|
2069
|
+
currentPage,
|
|
2070
|
+
totalPages,
|
|
2071
|
+
setPage,
|
|
2072
|
+
hasPages: totalPages > 1,
|
|
2073
|
+
pageSize
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
1996
2076
|
|
|
1997
2077
|
exports.CARD_STACK_BREAKPOINT = CARD_STACK_BREAKPOINT;
|
|
2078
|
+
exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
|
|
1998
2079
|
exports.DEFAULT_PAGE_SIZE_OPTIONS = DEFAULT_PAGE_SIZE_OPTIONS;
|
|
1999
2080
|
exports.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS = DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
2000
2081
|
exports.DEFAULT_TYPEAHEAD_MIN_CHARS = DEFAULT_TYPEAHEAD_MIN_CHARS;
|
|
@@ -2018,5 +2099,6 @@ exports.rowTestID = rowTestID;
|
|
|
2018
2099
|
exports.selectAllTestID = selectAllTestID;
|
|
2019
2100
|
exports.suggestOptions = suggestOptions;
|
|
2020
2101
|
exports.useFilterDraft = useFilterDraft;
|
|
2102
|
+
exports.usePagedRows = usePagedRows;
|
|
2021
2103
|
//# sourceMappingURL=index.js.map
|
|
2022
2104
|
//# sourceMappingURL=index.js.map
|