@dloizides/ui-tables 1.7.0 → 1.9.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 +34 -0
- package/README.md +1 -1
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +193 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +194 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.9.0
|
|
4
|
+
|
|
5
|
+
- **`Pager` dropdown-variant rows menu now escapes ancestor stacking contexts (web).** The
|
|
6
|
+
`rowsVariant="dropdown"` `SizeDropdown` menu opened but painted UNDER the results table on wide
|
|
7
|
+
web: react-native-web renders every `View` as `position: relative; z-index: 0`, so the in-tree
|
|
8
|
+
`position: absolute; zIndex: 1000` menu was trapped inside its anchor's stacking context and lost
|
|
9
|
+
to later-painting siblings (the table / cards below).
|
|
10
|
+
- On **web** the open menu now renders in a PORTAL to `document.body` with `position: fixed` at the
|
|
11
|
+
trigger's measured viewport rect (right-aligned, recomputed on scroll/resize) and a high `zIndex`
|
|
12
|
+
— clipped by nothing, above everything. Mirrors `@dloizides/ui-layout`'s InlineMenu fix.
|
|
13
|
+
- On **native** the menu is unchanged (in-tree `position: absolute` + `elevation`). All web-only code
|
|
14
|
+
(portal, `document`/`window` listeners, `position: fixed`) is guarded behind `Platform.OS === 'web'`.
|
|
15
|
+
- Outside-click dismissal now consults BOTH the anchor and the portalled menu node.
|
|
16
|
+
- `react-dom` is added as an **optional** peer dependency (only touched on web; every RN-web consumer
|
|
17
|
+
already has it). No API change: the `rowsVariant="dropdown"` contract, all test ids, the compact v1
|
|
18
|
+
look and a11y (role/aria/keyboard) are unchanged.
|
|
19
|
+
|
|
20
|
+
## 1.8.0
|
|
21
|
+
|
|
22
|
+
- `Pager` gains an additive, **default-off** `rowsVariant?: 'pills' | 'dropdown'` prop.
|
|
23
|
+
- `'pills'` (default) is unchanged — the RN-idiom row of pressable size pills. Every existing
|
|
24
|
+
consumer (erevna / katalogos / kefi / coverage) renders byte-identically.
|
|
25
|
+
- `'dropdown'` swaps the size pills for a compact `<select>`-like anchored dropdown matching
|
|
26
|
+
the v1 console's "Rows" select: a bordered trigger (height-matched to the Prev/Next ghost
|
|
27
|
+
buttons) showing the current size + a chevron, opening a popover of the `pageSizeOptions`
|
|
28
|
+
that fires `onPageSizeChange` and closes on select / outside-click / Escape. The "Rows"
|
|
29
|
+
caption is mixed-case (not uppercase) in this variant, matching v1's muted `.hint` label.
|
|
30
|
+
- Self-contained: the anchored dropdown is implemented inside ui-tables (new `SizeDropdown`),
|
|
31
|
+
reusing ui-layout's InlineMenu click-outside/Escape pattern WITHOUT taking a hard dependency
|
|
32
|
+
on `@dloizides/ui-layout` — its ModalDropdown trigger has fixed chunky padding and no chevron,
|
|
33
|
+
so it cannot match v1's compact select, and a low-level table primitive should not depend on
|
|
34
|
+
a higher-level layout package. New option/trigger test ids: `${testID}-size-trigger`,
|
|
35
|
+
`${testID}-size-menu`, and the existing `${testID}-size-${size}` per option.
|
|
36
|
+
|
|
3
37
|
## 1.7.0
|
|
4
38
|
|
|
5
39
|
- **Accessibility (WCAG 2.1 AA) hardening — additive + backward-compatible.**
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ portfolio. Reads theme + translations from the shared `@dloizides/ui-feedback` U
|
|
|
10
10
|
| `StatCard` | ✅ Available — labelled metric tile (label + locale-formatted value). |
|
|
11
11
|
| `DataTable` | ✅ Available — the shared, tokenized RN-web grid (the `GRID.md` contract): `columns + rows` API, sticky header, zebra striping, per-row tint, pressable rows, per-row `testID` + a11y, optional **expandable rows**, and a responsive label:value **card-stack** below `stackBreakpoint`. |
|
|
12
12
|
| `FilterBar` | ✅ Available — the `.ui-filters` shell: wrapping field row + live results count + actions slot. |
|
|
13
|
-
| `Pager` | ✅ Available — the `.ui-pager` control: `from–to of N` page-info + rows-per-page
|
|
13
|
+
| `Pager` | ✅ Available — the `.ui-pager` control: `from–to of N` page-info + rows-per-page control + Prev/Next. Pass an optional, already-translated `unitLabel` (e.g. `"leadership terms"`) to render `1–50 of 3,023 leadership terms`. The rows-per-page control defaults to a row of size **pills** (`rowsVariant="pills"`); pass `rowsVariant="dropdown"` for the compact v1-console `<select>`-style anchored dropdown (trigger + chevron + popover, mixed-case "Rows" caption). |
|
|
14
14
|
| `StatGrid` | ⏳ Deferred — exists only in kefi-web (n=1); moves in when a 2nd consumer appears. |
|
|
15
15
|
|
|
16
16
|
### DataTable / FilterBar / Pager
|
package/dist/index.d.mts
CHANGED
|
@@ -231,6 +231,14 @@ interface PagerProps {
|
|
|
231
231
|
onPageSizeChange: (pageSize: number) => void;
|
|
232
232
|
/** Rows-per-page choices. Default 25 / 50 / 100 / 200. */
|
|
233
233
|
pageSizeOptions?: readonly number[];
|
|
234
|
+
/**
|
|
235
|
+
* How the rows-per-page control renders. `'pills'` (default) keeps the RN-idiom row of
|
|
236
|
+
* pressable size pills — byte-identical for every existing consumer. `'dropdown'` swaps in
|
|
237
|
+
* a compact `<select>`-like anchored dropdown matching the v1 console's "Rows" select
|
|
238
|
+
* (compact trigger + chevron, popover of options, close on outside-click / Escape) and a
|
|
239
|
+
* mixed-case "Rows" caption.
|
|
240
|
+
*/
|
|
241
|
+
rowsVariant?: 'pills' | 'dropdown';
|
|
234
242
|
/**
|
|
235
243
|
* Optional, already-translated unit noun appended to the count line, e.g.
|
|
236
244
|
* `"leadership terms"` renders `1–50 of 3,023 leadership terms`. When omitted the
|
|
@@ -256,7 +264,7 @@ interface PagerProps {
|
|
|
256
264
|
styleOverrides?: PagerStyleOverrides;
|
|
257
265
|
testID?: string;
|
|
258
266
|
}
|
|
259
|
-
declare function Pager({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizeOptions, unitLabel, infoPrefix, boldNumbers, styleOverrides: o, testID, }: PagerProps): React.ReactElement;
|
|
267
|
+
declare function Pager({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizeOptions, rowsVariant, unitLabel, infoPrefix, boldNumbers, styleOverrides: o, testID, }: PagerProps): React.ReactElement;
|
|
260
268
|
|
|
261
269
|
/**
|
|
262
270
|
* Shared constants for the DataTable family (DataTable / FilterBar / Pager).
|
|
@@ -310,6 +318,8 @@ declare const TABLE_I18N: {
|
|
|
310
318
|
readonly pagerNextHint: "uiTables.pager.nextHint";
|
|
311
319
|
readonly pagerRows: "uiTables.pager.rows";
|
|
312
320
|
readonly pagerRowsOptionHint: "uiTables.pager.rowsOptionHint";
|
|
321
|
+
/** Accessible hint for the dropdown-variant rows-per-page trigger button. */
|
|
322
|
+
readonly pagerRowsTriggerHint: "uiTables.pager.rowsTriggerHint";
|
|
313
323
|
};
|
|
314
324
|
|
|
315
325
|
export { CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, Pager, type PagerProps, type PagerStyleOverrides, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, rowDetailTestID, rowTestID };
|
package/dist/index.d.ts
CHANGED
|
@@ -231,6 +231,14 @@ interface PagerProps {
|
|
|
231
231
|
onPageSizeChange: (pageSize: number) => void;
|
|
232
232
|
/** Rows-per-page choices. Default 25 / 50 / 100 / 200. */
|
|
233
233
|
pageSizeOptions?: readonly number[];
|
|
234
|
+
/**
|
|
235
|
+
* How the rows-per-page control renders. `'pills'` (default) keeps the RN-idiom row of
|
|
236
|
+
* pressable size pills — byte-identical for every existing consumer. `'dropdown'` swaps in
|
|
237
|
+
* a compact `<select>`-like anchored dropdown matching the v1 console's "Rows" select
|
|
238
|
+
* (compact trigger + chevron, popover of options, close on outside-click / Escape) and a
|
|
239
|
+
* mixed-case "Rows" caption.
|
|
240
|
+
*/
|
|
241
|
+
rowsVariant?: 'pills' | 'dropdown';
|
|
234
242
|
/**
|
|
235
243
|
* Optional, already-translated unit noun appended to the count line, e.g.
|
|
236
244
|
* `"leadership terms"` renders `1–50 of 3,023 leadership terms`. When omitted the
|
|
@@ -256,7 +264,7 @@ interface PagerProps {
|
|
|
256
264
|
styleOverrides?: PagerStyleOverrides;
|
|
257
265
|
testID?: string;
|
|
258
266
|
}
|
|
259
|
-
declare function Pager({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizeOptions, unitLabel, infoPrefix, boldNumbers, styleOverrides: o, testID, }: PagerProps): React.ReactElement;
|
|
267
|
+
declare function Pager({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizeOptions, rowsVariant, unitLabel, infoPrefix, boldNumbers, styleOverrides: o, testID, }: PagerProps): React.ReactElement;
|
|
260
268
|
|
|
261
269
|
/**
|
|
262
270
|
* Shared constants for the DataTable family (DataTable / FilterBar / Pager).
|
|
@@ -310,6 +318,8 @@ declare const TABLE_I18N: {
|
|
|
310
318
|
readonly pagerNextHint: "uiTables.pager.nextHint";
|
|
311
319
|
readonly pagerRows: "uiTables.pager.rows";
|
|
312
320
|
readonly pagerRowsOptionHint: "uiTables.pager.rowsOptionHint";
|
|
321
|
+
/** Accessible hint for the dropdown-variant rows-per-page trigger button. */
|
|
322
|
+
readonly pagerRowsTriggerHint: "uiTables.pager.rowsTriggerHint";
|
|
313
323
|
};
|
|
314
324
|
|
|
315
325
|
export { CARD_STACK_BREAKPOINT, DEFAULT_PAGE_SIZE_OPTIONS, DataTable, type DataTableColumn, type DataTableProps, type DataTableStyleOverrides, FilterBar, type FilterBarProps, type FilterBarStyleOverrides, Pager, type PagerProps, type PagerStyleOverrides, StatCard, type StatCardProps, TABLE_I18N, TABLE_TEST_IDS, rowDetailTestID, rowTestID };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var React2 = require('react');
|
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var uiFeedback = require('@dloizides/ui-feedback');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var reactDom = require('react-dom');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
|
|
@@ -70,6 +71,14 @@ var PAGER_SIZE_GAP = 6;
|
|
|
70
71
|
var CONTROL_PAD_H = 12;
|
|
71
72
|
var CONTROL_PAD_V = 6;
|
|
72
73
|
var CONTROL_FONT = 13;
|
|
74
|
+
var CHEVRON_FONT = 10;
|
|
75
|
+
var MENU_TOP_GAP = 4;
|
|
76
|
+
var MENU_PAD_V = 4;
|
|
77
|
+
var MENU_MIN_WIDTH = 80;
|
|
78
|
+
var MENU_OPT_PAD_V = 7;
|
|
79
|
+
var MENU_Z_INDEX = 1e3;
|
|
80
|
+
var MENU_ELEVATION = 8;
|
|
81
|
+
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
73
82
|
var RESULTS_FONT = 13;
|
|
74
83
|
var HEAD_LETTER_SPACING = 0.4;
|
|
75
84
|
var LABEL_LETTER_SPACING = 0.3;
|
|
@@ -114,11 +123,23 @@ var chromeStyles = reactNative.StyleSheet.create({
|
|
|
114
123
|
pagerInfo: { fontSize: CONTROL_FONT, fontVariant: ["tabular-nums"] },
|
|
115
124
|
pagerNav: { flexDirection: "row", alignItems: "center", gap: PAGER_SIZE_GAP, flexWrap: "wrap" },
|
|
116
125
|
pagerRowsLabel: { fontSize: HEAD_FONT, textTransform: "uppercase", letterSpacing: LABEL_LETTER_SPACING },
|
|
126
|
+
/** Mixed-case "Rows" caption for the dropdown variant (v1's muted `.hint` label — no uppercase transform). */
|
|
127
|
+
pagerRowsLabelPlain: { fontSize: HEAD_FONT, letterSpacing: LABEL_LETTER_SPACING },
|
|
117
128
|
sizeGroup: { flexDirection: "row", gap: PAGER_SIZE_GAP, alignItems: "center" },
|
|
118
129
|
control: { paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: BORDER_RADIUS, borderWidth: BORDER_WIDTH },
|
|
119
130
|
controlText: { fontSize: CONTROL_FONT, fontWeight: "600" },
|
|
120
131
|
sizePill: { paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: PILL_RADIUS, borderWidth: BORDER_WIDTH },
|
|
121
|
-
sizePillText: { fontSize: HEAD_FONT, fontWeight: "600", fontVariant: ["tabular-nums"] }
|
|
132
|
+
sizePillText: { fontSize: HEAD_FONT, fontWeight: "600", fontVariant: ["tabular-nums"] },
|
|
133
|
+
/** Dropdown variant: relatively-positioned wrapper holding the trigger + the anchored popover. */
|
|
134
|
+
sizeAnchor: { position: "relative" },
|
|
135
|
+
/** Dropdown variant: the compact `<select>`-like trigger (bordered ghost look, height-matched to Prev/Next) + chevron. */
|
|
136
|
+
sizeTrigger: { flexDirection: "row", alignItems: "center", gap: PAGER_SIZE_GAP, paddingHorizontal: CONTROL_PAD_H, paddingVertical: CONTROL_PAD_V, borderRadius: BORDER_RADIUS, borderWidth: BORDER_WIDTH },
|
|
137
|
+
sizeTriggerText: { fontSize: CONTROL_FONT, fontWeight: "600", fontVariant: ["tabular-nums"] },
|
|
138
|
+
sizeChevron: { fontSize: CHEVRON_FONT },
|
|
139
|
+
/** Dropdown variant: the anchored popover listing the rows-per-page options. */
|
|
140
|
+
sizeMenu: { position: "absolute", top: "100%", right: 0, marginTop: MENU_TOP_GAP, minWidth: MENU_MIN_WIDTH, borderWidth: BORDER_WIDTH, borderRadius: BORDER_RADIUS, paddingVertical: MENU_PAD_V, zIndex: MENU_Z_INDEX, boxShadow: MENU_BOX_SHADOW, elevation: MENU_ELEVATION },
|
|
141
|
+
sizeOption: { paddingHorizontal: CONTROL_PAD_H, paddingVertical: MENU_OPT_PAD_V },
|
|
142
|
+
sizeOptionText: { fontSize: CONTROL_FONT, fontVariant: ["tabular-nums"] }
|
|
122
143
|
});
|
|
123
144
|
function cellContent(column, row, textColor, overrides) {
|
|
124
145
|
const content = column.render(row);
|
|
@@ -186,7 +207,9 @@ var TABLE_I18N = {
|
|
|
186
207
|
pagerPrevHint: "uiTables.pager.prevHint",
|
|
187
208
|
pagerNextHint: "uiTables.pager.nextHint",
|
|
188
209
|
pagerRows: "uiTables.pager.rows",
|
|
189
|
-
pagerRowsOptionHint: "uiTables.pager.rowsOptionHint"
|
|
210
|
+
pagerRowsOptionHint: "uiTables.pager.rowsOptionHint",
|
|
211
|
+
/** Accessible hint for the dropdown-variant rows-per-page trigger button. */
|
|
212
|
+
pagerRowsTriggerHint: "uiTables.pager.rowsTriggerHint"
|
|
190
213
|
};
|
|
191
214
|
var FIRST_ROW_INDEX = 0;
|
|
192
215
|
function DataTable(props) {
|
|
@@ -356,6 +379,147 @@ function FilterBar({
|
|
|
356
379
|
!!actions && /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chromeStyles.filtersActions, o?.filtersActions], children: actions })
|
|
357
380
|
] });
|
|
358
381
|
}
|
|
382
|
+
var CHEVRON_DOWN = "\u25BE";
|
|
383
|
+
var CHEVRON_UP = "\u25B4";
|
|
384
|
+
var IS_WEB = reactNative.Platform.OS === "web";
|
|
385
|
+
var MENU_TOP_GAP2 = 4;
|
|
386
|
+
var VIEWPORT_EDGE = 0;
|
|
387
|
+
function readTriggerRect(anchorRef) {
|
|
388
|
+
if (!IS_WEB) return null;
|
|
389
|
+
const node = anchorRef.current;
|
|
390
|
+
if (node === null || typeof node.getBoundingClientRect !== "function") return null;
|
|
391
|
+
const r = node.getBoundingClientRect();
|
|
392
|
+
return { bottom: r.bottom, right: r.right };
|
|
393
|
+
}
|
|
394
|
+
function buildWebFixedStyle(rect, viewportWidth) {
|
|
395
|
+
return {
|
|
396
|
+
// RN's ViewStyle union omits 'fixed', but react-native-web honours it at runtime.
|
|
397
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- web-only position value
|
|
398
|
+
position: "fixed",
|
|
399
|
+
top: rect.bottom + MENU_TOP_GAP2,
|
|
400
|
+
right: Math.max(VIEWPORT_EDGE, viewportWidth - rect.right)
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function useTriggerRect(anchorRef, isOpen) {
|
|
404
|
+
const [rect, setRect] = React2.useState(null);
|
|
405
|
+
React2.useLayoutEffect(() => {
|
|
406
|
+
if (!IS_WEB || !isOpen) return void 0;
|
|
407
|
+
const measure = () => {
|
|
408
|
+
setRect(readTriggerRect(anchorRef));
|
|
409
|
+
};
|
|
410
|
+
measure();
|
|
411
|
+
window.addEventListener("scroll", measure, true);
|
|
412
|
+
window.addEventListener("resize", measure);
|
|
413
|
+
return () => {
|
|
414
|
+
window.removeEventListener("scroll", measure, true);
|
|
415
|
+
window.removeEventListener("resize", measure);
|
|
416
|
+
};
|
|
417
|
+
}, [anchorRef, isOpen]);
|
|
418
|
+
return rect;
|
|
419
|
+
}
|
|
420
|
+
function useDismissOnOutside(anchorRef, menuRef, isOpen, onClose) {
|
|
421
|
+
React2.useEffect(() => {
|
|
422
|
+
if (!IS_WEB || !isOpen) return void 0;
|
|
423
|
+
const onMouseDown = (event) => {
|
|
424
|
+
const anchorNode = anchorRef.current;
|
|
425
|
+
const menuNode = menuRef.current;
|
|
426
|
+
const target = event.target instanceof Node ? event.target : null;
|
|
427
|
+
const insideAnchor = anchorNode !== null && target !== null && anchorNode.contains(target);
|
|
428
|
+
const insideMenu = menuNode !== null && target !== null && menuNode.contains(target);
|
|
429
|
+
if (!insideAnchor && !insideMenu) onClose();
|
|
430
|
+
};
|
|
431
|
+
const onKeyDown = (event) => {
|
|
432
|
+
if (event.key === "Escape") onClose();
|
|
433
|
+
};
|
|
434
|
+
document.addEventListener("mousedown", onMouseDown);
|
|
435
|
+
document.addEventListener("keydown", onKeyDown);
|
|
436
|
+
return () => {
|
|
437
|
+
document.removeEventListener("mousedown", onMouseDown);
|
|
438
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
439
|
+
};
|
|
440
|
+
}, [anchorRef, menuRef, isOpen, onClose]);
|
|
441
|
+
}
|
|
442
|
+
function SizeDropdown({
|
|
443
|
+
pageSize,
|
|
444
|
+
pageSizeOptions,
|
|
445
|
+
onPageSizeChange,
|
|
446
|
+
testID,
|
|
447
|
+
triggerHint,
|
|
448
|
+
optionHint,
|
|
449
|
+
textColor,
|
|
450
|
+
mutedColor,
|
|
451
|
+
borderColor,
|
|
452
|
+
surfaceColor,
|
|
453
|
+
brandColor,
|
|
454
|
+
triggerStyle,
|
|
455
|
+
triggerTextStyle
|
|
456
|
+
}) {
|
|
457
|
+
const anchorRef = React2.useRef(null);
|
|
458
|
+
const menuRef = React2.useRef(null);
|
|
459
|
+
const [isOpen, setIsOpen] = React2.useState(false);
|
|
460
|
+
const close = React2.useCallback(() => {
|
|
461
|
+
setIsOpen(false);
|
|
462
|
+
}, []);
|
|
463
|
+
const toggle = React2.useCallback(() => {
|
|
464
|
+
setIsOpen((prev) => !prev);
|
|
465
|
+
}, []);
|
|
466
|
+
const select = React2.useCallback(
|
|
467
|
+
(size) => {
|
|
468
|
+
onPageSizeChange(size);
|
|
469
|
+
setIsOpen(false);
|
|
470
|
+
},
|
|
471
|
+
[onPageSizeChange]
|
|
472
|
+
);
|
|
473
|
+
const rect = useTriggerRect(anchorRef, isOpen);
|
|
474
|
+
useDismissOnOutside(anchorRef, menuRef, isOpen, close);
|
|
475
|
+
const webFixedStyle = IS_WEB && rect !== null ? buildWebFixedStyle(rect, window.innerWidth) : null;
|
|
476
|
+
const menu = /* @__PURE__ */ jsxRuntime.jsx(
|
|
477
|
+
reactNative.View,
|
|
478
|
+
{
|
|
479
|
+
ref: menuRef,
|
|
480
|
+
accessibilityRole: "menu",
|
|
481
|
+
style: [chromeStyles.sizeMenu, { borderColor, backgroundColor: surfaceColor }, webFixedStyle],
|
|
482
|
+
testID: `${testID}-size-menu`,
|
|
483
|
+
children: pageSizeOptions.map((size) => {
|
|
484
|
+
const active = size === pageSize;
|
|
485
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
486
|
+
reactNative.Pressable,
|
|
487
|
+
{
|
|
488
|
+
testID: `${testID}-size-${size}`,
|
|
489
|
+
accessibilityRole: "menuitem",
|
|
490
|
+
accessibilityLabel: String(size),
|
|
491
|
+
accessibilityHint: optionHint,
|
|
492
|
+
accessibilityState: { selected: active },
|
|
493
|
+
onPress: () => select(size),
|
|
494
|
+
style: chromeStyles.sizeOption,
|
|
495
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [chromeStyles.sizeOptionText, { color: active ? brandColor : textColor, fontWeight: active ? "700" : "400" }], children: size })
|
|
496
|
+
},
|
|
497
|
+
size
|
|
498
|
+
);
|
|
499
|
+
})
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: chromeStyles.sizeAnchor, children: [
|
|
503
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
504
|
+
reactNative.Pressable,
|
|
505
|
+
{
|
|
506
|
+
testID: `${testID}-size-trigger`,
|
|
507
|
+
accessibilityRole: "button",
|
|
508
|
+
accessibilityLabel: String(pageSize),
|
|
509
|
+
accessibilityHint: triggerHint,
|
|
510
|
+
accessibilityState: { expanded: isOpen },
|
|
511
|
+
"aria-expanded": isOpen,
|
|
512
|
+
onPress: toggle,
|
|
513
|
+
style: [chromeStyles.sizeTrigger, { borderColor, backgroundColor: surfaceColor }, triggerStyle],
|
|
514
|
+
children: [
|
|
515
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [chromeStyles.sizeTriggerText, { color: textColor }, triggerTextStyle], children: pageSize }),
|
|
516
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [chromeStyles.sizeChevron, { color: mutedColor }], "aria-hidden": true, children: isOpen ? CHEVRON_UP : CHEVRON_DOWN })
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
isOpen ? IS_WEB ? reactDom.createPortal(menu, document.body) : menu : null
|
|
521
|
+
] });
|
|
522
|
+
}
|
|
359
523
|
var FIRST_PAGE = 1;
|
|
360
524
|
var EN_DASH = "\u2013";
|
|
361
525
|
var DISABLED_OPACITY = 0.4;
|
|
@@ -387,6 +551,7 @@ function Pager({
|
|
|
387
551
|
onPageChange,
|
|
388
552
|
onPageSizeChange,
|
|
389
553
|
pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,
|
|
554
|
+
rowsVariant = "pills",
|
|
390
555
|
unitLabel,
|
|
391
556
|
infoPrefix,
|
|
392
557
|
boldNumbers = false,
|
|
@@ -396,6 +561,7 @@ function Pager({
|
|
|
396
561
|
const { theme, t } = uiFeedback.useUi();
|
|
397
562
|
const { colors, palette } = theme;
|
|
398
563
|
const brand = palette.primary["500"];
|
|
564
|
+
const isDropdown = rowsVariant === "dropdown";
|
|
399
565
|
const lastPage = Math.max(FIRST_PAGE, Math.ceil(total / pageSize));
|
|
400
566
|
const safePage = Math.min(Math.max(page, FIRST_PAGE), lastPage);
|
|
401
567
|
const from = total === 0 ? 0 : (safePage - 1) * pageSize + 1;
|
|
@@ -419,8 +585,31 @@ function Pager({
|
|
|
419
585
|
unitSuffix
|
|
420
586
|
] }) : info }),
|
|
421
587
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [chromeStyles.pagerNav, o?.pagerNav], children: [
|
|
422
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
423
|
-
|
|
588
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
589
|
+
reactNative.Text,
|
|
590
|
+
{
|
|
591
|
+
style: [isDropdown ? chromeStyles.pagerRowsLabelPlain : chromeStyles.pagerRowsLabel, { color: colors.textSecondary }, o?.pagerRowsLabel],
|
|
592
|
+
children: t(TABLE_I18N.pagerRows)
|
|
593
|
+
}
|
|
594
|
+
),
|
|
595
|
+
isDropdown ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
596
|
+
SizeDropdown,
|
|
597
|
+
{
|
|
598
|
+
pageSize,
|
|
599
|
+
pageSizeOptions,
|
|
600
|
+
onPageSizeChange,
|
|
601
|
+
testID,
|
|
602
|
+
triggerHint: t(TABLE_I18N.pagerRowsTriggerHint),
|
|
603
|
+
optionHint: t(TABLE_I18N.pagerRowsOptionHint),
|
|
604
|
+
textColor: colors.text,
|
|
605
|
+
mutedColor: colors.textSecondary,
|
|
606
|
+
borderColor: colors.border,
|
|
607
|
+
surfaceColor: colors.surface,
|
|
608
|
+
brandColor: brand,
|
|
609
|
+
triggerStyle: o?.sizePill,
|
|
610
|
+
triggerTextStyle: o?.sizePillText
|
|
611
|
+
}
|
|
612
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [chromeStyles.sizeGroup, o?.sizeGroup], children: pageSizeOptions.map((size) => {
|
|
424
613
|
const active = size === pageSize;
|
|
425
614
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
426
615
|
reactNative.Pressable,
|